]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve find-sibling-file error reporting
authorLars Ingebrigtsen <larsi@gnus.org>
Mon, 6 Jun 2022 12:34:41 +0000 (14:34 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 6 Jun 2022 12:34:50 +0000 (14:34 +0200)
* lisp/files.el (find-sibling-file): Improve error reporting.

lisp/files.el

index 97e58946bdafe5c855affcd5513857eedd73742b..07ab2b45a51b28253d4091204c4cb0c5da299006 100644 (file)
@@ -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))