[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [patch] add interactive browse of revisions from vc *Annotate* buffe
From: |
Kim F. Storm |
Subject: |
Re: [patch] add interactive browse of revisions from vc *Annotate* buffers |
Date: |
21 Jan 2004 17:39:31 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
Stefan Monnier <address@hidden> writes:
> > (defun line-at-pos (&optional pos)
> > "Return buffer line number and narrowed line number at position POS.
> > If POS is nil, use current buffer location.
> > Return value is a cons (line-number . narrowed-line-number)."
>
> I suggest to only return narrowed-line-number (i.e. ignore narrowing).
> After all, most/all functions are expected to ignore narrowing unless they
> specifically need to know about it.
>
> `what-line' can still make use of such a function by doing the widening
> itself like it used to (and use the same optimization you suggested).
>
How about this version?
(defun line-at-pos (&optional pos start)
"Return (narrowed) buffer line number at position POS.
If POS is nil, use current buffer location.
If START is non-nil, count lines from that buffer position,
even if narrowing is in effect."
(let ((opoint (or pos (point))))
(save-excursion
(save-restriction
(goto-char (point-min))
(widen)
(if start
(goto-char start))
(forward-line 0)
(setq start (point))
(goto-char opoint)
(forward-line 0)
(1+ (count-lines start (point)))))))
(defun what-line ()
"Print the current buffer line number and narrowed line number of point."
(interactive)
(let ((l1 (line-at-pos (point-min) 0))
(l2 (line-at-pos (point) (point-min))))
(if (> l1 1)
(message "line %d (narrowed line %d)" (+ l1 l2 -1) l2)
(message "Line %d" l2))))
--
Kim F. Storm <address@hidden> http://www.cua.dk
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers, (continued)
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers, Kim F. Storm, 2004/01/16
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers, Richard Stallman, 2004/01/17
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers, Benjamin Rutt, 2004/01/17
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers, Andre Spiegel, 2004/01/19
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers, Kai Grossjohann, 2004/01/19
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers, Benjamin Rutt, 2004/01/19
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers, Kim F. Storm, 2004/01/19
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers, Richard Stallman, 2004/01/20
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers, Kim F. Storm, 2004/01/21
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers, Stefan Monnier, 2004/01/21
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers,
Kim F. Storm <=
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers, Stefan Monnier, 2004/01/21
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers, Kim F. Storm, 2004/01/22
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers, Andre Spiegel, 2004/01/22
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers, Benjamin Rutt, 2004/01/22
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers, Richard Stallman, 2004/01/22
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers, Miles Bader, 2004/01/22
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers, Kevin Rodgers, 2004/01/20
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers, Stefan Monnier, 2004/01/20
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers, Benjamin Rutt, 2004/01/20
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers, Stefan Monnier, 2004/01/20