Function: unexpand-abbrev

unexpand-abbrev is an interactive and byte-compiled function defined in abbrev.el.gz.

Signature

(unexpand-abbrev)

Documentation

Undo the expansion of the last abbrev that expanded.

This differs from ordinary undo in that other editing done since then is not undone.

View in manual

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/abbrev.el.gz
(defun unexpand-abbrev ()
  "Undo the expansion of the last abbrev that expanded.
This differs from ordinary undo in that other editing done since then
is not undone."
  (interactive)
  (save-excursion
    (when (<= (point-min) last-abbrev-location (point-max))
      (goto-char last-abbrev-location)
      (when (stringp last-abbrev-text)
        ;; This isn't correct if last-abbrev's hook was used
        ;; to do the expansion.
        (let ((val (symbol-value last-abbrev)))
          (unless (stringp val)
            (error "Value of abbrev-symbol must be a string"))
          ;; Don't inherit properties here; just copy from old contents.
          (replace-region-contents (point) (+ (point) (length val))
                                   last-abbrev-text 0)
          (goto-char (+ (point) (length last-abbrev-text)))
          (setq last-abbrev-text nil))))))