summaryrefslogtreecommitdiff
path: root/lisp/abbrev.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2009-11-25 04:59:02 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2009-11-25 04:59:02 +0000
commitfe4346f0da7e8cc578eb60813bfc8e4e36c62c34 (patch)
tree2ecbcd0f3d9fc17008e672c6ae6e9c168361f9a2 /lisp/abbrev.el
parentcb190d7d5f3a63086e3f28981ca175945305a3c0 (diff)
downloademacs-fe4346f0da7e8cc578eb60813bfc8e4e36c62c34.tar.gz
(abbrev--before-point): Use word-motion functions
if :regexp is not specified (bug#5031).
Diffstat (limited to 'lisp/abbrev.el')
-rw-r--r--lisp/abbrev.el18
1 files changed, 13 insertions, 5 deletions
diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index 88c87dafa77..91c510694b0 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -671,11 +671,19 @@ then ABBREV is looked up in that table only."
(setq tables (append (abbrev-table-get table :parents) tables))
(setq res
(and (or (not enable-fun) (funcall enable-fun))
- (looking-back (or (abbrev-table-get table :regexp)
- "\\<\\(\\w+\\)\\W*")
- (line-beginning-position))
- (setq start (match-beginning 1))
- (setq end (match-end 1))
+ (let ((re (abbrev-table-get table :regexp)))
+ (if (null re)
+ ;; We used to default `re' to "\\<\\(\\w+\\)\\W*"
+ ;; but when words-include-escapes is set, that
+ ;; is not right and fixing it is boring.
+ (let ((lim (point)))
+ (backward-word 1)
+ (setq start (point))
+ (forward-word 1)
+ (setq end (min (point) lim)))
+ (when (looking-back re (line-beginning-position))
+ (setq start (match-beginning 1))
+ (setq end (match-end 1)))))
(setq name (buffer-substring start end))
(let ((abbrev (abbrev-symbol name table)))
(when abbrev