X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/34dc21db6e57ebbad81a196002fcd3cc557f096e..d1ab001b5ba5db6d33d93e78ae2373ce7fd72128:/lisp/abbrev.el diff --git a/lisp/abbrev.el b/lisp/abbrev.el index 43b6a5583e..d181d97703 100644 --- a/lisp/abbrev.el +++ b/lisp/abbrev.el @@ -1,6 +1,6 @@ ;;; abbrev.el --- abbrev mode commands for Emacs -*- lexical-binding: t -*- -;; Copyright (C) 1985-1987, 1992, 2001-2014 Free Software Foundation, +;; Copyright (C) 1985-1987, 1992, 2001-2016 Free Software Foundation, ;; Inc. ;; Maintainer: emacs-devel@gnu.org @@ -399,7 +399,7 @@ A prefix argument means don't query; expand all abbrevs." (buffer-substring-no-properties (save-excursion (forward-word -1) (point)) pnt))) - (if (or noquery (y-or-n-p (format "Expand `%s'? " string))) + (if (or noquery (y-or-n-p (format-message "Expand `%s'? " string))) (expand-abbrev))))))) ;;; Abbrev properties. @@ -580,6 +580,8 @@ An obsolete but still supported calling form is: ,@(if (cadr props) (list :system (cadr props)))))) (unless (plist-get props :count) (setq props (plist-put props :count 0))) + (setq props (plist-put props :abbrev-table-modiff + (abbrev-table-get table :abbrev-table-modiff))) (let ((system-flag (plist-get props :system)) (sym (intern name table))) ;; Don't override a prior user-defined abbrev with a system abbrev, @@ -824,23 +826,28 @@ see `define-abbrev' for details." value)) (defvar abbrev-expand-functions nil - "Wrapper hook around `expand-abbrev'.") + "Wrapper hook around `abbrev--default-expand'.") (make-obsolete-variable 'abbrev-expand-functions 'abbrev-expand-function "24.4") (defvar abbrev-expand-function #'abbrev--default-expand - "Function to perform abbrev expansion. + "Function that `expand-abbrev' uses to perform abbrev expansion. Takes no argument and should return the abbrev symbol if expansion took place.") (defun expand-abbrev () "Expand the abbrev before point, if there is an abbrev there. Effective when explicitly called even when `abbrev-mode' is nil. -Returns the abbrev symbol, if expansion took place. (The actual -return value is that of `abbrev-insert'.)" +Before doing anything else, runs `pre-abbrev-expand-hook'. +Calls `abbrev-expand-function' with no argument to do the work, +and returns whatever it does. (This should be the abbrev symbol +if expansion occurred, else nil.)" (interactive) (run-hooks 'pre-abbrev-expand-hook) (funcall abbrev-expand-function)) (defun abbrev--default-expand () + "Default function to use for `abbrev-expand-function'. +This respects the wrapper hook `abbrev-expand-functions'. +Calls `abbrev-insert' to insert any expansion, and returns what it does." (with-wrapper-hook abbrev-expand-functions () (pcase-let ((`(,sym ,name ,wordstart ,wordend) (abbrev--before-point))) (when sym @@ -948,7 +955,6 @@ Abbrevs marked as \"system abbrevs\" are omitted." (insert " ))\n\n"))) nil))) -(put 'define-abbrev-table 'doc-string-elt 3) (defun define-abbrev-table (tablename definitions &optional docstring &rest props) "Define TABLENAME (a symbol) as an abbrev table name. @@ -968,10 +974,15 @@ Properties with special meaning: - `:enable-function' can be set to a function of no argument which returns non-nil if and only if the abbrevs in this table should be used for this instance of `expand-abbrev'." + (declare (doc-string 3)) ;; We used to manually add the docstring, but we also want to record this ;; location as the definition of the variable (in load-history), so we may ;; as well just use `defvar'. - (eval `(defvar ,tablename nil ,@(if (stringp docstring) (list docstring)))) + (if (and docstring props (symbolp docstring)) + ;; There is really no docstring, instead the docstring arg + ;; is a property name. + (push docstring props) (setq docstring nil)) + (eval `(defvar ,tablename nil ,@(if docstring (list docstring)))) (let ((table (if (boundp tablename) (symbol-value tablename)))) (unless table (setq table (make-abbrev-table)) @@ -982,6 +993,7 @@ Properties with special meaning: ;; if the table was pre-existing as is the case if it was created by ;; loading the user's abbrev file. (while (consp props) + (unless (cdr props) (error "Missing value for property %S" (car props))) (abbrev-table-put table (pop props) (pop props))) (dolist (elt definitions) (apply 'define-abbrev table elt))))