Make find-file-noselect not pick buffers with broken symlinks
* lisp/files.el (find-buffer-visiting): Improve doc string. (find-file-noselect): Don't pick buffers with broken symlinks, because that's too confusing (bug#41414).
This commit is contained in:
parent
4c2ba16500
commit
7edf3d2902
1 changed files with 14 additions and 2 deletions
|
@ -2102,8 +2102,11 @@ started Emacs, set `abbreviated-home-dir' to nil so it will be recalculated)."
|
|||
"Return the buffer visiting file FILENAME (a string).
|
||||
This is like `get-file-buffer', except that it checks for any buffer
|
||||
visiting the same file, possibly under a different name.
|
||||
|
||||
If PREDICATE is non-nil, only buffers satisfying it are eligible,
|
||||
and others are ignored.
|
||||
and others are ignored. PREDICATE is called with the buffer as
|
||||
the only argument, but not with the buffer as the current buffer.
|
||||
|
||||
If there is no such live buffer, return nil."
|
||||
(let ((predicate (or predicate #'identity))
|
||||
(truename (abbreviate-file-name (file-truename filename))))
|
||||
|
@ -2324,7 +2327,16 @@ the various files."
|
|||
(attributes (file-attributes truename))
|
||||
(number (nthcdr 10 attributes))
|
||||
;; Find any buffer for a file that has same truename.
|
||||
(other (and (not buf) (find-buffer-visiting filename))))
|
||||
(other (and (not buf)
|
||||
(find-buffer-visiting
|
||||
filename
|
||||
;; We want to filter out buffers that we've
|
||||
;; visited via symlinks and the like, where
|
||||
;; the symlink no longer exists.
|
||||
(lambda (buffer)
|
||||
(let ((file (buffer-local-value
|
||||
'buffer-file-name buffer)))
|
||||
(and file (file-exists-p file))))))))
|
||||
;; Let user know if there is a buffer with the same truename.
|
||||
(if other
|
||||
(progn
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue