Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Check if file exists before loading editorconfig settings#3018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mawww merged 1 commit intomawww:masterfrommogenson:editorconfig
Sep 8, 2019

Conversation

mogenson
Copy link
Contributor

I noticed when using the recommendededitorconfig hook from the Wiki, that the editorconfig.kak script failed for buffers that were not real files. For example*scratch*,*debug*,*make*,*grep*, etc.

This PR adds a check in theeditorcofig-load command to see if a file exists before calling the externaleditorconfig utility.

It also moves theremove-hooks line to after the valid file check and directly prints the command to add a remove trailing whitespace hook from awk (if necessary). This prevents an invalid file from clearing a hook and removes the need to store an option and reference it from a spawned shell in the later hook.

@mogenson
Copy link
ContributorAuthor

Hello, does this PR seem reasonable?

print "autowrap-enable"
print "add-highlighter window/ column %sh{ echo $((" max_line_length "+1)) } default,bright-black"
file="${1:-$kak_buffile}"
if [-f"$file" ];then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
if [ -f"$file" ]; then
if [ -e"$file" ]; then

To handle symlinks.

@mawww
Copy link
Owner

mawww commentedAug 20, 2019
edited
Loading

Hello,

I dont think the logic should be to disable editorconfig for non-existing files, what we want is to disable it for non-file buffers (scratch buffers in Kakoune lingo). One distinction between file and non-file buffers is that $kak_buffile will be an absolute path for any file buffer, but just match the buffer name for a non-file buffer, so I suspect ignoring all buffers where $kak_buffile does not start with a slash would do the trick.

EDIT: Also, sorry for the delay in taking a look at that.

Check if buffile is a full path by checking for the beginning'/' character in editorconfig-load command. This avoids a parsingerror from feeding a *scratch*/*debug*/*grep*/etc. buffer name to theeditorcofig command. Don't clear editorconfig hooks until after checkingfor a valid bufffile path. This way, opening the *debug* buffer willnot clear the hooks from a previously parsed .editorconfig file. Iftrim_trailing_whitespace is true, print the hook directly from awk. Thisremoves the need to save a editorcofig_trim_trailing_whitespace option.Note: Setting the max_line_length requires a window to be created.Therefore, a global hook to load .editorconfig settings should be:    hook global WinCreate .* %{editorconfig-load}
@mogenson
Copy link
ContributorAuthor

I've updated this PR to check if$kak_buffile begins with a/ character.

As mawww suggested, this should work for all unix environments. On Cygwin, it appears you can specify a path that begins with a drive letter (ex:cd c:/some/path) but Cygwin will report back a path that begins with/ (ex:/cygdrive/c/some/path).

Lastly, if you want to keep the editorconfig.kak script as-is. I've been using a WinCreate hook with regex to filter out buffer names that start with a*. This could be added to the wiki.

hook global WinCreate ^[^*]+$ %{ editorconfig-load } # no *buffers*

@mawwwmawww merged commit37ded5e intomawww:masterSep 8, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
1 more reviewer

@lenormflenormflenormf left review comments

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@mogenson@mawww@lenormf

[8]ページ先頭

©2009-2025 Movatter.jp