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

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

[elpa] externals/agitate 43027aefb9 16/67: Add agitate-diff-narrow-dwim


From: ELPA Syncer
Subject: [elpa] externals/agitate 43027aefb9 16/67: Add agitate-diff-narrow-dwim command
Date: Wed, 28 Sep 2022 16:57:26 -0400 (EDT)

branch: externals/agitate
commit 43027aefb986626ffc4f8aa090c1e05233bbfd38
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Add agitate-diff-narrow-dwim command
---
 agitate.el | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/agitate.el b/agitate.el
index c6e3e0bfc0..e1707bf40c 100644
--- a/agitate.el
+++ b/agitate.el
@@ -90,6 +90,25 @@ relative to its latest revision."
           (diff-buffer-with-file (current-buffer))
       (vc-diff)))
 
+;;;###autoload
+(defun agitate-diff-narrow-dwim (&optional narrow-file)
+  "Narrow to diff hunk or file and widen when already narrowed.
+By default narrow to the focused diff hunk.  With optional
+NARROW-FILE as a prefix argument, operate on the current file
+instead."
+  (interactive "P")
+  (when (derived-mode-p 'diff-mode)
+    (cond
+     ((buffer-narrowed-p)
+      (widen)
+      (message "WIDENED the view"))
+     (narrow-file
+      (diff-restrict-view narrow-file)
+      (message "Narrowed to FILE"))
+     (t
+      (diff-restrict-view)
+      (message "Narrowed to diff HUNK")))))
+
 (defvar outline-minor-mode-highlight)
 
 ;;;###autoload



reply via email to

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