aboutsummaryrefslogtreecommitdiff
path: root/modules/custom-buffer-file.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-15 00:54:01 -0500
committerCraig Jennings <c@cjennings.net>2026-05-15 00:54:01 -0500
commitd797b7ad5d6af70d7d1ab082f824df07cf5bd536 (patch)
tree5fb6e96fc34d3299d7dd21a3f209392efd3c42aa /modules/custom-buffer-file.el
parent7fa46253f069079ef73c0be901cf60f16d3b2747 (diff)
downloaddotemacs-d797b7ad5d6af70d7d1ab082f824df07cf5bd536.tar.gz
dotemacs-d797b7ad5d6af70d7d1ab082f824df07cf5bd536.zip
feat(custom-buffer-file): extend buffer-source dispatch to mu4e and Info
Add two dispatchers to cj/buffer-source-functions so C-; b p yields a useful link form in two more major modes. mu4e-view-mode returns "mu4e:msgid:<id>" so the result pastes into org as a clickable link and matches mu4e's own org-protocol handler. Falls through to buffer-file-name when point isn't on a real message. Info-mode returns "info:(manual)node" -- the form org-info-store-link produces. file-name-base only strips one extension, so a compressed "emacs.info.gz" comes back as "emacs.info"; trim the trailing ".info" to get the bare manual name. Falls through when Info hasn't populated its current-file / current-node vars yet. Tests cover normal + boundary fallthrough for each new mode.
Diffstat (limited to 'modules/custom-buffer-file.el')
-rw-r--r--modules/custom-buffer-file.el23
1 files changed, 22 insertions, 1 deletions
diff --git a/modules/custom-buffer-file.el b/modules/custom-buffer-file.el
index 8c6014d3..d8ce6bee 100644
--- a/modules/custom-buffer-file.el
+++ b/modules/custom-buffer-file.el
@@ -218,7 +218,28 @@ When called interactively, prompts for confirmation if target file exists."
'((eww-mode . (lambda () (eww-current-url)))
(elfeed-show-mode . (lambda () (elfeed-entry-link elfeed-show-entry)))
(dired-mode . (lambda () (dired-get-filename nil t)))
- (dirvish-mode . (lambda () (dired-get-filename nil t))))
+ (dirvish-mode . (lambda () (dired-get-filename nil t)))
+ (mu4e-view-mode . (lambda ()
+ (when-let* ((msg (mu4e-message-at-point))
+ (id (plist-get msg :message-id)))
+ (format "mu4e:msgid:%s" id))))
+ (Info-mode . (lambda ()
+ (when (and (boundp 'Info-current-file)
+ (boundp 'Info-current-node)
+ Info-current-file
+ Info-current-node)
+ ;; Strip the compression suffix (via
+ ;; file-name-base) AND the .info suffix.
+ ;; "emacs.info.gz" -> base "emacs.info" ->
+ ;; manual "emacs".
+ (let* ((base (file-name-base Info-current-file))
+ (manual (if (string-suffix-p ".info" base)
+ (substring base 0 -5)
+ base))
+ (node Info-current-node))
+ (when (and (not (string-empty-p manual))
+ (not (string-empty-p node)))
+ (format "info:(%s)%s" manual node)))))))
"Alist mapping major-mode -> thunk returning the buffer's \"source\".
Each thunk is called with no arguments and should return a string