X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Fabbrev.el;h=75ce53b9b3236274dc94bcf59501e639e5d73458;hb=528ca5c9afc87d2d698ce64b29cc9b069d09894f;hp=110de3359b7afdae02cb812e3c6639c31f3d2e95;hpb=2fd9701a4f902054649dde9143a3f77809afee8f;p=chise%2Fxemacs-chise.git.1 diff --git a/lisp/abbrev.el b/lisp/abbrev.el index 110de33..75ce53b 100644 --- a/lisp/abbrev.el +++ b/lisp/abbrev.el @@ -67,38 +67,30 @@ This causes `save-some-buffers' to offer to save the abbrevs.") nil) -(defun define-abbrev-table (name defs) - "Define TABNAME (a symbol) as an abbrev table name. +(defun define-abbrev-table (table-name definitions) + "Define TABLE-NAME (a symbol) as an abbrev table name. Define abbrevs in it according to DEFINITIONS, which is a list of elements of the form (ABBREVNAME EXPANSION HOOK USECOUNT)." - (let ((table (and (boundp name) (symbol-value name)))) + (let ((table (and (boundp table-name) (symbol-value table-name)))) (cond ((vectorp table)) ((not table) (setq table (make-abbrev-table)) - (set name table) - (setq abbrev-table-name-list (cons name abbrev-table-name-list))) + (set table-name table) + (setq abbrev-table-name-list (cons table-name abbrev-table-name-list))) (t - (setq table (signal 'wrong-type-argument (list 'vectorp table))) - (set name table))) - (while defs - (apply (function define-abbrev) table (car defs)) - (setq defs (cdr defs))))) + (setq table (wrong-type-argument 'vectorp table)) + (set table-name table))) + (while definitions + (apply (function define-abbrev) table (car definitions)) + (setq definitions (cdr definitions))))) (defun define-abbrev (table name &optional expansion hook count) "Define an abbrev in TABLE named NAME, to expand to EXPANSION or call HOOK. NAME and EXPANSION are strings. Hook is a function or `nil'. To undefine an abbrev, define it with an expansion of `nil'." - (or (not expansion) - (stringp expansion) - (setq expansion (signal 'wrong-type-argument - (list 'stringp expansion)))) - (or (not count) - (integerp count) - (setq count (signal 'wrong-type-argument - (list 'fixnump count)))) - (or (vectorp table) - (setq table (signal 'wrong-type-argument - (list 'vectorp table)))) + (check-type expansion (or null string)) + (check-type count (or null integer)) + (check-type table vector) (let* ((sym (intern name table)) (oexp (and (boundp sym) (symbol-value sym))) (ohook (and (fboundp sym) (symbol-function sym)))) @@ -207,13 +199,13 @@ is not undone." -(defun insert-abbrev-table-description (name human-readable) +(defun insert-abbrev-table-description (name &optional human-readable) "Insert before point a full description of abbrev table named NAME. NAME is a symbol whose value is an abbrev table. -If optional 2nd arg HUMAN is non-nil, insert a human-readable description. -Otherwise the description is an expression, -a call to `define-abbrev-table', which would -define the abbrev table NAME exactly as it is currently defined." +If optional second argument HUMAN-READABLE is non-nil, insert a +human-readable description. Otherwise the description is an +expression, a call to `define-abbrev-table', which would define the +abbrev table NAME exactly as it is currently defined." (let ((table (symbol-value name)) (stream (current-buffer))) (message "Abbrev-table %s..." name) @@ -268,7 +260,7 @@ define the abbrev table NAME exactly as it is currently defined." (defun abbrev-mode (arg) "Toggle abbrev mode. -With argument ARG, turn abbrev mode on iff ARG is positive. +With argument ARG, enable abbrev mode if ARG is positive, else disable. In abbrev mode, inserting an abbreviation causes it to expand and be replaced by its expansion." (interactive "P") @@ -391,7 +383,7 @@ Optional second argument QUIETLY non-nil means don't print anything." (setq save-abbrevs t abbrevs-changed nil)) (defun quietly-read-abbrev-file (&optional file) - "Read abbrev definitions from file written with write-abbrev-file. + "Read abbrev definitions from file written with `write-abbrev-file'. Optional argument FILE is the name of the file to read; it defaults to the value of `abbrev-file-name'. Does not print anything." @@ -428,7 +420,7 @@ ARG is the argument to `add-global-abbrev' or `add-mode-abbrev'." (buffer-substring (point) (if (= arg 0) (mark) - (save-excursion (forward-word (- arg)) (point)))))) + (save-excursion (backward-word arg) (point)))))) (defun add-mode-abbrev (arg) "Define mode-specific abbrev for last word(s) before point. @@ -460,6 +452,13 @@ Don't use this function in a Lisp program; use `define-abbrev' instead." (add-abbrev global-abbrev-table "Global" arg)) (defun add-abbrev (table type arg) + "Add an abbreviation to abbrev table TABLE. +TYPE is a string describing in English the kind of abbrev this will be +(typically, \"global\" or \"mode-specific\"); this is used in +prompting the user. ARG is the number of words in the expansion. + +Return the symbol that internally represents the new abbrev, or nil if +the user declines to confirm redefining an existing abbrev." ;; XEmacs change: (let ((exp (abbrev-string-to-be-defined arg)) name) @@ -479,7 +478,7 @@ Don't use this function in a Lisp program; use `define-abbrev' instead." ARG is the argument to `inverse-add-global-abbrev' or `inverse-add-mode-abbrev'." (save-excursion - (forward-word (- arg)) + (backward-word arg) (buffer-substring (point) (progn (forward-word 1) (point))))) (defun inverse-add-mode-abbrev (arg) @@ -506,7 +505,7 @@ Expands the abbreviation after defining it." (defun inverse-add-abbrev (table type arg) (let (name nameloc exp) (save-excursion - (forward-word (- arg)) + (backward-word arg) (setq name (buffer-substring (point) (progn (forward-word 1) (setq nameloc (point)))))) (set-text-properties 0 (length name) nil name) @@ -549,7 +548,7 @@ If called from a Lisp program, arguments are START END &optional NOQUERY." (if (abbrev-expansion (setq string (buffer-substring - (save-excursion (forward-word -1) (point)) + (save-excursion (backward-word) (point)) pnt))) (if (or noquery (y-or-n-p (format "Expand `%s'? " string))) (expand-abbrev)))))))