Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
普段
(auto-sudoedit-mode 1)
で使わせていただいています。まだ存在しないディレクトリの中でファイルを開くことがあります。たとえば
~/foo
は存在しないとして、C-x C-f ~/foo/bar.txt
を行ってM-x make-directory RET RET
で後から~/foo
を作ります。このようにすると、
~/foo
の書き込み権限を持っているのに(sudo
は不要なのに)auto-sudoedit が発動します。原因はf-writable?
とtramp-tramp-file-p
の両方がnil
を返し、書き込み権限を持っていないファイルとの区別がつきません。対策として、パスを順に遡って
f-writable?
を実行することを提案したいと思います。こうすれば書き込みできる親ディレクトリを見つけて無駄な発動を防ぎ、また書き込みできる親がなければ通常どおり発動します。