aboutsummaryrefslogtreecommitdiff
path: root/modules/custom-buffer-file.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-07-11 13:45:58 -0500
committerCraig Jennings <c@cjennings.net>2026-07-11 13:45:58 -0500
commitdba72c4d24059d2cb5a7896ce9ca1ac67e775699 (patch)
tree84bd4f731888982a5d8e946ed06dd5a7179bbc37 /modules/custom-buffer-file.el
parent262c45559bcf2574b1f8d754c581040b076f3551 (diff)
downloaddotemacs-dba72c4d24059d2cb5a7896ce9ca1ac67e775699.tar.gz
dotemacs-dba72c4d24059d2cb5a7896ce9ca1ac67e775699.zip
fix(custom-buffer-file): error when copy-link has no file to copy
cj/copy-link-to-buffer-file did nothing in a non-file buffer, while every sibling copy command signals a user-error. The silent no-op gave no feedback either way. Now it signals a user-error too, and I updated the two tests and the commentary that had documented the silence as intended.
Diffstat (limited to 'modules/custom-buffer-file.el')
-rw-r--r--modules/custom-buffer-file.el13
1 files changed, 8 insertions, 5 deletions
diff --git a/modules/custom-buffer-file.el b/modules/custom-buffer-file.el
index d8e97e27..0ca06cf9 100644
--- a/modules/custom-buffer-file.el
+++ b/modules/custom-buffer-file.el
@@ -241,13 +241,16 @@ blast-radius operation on this map. The VC path is not double-prompted:
(cj/--delete-buffer-and-file))))))
(defun cj/copy-link-to-buffer-file ()
- "Copy the full file:// path of the current buffer's source file to the kill ring."
+ "Copy the full file:// path of the current buffer's source file to the kill ring.
+Signal a `user-error' when the buffer is not visiting a file, matching the
+other copy commands in this module."
(interactive)
(let ((file-path (buffer-file-name)))
- (when file-path
- (setq file-path (concat "file://" file-path))
- (kill-new file-path)
- (message "Copied file link to kill ring: %s" file-path))))
+ (unless file-path
+ (user-error "Buffer is not visiting a file"))
+ (setq file-path (concat "file://" file-path))
+ (kill-new file-path)
+ (message "Copied file link to kill ring: %s" file-path)))
(defvar cj/buffer-source-functions
'((eww-mode . (lambda () (eww-current-url)))