emacs-bug-tracker
[Top][All Lists]
Advanced

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

[debbugs-tracker] bug#23679: closed (25.0.94; vc-region-history does not


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#23679: closed (25.0.94; vc-region-history does not work correctly when narrowed)
Date: Wed, 20 Dec 2017 20:16:04 +0000

Your message dated Wed, 20 Dec 2017 21:18:55 +0100
with message-id <address@hidden>
and subject line Re: bug#23679: 25.0.94; vc-region-history does not work 
correctly when narrowed
has caused the debbugs.gnu.org bug report #23679,
regarding 25.0.94; vc-region-history does not work correctly when narrowed
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
23679: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=23679
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: 25.0.94; vc-region-history does not work correctly when narrowed Date: Wed, 1 Jun 2016 20:44:03 -0600
1. Emacs -Q
2. Open a file with git history, say something in the Emacs repository.
3. Narrow to a region not at the beginning of the file
4. Select a region
5. M-x vc-region-history
6. Notice that the history shown is for the beginning of the file

This is because vc-region-history uses line-number-at-pos which returns
the line number in the narrowed portion of the buffer.

We could either put a save-restriction/widen pair in vc-region-history
or create a function (say widened-line-number-at-pos or
file-line-number-at-pos), which would be generally useful IMO.
However, that would lead to two calles to save-restriction and widen
instead of just one.  Given the recent discussion on emacs-devel about
widening for programs I felt I should get some feed back on the
preferred method before pushing a fix.

-Ivan




--- End Message ---
--- Begin Message --- Subject: Re: bug#23679: 25.0.94; vc-region-history does not work correctly when narrowed Date: Wed, 20 Dec 2017 21:18:55 +0100
> From: Ivan Andrus <address@hidden>
> Date: Wed, 1 Jun 2016 20:44:03 -0600
> 
> 1. Emacs -Q
> 2. Open a file with git history, say something in the Emacs repository.
> 3. Narrow to a region not at the beginning of the file
> 4. Select a region
> 5. M-x vc-region-history
> 6. Notice that the history shown is for the beginning of the file
> 
> This is because vc-region-history uses line-number-at-pos which returns
> the line number in the narrowed portion of the buffer.
> 
> We could either put a save-restriction/widen pair in vc-region-history
> or create a function (say widened-line-number-at-pos or
> file-line-number-at-pos), which would be generally useful IMO.
> However, that would lead to two calles to save-restriction and widen
> instead of just one.  Given the recent discussion on emacs-devel about
> widening for programs I felt I should get some feed back on the
> preferred method before pushing a fix.
> 
> -Ivan

In the meantime, line-number-at-pos got an extra optional argument to
count from (point-min), so this should now be fixed:

branch: master
commit 9f1c613b07e4a745671af5818366660e3765984d

    Fix vc-region-history when narrowed
    
    * lisp/vc/vc.el (vc-region-history): Fix behavior when narrowed, by using
    line numbers starting from (point-min).
---
 lisp/vc/vc.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index b159991..f48f682 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -2417,8 +2417,8 @@ When called interactively with a prefix argument, prompt 
for REMOTE-LOCATION."
 (defun vc-region-history (from to)
   "Show the history of the region FROM..TO."
   (interactive "r")
-  (let* ((lfrom (line-number-at-pos from))
-         (lto   (line-number-at-pos (1- to)))
+  (let* ((lfrom (line-number-at-pos from t))
+         (lto   (line-number-at-pos (1- to) t))
          (file buffer-file-name)
          (backend (vc-backend file))
          (buf (get-buffer-create "*VC-history*")))

(I forgot to mention the bug# in the commit, will hopefully remember
next time.)


--- End Message ---

reply via email to

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