aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2007-10-30 01:39:19 +0000
committerStefan Monnier2007-10-30 01:39:19 +0000
commit79415279b3c0b8bc8b5f2a725a92c49cdc9d87bc (patch)
tree8bcdf00a7cf66da4ec85d2e9f35154dd9d50b45c
parent15f3eb73ae7ee6763c5d39bdeb6588050b9636f2 (diff)
downloademacs-79415279b3c0b8bc8b5f2a725a92c49cdc9d87bc.tar.gz
emacs-79415279b3c0b8bc8b5f2a725a92c49cdc9d87bc.zip
Rename `count' and `system-flag' to :count and :system. Update all users.
(abbrev-get, abbrev-put): Simplify. (define-abbrev): Don't store the `force' value in the :system property. (abbrev--before-point): Obey the :enable-function of the abbrev as well.
-rw-r--r--doc/lispref/abbrevs.texi62
-rw-r--r--etc/NEWS2
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/abbrev.el72
4 files changed, 73 insertions, 71 deletions
diff --git a/doc/lispref/abbrevs.texi b/doc/lispref/abbrevs.texi
index 9ccafe2de24..8415bdca2be 100644
--- a/doc/lispref/abbrevs.texi
+++ b/doc/lispref/abbrevs.texi
@@ -23,13 +23,10 @@ abbrev table. Normally both are used.
23each abbreviation. The symbol's name is the abbreviation; its value 23each abbreviation. The symbol's name is the abbreviation; its value
24is the expansion; its function definition is the hook function to do 24is the expansion; its function definition is the hook function to do
25the expansion (@pxref{Defining Abbrevs}); its property list cell 25the expansion (@pxref{Defining Abbrevs}); its property list cell
26typically contains the use count, the number of times the abbreviation 26typically contains various additional properties such as the use
27has been expanded. Alternatively, the use count is on the 27count, the number of times the abbreviation has been expanded, or
28@code{count} property and the system-abbrev flag is on the 28whether the abbrev is a so-called ``system'' abbrev defined by a major
29@code{system-type} property. Abbrevs with a non-@code{nil} 29mode rather than by the user (@pxref{Abbrev Properties}).
30@code{system-type} property are called ``system'' abbrevs. They are
31usually defined by modes or packages, instead of by the user, and are
32treated specially in certain respects.
33 30
34Because the symbols used for abbrevs are not interned in the usual 31Because the symbols used for abbrevs are not interned in the usual
35obarray, they will never appear as the result of reading a Lisp 32obarray, they will never appear as the result of reading a Lisp
@@ -82,7 +79,8 @@ This is the same as @code{(default-value 'abbrev-mode)}.
82@defun make-abbrev-table &rest props 79@defun make-abbrev-table &rest props
83This function creates and returns a new, empty abbrev table---an obarray 80This function creates and returns a new, empty abbrev table---an obarray
84containing no symbols. It is a vector filled with zeros. @var{props} 81containing no symbols. It is a vector filled with zeros. @var{props}
85is a property list that is applied to the new table. 82is a property list that is applied to the new table
83(@pxref{Abbrev Table Properties}).
86@end defun 84@end defun
87 85
88@defun abbrev-table-p table 86@defun abbrev-table-p table
@@ -145,7 +143,7 @@ to add these to @var{name} separately.)
145 @code{define-abbrev} is the low-level basic function for defining an 143 @code{define-abbrev} is the low-level basic function for defining an
146abbrev in a specified abbrev table. When major modes predefine standard 144abbrev in a specified abbrev table. When major modes predefine standard
147abbrevs, they should call @code{define-abbrev} and specify a @code{t} for 145abbrevs, they should call @code{define-abbrev} and specify a @code{t} for
148the @code{system-flag} property. 146the @code{:system} property.
149Be aware that any saved non-``system'' abbrevs are 147Be aware that any saved non-``system'' abbrevs are
150restored at startup, i.e. before some major modes are loaded. Major modes 148restored at startup, i.e. before some major modes are loaded. Major modes
151should therefore not assume that when they are first loaded their abbrev 149should therefore not assume that when they are first loaded their abbrev
@@ -155,6 +153,9 @@ tables are empty.
155This function defines an abbrev named @var{name}, in @var{table}, to 153This function defines an abbrev named @var{name}, in @var{table}, to
156expand to @var{expansion} and call @var{hook}, with properties 154expand to @var{expansion} and call @var{hook}, with properties
157@var{props} (@pxref{Abbrev Properties}). The return value is @var{name}. 155@var{props} (@pxref{Abbrev Properties}). The return value is @var{name}.
156The @code{:system} property in @var{props} is treated specially here:
157if it has the value @code{force}, then it will overwrite an existing
158definition even for a non-``system'' abbrev of the same name.
158 159
159The argument @var{name} should be a string. The argument 160The argument @var{name} should be a string. The argument
160@var{expansion} is normally the desired expansion (a string), or 161@var{expansion} is normally the desired expansion (a string), or
@@ -413,8 +414,8 @@ This is the local abbrev table used in Lisp mode and Emacs Lisp mode.
413@section Abbrev Properties 414@section Abbrev Properties
414 415
415Abbrevs have properties, some of which influence the way they work. 416Abbrevs have properties, some of which influence the way they work.
416They are usually set by providing the relevant arguments to 417You can provide them as arguments to @code{define-abbrev} and you can
417@code{define-abbrev} and can be manipulated with the functions: 418manipulate them with the functions:
418 419
419@defun abbrev-put abbrev prop val 420@defun abbrev-put abbrev prop val
420Set the property @var{prop} of abbrev @var{abbrev} to value @var{val}. 421Set the property @var{prop} of abbrev @var{abbrev} to value @var{val}.
@@ -428,38 +429,34 @@ if the abbrev has no such property.
428The following properties have special meaning: 429The following properties have special meaning:
429 430
430@table @code 431@table @code
431@item count 432@item :count
432This property counts the number of times the abbrev has 433This property counts the number of times the abbrev has
433been expanded. If not explicitly set, it is initialized to 0 by 434been expanded. If not explicitly set, it is initialized to 0 by
434@code{define-abbrev}. 435@code{define-abbrev}.
435 436
436@item system-flag 437@item :system
437If non-@code{nil}, this property marks the abbrev as a ``system'' 438If non-@code{nil}, this property marks the abbrev as a ``system''
438abbrev. Such abbrevs will not be saved to @var{abbrev-file-name}. 439abbrev. Such abbrevs will not be saved to @var{abbrev-file-name}.
439Also, unless @code{system-flag} has the value @code{force},
440a ``system'' abbrev will not overwrite an existing definition for
441a non-``system'' abbrev of the same name.
442 440
443@item :enable-function 441@item :enable-function
444If non-@code{nil}, this property should be set to a function of no 442If non-@code{nil}, this property should be a function of no
445arguments which returns @code{nil} if the abbrev should not be used 443arguments which returns @code{nil} if the abbrev should not be used
446and @code{t} otherwise. 444and @code{t} otherwise.
447 445
448@item :case-fixed 446@item :case-fixed
449If non-@code{nil}, this property indicates that the case of the 447If non-@code{nil}, this property indicates that the case of the
450abbrev's name is significant and should only match a text with the 448abbrev's name is significant and should only match a text with the
451same capitalization. It also disables the code that modifies the 449same pattern of capitalization. It also disables the code that
452capitalization of the expansion. 450modifies the capitalization of the expansion.
453
454@end table 451@end table
455 452
456@node Abbrev Table Properties, , Abbrev Properties, Abbrevs 453@node Abbrev Table Properties, , Abbrev Properties, Abbrevs
457@section Abbrev Table Properties 454@section Abbrev Table Properties
458 455
459Like abbrevs, abble tables have properties, some of which influence 456Like abbrevs, abble tables have properties, some of which influence
460the way they work. They are usually set by providing the relevant 457the way they work. You can provide them as arguments to
461arguments to @code{define-abbrev-table} and can be manipulated with 458@code{define-abbrev-table} and you can manipulate them with the
462the functions: 459functions:
463 460
464@defun abbrev-table-put table prop val 461@defun abbrev-table-put table prop val
465Set the property @var{prop} of abbrev table @var{table} to value @var{val}. 462Set the property @var{prop} of abbrev table @var{table} to value @var{val}.
@@ -474,26 +471,21 @@ The following properties have special meaning:
474 471
475@table @code 472@table @code
476@item :enable-function 473@item :enable-function
477If non-@code{nil}, this property should be set to a function of no 474This is like the @code{:enable-function} abbrev property except that
478arguments which returns @code{nil} if the abbrev table should not be 475it applies to all abbrevs in the table and is used even before trying
479used and @code{t} otherwise. This is like the @code{:enable-function} 476to find the abbrev before point so it can dynamically modify the
480abbrev property except that it applies to all abbrevs in the table and 477abbrev table.
481is used even before trying to find the abbrev before point.
482 478
483@item :case-fixed 479@item :case-fixed
484If non-@code{nil}, this property indicates that the case of the names 480This is like the @code{:case-fixed} abbrev property except that it
485is significant for all abbrevs in the table and should only match 481applies to all abbrevs in the table.
486a text with the same capitalization. It also disables the code that
487modifies the capitalization of the expansion. This is like the
488@code{:case-fixed} abbrev property except that it applies to all
489abbrevs in the table.
490 482
491@item :regexp 483@item :regexp
492If non-@code{nil}, this property is a regular expression that 484If non-@code{nil}, this property is a regular expression that
493indicates how to extract the name of the abbrev before point before 485indicates how to extract the name of the abbrev before point before
494looking it up in the table. When the regular expression matches 486looking it up in the table. When the regular expression matches
495before point, the abbrev name is expected to be in submatch 1. 487before point, the abbrev name is expected to be in submatch 1.
496If this property is nil, @code{expand-function} defaults to 488If this property is @code{nil}, @code{expand-function} defaults to
497@code{"\\<\\(\\w+\\)\\W"}. This property allows the use of abbrevs 489@code{"\\<\\(\\w+\\)\\W"}. This property allows the use of abbrevs
498whose name contains characters of non-word syntax. 490whose name contains characters of non-word syntax.
499 491
diff --git a/etc/NEWS b/etc/NEWS
index dcc066e9e3b..87773104dbc 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -180,7 +180,7 @@ consult the Remember Manual for usage details.
180*** New variable `abbrev-minor-mode-table-alist'. 180*** New variable `abbrev-minor-mode-table-alist'.
181*** `local-abbrev-table' can hold a list of abbrev-tables. 181*** `local-abbrev-table' can hold a list of abbrev-tables.
182*** Abbrevs have now the following special properties: 182*** Abbrevs have now the following special properties:
183 `count', `system-flag', `:enable-function', `:case-fixed'. 183 `:count', `:system', `:enable-function', `:case-fixed'.
184*** Abbrev-tables have now the following special properties: 184*** Abbrev-tables have now the following special properties:
185 `:parents', `:case-fixed', `:enable-function', `:regexp', 185 `:parents', `:case-fixed', `:enable-function', `:regexp',
186 `abbrev-table-modiff'. 186 `abbrev-table-modiff'.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 07bc2244f7a..d1910299720 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12007-10-30 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * abbrev.el: Rename `count' and `system-flag' to :count and :system.
4 Update all users.
5 (abbrev-get, abbrev-put): Simplify.
6 (define-abbrev): Don't store the `force' value in the :system property.
7 (abbrev--before-point): Obey the :enable-function of the abbrev as well.
8
12007-10-30 Michael Olson <mwolson@gnu.org> 92007-10-30 Michael Olson <mwolson@gnu.org>
2 10
3 * desktop.el (desktop-minor-mode-table): Add line for ERC. 11 * desktop.el (desktop-minor-mode-table): Add line for ERC.
diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index b13f0a60725..04b8a8ce97c 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -388,21 +388,16 @@ A prefix argument means don't query; expand all abbrevs."
388 (set sym nil) ; Make sure it won't be confused for an abbrev. 388 (set sym nil) ; Make sure it won't be confused for an abbrev.
389 (put sym prop val))) 389 (put sym prop val)))
390 390
391(defun abbrev-get (sym prop) 391(defalias 'abbrev-get 'get
392 "Get the property PROP of abbrev SYM." 392 "Get the property PROP of abbrev ABBREV
393 (let ((plist (symbol-plist sym))) 393
394 (if (listp plist) 394\(fn ABBREV PROP)")
395 (plist-get plist prop) 395
396 (if (eq 'count prop) plist)))) 396(defalias 'abbrev-put 'put
397 397 "Set the property PROP of abbrev ABREV to value VAL.
398(defun abbrev-put (sym prop val) 398See `define-abbrev' for the effect of some special properties.
399 "Set the property PROP of abbrev SYM to value VAL. 399
400See `define-abbrev' for the effect of some special properties." 400\(fn ABBREV PROP VAL)")
401 (let ((plist (symbol-plist sym)))
402 (if (consp plist)
403 (put sym prop val)
404 (setplist sym (if (eq 'count prop) val
405 (list 'count plist prop val))))))
406 401
407(defmacro abbrev-with-wrapper-hook (var &rest body) 402(defmacro abbrev-with-wrapper-hook (var &rest body)
408 "Run BODY wrapped with the VAR hook. 403 "Run BODY wrapped with the VAR hook.
@@ -543,11 +538,11 @@ If EXPANSION is not a string, the abbrev is a special one,
543 which does not expand in the usual way but only runs HOOK. 538 which does not expand in the usual way but only runs HOOK.
544 539
545PROPS is a property list. The following properties are special: 540PROPS is a property list. The following properties are special:
546- `count': the value for the abbrev's usage-count, which is incremented each time 541- `:count': the value for the abbrev's usage-count, which is incremented each time
547 the abbrev is used (the default is zero). 542 the abbrev is used (the default is zero).
548- `system-flag': if non-nil, says that this is a \"system\" abbreviation 543- `:system': if non-nil, says that this is a \"system\" abbreviation
549 which should not be saved in the user's abbreviation file. 544 which should not be saved in the user's abbreviation file.
550 Unless `system-flag' is `force', a system abbreviation will not 545 Unless `:system' is `force', a system abbreviation will not
551 overwrite a non-system abbreviation of the same name. 546 overwrite a non-system abbreviation of the same name.
552- `:case-fixed': non-nil means that abbreviations are looked up without 547- `:case-fixed': non-nil means that abbreviations are looked up without
553 case-folding, and the expansion is not capitalized/upcased. 548 case-folding, and the expansion is not capitalized/upcased.
@@ -556,20 +551,20 @@ PROPS is a property list. The following properties are special:
556 551
557An obsolete but still supported calling form is: 552An obsolete but still supported calling form is:
558 553
559\(define-abbrev TABLE NAME EXPANSION &optional HOOK COUNT SYSTEM-FLAG)." 554\(define-abbrev TABLE NAME EXPANSION &optional HOOK COUNT SYSTEM)."
560 (when (and (consp props) (or (null (car props)) (numberp (car props)))) 555 (when (and (consp props) (or (null (car props)) (numberp (car props))))
561 ;; Old-style calling convention. 556 ;; Old-style calling convention.
562 (setq props (list* 'count (car props) 557 (setq props (list* :count (car props)
563 (if (cadr props) (list 'system-flag (cadr props)))))) 558 (if (cadr props) (list :system (cadr props))))))
564 (unless (plist-get props 'count) 559 (unless (plist-get props :count)
565 (setq props (plist-put props 'count 0))) 560 (setq props (plist-put props :count 0)))
566 (let ((system-flag (plist-get props 'system-flag)) 561 (let ((system-flag (plist-get props :system))
567 (sym (intern name table))) 562 (sym (intern name table)))
568 ;; Don't override a prior user-defined abbrev with a system abbrev, 563 ;; Don't override a prior user-defined abbrev with a system abbrev,
569 ;; unless system-flag is `force'. 564 ;; unless system-flag is `force'.
570 (unless (and (not (memq system-flag '(nil force))) 565 (unless (and (not (memq system-flag '(nil force)))
571 (boundp sym) (symbol-value sym) 566 (boundp sym) (symbol-value sym)
572 (not (abbrev-get sym 'system-flag))) 567 (not (abbrev-get sym :system)))
573 (unless (or system-flag 568 (unless (or system-flag
574 (and (boundp sym) (fboundp sym) 569 (and (boundp sym) (fboundp sym)
575 ;; load-file-name 570 ;; load-file-name
@@ -578,7 +573,10 @@ An obsolete but still supported calling form is:
578 (setq abbrevs-changed t)) 573 (setq abbrevs-changed t))
579 (set sym expansion) 574 (set sym expansion)
580 (fset sym hook) 575 (fset sym hook)
581 (setplist sym props) 576 (setplist sym
577 ;; Don't store the `force' value of `system-flag' into
578 ;; the :system property.
579 (if (eq 'force system-flag) (plist-put props :system t) props))
582 (abbrev-table-put table :abbrev-table-modiff 580 (abbrev-table-put table :abbrev-table-modiff
583 (1+ (abbrev-table-get table :abbrev-table-modiff)))) 581 (1+ (abbrev-table-get table :abbrev-table-modiff))))
584 name)) 582 name))
@@ -710,10 +708,14 @@ then ABBREV is looked up in that table only."
710 (line-beginning-position)) 708 (line-beginning-position))
711 (setq start (match-beginning 1)) 709 (setq start (match-beginning 1))
712 (setq end (match-end 1)) 710 (setq end (match-end 1))
713 (setq name (buffer-substring start end)) 711 (setq name (buffer-substring start end))
714 ;; This will also look it up in parent tables. 712 (let ((abbrev (abbrev-symbol name table)))
715 ;; This is not on purpose, but it seems harmless. 713 (when abbrev
716 (list (abbrev-symbol name table) name start end))) 714 (setq enable-fun (abbrev-get abbrev :enable-function))
715 (and (or (not enable-fun) (funcall enable-fun))
716 ;; This will also look it up in parent tables.
717 ;; This is not on purpose, but it seems harmless.
718 (list abbrev name start end))))))
717 ;; Restore point. 719 ;; Restore point.
718 (goto-char pos))) 720 (goto-char pos)))
719 res))) 721 res)))
@@ -746,7 +748,7 @@ Returns the abbrev symbol, if expansion took place."
746 (setq last-abbrev sym) 748 (setq last-abbrev sym)
747 (setq last-abbrev-location wordstart) 749 (setq last-abbrev-location wordstart)
748 ;; Increment use count. 750 ;; Increment use count.
749 (abbrev-put sym 'count (1+ (abbrev-get sym 'count))) 751 (abbrev-put sym :count (1+ (abbrev-get sym :count)))
750 ;; If this abbrev has an expansion, delete the abbrev 752 ;; If this abbrev has an expansion, delete the abbrev
751 ;; and insert the expansion. 753 ;; and insert the expansion.
752 (when (stringp (symbol-value sym)) 754 (when (stringp (symbol-value sym))
@@ -815,7 +817,7 @@ is not undone."
815 "Write the abbrev in a `read'able form. 817 "Write the abbrev in a `read'able form.
816Only writes the non-system abbrevs. 818Only writes the non-system abbrevs.
817Presumes that `standard-output' points to `current-buffer'." 819Presumes that `standard-output' points to `current-buffer'."
818 (unless (or (null (symbol-value sym)) (abbrev-get sym 'system-flag)) 820 (unless (or (null (symbol-value sym)) (abbrev-get sym :system))
819 (insert " (") 821 (insert " (")
820 (prin1 name) 822 (prin1 name)
821 (insert " ") 823 (insert " ")
@@ -823,17 +825,17 @@ Presumes that `standard-output' points to `current-buffer'."
823 (insert " ") 825 (insert " ")
824 (prin1 (symbol-function sym)) 826 (prin1 (symbol-function sym))
825 (insert " ") 827 (insert " ")
826 (prin1 (abbrev-get sym 'count)) 828 (prin1 (abbrev-get sym :count))
827 (insert ")\n"))) 829 (insert ")\n")))
828 830
829(defun abbrev--describe (sym) 831(defun abbrev--describe (sym)
830 (when (symbol-value sym) 832 (when (symbol-value sym)
831 (prin1 (symbol-name sym)) 833 (prin1 (symbol-name sym))
832 (if (null (abbrev-get sym 'system-flag)) 834 (if (null (abbrev-get sym :system))
833 (indent-to 15 1) 835 (indent-to 15 1)
834 (insert " (sys)") 836 (insert " (sys)")
835 (indent-to 20 1)) 837 (indent-to 20 1))
836 (prin1 (abbrev-get sym 'count)) 838 (prin1 (abbrev-get sym :count))
837 (indent-to 20 1) 839 (indent-to 20 1)
838 (prin1 (symbol-value sym)) 840 (prin1 (symbol-value sym))
839 (when (symbol-function sym) 841 (when (symbol-function sym)