[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 12:26:27 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
Richard Stallman <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 line-number or a cons (line-number narrowed-line-number)."
>
> I don't like that complex definition of the return value.
> It should be one or the other.
What about this version?
(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)."
(let ((opoint (or pos (point))) start)
(save-excursion
(save-restriction
(goto-char (point-min))
(widen)
(forward-line 0)
(setq start (point))
(goto-char opoint)
(forward-line 0)
(let ((l1 (count-lines (point-min) start))
(l2 (count-lines start (point))))
(cons (+ l1 l2 1) (1+ l2)))))))
(defun what-line ()
"Print the current buffer line number and narrowed line number of point."
(interactive)
(let ((l (line-at-pos (point))))
(if (/= (car l) (cdr l))
(message "line %d (narrowed line %d)" (car l) (cdr l))
(message "Line %d" (car l)))))
It actually works faster by not counting the lines between start and
point twice!
--
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, Andre Spiegel, 2004/01/15
- Re: [patch] add interactive browse of revisions from vc *Annotate* buffers, Richard Stallman, 2004/01/16
- 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 <=
- 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/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, 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