all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Daniel Colascione <dan.colascione@gmail.com>
Cc: Emacs development discussions <emacs-devel@gnu.org>
Subject: Re: Why on earth is abbrev baked into the C code?
Date: Sun, 27 Feb 2011 22:18:56 -0500	[thread overview]
Message-ID: <jwvlj106eia.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <4D69BFD2.7060606@gmail.com> (Daniel Colascione's message of "Sat, 26 Feb 2011 19:06:58 -0800")

> 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



  reply	other threads:[~2011-02-28  3:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-27  3:06 Why on earth is abbrev baked into the C code? Daniel Colascione
2011-02-28  3:18 ` Stefan Monnier [this message]
     [not found]   ` <4D6BF0D7.3080005@gmail.com>
2011-03-01 21:08     ` Daniel Colascione
2011-03-02 17:21       ` Richard Stallman
2011-03-02 17:55       ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvlj106eia.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=dan.colascione@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.