diff options
| author | Stefan Monnier | 2009-12-07 20:06:26 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2009-12-07 20:06:26 +0000 |
| commit | 51ef56c47fc0b02b20f44b673f8b60350c03b4e1 (patch) | |
| tree | f3c898b5885cfc9cdca8681966bd223d3ee19ff7 | |
| parent | 5e7a90229a1c32ded160a6d27f4ad9f3c66f60c3 (diff) | |
| download | emacs-51ef56c47fc0b02b20f44b673f8b60350c03b4e1.tar.gz emacs-51ef56c47fc0b02b20f44b673f8b60350c03b4e1.zip | |
* 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.
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/ChangeLog | 20 | ||||
| -rw-r--r-- | lisp/emacs-lisp/lisp-mode.el | 21 | ||||
| -rw-r--r-- | lisp/emacs-lisp/lisp.el | 18 | ||||
| -rw-r--r-- | lisp/ielm.el | 4 | ||||
| -rw-r--r-- | lisp/indent.el | 41 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 30 | ||||
| -rw-r--r-- | lisp/obsolete/sym-comp.el (renamed from lisp/progmodes/sym-comp.el) | 1 | ||||
| -rw-r--r-- | lisp/progmodes/python.el | 23 |
9 files changed, 115 insertions, 49 deletions
| @@ -137,6 +137,10 @@ subsequent kills are not duplicated in the `kill-ring'. | |||
| 137 | 137 | ||
| 138 | ** Completion changes | 138 | ** Completion changes |
| 139 | 139 | ||
| 140 | *** The new command `completion-at-point' provides mode-sensitive completion. | ||
| 141 | |||
| 142 | *** tab-always-indent set to `complete' lets TAB do completion as well. | ||
| 143 | |||
| 140 | *** The new completion-style `initials' is available. | 144 | *** The new completion-style `initials' is available. |
| 141 | For instance, this can complete M-x lch to list-command-history. | 145 | For instance, this can complete M-x lch to list-command-history. |
| 142 | 146 | ||
| @@ -170,6 +174,8 @@ cycling order of C-l (`recenter-top-bottom'). | |||
| 170 | ** LaTeX mode now provides completion via latex-complete and | 174 | ** LaTeX mode now provides completion via latex-complete and |
| 171 | latex-indent-or-complete. | 175 | latex-indent-or-complete. |
| 172 | 176 | ||
| 177 | ** sym-comp.el is now declared obsolete, superceded by completion-at-point. | ||
| 178 | |||
| 173 | ** lucid.el and levents.el are now declared obsolete. | 179 | ** lucid.el and levents.el are now declared obsolete. |
| 174 | 180 | ||
| 175 | ** pcomplete provides a new command `pcomplete-std-completion' which | 181 | ** pcomplete provides a new command `pcomplete-std-completion' which |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9a13c3d51d8..1eec4f80e5f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,23 @@ | |||
| 1 | 2009-12-07 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * minibuffer.el (completion-at-point-functions): New var. | ||
| 4 | (completion-at-point): New command. | ||
| 5 | * indent.el (indent-for-tab-command): Handle the new `complete' behavior. | ||
| 6 | * progmodes/python.el (python-mode-map): Use completion-at-point. | ||
| 7 | (python-completion-at-point): Rename from python-partial-symbol and | ||
| 8 | adjust for use in completion-at-point-functions. | ||
| 9 | (python-mode): Setup completion-at-point for Python completion. | ||
| 10 | * emacs-lisp/lisp.el (lisp-completion-at-point): New function | ||
| 11 | extracted from lisp-complete-symbol. | ||
| 12 | (lisp-complete-symbol): Use it. | ||
| 13 | * emacs-lisp/lisp-mode.el (emacs-lisp-mode): Use define-derived-mode, | ||
| 14 | setup completion-at-point for Elisp completion. | ||
| 15 | (emacs-lisp-mode-map, lisp-interaction-mode-map): Use completion-at-point. | ||
| 16 | * ielm.el (ielm-map): Use completion-at-point. | ||
| 17 | (inferior-emacs-lisp-mode): Setup completion-at-point for Elisp completion. | ||
| 18 | * progmodes/sym-comp.el: Move to... | ||
| 19 | * obsolete/sym-comp.el: Move from progmodes. | ||
| 20 | |||
| 1 | 2009-12-07 Eli Zaretskii <eliz@gnu.org> | 21 | 2009-12-07 Eli Zaretskii <eliz@gnu.org> |
| 2 | 22 | ||
| 3 | Prevent save-buffer in Rmail buffers from using the coding-system | 23 | Prevent save-buffer in Rmail buffers from using the coding-system |
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index a42ef5da930..7e5d89c66dc 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el | |||
| @@ -280,7 +280,7 @@ font-lock keywords will not be case sensitive." | |||
| 280 | (prof-map (make-sparse-keymap)) | 280 | (prof-map (make-sparse-keymap)) |
| 281 | (tracing-map (make-sparse-keymap))) | 281 | (tracing-map (make-sparse-keymap))) |
| 282 | (set-keymap-parent map lisp-mode-shared-map) | 282 | (set-keymap-parent map lisp-mode-shared-map) |
| 283 | (define-key map "\e\t" 'lisp-complete-symbol) | 283 | (define-key map "\e\t" 'completion-at-point) |
| 284 | (define-key map "\e\C-x" 'eval-defun) | 284 | (define-key map "\e\C-x" 'eval-defun) |
| 285 | (define-key map "\e\C-q" 'indent-pp-sexp) | 285 | (define-key map "\e\C-q" 'indent-pp-sexp) |
| 286 | (define-key map [menu-bar emacs-lisp] (cons (purecopy "Emacs-Lisp") menu-map)) | 286 | (define-key map [menu-bar emacs-lisp] (cons (purecopy "Emacs-Lisp") menu-map)) |
| @@ -431,7 +431,7 @@ All commands in `lisp-mode-shared-map' are inherited by this map.") | |||
| 431 | :type 'hook | 431 | :type 'hook |
| 432 | :group 'lisp) | 432 | :group 'lisp) |
| 433 | 433 | ||
| 434 | (defun emacs-lisp-mode () | 434 | (define-derived-mode emacs-lisp-mode nil "Emacs-Lisp" |
| 435 | "Major mode for editing Lisp code to run in Emacs. | 435 | "Major mode for editing Lisp code to run in Emacs. |
| 436 | Commands: | 436 | Commands: |
| 437 | Delete converts tabs to spaces as it moves back. | 437 | Delete converts tabs to spaces as it moves back. |
| @@ -440,16 +440,11 @@ Blank lines separate paragraphs. Semicolons start comments. | |||
| 440 | \\{emacs-lisp-mode-map} | 440 | \\{emacs-lisp-mode-map} |
| 441 | Entry to this mode calls the value of `emacs-lisp-mode-hook' | 441 | Entry to this mode calls the value of `emacs-lisp-mode-hook' |
| 442 | if that value is non-nil." | 442 | if that value is non-nil." |
| 443 | (interactive) | 443 | :group 'lisp |
| 444 | (kill-all-local-variables) | ||
| 445 | (use-local-map emacs-lisp-mode-map) | ||
| 446 | (set-syntax-table emacs-lisp-mode-syntax-table) | ||
| 447 | (setq major-mode 'emacs-lisp-mode) | ||
| 448 | (setq mode-name "Emacs-Lisp") | ||
| 449 | (lisp-mode-variables) | 444 | (lisp-mode-variables) |
| 450 | (setq imenu-case-fold-search nil) | 445 | (setq imenu-case-fold-search nil) |
| 451 | (run-mode-hooks 'emacs-lisp-mode-hook)) | 446 | (add-hook 'completion-at-point-functions |
| 452 | (put 'emacs-lisp-mode 'custom-mode-group 'lisp) | 447 | 'lisp-completion-at-point nil 'local)) |
| 453 | 448 | ||
| 454 | (defvar lisp-mode-map | 449 | (defvar lisp-mode-map |
| 455 | (let ((map (make-sparse-keymap)) | 450 | (let ((map (make-sparse-keymap)) |
| @@ -519,7 +514,7 @@ if that value is non-nil." | |||
| 519 | (set-keymap-parent map lisp-mode-shared-map) | 514 | (set-keymap-parent map lisp-mode-shared-map) |
| 520 | (define-key map "\e\C-x" 'eval-defun) | 515 | (define-key map "\e\C-x" 'eval-defun) |
| 521 | (define-key map "\e\C-q" 'indent-pp-sexp) | 516 | (define-key map "\e\C-q" 'indent-pp-sexp) |
| 522 | (define-key map "\e\t" 'lisp-complete-symbol) | 517 | (define-key map "\e\t" 'completion-at-point) |
| 523 | (define-key map "\n" 'eval-print-last-sexp) | 518 | (define-key map "\n" 'eval-print-last-sexp) |
| 524 | (define-key map [menu-bar lisp-interaction] (cons (purecopy "Lisp-Interaction") menu-map)) | 519 | (define-key map [menu-bar lisp-interaction] (cons (purecopy "Lisp-Interaction") menu-map)) |
| 525 | (define-key menu-map [eval-defun] | 520 | (define-key menu-map [eval-defun] |
| @@ -535,8 +530,8 @@ if that value is non-nil." | |||
| 535 | (define-key menu-map [indent-pp-sexp] | 530 | (define-key menu-map [indent-pp-sexp] |
| 536 | `(menu-item ,(purecopy "Indent or Pretty-Print") indent-pp-sexp | 531 | `(menu-item ,(purecopy "Indent or Pretty-Print") indent-pp-sexp |
| 537 | :help ,(purecopy "Indent each line of the list starting just after point, or prettyprint it"))) | 532 | :help ,(purecopy "Indent each line of the list starting just after point, or prettyprint it"))) |
| 538 | (define-key menu-map [lisp-complete-symbol] | 533 | (define-key menu-map [complete-symbol] |
| 539 | `(menu-item ,(purecopy "Complete Lisp Symbol") lisp-complete-symbol | 534 | `(menu-item ,(purecopy "Complete Lisp Symbol") completion-at-point |
| 540 | :help ,(purecopy "Perform completion on Lisp symbol preceding point"))) | 535 | :help ,(purecopy "Perform completion on Lisp symbol preceding point"))) |
| 541 | map) | 536 | map) |
| 542 | "Keymap for Lisp Interaction mode. | 537 | "Keymap for Lisp Interaction mode. |
diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el index 0edd6556dbf..d364f2cb602 100644 --- a/lisp/emacs-lisp/lisp.el +++ b/lisp/emacs-lisp/lisp.el | |||
| @@ -622,6 +622,15 @@ symbols with function definitions are considered. Otherwise, all | |||
| 622 | symbols with function definitions, values or properties are | 622 | symbols with function definitions, values or properties are |
| 623 | considered." | 623 | considered." |
| 624 | (interactive) | 624 | (interactive) |
| 625 | (let* ((data (lisp-completion-at-point predicate)) | ||
| 626 | (plist (nthcdr 3 data))) | ||
| 627 | (let ((completion-annotate-function (plist-get plist :annotate-function))) | ||
| 628 | (completion-in-region (nth 0 data) (nth 1 data) (nth 2 data) | ||
| 629 | (plist-get plist :predicate))))) | ||
| 630 | |||
| 631 | |||
| 632 | (defun lisp-completion-at-point (&optional predicate) | ||
| 633 | ;; FIXME: the `end' could be after point? | ||
| 625 | (let* ((end (point)) | 634 | (let* ((end (point)) |
| 626 | (beg (with-syntax-table emacs-lisp-mode-syntax-table | 635 | (beg (with-syntax-table emacs-lisp-mode-syntax-table |
| 627 | (save-excursion | 636 | (save-excursion |
| @@ -648,10 +657,11 @@ considered." | |||
| 648 | nil | 657 | nil |
| 649 | ;; Else, we assume that a function name is expected. | 658 | ;; Else, we assume that a function name is expected. |
| 650 | 'fboundp)))))) | 659 | 'fboundp)))))) |
| 651 | (let ((completion-annotate-function | 660 | (list beg end obarray |
| 652 | (unless (eq predicate 'fboundp) | 661 | :predicate predicate |
| 653 | (lambda (str) (if (fboundp (intern-soft str)) " <f>"))))) | 662 | :annotate-function |
| 654 | (completion-in-region beg end obarray predicate)))) | 663 | (unless (eq predicate 'fboundp) |
| 664 | (lambda (str) (if (fboundp (intern-soft str)) " <f>")))))) | ||
| 655 | 665 | ||
| 656 | ;; arch-tag: aa7fa8a4-2e6f-4e9b-9cd9-fef06340e67e | 666 | ;; arch-tag: aa7fa8a4-2e6f-4e9b-9cd9-fef06340e67e |
| 657 | ;;; lisp.el ends here | 667 | ;;; lisp.el ends here |
diff --git a/lisp/ielm.el b/lisp/ielm.el index 10451877e8a..dc845376ae2 100644 --- a/lisp/ielm.el +++ b/lisp/ielm.el | |||
| @@ -172,7 +172,7 @@ This variable is buffer-local.") | |||
| 172 | (define-key map "\C-m" 'ielm-return) | 172 | (define-key map "\C-m" 'ielm-return) |
| 173 | (define-key map "\C-j" 'ielm-send-input) | 173 | (define-key map "\C-j" 'ielm-send-input) |
| 174 | (define-key map "\e\C-x" 'eval-defun) ; for consistency with | 174 | (define-key map "\e\C-x" 'eval-defun) ; for consistency with |
| 175 | (define-key map "\e\t" 'lisp-complete-symbol) ; lisp-interaction-mode | 175 | (define-key map "\e\t" 'completion-at-point) ; lisp-interaction-mode |
| 176 | ;; These bindings are from `lisp-mode-shared-map' -- can you inherit | 176 | ;; These bindings are from `lisp-mode-shared-map' -- can you inherit |
| 177 | ;; from more than one keymap?? | 177 | ;; from more than one keymap?? |
| 178 | (define-key map "\e\C-q" 'indent-sexp) | 178 | (define-key map "\e\C-q" 'indent-sexp) |
| @@ -493,6 +493,8 @@ Customized bindings may be defined in `ielm-map', which currently contains: | |||
| 493 | (set (make-local-variable 'indent-line-function) 'ielm-indent-line) | 493 | (set (make-local-variable 'indent-line-function) 'ielm-indent-line) |
| 494 | (set (make-local-variable 'ielm-working-buffer) (current-buffer)) | 494 | (set (make-local-variable 'ielm-working-buffer) (current-buffer)) |
| 495 | (set (make-local-variable 'fill-paragraph-function) 'lisp-fill-paragraph) | 495 | (set (make-local-variable 'fill-paragraph-function) 'lisp-fill-paragraph) |
| 496 | (add-hook 'completion-at-point-functions | ||
| 497 | 'lisp-completion-at-point nil 'local) | ||
| 496 | 498 | ||
| 497 | ;; Value holders | 499 | ;; Value holders |
| 498 | (set (make-local-variable '*) nil) | 500 | (set (make-local-variable '*) nil) |
diff --git a/lisp/indent.el b/lisp/indent.el index e91fe0b1a29..265b4ba4d30 100644 --- a/lisp/indent.el +++ b/lisp/indent.el | |||
| @@ -49,6 +49,9 @@ Don't rebind TAB unless you really need to.") | |||
| 49 | If t, hitting TAB always just indents the current line. | 49 | If t, hitting TAB always just indents the current line. |
| 50 | If nil, hitting TAB indents the current line if point is at the left margin | 50 | If nil, hitting TAB indents the current line if point is at the left margin |
| 51 | or in the line's indentation, otherwise it inserts a \"real\" TAB character. | 51 | or in the line's indentation, otherwise it inserts a \"real\" TAB character. |
| 52 | If `complete', TAB first tries to indent the current line, and if the line | ||
| 53 | was already indented, then try to complete the thing at point. | ||
| 54 | |||
| 52 | Some programming language modes have their own variable to control this, | 55 | Some programming language modes have their own variable to control this, |
| 53 | e.g., `c-tab-always-indent', and do not respect this variable." | 56 | e.g., `c-tab-always-indent', and do not respect this variable." |
| 54 | :group 'indent | 57 | :group 'indent |
| @@ -103,26 +106,32 @@ The function actually called to indent the line is determined by the value of | |||
| 103 | (eq this-command last-command)))) | 106 | (eq this-command last-command)))) |
| 104 | (insert-tab arg)) | 107 | (insert-tab arg)) |
| 105 | (t | 108 | (t |
| 106 | (let ((end-marker | 109 | (let ((old-tick (buffer-chars-modified-tick)) |
| 107 | (and arg | 110 | (old-point (point)) |
| 108 | (save-excursion | 111 | (old-indent (current-indentation))) |
| 109 | (forward-line 0) (forward-sexp) (point-marker)))) | ||
| 110 | (old-indent | ||
| 111 | (current-indentation))) | ||
| 112 | 112 | ||
| 113 | ;; Indent the line. | 113 | ;; Indent the line. |
| 114 | (funcall indent-line-function) | 114 | (funcall indent-line-function) |
| 115 | 115 | ||
| 116 | ;; If a prefix argument was given, rigidly indent the following | 116 | (cond |
| 117 | ;; sexp to match the change in the current line's indentation. | 117 | ;; If the text was already indented right, try completion. |
| 118 | ;; | 118 | ((and (eq tab-always-indent 'complete) |
| 119 | (when arg | 119 | (eq old-point (point)) |
| 120 | (let ((indentation-change (- (current-indentation) old-indent))) | 120 | (eq old-tick (buffer-chars-modified-tick))) |
| 121 | (unless (zerop indentation-change) | 121 | (completion-at-point)) |
| 122 | (save-excursion | 122 | |
| 123 | (forward-line 1) | 123 | ;; If a prefix argument was given, rigidly indent the following |
| 124 | (when (< (point) end-marker) | 124 | ;; sexp to match the change in the current line's indentation. |
| 125 | (indent-rigidly (point) end-marker indentation-change)))))))))) | 125 | (arg |
| 126 | (let ((end-marker | ||
| 127 | (save-excursion | ||
| 128 | (forward-line 0) (forward-sexp) (point-marker))) | ||
| 129 | (indentation-change (- (current-indentation) old-indent))) | ||
| 130 | (save-excursion | ||
| 131 | (forward-line 1) | ||
| 132 | (when (and (not (zerop indentation-change)) | ||
| 133 | (< (point) end-marker)) | ||
| 134 | (indent-rigidly (point) end-marker indentation-change)))))))))) | ||
| 126 | 135 | ||
| 127 | (defun insert-tab (&optional arg) | 136 | (defun insert-tab (&optional arg) |
| 128 | (let ((count (prefix-numeric-value arg))) | 137 | (let ((count (prefix-numeric-value arg))) |
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 62a0157c352..40c3f4193c0 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -1113,6 +1113,36 @@ Point needs to be somewhere between START and END." | |||
| 1113 | (call-interactively 'minibuffer-complete) | 1113 | (call-interactively 'minibuffer-complete) |
| 1114 | (delete-overlay ol))))) | 1114 | (delete-overlay ol))))) |
| 1115 | 1115 | ||
| 1116 | (defvar completion-at-point-functions nil | ||
| 1117 | "Special hook to find the completion table for the thing at point. | ||
| 1118 | It is called without any argument and should return either nil, | ||
| 1119 | or a function of no argument to perform completion (discouraged), | ||
| 1120 | or a list of the form (START END COLLECTION &rest PROPS) where | ||
| 1121 | START and END delimit the entity to complete and should include point, | ||
| 1122 | COLLECTION is the completion table to use to complete it, and | ||
| 1123 | PROPS is a property list for additional information. | ||
| 1124 | Currently supported properties are: | ||
| 1125 | `:predicate' a predicate that completion candidates need to satisfy. | ||
| 1126 | `:annotation-function' the value to use for `completion-annotate-function'.") | ||
| 1127 | |||
| 1128 | (defun completion-at-point () | ||
| 1129 | "Complete the thing at point according to local mode." | ||
| 1130 | (interactive) | ||
| 1131 | (let ((res (run-hook-with-args-until-success | ||
| 1132 | 'completion-at-point-functions))) | ||
| 1133 | (cond | ||
| 1134 | ((functionp res) (funcall res)) | ||
| 1135 | (res | ||
| 1136 | (let* ((plist (nthcdr 3 res)) | ||
| 1137 | (start (nth 0 res)) | ||
| 1138 | (end (nth 1 res)) | ||
| 1139 | (completion-annotate-function | ||
| 1140 | (or (plist-get plist :annotation-function) | ||
| 1141 | completion-annotate-function))) | ||
| 1142 | (completion-in-region start end (nth 2 res) | ||
| 1143 | (plist-get plist :predicate))))))) | ||
| 1144 | |||
| 1145 | |||
| 1116 | (let ((map minibuffer-local-map)) | 1146 | (let ((map minibuffer-local-map)) |
| 1117 | (define-key map "\C-g" 'abort-recursive-edit) | 1147 | (define-key map "\C-g" 'abort-recursive-edit) |
| 1118 | (define-key map "\r" 'exit-minibuffer) | 1148 | (define-key map "\r" 'exit-minibuffer) |
diff --git a/lisp/progmodes/sym-comp.el b/lisp/obsolete/sym-comp.el index a0f572266bd..722807b6273 100644 --- a/lisp/progmodes/sym-comp.el +++ b/lisp/obsolete/sym-comp.el | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | ;; Author: Dave Love <fx@gnu.org> | 5 | ;; Author: Dave Love <fx@gnu.org> |
| 6 | ;; Keywords: extensions | 6 | ;; Keywords: extensions |
| 7 | ;; URL: http://www.loveshack.ukfsn.org/emacs | 7 | ;; URL: http://www.loveshack.ukfsn.org/emacs |
| 8 | ;; Obsolete-since: 23.2 | ||
| 8 | 9 | ||
| 9 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 10 | 11 | ||
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index eff599c77a5..c401cdfbf54 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -268,7 +268,7 @@ Used for syntactic keywords. N is the match number (1, 2 or 3)." | |||
| 268 | (define-key map "\C-c\C-z" 'python-switch-to-python) | 268 | (define-key map "\C-c\C-z" 'python-switch-to-python) |
| 269 | (define-key map "\C-c\C-m" 'python-load-file) | 269 | (define-key map "\C-c\C-m" 'python-load-file) |
| 270 | (define-key map "\C-c\C-l" 'python-load-file) ; a la cmuscheme | 270 | (define-key map "\C-c\C-l" 'python-load-file) ; a la cmuscheme |
| 271 | (substitute-key-definition 'complete-symbol 'symbol-complete | 271 | (substitute-key-definition 'complete-symbol 'completion-at-point |
| 272 | map global-map) | 272 | map global-map) |
| 273 | (define-key map "\C-c\C-i" 'python-find-imports) | 273 | (define-key map "\C-c\C-i" 'python-find-imports) |
| 274 | (define-key map "\C-c\C-t" 'python-expand-template) | 274 | (define-key map "\C-c\C-t" 'python-expand-template) |
| @@ -319,7 +319,7 @@ Used for syntactic keywords. N is the match number (1, 2 or 3)." | |||
| 319 | "-" | 319 | "-" |
| 320 | ["Help on symbol" python-describe-symbol | 320 | ["Help on symbol" python-describe-symbol |
| 321 | :help "Use pydoc on symbol at point"] | 321 | :help "Use pydoc on symbol at point"] |
| 322 | ["Complete symbol" symbol-complete | 322 | ["Complete symbol" completion-at-point |
| 323 | :help "Complete (qualified) symbol before point"] | 323 | :help "Complete (qualified) symbol before point"] |
| 324 | ["Find function" python-find-function | 324 | ["Find function" python-find-function |
| 325 | :help "Try to find source definition of function at point"] | 325 | :help "Try to find source definition of function at point"] |
| @@ -2159,8 +2159,7 @@ Uses `python-imports' to load modules against which to complete." | |||
| 2159 | (delete-dups completions) | 2159 | (delete-dups completions) |
| 2160 | #'string<)))) | 2160 | #'string<)))) |
| 2161 | 2161 | ||
| 2162 | (defun python-partial-symbol () | 2162 | (defun python-completion-at-point () |
| 2163 | "Return the partial symbol before point (for completion)." | ||
| 2164 | (let ((end (point)) | 2163 | (let ((end (point)) |
| 2165 | (start (save-excursion | 2164 | (start (save-excursion |
| 2166 | (and (re-search-backward | 2165 | (and (re-search-backward |
| @@ -2168,7 +2167,9 @@ Uses `python-imports' to load modules against which to complete." | |||
| 2168 | (group (1+ (regexp "[[:alnum:]._]"))) point) | 2167 | (group (1+ (regexp "[[:alnum:]._]"))) point) |
| 2169 | nil t) | 2168 | nil t) |
| 2170 | (match-beginning 1))))) | 2169 | (match-beginning 1))))) |
| 2171 | (if start (buffer-substring-no-properties start end)))) | 2170 | (when start |
| 2171 | (list start end | ||
| 2172 | (completion-table-dynamic 'python-symbol-completions))))) | ||
| 2172 | 2173 | ||
| 2173 | ;;;; FFAP support | 2174 | ;;;; FFAP support |
| 2174 | 2175 | ||
| @@ -2471,10 +2472,8 @@ with skeleton expansions for compound statement templates. | |||
| 2471 | (add-hook 'eldoc-mode-hook | 2472 | (add-hook 'eldoc-mode-hook |
| 2472 | (lambda () (run-python nil t)) ; need it running | 2473 | (lambda () (run-python nil t)) ; need it running |
| 2473 | nil t) | 2474 | nil t) |
| 2474 | (set (make-local-variable 'symbol-completion-symbol-function) | 2475 | (add-hook 'completion-at-point-functions |
| 2475 | 'python-partial-symbol) | 2476 | 'python-completion-at-point nil 'local) |
| 2476 | (set (make-local-variable 'symbol-completion-completions-function) | ||
| 2477 | 'python-symbol-completions) | ||
| 2478 | ;; Fixme: should be in hideshow. This seems to be of limited use | 2477 | ;; Fixme: should be in hideshow. This seems to be of limited use |
| 2479 | ;; since it isn't (can't be) indentation-based. Also hide-level | 2478 | ;; since it isn't (can't be) indentation-based. Also hide-level |
| 2480 | ;; doesn't seem to work properly. | 2479 | ;; doesn't seem to work properly. |
| @@ -2488,12 +2487,6 @@ with skeleton expansions for compound statement templates. | |||
| 2488 | '((< '(backward-delete-char-untabify (min python-indent | 2487 | '((< '(backward-delete-char-untabify (min python-indent |
| 2489 | (current-column)))) | 2488 | (current-column)))) |
| 2490 | (^ '(- (1+ (current-indentation)))))) | 2489 | (^ '(- (1+ (current-indentation)))))) |
| 2491 | ;; Let's not mess with hippie-expand. Symbol-completion should rather be | ||
| 2492 | ;; bound to another key, since it has different performance requirements. | ||
| 2493 | ;; (if (featurep 'hippie-exp) | ||
| 2494 | ;; (set (make-local-variable 'hippie-expand-try-functions-list) | ||
| 2495 | ;; (cons 'symbol-completion-try-complete | ||
| 2496 | ;; hippie-expand-try-functions-list))) | ||
| 2497 | ;; Python defines TABs as being 8-char wide. | 2490 | ;; Python defines TABs as being 8-char wide. |
| 2498 | (set (make-local-variable 'tab-width) 8) | 2491 | (set (make-local-variable 'tab-width) 8) |
| 2499 | (unless font-lock-mode (font-lock-mode 1)) | 2492 | (unless font-lock-mode (font-lock-mode 1)) |