diff options
author | Gerd Moellmann <gerd@gnu.org> | 2000-03-17 22:32:39 +0000 |
---|---|---|
committer | Gerd Moellmann <gerd@gnu.org> | 2000-03-17 22:32:39 +0000 |
commit | 466840685febd3b615821df7ca789aef4fb6478f (patch) | |
tree | 32e751539db986fad497b2cd992bf80731433723 /lisp/abbrev.el | |
parent | 235d6821117f6af0a17b557dcc70dee8f1a52511 (diff) | |
download | emacs-466840685febd3b615821df7ca789aef4fb6478f.tar.gz |
(inverse-add-abbrev): Identify word by first moving
forward then moving backward. Reindent.
Diffstat (limited to 'lisp/abbrev.el')
-rw-r--r-- | lisp/abbrev.el | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/lisp/abbrev.el b/lisp/abbrev.el index 83d4a86a2d7..5111fc59013 100644 --- a/lisp/abbrev.el +++ b/lisp/abbrev.el @@ -263,22 +263,23 @@ Expands the abbreviation after defining it." (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. |