unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* How to change overlay arrow position silently?
@ 2009-08-02 13:01 Dmitry Dzhus
  2009-08-02 13:57 ` Johan Bockgård
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Dzhus @ 2009-08-02 13:01 UTC (permalink / raw)
  To: emacs-devel

How are you gentlemen.

In the package I'm working on, gdb-mi, overlay arrows are used in
several GDB buffers to mark current stack frame and current thread, just
like GUD uses overlay arrow to mark current line of program source.

Looks like changing overlay-arrow-position produces «Mark set» message,
which is undesirable for me because user may miss some notifications
provided by my code (like «Switched to thread #5»).

(mapc
 (lambda (n)
   (goto-line n)
   (set-marker overlay-arrow-position
               (point-marker)))
 '(1 2 3 4 5))
=>
Mark set [5 times]

Is there any way to inhibit «Mark set» message while changing overlay
arrow position? I see that push-mark has nomsg argument for this, but it
works only for The Mark, not any marker.
-- 
Happy Hacking.

http://sphinx.net.ru^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to change overlay arrow position silently?
  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
  0 siblings, 1 reply; 6+ messages in thread
From: Johan Bockgård @ 2009-08-02 13:57 UTC (permalink / raw)
  To: emacs-devel

Dmitry Dzhus <dima@sphinx.net.ru> writes:

> Looks like changing overlay-arrow-position produces «Mark set» message,
> which is undesirable for me because user may miss some notifications
> provided by my code (like «Switched to thread #5»).
>
> (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.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to change overlay arrow position silently?
  2009-08-02 13:57 ` Johan Bockgård
@ 2009-08-03  0:14   ` Juri Linkov
  2009-08-04 17:38     ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Juri Linkov @ 2009-08-03  0:14 UTC (permalink / raw)
  To: emacs-devel

>> (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/




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to change overlay arrow position silently?
  2009-08-03  0:14   ` Juri Linkov
@ 2009-08-04 17:38     ` Stefan Monnier
  2009-08-09 22:55       ` Juri Linkov
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2009-08-04 17:38 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel

> Its docstring says it can be used non-interactively:

>   When called from Lisp code, the optional argument BUFFER
>   ==========================
>   specifies a buffer to switch to.

It seems like even this `buffer' argument is very much an "interactive"
feature since it causes the buffer to be displayed, which may cause new
windows/frames to be created.

Makes me wonder: does any code use this `buffer' argument?  My guess is
that it's only used by things like the command-line-arg processing
(and/or the emacs-server).  We had better make it more clear: do not use
it from Elisp unless you know what you're doing (i.e. add it to
byte-compile-interactive-only-functions).


        Stefan




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to change overlay arrow position silently?
  2009-08-04 17:38     ` Stefan Monnier
@ 2009-08-09 22:55       ` Juri Linkov
  2009-08-10  2:41         ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Juri Linkov @ 2009-08-09 22:55 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

>> Its docstring says it can be used non-interactively:
>
>>   When called from Lisp code, the optional argument BUFFER
>>   ==========================
>>   specifies a buffer to switch to.
>
> It seems like even this `buffer' argument is very much an "interactive"
> feature since it causes the buffer to be displayed, which may cause new
> windows/frames to be created.
>
> Makes me wonder: does any code use this `buffer' argument?  My guess is
> that it's only used by things like the command-line-arg processing
> (and/or the emacs-server).  We had better make it more clear: do not use
> it from Elisp unless you know what you're doing (i.e. add it to
> byte-compile-interactive-only-functions).

I can't find any code that uses this `buffer' argument, but there are
more than 150 places in Emacs that call this `goto-line' function.
So we can't easily prohibit using it non-interactively.  But I think
there is no harm when using non-interactively.  A similar function
"goto-char" has interactive/non-interactive duality with no problem.

The only problem with "goto-line" is that it sets the mark and prints
the message "Mark set".  Using a new argument `interactivep' will allow
the programmer to decide where to do this.  When a command is just
a wrapper around the `goto-line' (like the command `View-goto-line')
then it should call `goto-line' with interactivep=t.

-- 
Juri Linkov
http://www.jurta.org/emacs/




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to change overlay arrow position silently?
  2009-08-09 22:55       ` Juri Linkov
@ 2009-08-10  2:41         ` Stefan Monnier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2009-08-10  2:41 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel

> I can't find any code that uses this `buffer' argument, but there are
> more than 150 places in Emacs that call this `goto-line' function.
> So we can't easily prohibit using it non-interactively.

Strawman: nobody's talking about prohibiting anything.  Only adding it
to byte-compile-interactive-only-functions.


        Stefan




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-08-10  2:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2009-08-04 17:38     ` Stefan Monnier
2009-08-09 22:55       ` Juri Linkov
2009-08-10  2:41         ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).