Mercurial > hg > xemacs-beta
comparison lisp/abbrev.el @ 412:697ef44129c6 r21-2-14
Import from CVS: tag r21-2-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:20:41 +0200 |
parents | 2f8bb876ab1d |
children |
comparison
equal
deleted
inserted
replaced
411:12e008d41344 | 412:697ef44129c6 |
---|---|
417 (insert-abbrev-table-description (car tables) nil) | 417 (insert-abbrev-table-description (car tables) nil) |
418 (setq tables (cdr tables)))) | 418 (setq tables (cdr tables)))) |
419 (write-region 1 (point-max) file) | 419 (write-region 1 (point-max) file) |
420 (erase-buffer))) | 420 (erase-buffer))) |
421 | 421 |
422 (defun abbrev-string-to-be-defined (arg) | |
423 "Return the string for which an abbrev will be defined. | |
424 ARG is the argument to `add-global-abbrev' or `add-mode-abbrev'." | |
425 (if (and (not arg) (region-active-p)) (setq arg 0) | |
426 (setq arg (prefix-numeric-value arg))) | |
427 (and (>= arg 0) | |
428 (buffer-substring | |
429 (point) | |
430 (if (= arg 0) (mark) | |
431 (save-excursion (forward-word (- arg)) (point)))))) | |
432 | |
433 (defun add-mode-abbrev (arg) | 422 (defun add-mode-abbrev (arg) |
434 "Define mode-specific abbrev for last word(s) before point. | 423 "Define mode-specific abbrev for last word(s) before point. |
435 Argument is how many words before point form the expansion; | 424 Argument is how many words before point form the expansion; |
436 or zero means the region is the expansion. | 425 or zero means the region is the expansion. |
437 A negative argument means to undefine the specified abbrev. | 426 A negative argument means to undefine the specified abbrev. |
459 (interactive "P") | 448 (interactive "P") |
460 (add-abbrev global-abbrev-table "Global" arg)) | 449 (add-abbrev global-abbrev-table "Global" arg)) |
461 | 450 |
462 (defun add-abbrev (table type arg) | 451 (defun add-abbrev (table type arg) |
463 ;; XEmacs change: | 452 ;; XEmacs change: |
464 (let ((exp (abbrev-string-to-be-defined arg)) | 453 (if (and (not arg) (region-active-p)) (setq arg 0) |
454 (setq arg (prefix-numeric-value arg))) | |
455 (let ((exp (and (>= arg 0) | |
456 (buffer-substring | |
457 (point) | |
458 (if (= arg 0) (mark) | |
459 (save-excursion (forward-word (- arg)) (point)))))) | |
465 name) | 460 name) |
466 (setq name | 461 (setq name |
467 (read-string (format (if exp "%s abbrev for \"%s\": " | 462 (read-string (format (if exp "%s abbrev for \"%s\": " |
468 "Undefine %s abbrev: ") | 463 "Undefine %s abbrev: ") |
469 type exp))) | 464 type exp))) |
471 (if (or (null exp) | 466 (if (or (null exp) |
472 (not (abbrev-expansion name table)) | 467 (not (abbrev-expansion name table)) |
473 (y-or-n-p (format "%s expands to \"%s\"; redefine? " | 468 (y-or-n-p (format "%s expands to \"%s\"; redefine? " |
474 name (abbrev-expansion name table)))) | 469 name (abbrev-expansion name table)))) |
475 (define-abbrev table (downcase name) exp)))) | 470 (define-abbrev table (downcase name) exp)))) |
476 | |
477 (defun inverse-abbrev-string-to-be-defined (arg) | |
478 "Return the string for which an inverse abbrev will be defined. | |
479 ARG is the argument to `inverse-add-global-abbrev' or | |
480 `inverse-add-mode-abbrev'." | |
481 (save-excursion | |
482 (forward-word (- arg)) | |
483 (buffer-substring (point) (progn (forward-word 1) (point))))) | |
484 | 471 |
485 (defun inverse-add-mode-abbrev (arg) | 472 (defun inverse-add-mode-abbrev (arg) |
486 "Define last word before point as a mode-specific abbrev. | 473 "Define last word before point as a mode-specific abbrev. |
487 With prefix argument N, defines the Nth word before point. | 474 With prefix argument N, defines the Nth word before point. |
488 This command uses the minibuffer to read the expansion. | 475 This command uses the minibuffer to read the expansion. |