From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Lee Newsgroups: gmane.emacs.help Subject: Re: can a command specify overwrite selection behavior? Date: Wed, 22 Dec 2010 18:33:34 -0800 (PST) Organization: http://groups.google.com Message-ID: <7653835a-7564-482a-9621-b73c7247ef78@j32g2000prh.googlegroups.com> References: <33ac6984-0a0c-4db8-8ea1-50ec5c271a25@x18g2000pro.googlegroups.com><05a87fbb-31a7-40c3-a890-6c7aacaefac3@t5g2000prd.googlegroups.com><92235e12-464c-41d9-9a49-33598c157113@i25g2000prd.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1293072041 26369 80.91.229.12 (23 Dec 2010 02:40:41 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 23 Dec 2010 02:40:41 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 23 03:40:37 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PVb6a-0004uR-S9 for geh-help-gnu-emacs@m.gmane.org; Thu, 23 Dec 2010 03:40:37 +0100 Original-Received: from localhost ([127.0.0.1]:43265 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PVb6a-0006iR-Bb for geh-help-gnu-emacs@m.gmane.org; Wed, 22 Dec 2010 21:40:36 -0500 Original-Path: usenet.stanford.edu!postnews.google.com!j32g2000prh.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 64 Original-NNTP-Posting-Host: 76.126.112.84 Original-X-Trace: posting.google.com 1293071614 8697 127.0.0.1 (23 Dec 2010 02:33:34 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Thu, 23 Dec 2010 02:33:34 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: j32g2000prh.googlegroups.com; posting-host=76.126.112.84; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.224 Safari/534.10, gzip(gfe) Original-Xref: usenet.stanford.edu gnu.emacs.help:183570 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:77812 Archived-At: On Dec 22, 9:12=A0am, "Drew Adams" 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. =A0Here's the answer: > > (defun delete-selection-pre-hook () > =A0 (when (and delete-selection-mode > =A0 =A0 =A0 =A0 =A0 =A0 =A0transient-mark-mode mark-active > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(not buffer-read-only)) > =A0 =A0 (let ((type (and (symbolp this-command) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(get this-command ; <= =3D=3D=3D=3D=3D=3D=3D > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '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'. =A0And `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'. =A0It DTRT in the end, essentially removing itself from t= he party, > but that's only at the end. =A0While `execute-extended-command' is execut= ing, 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 ar= e bound > to commands, and that even though they invoke or evaluate other stuff (an= d that > other stuff is what we focus on), that is not the same as just invoking o= r > evaluating the other stuff directly. =A0They add their bit to the mix, an= d > sometimes that makes a difference. > > It can help to remember that EVERYTHING in Emacs is a COMMAND. =A0Or, rat= her, > every user interaction is via a command. =A0Outside Emacs we are not used= to > thinking that way (because outside Emacs it is not true). =A0But even whe= n you hit > a letter key such as `g' Emacs invokes a command (by default, > `self-insert-command'). > > Always. =A0Well no, you can undefine keys: (global-unset-key "a") etc., b= ut 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. =A0Emacs interaction is all about commands.) hi Drew. Very useful info i do not know about. Thanks. Xah