1

My abbreviations are not expanding when I type the abbreviations

I have the following in my ~/.emacs for initiating the abbrev mode

(setq-default abbrev-mode t)

(setq save-abbrevs t)

(setq abbrev-file-name "~/abbrev.el")

(if (file-readable-p abbrev-file-name)
  (read-abbrev-file abbrev-file-name))

(dolist (hook '(erc-mode-hook
                emacs-lisp-mode-hook
                text-mode-hook))
  (add-hook hook #'abbrev-mode))

I get the following message saying that the abbreviation file is loaded

Loading /Users/baburaj/abbrev.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark set
Automatic display of crossref information was turned on
Applying style hooks...
Loading /Users/baburaj/auto/junk.el (source)...done
Loading /Users/baburaj/.emacs.d/elpa/auctex-12.2.0/style/article.elc...do
Applying style hooks...done
Sorting environment...done
Removing duplicates...done
Mark set

I also get the following when I type M-x list-abbrev

(text-mode-abbrev-table)

";af"          1    "aerofoil"

However when I type ;af it does not expand to aerofoil

What is the error that I am making? How can I fix this?

1

From the documentation:

M-x abbrev-mode toggles Abbrev mode.

Either, you want Abbrev mode always on, everytime/everywhere, then you put the following in your ~/.emacs file: (setq-default abbrev-mode t)

Either you want Abbrev mode on, but only for the some modes, for example: erc-mode, emacs-lisp-mode, text-mode, in this case, you can put in your ~/.emacs file:

    ;; enable Abbrev mode only for erc, emacs-lisp, and text modes
    (dolist (hook '(erc-mode-hook
                    emacs-lisp-mode-hook
                    text-mode-hook))
      (add-hook hook #'abbrev-mode))

Now, it is also written in another part of the documentation that:

and any word-constituent character can be part of an abbrev.

A ; is not word constituent, unless you want it to be. So a semicolon can't be part of an abbrev.

Maybe it's time to write some Fortran :)

| improve this answer | |
  • Thank you, I removed the ; in my abbreviations and it worked. I was using XEmacs earlier and ; used to work there. Had tried using my same abbreviations file in GNU Emacs too. – Baburaj Puthenveettil Mar 27 at 6:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.