diff options
| author | Gerd Moellmann | 2000-03-17 22:32:39 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-03-17 22:32:39 +0000 |
| commit | 466840685febd3b615821df7ca789aef4fb6478f (patch) | |
| tree | 32e751539db986fad497b2cd992bf80731433723 | |
| parent | 235d6821117f6af0a17b557dcc70dee8f1a52511 (diff) | |
| download | emacs-466840685febd3b615821df7ca789aef4fb6478f.tar.gz emacs-466840685febd3b615821df7ca789aef4fb6478f.zip | |
(inverse-add-abbrev): Identify word by first moving
forward then moving backward. Reindent.
| -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." | |||
| 263 | (inverse-add-abbrev global-abbrev-table "Global" arg)) | 263 | (inverse-add-abbrev global-abbrev-table "Global" arg)) |
| 264 | 264 | ||
| 265 | (defun inverse-add-abbrev (table type arg) | 265 | (defun inverse-add-abbrev (table type arg) |
| 266 | (let (name nameloc exp) | 266 | (let (name exp start end) |
| 267 | (save-excursion | 267 | (save-excursion |
| 268 | (forward-word (- arg)) | 268 | (forward-word (1+ (- arg))) |
| 269 | (setq name (buffer-substring-no-properties | 269 | (setq end (point)) |
| 270 | (point) (progn (forward-word 1) (setq nameloc (point)))))) | 270 | (backward-word 1) |
| 271 | (set-text-properties 0 (length name) nil name) | 271 | (setq start (point) |
| 272 | (setq exp (read-string (format "%s expansion for \"%s\": " | 272 | name (buffer-substring-no-properties start end))) |
| 273 | type name) nil nil nil t)) | 273 | |
| 274 | (if (or (not (abbrev-expansion name table)) | 274 | (setq exp (read-string (format "%s expansion for \"%s\": " type name) |
| 275 | (y-or-n-p (format "%s expands to \"%s\"; redefine? " | 275 | nil nil nil t)) |
| 276 | name (abbrev-expansion name table)))) | 276 | (when (or (not (abbrev-expansion name table)) |
| 277 | (progn | 277 | (y-or-n-p (format "%s expands to \"%s\"; redefine? " |
| 278 | (define-abbrev table (downcase name) exp) | 278 | name (abbrev-expansion name table)))) |
| 279 | (save-excursion | 279 | (define-abbrev table (downcase name) exp) |
| 280 | (goto-char nameloc) | 280 | (save-excursion |
| 281 | (expand-abbrev)))))) | 281 | (goto-char end) |
| 282 | (expand-abbrev))))) | ||
| 282 | 283 | ||
| 283 | (defun abbrev-prefix-mark (&optional arg) | 284 | (defun abbrev-prefix-mark (&optional arg) |
| 284 | "Mark current point as the beginning of an abbrev. | 285 | "Mark current point as the beginning of an abbrev. |