emacs-devel
[Top][All Lists]
Advanced

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

RE: Key binding M-g should really be goto-line autolearn=noversion=3.0.2


From: Drew Adams
Subject: RE: Key binding M-g should really be goto-line autolearn=noversion=3.0.2 autolearn=no version=3.0.2
Date: Thu, 3 Mar 2005 14:24:41 -0800

    > What I suggested was a simple command to pick up a numeral
    > from any buffer,
    > regardless of what the numeral might mean in that buffer. It would be
    > rudimentary, but would do at least what people are doing with
    > `goto-line',
    > without requiring them to key in the line number.

    Is this what you have in mind?

    (defun goto-line-at-point (&optional buffer)
       "Go to the line whose number is given at point, counting like \
    \\[goto-line].
    With a prefix arg, prompt for a BUFFER and select it before moving."
       (interactive (list (if current-prefix-arg
                              (read-buffer "Goto buffer: "
                                           (other-buffer (current-buffer) t)
                                           t))))
       (when buffer
         (pop-to-buffer buffer))
       (goto-line (number-at-point)))

I was thinking more like the following. You don't want to have to input the
buffer each time (even hitting RET to get the default). And it's unlikely
that you would want to go to a line in the same buffer in which the line
number appears.

(defun goto-line-at-point (buffer)
  "In another buffer, go to the line whose number is at point.
With prefix argument, you are prompted for the buffer.
Without it, `other-buffer' is used."
  (interactive
   (list (if current-prefix-arg
             (read-buffer
                "Buffer: "
                (other-buffer (current-buffer) t)
                t)
           (other-buffer (current-buffer) t))))
  (let ((lineno (or (number-at-point)
                    (error "No number near cursor"))))
    (unless (wholenump lineno)
            (setq lineno (abs (truncate lineno))))
    (message "Line %s in buffer `%s'" lineno buffer)
    (pop-to-buffer buffer)
    (goto-line lineno)))

    If so, maybe a mouse- version would be useful, too.

Yes, that's what I was suggesting. I don't have a need for such commands,
but it sounded like they might be useful for the use case cited.





reply via email to

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