unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Tino Calancha <tino.calancha@gmail.com>
To: Andreas Schwab <schwab@suse.de>
Cc: 24725@debbugs.gnu.org, Dmitry Gutov <dgutov@yandex.ru>,
	Tino Calancha <tino.calancha@gmail.com>
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	[thread overview]
Message-ID: <87r37bcuho.fsf@gmail.com> (raw)
In-Reply-To: <mvmeg3bo4yt.fsf@hawking.suse.de> (Andreas Schwab's message of "Thu, 20 Oct 2016 09:27:22 +0200")

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	other threads:[~2016-10-20  8:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-18 14:27 bug#24725: 25.1.50; vc-region-history may exceed max line number of file in repository Tino Calancha
2016-10-19 23:22 ` Dmitry Gutov
2016-10-20  4:22   ` Tino Calancha
2016-10-20  7:27     ` Andreas Schwab
2016-10-20  8:09       ` Tino Calancha [this message]
2016-10-20 10:21         ` Dmitry Gutov
2016-10-20 10:44           ` Tino Calancha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r37bcuho.fsf@gmail.com \
    --to=tino.calancha@gmail.com \
    --cc=24725@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    --cc=schwab@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).