/[emacs]/emacs/lisp/simple.el
ViewVC logotype

Diff of /emacs/lisp/simple.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.691 by kfstorm, Sat Feb 19 23:30:29 2005 UTC revision 1.692 by rms, Sat Mar 5 18:02:40 2005 UTC
# Line 733  that uses or sets the mark." Line 733  that uses or sets the mark."
733    
734  ;; Counting lines, one way or another.  ;; Counting lines, one way or another.
735    
736  (defun goto-line (arg)  (defun goto-line (arg &optional buffer)
737    "Goto line ARG, counting from line 1 at beginning of buffer."    "Goto line ARG, counting from line 1 at beginning of buffer.
738    (interactive "NGoto line: ")  Normally, move point in the curren buffer.
739    (setq arg (prefix-numeric-value arg))  With just C-u as argument, move point in the most recently displayed
740    other buffer, and switch to it.
741    
742    If there's a number in the buffer at point, it is the default for ARG."
743      (interactive
744       (if (and current-prefix-arg (not (consp current-prefix-arg)))
745           (list (prefix-numeric-value current-prefix-arg))
746         ;; Look for a default, a number in the buffer at point.
747         (let* ((default
748                  (save-excursion
749                    (skip-chars-backward "0-9")
750                    (if (looking-at "[0-9]")
751                        (buffer-substring-no-properties
752                         (point)
753                         (progn (skip-chars-forward "0-9")
754                                (point))))))
755                ;; Decide if we're switching buffers.
756                (buffer
757                 (if (consp current-prefix-arg)
758                     (other-buffer (current-buffer) t)))
759                (buffer-prompt
760                 (if buffer
761                     (concat " in " (buffer-name buffer))
762                   "")))
763           ;; Read the argument, offering that number (if any) as default.
764           (list (read-from-minibuffer (format (if default "Goto line%s (%s): "
765                                                 "Goto line%s: ")
766                                               buffer-prompt
767                                               default)
768                                       nil nil t
769                                       'minibuffer-history
770                                       default)
771                 buffer))))
772      ;; Switch to the desired buffer, one way or another.
773      (if buffer
774          (let ((window (get-buffer-window buffer)))
775            (if window (select-window window)
776              (switch-to-buffer-other-window buffer))))
777      ;; Move to the specified line number in that buffer.
778    (save-restriction    (save-restriction
779      (widen)      (widen)
780      (goto-char 1)      (goto-char 1)
781      (if (eq selective-display t)      (if (eq selective-display t)
782          (re-search-forward "[\n\C-m]" nil 'end (1- arg))          (re-search-forward "[\n\C-m]" nil 'end (1- arg))
783        (forward-line (1- arg)))))        (forward-line (1- arg))))))
784    
785  (defun count-lines-region (start end)  (defun count-lines-region (start end)
786    "Print number of lines and characters in the region."    "Print number of lines and characters in the region."

Legend:
Removed from v.1.691  
changed lines
  Added in v.1.692

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26