Skip to content

Commit 6090b76

Browse files
committed
Make ignorable commands customizable
1 parent 90e27f9 commit 6090b76

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

diff-hl-show-hunk-inline.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ to scroll in the popup")
222222
(defun diff-hl-show-hunk-inline--post-command-hook ()
223223
"Called each time a command is executed."
224224
(let ((allowed-command (or
225+
(diff-hl-show-hunk-ignorable-command-p this-command)
225226
(string-match-p "diff-hl-show-hunk-inline-" (symbol-name this-command))
226227
(diff-hl-show-hunk-inline--ignorable-command-p this-command))))
227228
(unless allowed-command

diff-hl-show-hunk.el

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,29 @@
3838

3939
(require 'diff-hl)
4040

41+
(defgroup diff-hl-show-hunk nil
42+
"Show vc diffs in a posframe or popup."
43+
:group 'diff-hl)
44+
45+
(defcustom diff-hl-show-hunk-ignorable-commands
46+
'(ignore
47+
diff-hl-show-hunk
48+
handle-switch-frame
49+
diff-hl-show-hunk--click)
50+
"Commands that will keep the hunk shown.
51+
Any command not on this list will cause the hunk to be hidden."
52+
:type '(repeat function)
53+
:group 'diff-hl-show-hunk)
54+
55+
(defcustom diff-hl-show-hunk-function 'diff-hl-show-hunk-inline
56+
"The function used to render the hunk.
57+
The function receives as first parameter a buffer with the
58+
contents of the hunk, and as second parameter the line number
59+
corresponding to the clicked line in the original buffer."
60+
:type '(choice
61+
(const :tag "Show inline" diff-hl-show-hunk-inline)
62+
(const :tag "Show using posframe" diff-hl-show-hunk-posframe)))
63+
4164
(defvar diff-hl-show-hunk-mouse-mode-map
4265
(let ((map (make-sparse-keymap)))
4366
(define-key map (kbd "<left-margin> <mouse-1>") 'diff-hl-show-hunk--click)
@@ -65,22 +88,9 @@
6588
(defvar diff-hl-show-hunk--original-overlay nil
6689
"Copy of the diff-hl hunk overlay.")
6790

68-
(defgroup diff-hl-show-hunk nil
69-
"Show vc diffs in a posframe or popup."
70-
:group 'diff-hl)
71-
7291
(defconst diff-hl-show-hunk-boundary "^@@.*@@")
7392
(defconst diff-hl-show-hunk--no-lines-removed-message (list "<<no lines removed>>"))
7493

75-
(defcustom diff-hl-show-hunk-function 'diff-hl-show-hunk-inline
76-
"The function used to render the hunk.
77-
The function receives as first parameter a buffer with the
78-
contents of the hunk, and as second parameter the line number
79-
corresponding to the clicked line in the original buffer."
80-
:type '(choice
81-
(const :tag "Show inline" diff-hl-show-hunk-inline)
82-
(const :tag "Show using posframe" diff-hl-show-hunk-posframe)))
83-
8494
(defvar diff-hl-show-hunk--hide-function nil
8595
"Function to call to close the shown hunk.")
8696

@@ -111,7 +121,7 @@ corresponding to the clicked line in the original buffer."
111121

112122
(defun diff-hl-show-hunk-ignorable-command-p (command)
113123
"Decide if COMMAND is a command allowed while showing the current hunk."
114-
(member command '(ignore diff-hl-show-hunk handle-switch-frame diff-hl-show-hunk--click)))
124+
(member command diff-hl-show-hunk-ignorable-commands))
115125

116126
(defun diff-hl-show-hunk--compute-diffs ()
117127
"Compute diffs using functions of diff-hl.

0 commit comments

Comments
 (0)