# HG changeset patch # User Gerd Moellmann # Date 953332359 0 # Node ID a552a942b327d0f9cf3e4f21ced5c7ce3edbd251 # Parent 586eaf504de7f99f9953563e9ed046727153c251 (inverse-add-abbrev): Identify word by first moving forward then moving backward. Reindent. diff -r 586eaf504de7 -r a552a942b327 lisp/abbrev.el --- a/lisp/abbrev.el Fri Mar 17 21:29:09 2000 +0000 +++ b/lisp/abbrev.el Fri Mar 17 22:32:39 2000 +0000 @@ -263,22 +263,23 @@ (inverse-add-abbrev global-abbrev-table "Global" arg)) (defun inverse-add-abbrev (table type arg) - (let (name nameloc exp) + (let (name exp start end) (save-excursion - (forward-word (- arg)) - (setq name (buffer-substring-no-properties - (point) (progn (forward-word 1) (setq nameloc (point)))))) - (set-text-properties 0 (length name) nil name) - (setq exp (read-string (format "%s expansion for \"%s\": " - type name) nil nil nil t)) - (if (or (not (abbrev-expansion name table)) - (y-or-n-p (format "%s expands to \"%s\"; redefine? " - name (abbrev-expansion name table)))) - (progn - (define-abbrev table (downcase name) exp) - (save-excursion - (goto-char nameloc) - (expand-abbrev)))))) + (forward-word (1+ (- arg))) + (setq end (point)) + (backward-word 1) + (setq start (point) + name (buffer-substring-no-properties start end))) + + (setq exp (read-string (format "%s expansion for \"%s\": " type name) + nil nil nil t)) + (when (or (not (abbrev-expansion name table)) + (y-or-n-p (format "%s expands to \"%s\"; redefine? " + name (abbrev-expansion name table)))) + (define-abbrev table (downcase name) exp) + (save-excursion + (goto-char end) + (expand-abbrev))))) (defun abbrev-prefix-mark (&optional arg) "Mark current point as the beginning of an abbrev.