[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to change overlay arrow position silently?
From: |
Juri Linkov |
Subject: |
Re: How to change overlay arrow position silently? |
Date: |
Mon, 03 Aug 2009 03:14:36 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) |
>> (mapc
>> (lambda (n)
>> (goto-line n)
>> (set-marker overlay-arrow-position
>> (point-marker)))
>> '(1 2 3 4 5))
>> =>
>> Mark set [5 times]
>
> It is `goto-line' that prints this.
Its docstring says it can be used non-interactively:
When called from Lisp code, the optional argument BUFFER
==========================
specifies a buffer to switch to.
This means it is not a purely interactive command unlike
e.g. `query-replace' etc.
Therefore we need to distinguish interactive and non-interactive calls.
I remember Richard insisted on adding a new argument instead of relying
on `called-interactively-p'. So perhaps the right fix is following.
Another option would be using a prefix argument C-u like
`M-<' (`beginning-of-buffer') and `M->' (`end-of-buffer') do
to not set mark at previous position. But `goto-line'
already uses the C-u argument to move point in the most recently
selected other buffer.
Index: lisp/simple.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/simple.el,v
retrieving revision 1.1001
diff -u -r1.1001 simple.el
--- lisp/simple.el 31 Jul 2009 02:14:46 -0000 1.1001
+++ lisp/simple.el 3 Aug 2009 00:12:29 -0000
@@ -843,7 +843,7 @@
;; Counting lines, one way or another.
-(defun goto-line (line &optional buffer)
+(defun goto-line (line &optional buffer interactivep)
"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 \\[universal-argument] as argument,
@@ -855,7 +855,7 @@
LINE."
(interactive
(if (and current-prefix-arg (not (consp current-prefix-arg)))
- (list (prefix-numeric-value current-prefix-arg))
+ (list (prefix-numeric-value current-prefix-arg t))
;; Look for a default, a number in the buffer at point.
(let* ((default
(save-excursion
@@ -881,18 +881,18 @@
nil nil t
'minibuffer-history
default)
- buffer))))
+ buffer t))))
;; Switch to the desired buffer, one way or another.
(if buffer
(let ((window (get-buffer-window buffer)))
(if window (select-window window)
(switch-to-buffer-other-window buffer))))
;; Leave mark at previous position
- (or (region-active-p) (push-mark))
+ (or (not interactivep) (region-active-p) (push-mark))
;; Move to the specified line number in that buffer.
(save-restriction
(widen)
- (goto-char 1)
+ (goto-char (point-min))
(if (eq selective-display t)
(re-search-forward "[\n\C-m]" nil 'end (1- line))
(forward-line (1- line)))))
--
Juri Linkov
http://www.jurta.org/emacs/