all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* other-frame, other-window prefix keys
@ 2015-08-08  7:24 Stephen Leake
  2015-08-08  7:31 ` Andreas Schwab
  2015-08-08 20:52 ` Stefan Monnier
  0 siblings, 2 replies; 8+ messages in thread
From: Stephen Leake @ 2015-08-08  7:24 UTC (permalink / raw
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 2111 bytes --]

I finally made time to work on universal other-frame and other-window
prefix keys. This was discussed about 2 years ago here:
https://lists.gnu.org/archive/html/emacs-devel/2013-09/msg00075.html. It
turned out to be easier than I anticipated.

Attached is a minor mode that implements this.

It advises switch-to-buffer and temp-buffer-window-show-advice, and
binds C-x 7 and C-x 8 such that:

C-x 7 <command> causes a buffer displayed by <command> to appear in
another window in the same frame; a window is created if necessary.

C-x 8 <command> causes a buffer displayed by <command> to appear in
another frame; a frame is created if necessary.


This avoids the need to define -other-window and -other-frame variants
of commands that switch to a new buffer; it adds those variants in a
generic way.

It also binds:

C-x W move current buffer to another window in the same frame

C-x F move current buffer to another frame

These make it easy to rearrange the buffer placement, and to recover
from forgetting to type C-x 7 or 8.


It works nicely, and I'm already getting dependent on it. 

I used C-x 7, C-x 8 because they are currently unbound. That's a bit
awkward to type, so in my personal setup I bound M-m, M-M, which are
close to M-. , which I use a lot, so this is very convenient.

Advising temp-buffer-window-show-advice addresses the issue of how
temporary prompt buffers are displayed.

There is one issue (see the FIXMEs); if the command is aborted for any
reason, the prefix (set in ofw-frame-window-prefix-arg) needs to be
reset. I haven't looked into doing that yet.

If post-command-hook is run even if a command is aborted, that might be
a good place to reset this. I'll have to try it.

I also haven't finished porting this to Emacs 24.3.

I'd be happy to put this in Gnu ELPA (in part so it is available for
Emacs 24.3), but there was some discussion in the original thread about
having something like this in core.

The advice on switch-to-buffer simply redefines the function; it is
probably possible to do that more carefully, to preserve more of the
current semantics.

-- 
-- Stephe

[-- Attachment #2: other-frame-window.el --]
[-- Type: application/emacs-lisp, Size: 10139 bytes --]

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

* Re: other-frame, other-window prefix keys
  2015-08-08  7:24 other-frame, other-window prefix keys Stephen Leake
@ 2015-08-08  7:31 ` Andreas Schwab
  2015-08-09  5:32   ` Stephen Leake
  2015-08-08 20:52 ` Stefan Monnier
  1 sibling, 1 reply; 8+ messages in thread
From: Andreas Schwab @ 2015-08-08  7:31 UTC (permalink / raw
  To: Stephen Leake; +Cc: emacs-devel

Stephen Leake <stephen_leake@stephe-leake.org> writes:

> I used C-x 7, C-x 8 because they are currently unbound.

C-x 8 is already bound.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



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

* Re: other-frame, other-window prefix keys
  2015-08-08  7:24 other-frame, other-window prefix keys Stephen Leake
  2015-08-08  7:31 ` Andreas Schwab
@ 2015-08-08 20:52 ` Stefan Monnier
  2015-08-09  6:06   ` Stephen Leake
  1 sibling, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2015-08-08 20:52 UTC (permalink / raw
  To: Stephen Leake; +Cc: emacs-devel

> C-x 7 <command> causes a buffer displayed by <command> to appear in
> another window in the same frame; a window is created if necessary.
>
> C-x 8 <command> causes a buffer displayed by <command> to appear in
> another frame; a frame is created if necessary.

It'd be great if you could bind them to C-x 4 and C-x 5 and arrange for
C-x 4 f (and friends) to still work as before.

That would make the advice on switch-to-buffer unnecessary, I think
since C-x 4 b and C-x 5 b would be more handy than C-x 4 C-x C-b anyway.

> Advising temp-buffer-window-show-advice addresses the issue of how
> temporary prompt buffers are displayed.

Indeed, this is a bit ugly.  Doesn't it prevent C-x 5 C-h f from
displaying the help in a separate frame?

Maybe we should arrange for the ofw-frame-window-prefix-arg to be
save&restored around calls to read-from-minibuffer.  It's not the first
time we have a need for such a thing, so adding a general list of "vars
to save&restore around recursive edits" might be a good idea.

> There is one issue (see the FIXMEs); if the command is aborted for any
> reason, the prefix (set in ofw-frame-window-prefix-arg) needs to be
> reset. I haven't looked into doing that yet.
> If post-command-hook is run even if a command is aborted, that might be
> a good place to reset this. I'll have to try it.

Yes, post-command-hook should run even if the command is aborted, IIRC.
But it's also run right after C-x 7 calls ofw-other-window-argument, so
you'd have to be careful to make it survive one post-command-hook.
It's also run for each command executed in the minibuffer (similar
problem to the one for temp-buffer-window-show-advice).

> I'd be happy to put this in GNU ELPA (in part so it is available for
> Emacs 24.3), but there was some discussion in the original thread about
> having something like this in core.

I think it's OK to put in GNU ELPA for now.  I do hope it can be moved
later into core to replace the C-x 4 and C-x 5 keymaps.

Regarding experimentation: I'm slightly worried about having
a constantly non-nil display-buffer-overriding-action.  So maybe instead
of setting ofw-frame-window-prefix-arg and then interpret this from
a globally-set display-buffer-overriding-action, we could make
ofw-other-window-argument set display-buffer-overriding-action and
dispense with ofw-frame-window-prefix-arg.

One other thing: I'd be neat if the echo-area could display the "C-x 7"
prefix if you wait a couple seconds, like it does for C-u.  I have some
experimental code around somewhere that moves some of that C-u code from
C so it could be used for C-x 7.


        Stefan



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

* Re: other-frame, other-window prefix keys
  2015-08-08  7:31 ` Andreas Schwab
@ 2015-08-09  5:32   ` Stephen Leake
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen Leake @ 2015-08-09  5:32 UTC (permalink / raw
  To: emacs-devel

Andreas Schwab <schwab@linux-m68k.org> writes:

> Stephen Leake <stephen_leake@stephe-leake.org> writes:
>
>> I used C-x 7, C-x 8 because they are currently unbound.
>
> C-x 8 is already bound.

In both master and 24.3. Arrgggh!. I thought I tested that. Well, that's
easy to change. Assuming there are any unbound keys left ...

-- 
-- Stephe



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

* Re: other-frame, other-window prefix keys
  2015-08-08 20:52 ` Stefan Monnier
@ 2015-08-09  6:06   ` Stephen Leake
  2015-08-09  8:10     ` Kalle Olavi Niemitalo
  2015-08-09 16:17     ` Stefan Monnier
  0 siblings, 2 replies; 8+ messages in thread
From: Stephen Leake @ 2015-08-09  6:06 UTC (permalink / raw
  To: emacs-devel

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>> C-x 7 <command> causes a buffer displayed by <command> to appear in
>> another window in the same frame; a window is created if necessary.
>>
>> C-x 8 <command> causes a buffer displayed by <command> to appear in
>> another frame; a frame is created if necessary.
>
> It'd be great if you could bind them to C-x 4 and C-x 5 and arrange for
> C-x 4 f (and friends) to still work as before.

I agree it would be nice. I think that means redoing all those bindings.
But that's only about 10, so it's doable. But that doesn't handle
third-party additions to the C-x 4/5 prefix key maps.

> That would make the advice on switch-to-buffer unnecessary, I think
> since C-x 4 b and C-x 5 b would be more handy than C-x 4 C-x C-b
> anyway.

Well, I don't use C-x 4 etc (and I never have); I use M-m and M-M, bound
to ofw-other-window-argument and ofw-other-frame-argument.

More importantly, there is plenty of code that uses switch-to-buffer
that does _not_ provide C-x 4 bindings, or even -other-window,
-other-frame variants. That's the main point of this package; to make it
unnecessary to define those variants in the first place.

The other-frame, other-window keys must be easy to type to be useful, so
we could consider preempting one of the meta-letter keys for this.

>> Advising temp-buffer-window-show-advice addresses the issue of how
>> temporary prompt buffers are displayed.
>
> Indeed, this is a bit ugly.  Doesn't it prevent C-x 5 C-h f from
> displaying the help in a separate frame?

That key sequence pops up *Help* for "Global Bindings Starting With C-x
5" (in emacs -Q). So no, the advice is not what makes that not work :).

I think you meant C-x 8 C-h f; indeed, that is not shown in another
frame. But the next command that displays a buffer is shown in another
frame, which is _very_ surprising :).

I would argue that `describe-function' should not be using
temp-buffer-window-show; the *Help* buffer is _not_ temporary, because
it is _not_ automatically closed; it is left to the user to close it.

> Maybe we should arrange for the ofw-frame-window-prefix-arg to be
> save&restored around calls to read-from-minibuffer.  It's not the first
> time we have a need for such a thing, so adding a general list of "vars
> to save&restore around recursive edits" might be a good idea.

That would probably fix other problems, yes.

>> There is one issue (see the FIXMEs); if the command is aborted for any
>> reason, the prefix (set in ofw-frame-window-prefix-arg) needs to be
>> reset. I haven't looked into doing that yet.
>> If post-command-hook is run even if a command is aborted, that might be
>> a good place to reset this. I'll have to try it.
>
> Yes, post-command-hook should run even if the command is aborted, IIRC.
> But it's also run right after C-x 7 calls ofw-other-window-argument, so
> you'd have to be careful to make it survive one post-command-hook.
> It's also run for each command executed in the minibuffer (similar
> problem to the one for temp-buffer-window-show-advice).

Sigh; I knew it would not be simple.

Is there an "error-hook" that is run for any error? That would be
cleaner. I don't see one in M-x apropos-variable -hook$

>> I'd be happy to put this in GNU ELPA (in part so it is available for
>> Emacs 24.3), but there was some discussion in the original thread about
>> having something like this in core.
>
> I think it's OK to put in GNU ELPA for now.  

Ok

> I do hope it can be moved later into core to replace the C-x 4 and C-x
> 5 keymaps.

Ok.

> Regarding experimentation: I'm slightly worried about having
> a constantly non-nil display-buffer-overriding-action.  So maybe instead
> of setting ofw-frame-window-prefix-arg and then interpret this from
> a globally-set display-buffer-overriding-action, we could make
> ofw-other-window-argument set display-buffer-overriding-action and
> dispense with ofw-frame-window-prefix-arg.

Yes, that's better.

> One other thing: I'd be neat if the echo-area could display the "C-x 7"
> prefix if you wait a couple seconds, like it does for C-u.  I have some
> experimental code around somewhere that moves some of that C-u code from
> C so it could be used for C-x 7.

Ok, please send the code; I have no idea how that works.

-- 
-- Stephe



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

* Re: other-frame, other-window prefix keys
  2015-08-09  6:06   ` Stephen Leake
@ 2015-08-09  8:10     ` Kalle Olavi Niemitalo
  2015-08-09 16:17     ` Stefan Monnier
  1 sibling, 0 replies; 8+ messages in thread
From: Kalle Olavi Niemitalo @ 2015-08-09  8:10 UTC (permalink / raw
  To: Stephen Leake; +Cc: emacs-devel

Stephen Leake <stephen_leake@stephe-leake.org> writes:

> I agree it would be nice. I think that means redoing all those bindings.
> But that's only about 10, so it's doable. But that doesn't handle
> third-party additions to the C-x 4/5 prefix key maps.

If those third-party additions are using
  (define-key ctl-x-4-map (kbd "z") 'foo)
rather than
  (global-set-key (kbd "C-x 4 z") 'foo)
then I think you can handle it, by changing ctl-x-4-prefix and
ctl-x-5-prefix to functions that temporarily add ctl-x-4-map or
ctl-x-5-map as a minor-mode keymap and then read a key sequence.

And if they are using global-set-key, then I think it can be
hacked around by doing
  (put 'ctl-x-4-prefix 'define-key-keymap ctl-x-4-map)
  (put 'ctl-x-5-prefix 'define-key-keymap ctl-x-5-map)
and changing define-key to follow the define-key-keymap property
if the keymap contains a symbol whose function definition is a
function and the key sequence didn't end yet.



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

* Re: other-frame, other-window prefix keys
  2015-08-09  6:06   ` Stephen Leake
  2015-08-09  8:10     ` Kalle Olavi Niemitalo
@ 2015-08-09 16:17     ` Stefan Monnier
  2015-08-11 17:37       ` Setting "echoing prefix" from Elisp (was: other-frame, other-window prefix keys) Stefan Monnier
  1 sibling, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2015-08-09 16:17 UTC (permalink / raw
  To: Stephen Leake; +Cc: emacs-devel

> I agree it would be nice. I think that means redoing all those bindings.
> But that's only about 10, so it's doable.

That's the idea, yes.

> But that doesn't handle third-party additions to the C-x 4/5 prefix
> key maps.

We could handle third party additions made via ctl-x-4-map and
ctl-x-5-map, but indeed, I don't think we can reasonably handle those
made via something like (define-key global-map "\C-x4.." ...).

But I think this amount of breakage is acceptable (especially if can
redirect them to use ctl-x-4-map to be both backward and forward compatible).

> More importantly, there is plenty of code that uses switch-to-buffer

That's a good point.  So we should fix switch-to-buffer to pay attention
to display-buffer-overriding-action.

> I think you meant C-x 8 C-h f;

Right.

> I would argue that `describe-function' should not be using
> temp-buffer-window-show; the *Help* buffer is _not_ temporary, because
> it is _not_ automatically closed; it is left to the user to close it.

This is a can of worms.

> Is there an "error-hook" that is run for any error? That would be
> cleaner.  I don't see one in M-x apropos-variable -hook$

Maybe a better solution is to try and generalize the code used for
(current-)prefix-arg.

>> One other thing: I'd be neat if the echo-area could display the "C-x 7"
>> prefix if you wait a couple seconds, like it does for C-u.  I have some
>> experimental code around somewhere that moves some of that C-u code from
>> C so it could be used for C-x 7.
> Ok, please send the code; I have no idea how that works.

I don't really have a good idea how it works either, mind you.
I experimented with it specifically thinking of prefixes like C-x 4, but
there are some non-trivial issues.
I'll try and dig it up,


        Stefan



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

* Setting "echoing prefix" from Elisp (was: other-frame, other-window prefix keys)
  2015-08-09 16:17     ` Stefan Monnier
@ 2015-08-11 17:37       ` Stefan Monnier
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2015-08-11 17:37 UTC (permalink / raw
  To: Stephen Leake; +Cc: emacs-devel

>>> One other thing: I'd be neat if the echo-area could display the "C-x 7"
>>> prefix if you wait a couple seconds, like it does for C-u.  I have some
>>> experimental code around somewhere that moves some of that C-u code from
>>> C so it could be used for C-x 7.
>> Ok, please send the code; I have no idea how that works.
> I don't really have a good idea how it works either, mind you.
> I experimented with it specifically thinking of prefixes like C-x 4, but
> there are some non-trivial issues.
> I'll try and dig it up,

OK, found it.  Here's an updated version which should apply cleanly to
"master".  It's likely that this change will require adjustment in any code
which uses reset-this-command-lengths (aka cua-base.el and kmacro.el).


        Stefan


diff --git a/lisp/simple.el b/lisp/simple.el
index 2636777..e216794 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -3661,7 +3661,19 @@ see other processes running on the system, use `list-system-processes'."
   "Keymap used while processing \\[universal-argument].")
 
 (defun universal-argument--mode ()
-  (set-transient-map universal-argument-map))
+  (setq echo-keystrokes-prefix
+        (concat "C-u"
+                (pcase prefix-arg
+                  (`(-) " -")
+                  (`(,(and (pred integerp) n))
+                   (let ((str ""))
+                     (while (and (> n 4) (= (mod n 4) 0))
+                       (setq str (concat str " C-u"))
+                       (setq n (/ n 4)))
+                     (if (= n 4) str (format " %s" prefix-arg))))
+                  (_ (format " %s" prefix-arg)))))
+  (set-transient-map universal-argument-map nil
+                     (lambda () (setq echo-keystrokes-prefix nil))))
 
 (defun universal-argument ()
   "Begin a numeric argument for the following command.
diff --git a/src/keyboard.c b/src/keyboard.c
index f670da3..3c5ade2 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -441,10 +441,12 @@ echo_add_key (Lisp_Object c)
   ptrdiff_t size = sizeof initbuf;
   char *buffer = initbuf;
   char *ptr = buffer;
-  Lisp_Object echo_string;
+  Lisp_Object echo_string = KVAR (current_kboard, echo_string);
   USE_SAFE_ALLOCA;
 
-  echo_string = KVAR (current_kboard, echo_string);
+  if (STRINGP (echo_string) && SCHARS (echo_string) > 0)
+    /* Add a space at the end as a separator between keys.  */
+    ptr++[0] = ' ';
 
   /* If someone has passed us a composite event, use its head symbol.  */
   c = EVENT_HEAD (c);
@@ -475,6 +477,7 @@ echo_add_key (Lisp_Object c)
       int len = sizeof text - 1;
 
       if (size - (ptr - buffer) < len)
+	/* FIXME: I had "abort ();" here !?!  */
 	{
 	  ptrdiff_t offset = ptr - buffer;
 	  size += len;
@@ -486,48 +489,12 @@ echo_add_key (Lisp_Object c)
       ptr += len;
     }
 
-  /* Replace a dash from echo_dash with a space, otherwise add a space
-     at the end as a separator between keys.  */
-  AUTO_STRING (space, " ");
-  if (STRINGP (echo_string) && SCHARS (echo_string) > 1)
-    {
-      Lisp_Object last_char, prev_char, idx;
-
-      idx = make_number (SCHARS (echo_string) - 2);
-      prev_char = Faref (echo_string, idx);
-
-      idx = make_number (SCHARS (echo_string) - 1);
-      last_char = Faref (echo_string, idx);
-
-      /* We test PREV_CHAR to make sure this isn't the echoing of a
-	 minus-sign.  */
-      if (XINT (last_char) == '-' && XINT (prev_char) != ' ')
-	Faset (echo_string, idx, make_number (' '));
-      else
-	echo_string = concat2 (echo_string, space);
-    }
-  else if (STRINGP (echo_string) && SCHARS (echo_string) > 0)
-    echo_string = concat2 (echo_string, space);
-
   kset_echo_string
     (current_kboard,
      concat2 (echo_string, make_string (buffer, ptr - buffer)));
   SAFE_FREE ();
 }
 
-/* Add C to the echo string, if echoing is going on.  C can be a
-   character or a symbol.  */
-
-static void
-echo_char (Lisp_Object c)
-{
-  if (current_kboard->immediate_echo)
-    {
-      echo_add_key (c);
-      echo_now ();
-    }
-}
-
 /* Temporarily add a dash to the end of the echo string if it's not
    empty, so that it serves as a mini-prompt for the very next
    character.  */
@@ -539,9 +506,6 @@ echo_dash (void)
   if (NILP (KVAR (current_kboard, echo_string)))
     return;
 
-  if (this_command_key_count == 0)
-    return;
-
   if (!current_kboard->immediate_echo
       && SCHARS (KVAR (current_kboard, echo_string)) == 0)
     return;
@@ -574,16 +538,13 @@ echo_dash (void)
   echo_now ();
 }
 
-/* Display the current echo string, and begin echoing if not already
-   doing so.  */
-
 static void
-echo_now (void)
+echo_update (void)
 {
-  if (!current_kboard->immediate_echo)
+  if (current_kboard->immediate_echo)
     {
       ptrdiff_t i;
-      current_kboard->immediate_echo = 1;
+      kset_echo_string (current_kboard, Vecho_keystrokes_prefix);
 
       for (i = 0; i < this_command_key_count; i++)
 	{
@@ -598,7 +559,7 @@ echo_now (void)
 	  c = AREF (this_command_keys, i);
 	  if (! (EVENT_HAS_PARAMETERS (c)
 		 && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_movement)))
-	    echo_char (c);
+	    echo_add_key (c);
 	}
 
       /* Set before_command_echo_length to the value that would
@@ -607,10 +568,23 @@ echo_now (void)
       if (this_command_key_count == this_single_command_key_start)
 	before_command_echo_length = echo_length ();
 
+      echo_now ();
+    }
+}
+
+/* Display the current echo string, and begin echoing if not already
+   doing so.  */
+
+static void
+echo_now (void)
+{
+  if (!current_kboard->immediate_echo)
+    {
+      current_kboard->immediate_echo = true;
+      echo_update ();
       /* Put a dash at the end to invite the user to type more.  */
       echo_dash ();
     }
-
   echoing = 1;
   /* FIXME: Use call (Qmessage) so it can be advised (e.g. emacspeak).  */
   message3_nolog (KVAR (current_kboard, echo_string));
@@ -1550,9 +1524,6 @@ command_loop_1 (void)
 	 2) we want to leave echoing on so that the prefix will be
 	 echoed as part of this key sequence, so don't call
 	 cancel_echoing, and
-	 3) we want to leave this_command_key_count non-zero, so that
-	 read_char will realize that it is re-reading a character, and
-	 not echo it a second time.
 
 	 If the command didn't actually create a prefix arg,
 	 but is merely a frame event that is transparent to prefix args,
@@ -1565,9 +1536,17 @@ command_loop_1 (void)
 	  if (!CONSP (last_command_event))
 	    kset_last_repeatable_command (current_kboard, Vreal_this_command);
 	  cancel_echoing ();
-	  this_command_key_count = 0;
-	  this_command_key_count_reset = 0;
-	  this_single_command_key_start = 0;
+	}
+
+      this_command_key_count = 0;
+      this_command_key_count_reset = false;
+      this_single_command_key_start = 0;
+
+      if (current_kboard->immediate_echo && !NILP (Vecho_keystrokes_prefix))
+	{
+	  current_kboard->immediate_echo = false;
+	  /* Refresh the echo message.  */
+	  echo_now ();
 	}
 
       if (!NILP (BVAR (current_buffer, mark_active))
@@ -2577,7 +2556,7 @@ read_char (int commandflag, Lisp_Object map,
 
      (3) There's only one place in 20.x where ok_to_echo_at_next_pause
      is set to a non-null value.  This is done in read_char and it is
-     set to echo_area_glyphs after a call to echo_char.  That means
+     set to echo_area_glyphs.  That means
      ok_to_echo_at_next_pause is either null or
      current_kboard->echobuf with the appropriate current_kboard at
      that time.
@@ -2684,7 +2663,7 @@ read_char (int commandflag, Lisp_Object map,
   if (minibuf_level == 0
       && !end_time
       && !current_kboard->immediate_echo
-      && this_command_key_count > 0
+      && (this_command_key_count > 0 || STRINGP (Vecho_keystrokes_prefix))
       && ! noninteractive
       && echo_keystrokes_p ()
       && (/* No message.  */
@@ -3172,22 +3151,18 @@ read_char (int commandflag, Lisp_Object map,
     {
 
       /* Don't echo mouse motion events.  */
-      if (echo_keystrokes_p ()
-	  && ! (EVENT_HAS_PARAMETERS (c)
-		&& EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_movement)))
-	{
-	  echo_char (c);
-	  if (! NILP (also_record))
-	    echo_char (also_record);
-	  /* Once we reread a character, echoing can happen
-	     the next time we pause to read a new one.  */
-	  ok_to_echo_at_next_pause = current_kboard;
-	}
+      if (! (EVENT_HAS_PARAMETERS (c)
+	     && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_movement)))
+	/* Once we reread a character, echoing can happen
+	   the next time we pause to read a new one.  */
+	ok_to_echo_at_next_pause = current_kboard;
 
       /* Record this character as part of the current key.  */
       add_command_key (c);
       if (! NILP (also_record))
 	add_command_key (also_record);
+
+      echo_update ();
     }
 
   last_input_event = c;
@@ -3248,18 +3223,13 @@ record_menu_key (Lisp_Object c)
   before_command_echo_length = echo_length ();
 #endif
 
-  /* Don't echo mouse motion events.  */
-  if (echo_keystrokes_p ())
-    {
-      echo_char (c);
-
-      /* Once we reread a character, echoing can happen
-	 the next time we pause to read a new one.  */
-      ok_to_echo_at_next_pause = 0;
-    }
+  /* Once we reread a character, echoing can happen
+     the next time we pause to read a new one.  */
+  ok_to_echo_at_next_pause = NULL;
 
   /* Record this character as part of the current key.  */
   add_command_key (c);
+  echo_update ();
 
   /* Re-reading in the middle of a command.  */
   last_input_event = c;
@@ -9157,11 +9127,12 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
 	{
 	  key = keybuf[t];
 	  add_command_key (key);
-	  if (echo_keystrokes_p ()
-	      && current_kboard->immediate_echo)
+	  if (current_kboard->immediate_echo)
 	    {
-	      echo_add_key (key);
-	      echo_dash ();
+	      /* Set immediate_echo to false so as to force echo_now to
+		 redisplay (it will set immediate_echo right back to true).  */
+	      current_kboard->immediate_echo = false;
+	      echo_now ();
 	    }
 	}
 
@@ -9833,11 +9804,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
 
      Better ideas?  */
   for (; t < mock_input; t++)
-    {
-      if (echo_keystrokes_p ())
-	echo_char (keybuf[t]);
-      add_command_key (keybuf[t]);
-    }
+    add_command_key (keybuf[t]);
+  echo_update ();
 
   UNGCPRO;
   return t;
@@ -10129,6 +10097,7 @@ The value is always a vector.  */)
 
 DEFUN ("reset-this-command-lengths", Freset_this_command_lengths,
        Sreset_this_command_lengths, 0, 0, 0,
+       /* FIXME: Bad&wrong docstring!  */
        doc: /* Make the unread events replace the last command and echo.
 Used in `universal-argument-other-key'.
 
@@ -11439,6 +11408,10 @@ The value may be integer or floating point.
 If the value is zero, don't echo at all.  */);
   Vecho_keystrokes = make_number (1);
 
+  DEFVAR_LISP ("echo-keystrokes-prefix", Vecho_keystrokes_prefix,
+	       doc: /* String to prefix in front of unfinished key sequences.  */);
+  Vecho_keystrokes_prefix = Qnil;
+
   DEFVAR_INT ("polling-period", polling_period,
 	      doc: /* Interval between polling for input during Lisp execution.
 The reason for polling is to make C-g work to stop a running program.



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

end of thread, other threads:[~2015-08-11 17:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-08  7:24 other-frame, other-window prefix keys Stephen Leake
2015-08-08  7:31 ` Andreas Schwab
2015-08-09  5:32   ` Stephen Leake
2015-08-08 20:52 ` Stefan Monnier
2015-08-09  6:06   ` Stephen Leake
2015-08-09  8:10     ` Kalle Olavi Niemitalo
2015-08-09 16:17     ` Stefan Monnier
2015-08-11 17:37       ` Setting "echoing prefix" from Elisp (was: other-frame, other-window prefix keys) Stefan Monnier

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.