unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#8366: wish: include vc-annotate-goto-line
@ 2011-03-28 15:12 Uwe Brauer
  2011-03-28 17:49 ` Stefan Monnier
  2022-01-31 16:46 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 9+ messages in thread
From: Uwe Brauer @ 2011-03-28 15:12 UTC (permalink / raw)
  To: 8366

Hello

some days ago Juanma Barranquero wrote a very useful function which allows 
you to jump from the vc-annotate buffer to the corresponding point in the
file which is under vc. 


I strongly suggesto to include this function.

(defun vc-annotate-goto-line ()
  (interactive)
  (unless (eq major-mode 'vc-annotate-mode)
    (error "vc-annotate-goto-line must be used on a VC-Annotate buffer"))
  (let* ((name (buffer-name))
         (base (and (string-match "Annotate \\(.*\\) (rev" name)
                    (match-string 1 name)))
         (line (save-restriction
                 (widen)
                 (line-number-at-pos))))
    (with-current-buffer (get-buffer base)
      (pop-to-buffer (current-buffer))
      (save-restriction
        (widen)
        (goto-char (point-min))
        (forward-line (1- line))
        (recenter)))))

Uwe Brauer 

In GNU Emacs 22.2.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2010-03-26 on palmer, modified by Ubuntu
Windowing system distributor `The X.Org Foundation', version 11.0.10600000
configured using `configure  '--build=i486-linux-gnu' '--host=i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs22:/etc/emacs:/usr/local/share/emacs/22.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/22.2/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/22.2/leim' '--with-x=yes' '--with-x-toolkit=athena' '--with-toolkit-scroll-bars' 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2' 'LDFLAGS=-g -Wl,--as-needed' 'CPPFLAGS=''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8
  default-enable-multibyte-characters: t

Major mode: Apropos

Minor modes in effect:
  tooltip-mode: t
  tool-bar-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t

Recent input:
y e s C-g C-x C-q C-x v v y y e s <return> y e s <return> 
C-x 2 C-x C-f C-g C-x o C-x o C-x 1 C-x C-f <backspace> 
<return> g <down> <down> <up> <up> <up> <up> <up> <down> 
f <end> <C-f1> <up> <up> <up> <up> <return> <return> 
<return> <return> <return> <up> <up> <up> C-x 2 C-x 
C-f <M-backspace> x e <tab> / s i <tab> v <tab> <M-backspace> 
<M-backspace> <M-backspace> <return> s <C-home> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <up> <up> <up> <up> <up> <up> <up> <up> f s 
<C-home> <down> <down> <down> f <C-end> <up> <up> <up> 
<up> <up> <up> <up> <up> C-SPC <down> <down> <down> 
<down> C-w C-y C-x o C-y <up> C-x C-e C-x o C-e C-x 
C-e <C-prior> <return> C-x C-f <backspace> <return> 
g C-x 1 f C-x C-s C-x k <return> g <down> <down> <down> 
f C-x v v C-c C-a C-c C-a C-c C-c <C-f12> <return> 
M-x e m a c s SPC s u <tab> C-h a b u g <return> C-x 
o C-s s u b m i t C-s C-s C-s C-s C-s C-s C-s <home> 
<next> <next> <next> <next> <prior> <home> C-s e m 
a c s - b C-s C-x o M-x r e p o r t SPC e m <tab> <return> 
w i s h : SPC i n c l u c <backspace> d e SPC <f10> 
<S-f1> <help-echo> <down-mouse-1> <mouse-1> C-g C-x 
C-x o C-x o C-x o C-g <backspace> C-x C-f s i <tab> 
v c <tab> <backspace> <backspace> v <tab> v c <tab> 
a <tab> <return> <next> <next> <next> <next> <next> 
<next> <next> <next> <down> <right> <right> <right> 
<right> <right> <right> <right> C-M-k C-y C-x o x M-x 
r e p o r <tab> <return>

Recent messages:
Loading apropos...done
Type C-x 1 to remove help window.  
Mark saved where search started
Mark set [2 times]
Mark saved where search started
Loading emacsbug...done
Quit
exchange-point-and-mark: No mark set in this buffer
Quit
Mark set
byte-code: Buffer is read-only: #<buffer *Apropos*>






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#8366: wish: include vc-annotate-goto-line
  2011-03-28 15:12 bug#8366: wish: include vc-annotate-goto-line Uwe Brauer
@ 2011-03-28 17:49 ` Stefan Monnier
  2011-03-29  0:43   ` Juanma Barranquero
  2011-03-29  8:47   ` martin rudalics
  2022-01-31 16:46 ` Lars Ingebrigtsen
  1 sibling, 2 replies; 9+ messages in thread
From: Stefan Monnier @ 2011-03-28 17:49 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: 8366

> I strongly suggesto to include this function.

Juanma, feel free to install such a feature.

> (defun vc-annotate-goto-line ()
>   (interactive)
>   (unless (eq major-mode 'vc-annotate-mode)
>     (error "vc-annotate-goto-line must be used on a VC-Annotate buffer"))
>   (let* ((name (buffer-name))
>          (base (and (string-match "Annotate \\(.*\\) (rev" name)

AFAIK there should be a better way to find the file.
E.g. vc-parent-buffer.

>                     (match-string 1 name)))
>          (line (save-restriction
>                  (widen)
>                  (line-number-at-pos))))
>     (with-current-buffer (get-buffer base)
>       (pop-to-buffer (current-buffer))
>       (save-restriction
>         (widen)
>         (goto-char (point-min))
>         (forward-line (1- line))
>         (recenter)))))

Annotate buffer may display a different version that the one of the
checked out file.  E.g. because you have local uncommitted changes, or
because you asked for the annotations of an older revision.  So line
numbers may not fully match.  In general, there's no much we can do
about it, but we should probably try a bit harder than the above,
e.g. by looking for the closest line with the same text as the line
we're looking for.  Better would be to ask for a diff between the
annotated revision and the current file and use it to find out the
line-offset to use (for those cases where this method works).


        Stefan





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#8366: wish: include vc-annotate-goto-line
  2011-03-28 17:49 ` Stefan Monnier
@ 2011-03-29  0:43   ` Juanma Barranquero
  2011-03-29  3:32     ` Stefan Monnier
  2011-04-24 19:43     ` Chong Yidong
  2011-03-29  8:47   ` martin rudalics
  1 sibling, 2 replies; 9+ messages in thread
From: Juanma Barranquero @ 2011-03-29  0:43 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Uwe Brauer, 8366

On Mon, Mar 28, 2011 at 19:49, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> Juanma, feel free to install such a feature.

Hmm, no. It's just half-cooked; I threw it together in a few minutes
to help the OP.

> AFAIK there should be a better way to find the file.
> E.g. vc-parent-buffer.

Fist time I've heard of it ;-)

> Annotate buffer may display a different version that the one of the
> checked out file.  E.g. because you have local uncommitted changes, or
> because you asked for the annotations of an older revision.  So line
> numbers may not fully match.  In general, there's no much we can do
> about it, but we should probably try a bit harder than the above,
> e.g. by looking for the closest line with the same text as the line
> we're looking for.  Better would be to ask for a diff between the
> annotated revision and the current file and use it to find out the
> line-offset to use (for those cases where this method works).

Even if the buffer contains the same version, there's the matter of
visual-line-mode, truncate-lines, etc. which can affect line count. So
yes, for a robust answer looking at the context seems essential.

    Juanma





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#8366: wish: include vc-annotate-goto-line
  2011-03-29  0:43   ` Juanma Barranquero
@ 2011-03-29  3:32     ` Stefan Monnier
  2011-04-24 19:43     ` Chong Yidong
  1 sibling, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2011-03-29  3:32 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Uwe Brauer, 8366

> Even if the buffer contains the same version, there's the matter of
> visual-line-mode, truncate-lines, etc. which can affect line count.

count-lines and goto-line only pays attention to hard newlines and are
unaffected by display settings, so that shouldn't be an issue.


        Stefan





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#8366: wish: include vc-annotate-goto-line
  2011-03-28 17:49 ` Stefan Monnier
  2011-03-29  0:43   ` Juanma Barranquero
@ 2011-03-29  8:47   ` martin rudalics
  2011-03-29 13:51     ` Stefan Monnier
  1 sibling, 1 reply; 9+ messages in thread
From: martin rudalics @ 2011-03-29  8:47 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Uwe Brauer, 8366

 > Annotate buffer may display a different version that the one of the
 > checked out file.  E.g. because you have local uncommitted changes, or
 > because you asked for the annotations of an older revision.  So line
 > numbers may not fully match.  In general, there's no much we can do
 > about it, but we should probably try a bit harder than the above,
 > e.g. by looking for the closest line with the same text as the line
 > we're looking for.  Better would be to ask for a diff between the
 > annotated revision and the current file and use it to find out the
 > line-offset to use (for those cases where this method works).

I'm often in need for a general, customizable function for finding the
best match of some text in two different buffers.  For example, to get
from a texinfo to an info buffer and vice-versa.  Any advances in that
direction would be very appreciated.

martin






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#8366: wish: include vc-annotate-goto-line
  2011-03-29  8:47   ` martin rudalics
@ 2011-03-29 13:51     ` Stefan Monnier
  2011-03-29 15:18       ` martin rudalics
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2011-03-29 13:51 UTC (permalink / raw)
  To: martin rudalics; +Cc: Uwe Brauer, 8366

> I'm often in need for a general, customizable function for finding the
> best match of some text in two different buffers.  For example, to get
> from a texinfo to an info buffer and vice-versa.  Any advances in that
> direction would be very appreciated.

Damn!  And I thought you had this stashed in your window-pub branch!


        Stefan





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#8366: wish: include vc-annotate-goto-line
  2011-03-29 13:51     ` Stefan Monnier
@ 2011-03-29 15:18       ` martin rudalics
  0 siblings, 0 replies; 9+ messages in thread
From: martin rudalics @ 2011-03-29 15:18 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Uwe Brauer, 8366

 >> I'm often in need for a general, customizable function for finding the
 >> best match of some text in two different buffers.  For example, to get
 >> from a texinfo to an info buffer and vice-versa.  Any advances in that
 >> direction would be very appreciated.
 >
 > Damn!  And I thought you had this stashed in your window-pub branch!

I've stashed it somewhere else.  But it's far from perfect :-(

martin





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#8366: wish: include vc-annotate-goto-line
  2011-03-29  0:43   ` Juanma Barranquero
  2011-03-29  3:32     ` Stefan Monnier
@ 2011-04-24 19:43     ` Chong Yidong
  1 sibling, 0 replies; 9+ messages in thread
From: Chong Yidong @ 2011-04-24 19:43 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: Uwe Brauer, 8366

Juanma Barranquero <lekktu@gmail.com> writes:

>> Juanma, feel free to install such a feature.
>
> Hmm, no. It's just half-cooked; I threw it together in a few minutes
> to help the OP.
>
>> Annotate buffer may display a different version that the one of the
>> checked out file.  E.g. because you have local uncommitted changes, or
>> because you asked for the annotations of an older revision.  So line
>> numbers may not fully match.  In general, there's no much we can do
>> about it, but we should probably try a bit harder than the above,
>> e.g. by looking for the closest line with the same text as the line
>> we're looking for.  Better would be to ask for a diff between the
>> annotated revision and the current file and use it to find out the
>> line-offset to use (for those cases where this method works).
>
> Even if the buffer contains the same version, there's the matter of
> visual-line-mode, truncate-lines, etc. which can affect line count. So
> yes, for a robust answer looking at the context seems essential.

A non-robust implementation is better than nothing, so I committed the
command to the trunk, starting from your version, and revising it to use
vc-parent-buffer and emitting warning messages if the parent file/buffer
is modified or out of date.

As for the "look for the closest line with the same text" functionality,
my feeling is that this is a mug's game when version control is
involved.  If you or anyone else wants to take a stab at it, feel free.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#8366: wish: include vc-annotate-goto-line
  2011-03-28 15:12 bug#8366: wish: include vc-annotate-goto-line Uwe Brauer
  2011-03-28 17:49 ` Stefan Monnier
@ 2022-01-31 16:46 ` Lars Ingebrigtsen
  1 sibling, 0 replies; 9+ messages in thread
From: Lars Ingebrigtsen @ 2022-01-31 16:46 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: 8366

Uwe Brauer <oub@mat.ucm.es> writes:

> some days ago Juanma Barranquero wrote a very useful function which allows 
> you to jump from the vc-annotate buffer to the corresponding point in the
> file which is under vc. 
>
> I strongly suggesto to include this function.
>
> (defun vc-annotate-goto-line ()
>   (interactive)

This was apparently added a week later:

commit 3ba7869ce8386d79d21f8e6f7d3c23088f9838ce
Author:     Chong Yidong <cyd@stupidchicken.com>
AuthorDate: Sun Apr 24 15:37:47 2011 -0400

    Add vc-annotate-goto-line.
    * vc/vc-annotate.el (vc-annotate-goto-line): New command.  Based
    on a previous implementation by Juanma Barranquero (Bug#8366).

So I'm therefore closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-01-31 16:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-28 15:12 bug#8366: wish: include vc-annotate-goto-line Uwe Brauer
2011-03-28 17:49 ` Stefan Monnier
2011-03-29  0:43   ` Juanma Barranquero
2011-03-29  3:32     ` Stefan Monnier
2011-04-24 19:43     ` Chong Yidong
2011-03-29  8:47   ` martin rudalics
2011-03-29 13:51     ` Stefan Monnier
2011-03-29 15:18       ` martin rudalics
2022-01-31 16:46 ` Lars Ingebrigtsen

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).