all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Using punctuation in abbrev
@ 2013-06-01 17:41 Aurélien Aptel
  2013-06-01 18:42 ` Drew Adams
  2013-06-02 14:24 ` Stefan Monnier
  0 siblings, 2 replies; 25+ messages in thread
From: Aurélien Aptel @ 2013-06-01 17:41 UTC (permalink / raw)
  To: help-gnu-emacs

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)



^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2013-06-05 21:12 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-01 17:41 Using punctuation in abbrev Aurélien Aptel
2013-06-01 18:42 ` Drew Adams
2013-06-01 22:49   ` Aurélien Aptel
2013-06-02 18:48     ` Drew Adams
     [not found]   ` <mailman.841.1370126985.22516.help-gnu-emacs@gnu.org>
2013-06-02  5:02     ` Emanuel Berg
2013-06-02  5:21     ` Emanuel Berg
2013-06-02 17:17       ` Aurélien Aptel
2013-06-02 18:10         ` Jambunathan K
2013-06-03  3:44         ` Yuri Khan
     [not found]         ` <mailman.905.1370231076.22516.help-gnu-emacs@gnu.org>
2013-06-03 18:05           ` Emanuel Berg
2013-06-04  3:05             ` Yuri Khan
2013-06-04  9:14               ` Aurélien Aptel
     [not found]             ` <mailman.968.1370315124.22516.help-gnu-emacs@gnu.org>
2013-06-04 17:27               ` Emanuel Berg
2013-06-05  6:59                 ` Yuri Khan
     [not found]                 ` <mailman.1022.1370415567.22516.help-gnu-emacs@gnu.org>
2013-06-05 21:12                   ` Emanuel Berg
2013-06-04 21:39             ` Stefan Monnier
     [not found]             ` <mailman.1002.1370382007.22516.help-gnu-emacs@gnu.org>
2013-06-04 22:47               ` Emanuel Berg
     [not found]       ` <mailman.880.1370193431.22516.help-gnu-emacs@gnu.org>
2013-06-02 19:48         ` Emanuel Berg
2013-06-02 21:06           ` Stefan Monnier
2013-06-02 22:36           ` Aurélien Aptel
     [not found]           ` <mailman.901.1370212579.22516.help-gnu-emacs@gnu.org>
2013-06-03  0:10             ` Emanuel Berg
2013-06-02 14:24 ` Stefan Monnier
2013-06-02 17:00   ` Aurélien Aptel
2013-06-02 17:54     ` Andreas Röhler
2013-06-02 17:56     ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.