From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Why on earth is abbrev baked into the C code? Date: Sun, 27 Feb 2011 22:18:56 -0500 Message-ID: References: <4D69BFD2.7060606@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1298863167 11770 80.91.229.12 (28 Feb 2011 03:19:27 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 28 Feb 2011 03:19:27 +0000 (UTC) Cc: Emacs development discussions To: Daniel Colascione Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Feb 28 04:19:23 2011 Return-path: Envelope-to: ged-emacs-devel@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 1Pttdq-0004BQ-Tg for ged-emacs-devel@m.gmane.org; Mon, 28 Feb 2011 04:19:23 +0100 Original-Received: from localhost ([127.0.0.1]:59300 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pttdq-0002OM-7l for ged-emacs-devel@m.gmane.org; Sun, 27 Feb 2011 22:19:22 -0500 Original-Received: from [140.186.70.92] (port=37942 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pttdi-0002NH-VZ for emacs-devel@gnu.org; Sun, 27 Feb 2011 22:19:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pttdh-0006MK-My for emacs-devel@gnu.org; Sun, 27 Feb 2011 22:19:14 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:7513 helo=ironport2-out.pppoe.ca) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pttdh-0006MF-EI for emacs-devel@gnu.org; Sun, 27 Feb 2011 22:19:13 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAGqjak1FxKsT/2dsb2JhbACmQ3WpdpBShWEEhRCPXw X-IronPort-AV: E=Sophos;i="4.62,237,1297054800"; d="scan'208";a="93758757" Original-Received: from 69-196-171-19.dsl.teksavvy.com (HELO ceviche.home) ([69.196.171.19]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 27 Feb 2011 22:18:56 -0500 Original-Received: by ceviche.home (Postfix, from userid 20848) id 9C4EE660D6; Sun, 27 Feb 2011 22:18:56 -0500 (EST) In-Reply-To: <4D69BFD2.7060606@gmail.com> (Daniel Colascione's message of "Sat, 26 Feb 2011 19:06:58 -0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:136585 Archived-At: > I was looking into abbrev.el to figure out how to code up a change I > wanted to make (having undo undo the abbrev expansion without undoing > the self-insert-command that triggered the expansion), You should be able to use abbrev-expand-functions for that (it's a wrapper hook, so it has complete control over the expansion, like an `around' advice). > when I realized > to my surprise that abbrev is actually baked into the Emacs C core. Until Emacs-22, the abbrev code was even all coded in C. > This defies common sense: why can't abbrev.el be a standalone module > that uses post-self-insert-hook or post-command-hook? E.g. because post-self-insert-hook is brand new and post-command-hook is inappropriate? BTW, I haven't moved it to post-self-insert-hook because it is hooked a bit more intimately into self-insert-command (e.g. the successful expansion of an abbrev can prevent the char from being inserted and the post-self-insert-hook from being run), so it is difficult to move it to post-self-insert-hook without changing some of the subtle points of its semantic. > I realize we're not supposed to use hooks to communicate between > components that are part of GNU Emacs, but the alternative in this > case seems unnecessarily invasive. Actually post-self-insert-hook is not nil by default, so this convention is already broken for this hook. > (By the way: the comment in front of self-insert-command is no longer > valid; ISTR that dubious optimization was removed a while ago.) Indeed, thanks. Please install the patch, Stefan