[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/diff-hl 1335389 2/2: Add diff-hl-show-hunk-stage-hunk a
From: |
ELPA Syncer |
Subject: |
[elpa] externals/diff-hl 1335389 2/2: Add diff-hl-show-hunk-stage-hunk and the buttons |
Date: |
Sun, 31 Oct 2021 19:57:17 -0400 (EDT) |
branch: externals/diff-hl
commit 133538973b58cc8a236126c8cada494fb7118aee
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
Add diff-hl-show-hunk-stage-hunk and the buttons
#71
---
diff-hl-show-hunk-posframe.el | 9 ++++++++-
diff-hl-show-hunk.el | 14 ++++++++++++--
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/diff-hl-show-hunk-posframe.el b/diff-hl-show-hunk-posframe.el
index f6a2cb3..9254e1c 100644
--- a/diff-hl-show-hunk-posframe.el
+++ b/diff-hl-show-hunk-posframe.el
@@ -156,7 +156,14 @@ The button calls an ACTION."
(diff-hl-show-hunk--posframe-button
"♻ Revert hunk"
"Revert hunk (\\[diff-hl-show-hunk-revert-hunk])"
- #'diff-hl-show-hunk-revert-hunk)))
+ #'diff-hl-show-hunk-revert-hunk)
+
+ (unless diff-hl-show-staged-changes
+ (diff-hl-show-hunk--posframe-button
+ "⊕ Stage hunk"
+ "Stage hunk (\\[diff-hl-show-hunk-stage-hunk])"
+ #'diff-hl-show-hunk-stage-hunk))
+ ))
;;;###autoload
(defun diff-hl-show-hunk-posframe (buffer &optional _line)
diff --git a/diff-hl-show-hunk.el b/diff-hl-show-hunk.el
index 1a5d883..00f6d92 100644
--- a/diff-hl-show-hunk.el
+++ b/diff-hl-show-hunk.el
@@ -220,6 +220,7 @@ Returns a list with the buffer and the line number of the
clicked line."
(define-key map (kbd "]") #'diff-hl-show-hunk-next)
(define-key map (kbd "{") #'diff-hl-show-hunk-previous)
(define-key map (kbd "}") #'diff-hl-show-hunk-next)
+ (define-key map (kbd "S") #'diff-hl-show-hunk-stage-hunk)
map))
(defvar diff-hl-show-hunk--hide-function)
@@ -268,13 +269,16 @@ BUFFER is a buffer with the hunk."
(let ((height
(when smart-lines
(when (not (eq 0 original-lines-number))
- original-lines-number))))
+ original-lines-number)))
+ (footer "(q)Quit (p)Previous (n)Next (r)Revert (c)Copy
original"))
+ (unless diff-hl-show-staged-changes
+ (setq footer (concat footer " (S)Stage")))
(diff-hl-inline-popup-show
propertized-lines
(if (and (boundp 'diff-hl-reference-revision)
diff-hl-reference-revision)
(concat "Diff with " diff-hl-reference-revision)
"Diff with HEAD")
- "(q)Quit (p)Previous (n)Next (r)Revert (c)Copy original"
+ footer
diff-hl-show-hunk-map
#'diff-hl-show-hunk-hide
point
@@ -294,6 +298,12 @@ BUFFER is a buffer with the hunk."
(let (diff-hl-ask-before-revert-hunk)
(diff-hl-revert-hunk)))
+(defun diff-hl-show-hunk-stage-hunk ()
+ "Dismiss the popup and stage the current hunk."
+ (interactive)
+ (diff-hl-show-hunk-hide)
+ (diff-hl-stage-current-hunk))
+
;;;###autoload
(defun diff-hl-show-hunk-previous ()
"Go to previous hunk/change and show it."