[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Using punctuation in abbrev
From: |
Aurélien Aptel |
Subject: |
Using punctuation in abbrev |
Date: |
Sat, 1 Jun 2013 19:41:55 +0200 |
Hi,
I want to substitute $-> with a unicode rightwards arrow (U+2192 →).
Since abbrev defaults to backward-word to extract the word before
point, I've used the :regexp property of an abbrev-table to define
what to extract.
>From define-abbrev-table documentation:
- `:regexp' is a regular expression that specifies how to extract the
name of the abbrev before point. The submatch 1 is treated
as the potential name of an abbrev. If :regexp is nil, the default
behavior uses `backward-word' and `forward-word' to extract the name
of the abbrev, which can therefore only be a single word.
Here's what I put in my init file:
(define-abbrev-table 'global-abbrev-table '(
("$->" "→")
("$=>" "⇒")
("$foo" "X")
)
"custom abbrev table"
:regexp (rx (or bos bol space) (group (+ (not space)))))
(setq save-abbrevs nil)
(setq-default abbrev-mode t)
But only the $foo substitution works and I can't figure out why.
The regex seems to be correct:
(let ((rx (rx (or bos bol space) (group (+ (not space)))))
(slist '(" $->" "\n$=>" " $foo")))
(mapcar (lambda (s) (string-match-p rx s)) slist))
=> (0 0 0)
- Using punctuation in abbrev,
Aurélien Aptel <=
- RE: Using punctuation in abbrev, Drew Adams, 2013/06/01
- Message not available
- Re: Using punctuation in abbrev, Emanuel Berg, 2013/06/02
- Re: Using punctuation in abbrev, Aurélien Aptel, 2013/06/02
- Re: Using punctuation in abbrev, Jambunathan K, 2013/06/02
- Re: Using punctuation in abbrev, Yuri Khan, 2013/06/02
- Message not available
- Re: Using punctuation in abbrev, Emanuel Berg, 2013/06/03
- Re: Using punctuation in abbrev, Yuri Khan, 2013/06/03