help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: can a command specify overwrite selection behavior?


From: Xah Lee
Subject: Re: can a command specify overwrite selection behavior?
Date: Wed, 22 Dec 2010 18:33:34 -0800 (PST)
User-agent: G2/1.0

On Dec 22, 9:12 am, "Drew Adams" <drew.ad...@oracle.com> wrote:
> > Drew, what i didn't understand is why the insert-date property makes a
> > distinction on whether a command is called by name or by a keyboard
> > shortcut?
>
> Ah, good question.  Here's the answer:
>
> (defun delete-selection-pre-hook ()
>   (when (and delete-selection-mode
>              transient-mark-mode mark-active
>                (not buffer-read-only))
>     (let ((type (and (symbolp this-command)
>                          (get this-command ; <=======
>                           'delete-selection))))
>
> If you debug this (use `message', not `debug-on-entry'!), you'll see that when
> you use `M-x' the value of `this-command' is `execute-extended-command', not
> `insert-date'.  And `execute-extended-command' does not have a non-nil
> `delete-selection' property.
>
> `execute-extended-command' is a bit special wrt `this-command' and
> `last-command'.  It DTRT in the end, essentially removing itself from the 
> party,
> but that's only at the end.  While `execute-extended-command' is executing, it
> is the value of `this-command'.
>
> People sometimes get thrown off by this kind of thing, and similar things wrt
> `M-:' (and `C-x C-e', `C-M-x'...).
>
> The thing to remember is that `M-x' and `M-:' are themselves keys that are 
> bound
> to commands, and that even though they invoke or evaluate other stuff (and 
> that
> other stuff is what we focus on), that is not the same as just invoking or
> evaluating the other stuff directly.  They add their bit to the mix, and
> sometimes that makes a difference.
>
> It can help to remember that EVERYTHING in Emacs is a COMMAND.  Or, rather,
> every user interaction is via a command.  Outside Emacs we are not used to
> thinking that way (because outside Emacs it is not true).  But even when you 
> hit
> a letter key such as `g' Emacs invokes a command (by default,
> `self-insert-command').
>
> Always.  Well no, you can undefine keys: (global-unset-key "a") etc., but as a
> general rule it is true.
>
> (I know that you know all of this, but I find it's worth reminding myself from
> time to time.  Emacs interaction is all about commands.)

hi Drew. Very useful info i do not know about. Thanks.

 Xah


reply via email to

[Prev in Thread] Current Thread [Next in Thread]