emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/denote 02d296d8e8 3/4: Add command to toggle context in


From: ELPA Syncer
Subject: [elpa] externals/denote 02d296d8e8 3/4: Add command to toggle context in the backlinks buffer
Date: Thu, 25 Jul 2024 06:57:51 -0400 (EDT)

branch: externals/denote
commit 02d296d8e8278d5049e7afefb4f973c2b1b89036
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Add command to toggle context in the backlinks buffer
    
    I am not documenting this in the manual for the time being because I
    expect it to undergo further changes.
---
 denote.el | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/denote.el b/denote.el
index 8aeb669dd0..247d962501 100644
--- a/denote.el
+++ b/denote.el
@@ -4323,10 +4323,34 @@ matching identifiers."
       (xref-prev-line)
     (backward-button n)))
 
+;; NOTE 2024-07-25: This can be a minor mode, though I do not like
+;; that global minor modes have to be autoloaded.  We do not need to
+;; autoload a secondary piece of functionality.
+;;
+;; NOTE 2024-07-25: We do not need the user option if we turn this
+;; into a minor mode.
+;;
+;; NOTE 2024-07-25: I would prefer to have a buffer-local toggle which
+;; does not affect the global user preference.  The trick is to make
+;; this work with `revert-buffer'.
+(defun denote-backlinks-toggle-context ()
+  "Show or hide the context of links in backlinks buffers.
+This is the same as toggling the `denote-backlinks-show-context' user
+option.
+
+When called inside of a backlinks buffer, also revert the buffer."
+  (interactive)
+  (if denote-backlinks-show-context
+      (setq denote-backlinks-show-context nil)
+    (setq denote-backlinks-show-context t))
+  (when (derived-mode-p 'denote-backlinks-mode)
+    (revert-buffer)))
+
 (defvar denote-backlinks-mode-map
   (let ((m (make-sparse-keymap)))
     (define-key m "n" #'denote-backlinks-mode-next)
     (define-key m "p" #'denote-backlinks-mode-previous)
+    (define-key m "c" #'denote-backlinks-toggle-context)
     (define-key m "g" #'revert-buffer)
     m)
   "Keymap for `denote-backlinks-mode'.")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]