Function: inverse-add-abbrev
inverse-add-abbrev is a byte-compiled function defined in
abbrev.el.gz.
Signature
(inverse-add-abbrev TABLE TYPE ARG)
Documentation
Define the word before point as an abbrev in TABLE.
Read the expansion from the minibuffer, using prompt TYPE, define the abbrev, and then expand the abbreviation in the current buffer.
ARG means use the ARG-th word before point as the abbreviation. Negative ARG means use the ARG-th word after point.
TYPE is an arbitrary string used to prompt user for the kind of abbrev, such as "Global", "Mode". (This has no influence on the choice of the actual TABLE).
See also add-abbrev, which performs the opposite task.
Source Code
;; Defined in /usr/src/emacs/lisp/abbrev.el.gz
(defun inverse-add-abbrev (table type arg)
"Define the word before point as an abbrev in TABLE.
Read the expansion from the minibuffer, using prompt TYPE, define
the abbrev, and then expand the abbreviation in the current
buffer.
ARG means use the ARG-th word before point as the abbreviation.
Negative ARG means use the ARG-th word after point.
TYPE is an arbitrary string used to prompt user for the kind of
abbrev, such as \"Global\", \"Mode\". (This has no influence on the
choice of the actual TABLE).
See also `add-abbrev', which performs the opposite task."
(let (name exp start end)
(save-excursion
(forward-word (1+ (- arg)))
(skip-syntax-backward "^w")
(setq end (point))
(backward-word 1)
(setq start (point)
name (buffer-substring-no-properties start end)))
(setq exp (read-string (format "Expansion for %s abbrev \"%s\": " type name)
nil nil nil t))
(when (or (not (abbrev-expansion name table))
(y-or-n-p (format "%s expands into \"%s\"; redefine? "
name (abbrev-expansion name table))))
(define-abbrev table (downcase name) exp)
(save-excursion
(goto-char end)
(expand-abbrev)))))