changeset 106233:13733fc37569

(abbrev--before-point): Use word-motion functions if :regexp is not specified (bug#5031).
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 25 Nov 2009 04:59:02 +0000
parents f44541b1d13c
children e5945bbfa5b1
files lisp/ChangeLog lisp/abbrev.el
diffstat 2 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Wed Nov 25 03:59:19 2009 +0000
+++ b/lisp/ChangeLog	Wed Nov 25 04:59:02 2009 +0000
@@ -1,5 +1,8 @@
 2009-11-25  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+	* abbrev.el (abbrev--before-point): Use word-motion functions
+	if :regexp is not specified (bug#5031).
+
 	* subr.el (string-prefix-p): New function.
 
 	* man.el (Man-completion-cache): New var.
--- a/lisp/abbrev.el	Wed Nov 25 03:59:19 2009 +0000
+++ b/lisp/abbrev.el	Wed Nov 25 04:59:02 2009 +0000
@@ -671,11 +671,19 @@
           (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