From: Juri Linkov <juri@jurta.org>
To: emacs-devel@gnu.org
Subject: Re: How to change overlay arrow position silently?
Date: Mon, 03 Aug 2009 03:14:36 +0300 [thread overview]
Message-ID: <874ospda07.fsf@mail.jurta.org> (raw)
In-Reply-To: <87hbwqfhd7.fsf@dd.chalmers.se> ("Johan Bockgård"'s message of "Sun, 02 Aug 2009 15:57:40 +0200")
>> (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/
next prev parent reply other threads:[~2009-08-03 0:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-02 13:01 How to change overlay arrow position silently? Dmitry Dzhus
2009-08-02 13:57 ` Johan Bockgård
2009-08-03 0:14 ` Juri Linkov [this message]
2009-08-04 17:38 ` Stefan Monnier
2009-08-09 22:55 ` Juri Linkov
2009-08-10 2:41 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874ospda07.fsf@mail.jurta.org \
--to=juri@jurta.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.