Mercurial > hg > xemacs-beta
comparison lisp/modes/abbrev.el @ 167:85ec50267440 r20-3b10
Import from CVS: tag r20-3b10
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:45:46 +0200 |
parents | ac2d302a0011 |
children | 15872534500d |
comparison
equal
deleted
inserted
replaced
166:7a77eb660975 | 167:85ec50267440 |
---|---|
28 ;; This facility is documented in the Emacs Manual. | 28 ;; This facility is documented in the Emacs Manual. |
29 | 29 |
30 ;;; Code: | 30 ;;; Code: |
31 | 31 |
32 ;jwz: this is preloaded so don't ;;;###autoload | 32 ;jwz: this is preloaded so don't ;;;###autoload |
33 (defconst only-global-abbrevs nil "\ | 33 (defcustom only-global-abbrevs nil "\ |
34 *t means user plans to use global abbrevs only. | 34 *Non-nil means user plans to use global abbrevs only. |
35 Makes the commands to define mode-specific abbrevs define global ones instead.") | 35 Makes the commands to define mode-specific abbrevs define global ones instead." |
36 :type 'boolean | |
37 :group 'abbrev) | |
36 | 38 |
37 ;;; XEmacs: the following block of code is not in FSF | 39 ;;; XEmacs: the following block of code is not in FSF |
38 (defvar abbrev-table-name-list '() | 40 (defvar abbrev-table-name-list '() |
39 "List of symbols whose values are abbrev tables.") | 41 "List of symbols whose values are abbrev tables.") |
40 | 42 |
71 (setq defs (cdr defs))))) | 73 (setq defs (cdr defs))))) |
72 | 74 |
73 (defun define-abbrev (table name &optional expansion hook count) | 75 (defun define-abbrev (table name &optional expansion hook count) |
74 "Define an abbrev in TABLE named NAME, to expand to EXPANSION or call HOOK. | 76 "Define an abbrev in TABLE named NAME, to expand to EXPANSION or call HOOK. |
75 NAME and EXPANSION are strings. Hook is a function or `nil'. | 77 NAME and EXPANSION are strings. Hook is a function or `nil'. |
76 To undefine an abbrev, define with the an expansion of `nil'." | 78 To undefine an abbrev, define it with an expansion of `nil'." |
77 (or (not expansion) | 79 (or (not expansion) |
78 (stringp expansion) | 80 (stringp expansion) |
79 (setq expansion (signal 'wrong-type-argument | 81 (setq expansion (signal 'wrong-type-argument |
80 (list 'stringp expansion)))) | 82 (list 'stringp expansion)))) |
81 (or (not count) | 83 (or (not count) |
82 (integerp count) | 84 (integerp count) |
83 (setq count (signal 'wrong-type-argument | 85 (setq count (signal 'wrong-type-argument |
84 (list 'fixnump count)))) | 86 (list 'fixnump count)))) |
87 (or (vectorp table) | |
88 (setq table (signal 'wrong-type-argument | |
89 (list 'vectorp table)))) | |
85 (let* ((sym (intern name table)) | 90 (let* ((sym (intern name table)) |
86 (oexp (and (boundp sym) (symbol-value sym))) | 91 (oexp (and (boundp sym) (symbol-value sym))) |
87 (ohook (and (fboundp sym) (symbol-function sym)))) | 92 (ohook (and (fboundp sym) (symbol-function sym)))) |
88 (if (not (and (equal ohook hook) | 93 (unless (and (equal ohook hook) |
89 (stringp oexp) | 94 (stringp oexp) |
90 (stringp expansion) | 95 (stringp expansion) |
91 (string-equal oexp expansion))) | 96 (string-equal oexp expansion)) |
92 (setq abbrevs-changed t)) | 97 (setq abbrevs-changed t) |
98 ;; If there is a non-word character in the string, set the flag. | |
99 (if (string-match "\\W" name) | |
100 (set (intern " " table) nil))) | |
93 (set sym expansion) | 101 (set sym expansion) |
94 (fset sym hook) | 102 (fset sym hook) |
95 (setplist sym (or count 0)) | 103 (setplist sym (or count 0)) |
96 name)) | 104 name)) |
97 | 105 |
130 (defun define-mode-abbrev (name expansion) | 138 (defun define-mode-abbrev (name expansion) |
131 "Define ABBREV as a mode-specific abbreviation for EXPANSION." | 139 "Define ABBREV as a mode-specific abbreviation for EXPANSION." |
132 (interactive "sDefine mode abbrev: \nsExpansion for %s: ") | 140 (interactive "sDefine mode abbrev: \nsExpansion for %s: ") |
133 (define-abbrev (or local-abbrev-table | 141 (define-abbrev (or local-abbrev-table |
134 (error "Major mode has no abbrev table")) | 142 (error "Major mode has no abbrev table")) |
135 (downcase name) nil 0)) | 143 (downcase name) expansion 0)) |
136 | 144 |
137 (defun abbrev-symbol (abbrev &optional table) | 145 (defun abbrev-symbol (abbrev &optional table) |
138 "Return the symbol representing abbrev named ABBREV. | 146 "Return the symbol representing abbrev named ABBREV. |
139 This symbol's name is ABBREV, but it is not the canonical symbol of that name; | 147 This symbol's name is ABBREV, but it is not the canonical symbol of that name; |
140 it is interned in an abbrev-table rather than the normal obarray. | 148 it is interned in an abbrev-table rather than the normal obarray. |