emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacs's handling of line numbers [from bug#5042]


From: Mark Lillibridge
Subject: Re: Emacs's handling of line numbers [from bug#5042]
Date: Wed, 23 Jun 2010 19:24:19 -0700

Glenn wrote:
>  Mark Lillibridge wrote:
>  
>  >>  Grep counts 8 such calls only.  Doesn't seem unmanageable at all.
>  >
>  > I think you missed some:
>  >
>  > ts-rhel4 [58]% pwd
>  > /nfs/pm-data1/mnt/d4/home/mdl/bin/emacs-23.1/lisp
>  
>  You should check the trunk (or even Emacs 23.2), where the
>  documentation and usage of goto-line is different to that in 23.1.

Finally got a chance to do that; you are correct:

    GNU Emacs 24.0.50.1 (i386-mingw-nt6.0.6002) of 2010-06-23 on LENNART-69DE564

    
    goto-line is an interactive compiled Lisp function in `simple.el'.
    
    It is bound to M-g, <menu-bar> <edit> <goto> <go-to-line>.
    
    (goto-line LINE &optional BUFFER)
    
    Goto LINE, counting from line 1 at beginning of buffer.
    Normally, move point in the current buffer, and leave mark at the
    previous position.  With just C-u as argument,
    move point in the most recently selected other buffer, and switch to it.
    
    If there's a number in the buffer at point, it is the default for LINE.
    
    This function is usually the wrong thing to use in a Lisp program.
    What you probably want instead is something like:
      (goto-char (point-min)) (forward-line (1- N))
    If at all possible, an even better solution is to use char counts
    rather than line counts.


    address@hidden /cygdrive/c/Program Files (x86)/Emacs_24/emacs/lisp
    $ find . -name \*.el -exec grep '(goto-line' {} \; -print
        (with-no-warnings (goto-line line))
    ./cedet/semantic/symref/list.el
                  ;; (goto-line line)
    ./cedet/semantic/symref.el
         (with-no-warnings (goto-line (vi-prefix-numeric-value arg)))))
    ./emulation/vi.el
                `(goto-line (string-to-int (elt ,elt 1))))
    ./progmodes/cperl-mode.el
                (goto-line ,current-line)
    ./vc/vc-annotate.el
    ;;  (if line (goto-line (prefix-numeric-value line))
    ./view.el

So, am I hearing that we should change goto-line to the following
functionality:

    goto-line is an interactive compiled Lisp function in `simple.el'.
    
    It is bound to M-g, <menu-bar> <edit> <goto> <go-to-line>.
    
    (goto-line LINE &optional BUFFER)
    
|   Goto line with line number LINE; use linum mode to see what line
|   numbers each line is assigned.
    Normally, move point in the current buffer, and leave mark at the
    previous position.  With just C-u as argument,
    move point in the most recently selected other buffer, and switch to it.
    
    If there's a number in the buffer at point, it is the default for LINE.
    
    This function is usually the wrong thing to use in a Lisp program.
    What you probably want instead is something like:
      (goto-char (point-min)) (forward-line (1- N))
    If at all possible, an even better solution is to use char counts
    rather than line counts.

Amusingly, the core of the first implementation would be the elisp above:

      (goto-char (point-min)) (forward-line (1- N))

which is *not* what goto-line actually does!  (It does a widen, which
this change would remove.)

- Mark



reply via email to

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