all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* last-command-other-than-handle-switch-frame?
@ 2008-01-05 23:24 Drew Adams
  2008-01-06 18:09 ` last-command-other-than-handle-switch-frame? Richard Stallman
  0 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2008-01-05 23:24 UTC (permalink / raw
  To: Emacs-Devel

I use non-nil pop-up-frames, so lots of `handle-switch-frame' commands get
executed behind the scene. Why that is needed I've never quite understood -
why should a focus event be treated as a "command"? Anyway, I'm not
questioning that design here - so be it.

For some time now, I've been coding ugly hacks like this:

 (if (memq last-command '(foo handle-switch-frame))...

when all I really wanted was to know whether the last user command was
`foo'.

And such code doesn't actually test whether the command prior to
`handle-switch-frame' was `foo'.

Does this nuisance ring a bell for anyone else?

Shouldn't there be another variable, in addition to `last-command' and
`real-last-command' - something that gives us the last command other than
`handle-switch-frame'?

What I'm asking for, I guess, is a `last-user-command' variable, something
free from pollution by pseudo-commands (or generated commands or whatever
they are) such as `handle-switch-frame'. (I presume, based on its doc, that
`real-last-command' does not filter out `handle-switch-frame'.)

See also this 2006 thread, where I mentioned the same problem:
http://lists.gnu.org/archive/html/emacs-devel/2006-07/msg00165.html

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

* Re: last-command-other-than-handle-switch-frame?
  2008-01-05 23:24 last-command-other-than-handle-switch-frame? Drew Adams
@ 2008-01-06 18:09 ` Richard Stallman
  2008-01-06 19:41   ` last-command-other-than-handle-switch-frame? Drew Adams
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Stallman @ 2008-01-06 18:09 UTC (permalink / raw
  To: Drew Adams; +Cc: emacs-devel

    I use non-nil pop-up-frames, so lots of `handle-switch-frame' commands get
    executed behind the scene. Why that is needed I've never quite understood -
    why should a focus event be treated as a "command"?

The reason to make it generate an event is to make the command loop
check for the new frame's buffer's keymaps.

What does "treated as a command" mean?

    For some time now, I've been coding ugly hacks like this:

     (if (memq last-command '(foo handle-switch-frame))...

Does "treated as a command" mean that it goes into last-command?
I don't see any specific reason for doing so.
Maybe we should change that.  

We cannot handle them thru special-event-map because they they would
not cause the command loop to recheck the keymaps.  But we could give
it a definition that sets this-command to last-command, or something
else with similar effect.

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

* RE: last-command-other-than-handle-switch-frame?
  2008-01-06 18:09 ` last-command-other-than-handle-switch-frame? Richard Stallman
@ 2008-01-06 19:41   ` Drew Adams
  2008-01-07 11:31     ` last-command-other-than-handle-switch-frame? Richard Stallman
  0 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2008-01-06 19:41 UTC (permalink / raw
  To: rms; +Cc: emacs-devel

>     I use non-nil pop-up-frames, so lots of `handle-switch-frame'
>     commands get executed behind the scene. Why that is needed I've
>     never quite understood - why should a focus event be treated as
>     a "command"?
>
> The reason to make it generate an event is to make the command loop
> check for the new frame's buffer's keymaps.
>
> What does "treated as a command" mean?

Set `last-command' to it.

Again, if that is unavoidable, then how about also having a
`last-user-command' variable, which gets only user commands, not
pseudo-commands such as `handle-switch-frame'.

>     For some time now, I've been coding ugly hacks like this:
>
>      (if (memq last-command '(foo handle-switch-frame))...
>
> Does "treated as a command" mean that it goes into last-command?

Yes. That is what the annoyance is.

> I don't see any specific reason for doing so.
> Maybe we should change that.

That would be great.

> We cannot handle them thru special-event-map because they they would
> not cause the command loop to recheck the keymaps.  But we could give
> it a definition that sets this-command to last-command, or something
> else with similar effect.

I would appreciate such a fix.

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

* Re: last-command-other-than-handle-switch-frame?
  2008-01-06 19:41   ` last-command-other-than-handle-switch-frame? Drew Adams
@ 2008-01-07 11:31     ` Richard Stallman
  2008-01-14 19:13       ` last-command-other-than-handle-switch-frame? Drew Adams
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Stallman @ 2008-01-07 11:31 UTC (permalink / raw
  To: Drew Adams; +Cc: emacs-devel

    > We cannot handle them thru special-event-map because they they would
    > not cause the command loop to recheck the keymaps.  But we could give
    > it a definition that sets this-command to last-command, or something
    > else with similar effect.

    I would appreciate such a fix.

Try this:

(defun no-command ()
  (interactive)
  (setq this-command last-command))

(define-key global-map [handle-switch-frame] 'no-command)


Does that give good results?

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

* RE: last-command-other-than-handle-switch-frame?
  2008-01-07 11:31     ` last-command-other-than-handle-switch-frame? Richard Stallman
@ 2008-01-14 19:13       ` Drew Adams
  0 siblings, 0 replies; 5+ messages in thread
From: Drew Adams @ 2008-01-14 19:13 UTC (permalink / raw
  To: rms; +Cc: emacs-devel

>     > We cannot handle them thru special-event-map because they they would
>     > not cause the command loop to recheck the keymaps.  But we
>     > could give it a definition that sets this-command to last-command,
>     > or something else with similar effect.
>
>     I would appreciate such a fix.
>
> Try this:
>
> (defun no-command ()
>   (interactive)
>   (setq this-command last-command))
>
> (define-key global-map [handle-switch-frame] 'no-command)
>
>
> Does that give good results?

Yes, it seems to; thanks. I've been using it for a week now, and it seems to
DTRT. How about adding it to Emacs?

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

end of thread, other threads:[~2008-01-14 19:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-05 23:24 last-command-other-than-handle-switch-frame? Drew Adams
2008-01-06 18:09 ` last-command-other-than-handle-switch-frame? Richard Stallman
2008-01-06 19:41   ` last-command-other-than-handle-switch-frame? Drew Adams
2008-01-07 11:31     ` last-command-other-than-handle-switch-frame? Richard Stallman
2008-01-14 19:13       ` last-command-other-than-handle-switch-frame? Drew Adams

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.