Emacs: Abbrev No Space

By Xah Lee. Date: . Last updated: .

Make Abbrev Not Add Space

How to make abbrev not add the space?

Define this function:

(defun xah-abbrev-ahf ()
  "Abbrev hook function, used for `define-abbrev'.
 Our use is to prevent inserting the char that triggered expansion. Experimental.
 the “ahf” stand for abbrev hook function.
Version 2016-10-24"
  t)

(put 'xah-abbrev-ahf 'no-self-insert t)

And for each of the abbrev that you don't want space added after expansion, add the function there as third argument, like this:

(define-abbrev-table 'global-abbrev-table
  '(
    ("addr" "address" xah-abbrev-ahf)
    ))

in order to add this, you must use lisp code for defining the abbrevs. Emacs: Abbrev Mode by Lisp Code

Emacs, Abbrev Mode