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

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

bug#24725: 25.1.50; vc-region-history may exceed max line number of file


From: Tino Calancha
Subject: bug#24725: 25.1.50; vc-region-history may exceed max line number of file in repository
Date: Thu, 20 Oct 2016 17:09:07 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Andreas Schwab <schwab@suse.de> writes:

> On Okt 20 2016, Tino Calancha <tino.calancha@gmail.com> wrote:
>
>> diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
>> index 9eac5b2..c6a9064 100644
>> --- a/lisp/vc/vc-git.el
>> +++ b/lisp/vc/vc-git.el
>> @@ -1016,6 +1016,8 @@ vc-git-region-history
>>    ;; FIXME: Maybe this should be done in vc.el (i.e. for all backends), but
>>    ;; since Git is the only backend to support this operation so far, it's 
>> hard
>>    ;; to tell.
>> +  (when (> lto (line-number-at-pos (1- (point-max))))
>> +    (setq lto (line-number-at-pos (1- (point-max)))))
>
> Shouldn't that be fixed in the caller, and lto always be decremented if
> the regions ends at bol?
I think you are right.  Otherwise we are including a line out of the
region, i.e., in interactive calls we also search in the history for
a line out of the highlighted region.
How about following new patch?

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>From b05b6d12171ea270f6b392c8af7f4415414960e5 Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha@gmail.com>
Date: Thu, 20 Oct 2016 17:00:04 +0900
Subject: [PATCH] vc-region-history: Search just on lines within the region

* lisp/vc/vc.el (vc-region-history): If region ends in the beginning
of a line, then exclude that line from the search (Bug#24725).
---
 lisp/vc/vc.el | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index af875e8..0d8e308 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -2393,7 +2393,11 @@ vc-region-history
   "Show the history of the region FROM..TO."
   (interactive "r")
   (let* ((lfrom (line-number-at-pos from))
-         (lto   (line-number-at-pos to))
+         (lto   (save-excursion
+                  (goto-char to)
+                  (if (bolp)
+                      (1- (line-number-at-pos to))
+                    (line-number-at-pos to))))
          (file buffer-file-name)
          (backend (vc-backend file))
          (buf (get-buffer-create "*VC-history*")))
-- 
2.9.3

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
In GNU Emacs 25.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.1)
 of 2016-10-20
Repository revision: 8988327d548db7b69f30ea15496ccb0726fa4502





reply via email to

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