Skip to content

Commit 58ed284

Browse files
committed
Make ignorable commands customizable
1 parent 3a7e943 commit 58ed284

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

diff-hl-show-hunk-inline.el

+1
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ to scroll in the popup")
228228
(defun diff-hl-show-hunk-inline--post-command-hook ()
229229
"Called each time a command is executed."
230230
(let ((allowed-command (or
231+
(diff-hl-show-hunk-ignorable-command-p this-command)
231232
(string-match-p "diff-hl-show-hunk-inline-" (symbol-name this-command))
232233
(diff-hl-show-hunk-inline--ignorable-command-p this-command))))
233234
(unless allowed-command

diff-hl-show-hunk.el

+24-5
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-popup)
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,10 +88,6 @@
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

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

112131
(defun diff-hl-show-hunk-ignorable-command-p (command)
113132
"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)))
133+
(member command diff-hl-show-hunk-ignorable-commands))
115134

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

0 commit comments

Comments
 (0)