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.

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
    (unless (or (< last-abbrev-location (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.
          (insert last-abbrev-text)
          ;; Delete after inserting, to better preserve markers.
          (delete-region (point) (+ (point) (length val)))
          (setq last-abbrev-text nil))))))