Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In Emacs, how can I make a macro, that is local to the HTML mode, and uses dashes and dots? Take a look at the Elisp below:

(define-abbrev-table 'html-mode-abbrev-table
   '(("..." "…")   ; won't work
     ("---" "—")    ; won't work
     ("aaa" "…")   ; works
     ("bbb" "—") )) ; works
share|improve this question

Abbrevs can only contain characters that are considered word syntax as specified by the current buffer's syntax table. If you make "." and "-" word characters, then you can use them in abbrevs.

(require 'sgml-mode)
(modify-syntax-entry ?- "w" html-mode-syntax-table)
(modify-syntax-entry ?. "w" html-mode-syntax-table)
share|improve this answer
Are there any drawbacks to this? – Emanuel Berg Apr 4 '13 at 20:41
If you do regex searches using \w, dash and period are now going to be matched in buffers using the altered syntax table. Cursor motion commands will also be affected; forward-word will no longer stop before these characters. Similarly kill-word will delete more text than before. I think this behavior would be quite surprising and unpleasant in programming mode buffers, but in a text mode like HTML, I don't think it would cause much grief. – Kyle Jones Apr 4 '13 at 22:24
Aha, no, cursor movement and word killing are holy cows. I'll have to find another solution. I'll leave this question open for some time, if there is no other suggestion, I'll accept your answer. Because in a way it is correct, although I won't use it. – Emanuel Berg Apr 4 '13 at 23:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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