all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Daniel Colascione <dan.colascione@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Emacs development discussions <emacs-devel@gnu.org>
Subject: Re: Why on earth is abbrev baked into the C code?
Date: Tue, 1 Mar 2011 13:08:55 -0800	[thread overview]
Message-ID: <AANLkTimOKtUVCV+VmxLdfSmD7dGi+AqFZus-jD1OvNdY@mail.gmail.com> (raw)
In-Reply-To: <4D6BF0D7.3080005@gmail.com>

;; This hack works for me, but there must be an easier, safer way.

(defun qtmstr-expand-abbrev-wrapper (orig-func &rest args)
  (if (and qtmstr-abbrev-mode
           (eq this-command 'self-insert-command)
           (not executing-kbd-macro)
           (not noninteractive)
           (not (window-minibuffer-p (selected-window)))
           (characterp last-command-event))

      ;; Our own implementation of expand-abbrev
      (destructuring-bind (&optional sym name wordstart wordend)
          (abbrev--before-point)

        (when sym
          (let ((value sym))
            ;; Now sym is the abbrev symbol.
            (setq last-abbrev-text name)
            (setq last-abbrev sym)
            (setq last-abbrev-location wordstart)

            ;; Do what the self-insert-command would normally do
            (insert-char last-command-event 1 t)
            (undo-boundary)
            (delete-char -1)

            ;; If this abbrev has an expansion, delete the abbrev
            ;; and insert the expansion.
            (abbrev-insert sym name wordstart wordend))))

    ;; Otherwise, let the original expand-abbrev do its thing
    (apply orig-func args)))

(add-hook 'abbrev-expand-functions #'qtmstr-expand-abbrev-wrapper)



  parent reply	other threads:[~2011-03-01 21:08 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
     [not found]   ` <4D6BF0D7.3080005@gmail.com>
2011-03-01 21:08     ` Daniel Colascione [this message]
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=AANLkTimOKtUVCV+VmxLdfSmD7dGi+AqFZus-jD1OvNdY@mail.gmail.com \
    --to=dan.colascione@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.