Mercurial > emacs
comparison lisp/abbrev.el @ 106109:42ca82b4620b
* abbrev.el (abbrev-with-wrapper-hook): (re)move...
* simple.el (with-wrapper-hook): ...to here. Add argument `args'.
* minibuffer.el (completion-in-region-functions): New hook.
(completion-in-region): New function.
* emacs-lisp/lisp.el (lisp-complete-symbol):
* pcomplete.el (pcomplete-std-complete): Use it.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Thu, 19 Nov 2009 03:12:51 +0000 |
parents | 0ea87b098bb0 |
children | 13733fc37569 |
comparison
equal
deleted
inserted
replaced
106108:48d6337584da | 106109:42ca82b4620b |
---|---|
389 (defalias 'abbrev-put 'put | 389 (defalias 'abbrev-put 'put |
390 "Set the property PROP of abbrev ABREV to value VAL. | 390 "Set the property PROP of abbrev ABREV to value VAL. |
391 See `define-abbrev' for the effect of some special properties. | 391 See `define-abbrev' for the effect of some special properties. |
392 | 392 |
393 \(fn ABBREV PROP VAL)") | 393 \(fn ABBREV PROP VAL)") |
394 | |
395 (defmacro abbrev-with-wrapper-hook (var &rest body) | |
396 "Run BODY wrapped with the VAR hook. | |
397 VAR is a special hook: its functions are called with one argument which | |
398 is the \"original\" code (the BODY), so the hook function can wrap the | |
399 original function, can call it several times, or even not call it at all. | |
400 VAR is normally a symbol (a variable) in which case it is treated like a hook, | |
401 with a buffer-local and a global part. But it can also be an arbitrary expression. | |
402 This is similar to an `around' advice." | |
403 (declare (indent 1) (debug t)) | |
404 ;; We need those two gensyms because CL's lexical scoping is not available | |
405 ;; for function arguments :-( | |
406 (let ((funs (make-symbol "funs")) | |
407 (global (make-symbol "global"))) | |
408 ;; Since the hook is a wrapper, the loop has to be done via | |
409 ;; recursion: a given hook function will call its parameter in order to | |
410 ;; continue looping. | |
411 `(labels ((runrestofhook (,funs ,global) | |
412 ;; `funs' holds the functions left on the hook and `global' | |
413 ;; holds the functions left on the global part of the hook | |
414 ;; (in case the hook is local). | |
415 (lexical-let ((funs ,funs) | |
416 (global ,global)) | |
417 (if (consp funs) | |
418 (if (eq t (car funs)) | |
419 (runrestofhook (append global (cdr funs)) nil) | |
420 (funcall (car funs) | |
421 (lambda () (runrestofhook (cdr funs) global)))) | |
422 ;; Once there are no more functions on the hook, run | |
423 ;; the original body. | |
424 ,@body)))) | |
425 (runrestofhook ,var | |
426 ;; The global part of the hook, if any. | |
427 ,(if (symbolp var) | |
428 `(if (local-variable-p ',var) | |
429 (default-value ',var))))))) | |
430 | |
431 | 394 |
432 ;;; Code that used to be implemented in src/abbrev.c | 395 ;;; Code that used to be implemented in src/abbrev.c |
433 | 396 |
434 (defvar abbrev-table-name-list '(fundamental-mode-abbrev-table | 397 (defvar abbrev-table-name-list '(fundamental-mode-abbrev-table |
435 global-abbrev-table) | 398 global-abbrev-table) |
797 "Expand the abbrev before point, if there is an abbrev there. | 760 "Expand the abbrev before point, if there is an abbrev there. |
798 Effective when explicitly called even when `abbrev-mode' is nil. | 761 Effective when explicitly called even when `abbrev-mode' is nil. |
799 Returns the abbrev symbol, if expansion took place." | 762 Returns the abbrev symbol, if expansion took place." |
800 (interactive) | 763 (interactive) |
801 (run-hooks 'pre-abbrev-expand-hook) | 764 (run-hooks 'pre-abbrev-expand-hook) |
802 (abbrev-with-wrapper-hook abbrev-expand-functions | 765 (with-wrapper-hook abbrev-expand-functions () |
803 (destructuring-bind (&optional sym name wordstart wordend) | 766 (destructuring-bind (&optional sym name wordstart wordend) |
804 (abbrev--before-point) | 767 (abbrev--before-point) |
805 (when sym | 768 (when sym |
806 (let ((value sym)) | 769 (let ((value sym)) |
807 (unless (or ;; executing-kbd-macro | 770 (unless (or ;; executing-kbd-macro |