Mercurial > emacs
diff lisp/minibuffer.el @ 106482:806e9f7990d8
* minibuffer.el (completion-at-point-functions): New var.
(completion-at-point): New command.
* indent.el (indent-for-tab-command): Handle the new `complete' behavior.
* progmodes/python.el (python-mode-map): Use completion-at-point.
(python-completion-at-point): Rename from python-partial-symbol and
adjust for use in completion-at-point-functions.
(python-mode): Setup completion-at-point for Python completion.
* emacs-lisp/lisp.el (lisp-completion-at-point): New function
extracted from lisp-complete-symbol.
(lisp-complete-symbol): Use it.
* emacs-lisp/lisp-mode.el (emacs-lisp-mode): Use define-derived-mode,
setup completion-at-point for Elisp completion.
(emacs-lisp-mode-map, lisp-interaction-mode-map): Use completion-at-point.
* ielm.el (ielm-map): Use completion-at-point.
(inferior-emacs-lisp-mode): Setup completion-at-point for Elisp completion.
* progmodes/sym-comp.el: Move to...
* obsolete/sym-comp.el: Move from progmodes.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 07 Dec 2009 20:06:26 +0000 |
parents | eaa5eba6d613 |
children | 82c7a7ac0c67 |
line wrap: on
line diff
--- a/lisp/minibuffer.el Mon Dec 07 19:21:57 2009 +0000 +++ b/lisp/minibuffer.el Mon Dec 07 20:06:26 2009 +0000 @@ -1113,6 +1113,36 @@ (call-interactively 'minibuffer-complete) (delete-overlay ol))))) +(defvar completion-at-point-functions nil + "Special hook to find the completion table for the thing at point. +It is called without any argument and should return either nil, +or a function of no argument to perform completion (discouraged), +or a list of the form (START END COLLECTION &rest PROPS) where + START and END delimit the entity to complete and should include point, + COLLECTION is the completion table to use to complete it, and + PROPS is a property list for additional information. +Currently supported properties are: + `:predicate' a predicate that completion candidates need to satisfy. + `:annotation-function' the value to use for `completion-annotate-function'.") + +(defun completion-at-point () + "Complete the thing at point according to local mode." + (interactive) + (let ((res (run-hook-with-args-until-success + 'completion-at-point-functions))) + (cond + ((functionp res) (funcall res)) + (res + (let* ((plist (nthcdr 3 res)) + (start (nth 0 res)) + (end (nth 1 res)) + (completion-annotate-function + (or (plist-get plist :annotation-function) + completion-annotate-function))) + (completion-in-region start end (nth 2 res) + (plist-get plist :predicate))))))) + + (let ((map minibuffer-local-map)) (define-key map "\C-g" 'abort-recursive-edit) (define-key map "\r" 'exit-minibuffer)