emacs-devel
[Top][All Lists]
Advanced

[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: 20 Jan 2004 02:28:34 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

Benjamin Rutt <address@hidden> writes:

> Kai Grossjohann <address@hidden> writes:
> 
> > Andre Spiegel <address@hidden> writes:
> >
> >> I'm a bit puzzled by your function vc-current-line.  I must admit that
> >> I'm totally clueless in this area, but is there really no simpler way to
> >> determine this?  Surely, this problem must have occured elsewhere
> >> already.  Anybody got a hint for us?
> >
> > Wow, what-line uses the same logic, it seems.
> 
> So maybe what-line could be modified to return a useful value, namely
> the line number as an integer?

I think we should make a line-at-pos function:

(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)."
  (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)
        (if (/= start (point-min))
            (cons (1+ (count-lines (point-min) (point)))
                  (1+ (count-lines start (point))))
          (1+ (count-lines (point-min) (point))))))))

and then implement what-line in terms of this function:

(defun what-line ()
  "Print the current buffer line number and narrowed line number of point."
  (interactive)
  (let ((l (line-at-pos (point))))
    (if (consp l)
        (message "line %d (narrowed line %d)" (car l) (cdr l))
      (message "Line %d" l))))


-- 
Kim F. Storm <address@hidden> http://www.cua.dk





reply via email to

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