From: Lars Ingebrigtsen Date: Mon, 6 Jun 2022 12:34:41 +0000 (+0200) Subject: Improve find-sibling-file error reporting X-Git-Tag: emacs-29.0.90~1910^2~193 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5f12e288a51eb70e7d38a111d610cb09dfe04332;p=emacs.git Improve find-sibling-file error reporting * lisp/files.el (find-sibling-file): Improve error reporting. --- diff --git a/lisp/files.el b/lisp/files.el index 97e58946bda..07ab2b45a51 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -7303,16 +7303,22 @@ The \"sibling\" file is defined by the `find-sibling-rules' variable." (unless buffer-file-name (user-error "Not visiting a file")) (list buffer-file-name))) + (unless find-sibling-rules + (user-error "The `find-sibling-rules' variable has not been configured")) (let ((siblings (find-sibling-file--search (expand-file-name file)))) - (if (length= siblings 1) - (find-file (car siblings)) + (cond + ((null siblings) + (user-error "Couldn't find any sibling files")) + ((length= siblings 1) + (find-file (car siblings))) + (t (let ((relatives (mapcar (lambda (sibling) (file-relative-name sibling (file-name-directory file))) siblings))) (find-file (completing-read (format-prompt "Find file" (car relatives)) - relatives nil t nil nil (car relatives))))))) + relatives nil t nil nil (car relatives)))))))) (defun find-sibling-file--search (file) (let ((results nil))