Mercurial > hg > xemacs-beta
comparison lisp/abbrev.el @ 272:c5d627a313b1 r21-0b34
Import from CVS: tag r21-0b34
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:28:48 +0200 |
parents | 0e522484dd2a |
children | 2f8bb876ab1d |
comparison
equal
deleted
inserted
replaced
271:c7b7086b0a39 | 272:c5d627a313b1 |
---|---|
55 (defvar abbrevs-changed nil | 55 (defvar abbrevs-changed nil |
56 "Set non-nil by defining or altering any word abbrevs. | 56 "Set non-nil by defining or altering any word abbrevs. |
57 This causes `save-some-buffers' to offer to save the abbrevs.") | 57 This causes `save-some-buffers' to offer to save the abbrevs.") |
58 | 58 |
59 (defun make-abbrev-table () | 59 (defun make-abbrev-table () |
60 "Create a new, empty abbrev table object." | 60 "Return a new, empty abbrev table object." |
61 (make-vector 59 0)) ; 59 is prime | 61 (make-vector 59 0)) ; 59 is prime |
62 | 62 |
63 (defun clear-abbrev-table (table) | 63 (defun clear-abbrev-table (table) |
64 "Undefine all abbrevs in abbrev table TABLE, leaving it empty." | 64 "Undefine all abbrevs in abbrev table TABLE, leaving it empty." |
65 (fillarray table 0) | 65 (fillarray table 0) |
123 (if (consp fixup) | 123 (if (consp fixup) |
124 (progn | 124 (progn |
125 (setq abbrev-table-name-list (delq fixup abbrev-table-name-list)) | 125 (setq abbrev-table-name-list (delq fixup abbrev-table-name-list)) |
126 (define-abbrev-table (car fixup) (cdr fixup)))) | 126 (define-abbrev-table (car fixup) (cdr fixup)))) |
127 (setq l (cdr l)))) | 127 (setq l (cdr l)))) |
128 ;; These are no longer initialised by C code | 128 ;; These are no longer initialized by C code |
129 (if (not global-abbrev-table) | 129 (if (not global-abbrev-table) |
130 (progn | 130 (progn |
131 (setq global-abbrev-table (make-abbrev-table)) | 131 (setq global-abbrev-table (make-abbrev-table)) |
132 (setq abbrev-table-name-list (cons 'global-abbrev-table | 132 (setq abbrev-table-name-list (cons 'global-abbrev-table |
133 abbrev-table-name-list)))) | 133 abbrev-table-name-list)))) |
184 | 184 |
185 (defun unexpand-abbrev () | 185 (defun unexpand-abbrev () |
186 "Undo the expansion of the last abbrev that expanded. | 186 "Undo the expansion of the last abbrev that expanded. |
187 This differs from ordinary undo in that other editing done since then | 187 This differs from ordinary undo in that other editing done since then |
188 is not undone." | 188 is not undone." |
189 (interactive) | 189 (interactive) |
190 (if (or (< last-abbrev-location (point-min)) | 190 (if (or (< last-abbrev-location (point-min)) |
191 (> last-abbrev-location (point-max)) | 191 (> last-abbrev-location (point-max)) |
192 (not (stringp last-abbrev-text))) | 192 (not (stringp last-abbrev-text))) |
193 nil | 193 nil |
194 (let* ((opoint (point)) | 194 (let* ((opoint (point)) |
214 Otherwise the description is an expression, | 214 Otherwise the description is an expression, |
215 a call to `define-abbrev-table', which would | 215 a call to `define-abbrev-table', which would |
216 define the abbrev table NAME exactly as it is currently defined." | 216 define the abbrev table NAME exactly as it is currently defined." |
217 (let ((table (symbol-value name)) | 217 (let ((table (symbol-value name)) |
218 (stream (current-buffer))) | 218 (stream (current-buffer))) |
219 (message "Abbrev-table %s..." name) | 219 (message "Abbrev-table %s..." name) |
220 (if human-readable | 220 (if human-readable |
221 (progn | 221 (progn |
222 (prin1 (list name) stream) | 222 (prin1 (list name) stream) |
223 ;; Need two terpri's or cretinous edit-abbrevs blows out | 223 ;; Need two terpri's or cretinous edit-abbrevs blows out |
224 (terpri stream) | 224 (terpri stream) |
429 Don't use this function in a Lisp program; use `define-abbrev' instead." | 429 Don't use this function in a Lisp program; use `define-abbrev' instead." |
430 ;; XEmacs change: | 430 ;; XEmacs change: |
431 (interactive "P") | 431 (interactive "P") |
432 (add-abbrev | 432 (add-abbrev |
433 (if only-global-abbrevs | 433 (if only-global-abbrevs |
434 global-abbrev-table | 434 global-abbrev-table |
435 (or local-abbrev-table | 435 (or local-abbrev-table |
436 (error "No per-mode abbrev table"))) | 436 (error "No per-mode abbrev table"))) |
437 "Mode" arg)) | 437 "Mode" arg)) |
438 | 438 |
439 (defun add-global-abbrev (arg) | 439 (defun add-global-abbrev (arg) |
466 (if (or (null exp) | 466 (if (or (null exp) |
467 (not (abbrev-expansion name table)) | 467 (not (abbrev-expansion name table)) |
468 (y-or-n-p (format "%s expands to \"%s\"; redefine? " | 468 (y-or-n-p (format "%s expands to \"%s\"; redefine? " |
469 name (abbrev-expansion name table)))) | 469 name (abbrev-expansion name table)))) |
470 (define-abbrev table (downcase name) exp)))) | 470 (define-abbrev table (downcase name) exp)))) |
471 | 471 |
472 (defun inverse-add-mode-abbrev (arg) | 472 (defun inverse-add-mode-abbrev (arg) |
473 "Define last word before point as a mode-specific abbrev. | 473 "Define last word before point as a mode-specific abbrev. |
474 With prefix argument N, defines the Nth word before point. | 474 With prefix argument N, defines the Nth word before point. |
475 This command uses the minibuffer to read the expansion. | 475 This command uses the minibuffer to read the expansion. |
476 Expands the abbreviation after defining it." | 476 Expands the abbreviation after defining it." |
477 (interactive "p") | 477 (interactive "p") |
478 (inverse-add-abbrev | 478 (inverse-add-abbrev |
479 (if only-global-abbrevs | 479 (if only-global-abbrevs |
480 global-abbrev-table | 480 global-abbrev-table |
481 (or local-abbrev-table | 481 (or local-abbrev-table |
482 (error "No per-mode abbrev table"))) | 482 (error "No per-mode abbrev table"))) |
483 "Mode" arg)) | 483 "Mode" arg)) |
484 | 484 |
485 (defun inverse-add-global-abbrev (arg) | 485 (defun inverse-add-global-abbrev (arg) |