Let's say abbrev
expands "com" into "commission".
The problem is that this expands "google.com" into "google.commission".
Is there a way to disable this expansion if "com" is preceded by a "."?
Let's say abbrev
expands "com" into "commission".
The problem is that this expands "google.com" into "google.commission".
Is there a way to disable this expansion if "com" is preceded by a "."?
I ended up solving this question using the :enable-function
in define-abbrev-table
(similar to what's recommended here: Do not expand a given abbrev when followed by ":").
My solution is to put all my abbreviations in the global-abbrev-table
and all my exceptions in text-mode-abbrev-table
. Then have an enable-function
that checks that the character preceding the current word is not a ".
".
(defun my-char-preceding-word ()
(interactive)
(save-excursion
(backward-word)
(char-before)))
(define-abbrev-table 'text-mode-abbrev-table
'(("com" "commission"))
"My exceptions table."
:enable-function (lambda ()
(not (eq (my-char-preceding-word) ?.))))