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

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

[elpa] externals/diff-hl f3b2d15 11/25: diff-hl-diff-goto-hunk, diff-hl-


From: Dmitry Gutov
Subject: [elpa] externals/diff-hl f3b2d15 11/25: diff-hl-diff-goto-hunk, diff-hl-revert-hunk: handle indirect buffers.
Date: Sun, 20 Dec 2020 05:07:01 -0500 (EST)

branch: externals/diff-hl
commit f3b2d1518caf23cdb0c8fa617bcfe62b680f801b
Author: Nathan Moreau <nathan.moreau@m4x.org>
Commit: Nathan Moreau <nathan.moreau@m4x.org>

    diff-hl-diff-goto-hunk, diff-hl-revert-hunk: handle indirect buffers.
---
 diff-hl.el | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/diff-hl.el b/diff-hl.el
index f504ddf..2dcff96 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -1,6 +1,6 @@
 ;;; diff-hl.el --- Highlight uncommitted changes using VC -*- lexical-binding: 
t -*-
 
-;; Copyright (C) 2012-2019  Free Software Foundation, Inc.
+;; Copyright (C) 2012-2020  Free Software Foundation, Inc.
 
 ;; Author:   Dmitry Gutov <dgutov@yandex.ru>
 ;; URL:      https://github.com/dgutov/diff-hl
@@ -376,9 +376,7 @@ the end position as its only argument."
     (unless (buffer-modified-p)
       (diff-hl-update))))
 
-(defun diff-hl-diff-goto-hunk ()
-  "Run VC diff command and go to the line corresponding to the current."
-  (interactive)
+(defun diff-hl-diff-goto-hunk-1 ()
   (vc-buffer-sync)
   (let* ((line (line-number-at-pos))
          (buffer (current-buffer)))
@@ -388,6 +386,12 @@ the end position as its only argument."
                       (diff-hl-diff-skip-to ,line)
                       (setq vc-sentinel-movepoint (point))))))
 
+(defun diff-hl-diff-goto-hunk ()
+  "Run VC diff command and go to the line corresponding to the current."
+  (interactive)
+  (with-current-buffer (or (buffer-base-buffer) (current-buffer))
+    (diff-hl-diff-goto-hunk-1)))
+
 (defun diff-hl-diff-skip-to (line)
   "In `diff-mode', skip to the hunk and line corresponding to LINE
 in the source file, or the last line of the hunk above it."
@@ -421,9 +425,7 @@ in the source file, or the last line of the hunk above it."
                                          'diff-hl-reverted-hunk-highlight)
         (forward-line 1)))))
 
-(defun diff-hl-revert-hunk ()
-  "Revert the diff hunk with changes at or above the point."
-  (interactive)
+(defun diff-hl-revert-hunk-1 ()
   (save-restriction
     (widen)
     (vc-buffer-sync)
@@ -475,6 +477,12 @@ in the source file, or the last line of the hunk above it."
                 (message "Hunk reverted"))))
         (quit-windows-on diff-buffer t)))))
 
+(defun diff-hl-revert-hunk ()
+  "Revert the diff hunk with changes at or above the point."
+  (interactive)
+  (with-current-buffer (or (buffer-base-buffer) (current-buffer))
+    (diff-hl-revert-hunk-1)))
+
 (defun diff-hl-hunk-overlay-at (pos)
   (cl-loop for o in (overlays-in pos (1+ pos))
            when (overlay-get o 'diff-hl-hunk)



reply via email to

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