summaryrefslogtreecommitdiff
path: root/lisp/indent.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2009-12-07 20:06:26 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2009-12-07 20:06:26 +0000
commit51ef56c47fc0b02b20f44b673f8b60350c03b4e1 (patch)
treef3c898b5885cfc9cdca8681966bd223d3ee19ff7 /lisp/indent.el
parent5e7a90229a1c32ded160a6d27f4ad9f3c66f60c3 (diff)
downloademacs-51ef56c47fc0b02b20f44b673f8b60350c03b4e1.tar.gz
* 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.
Diffstat (limited to 'lisp/indent.el')
-rw-r--r--lisp/indent.el41
1 files changed, 25 insertions, 16 deletions
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.")
If t, hitting TAB always just indents the current line.
If nil, hitting TAB indents the current line if point is at the left margin
or in the line's indentation, otherwise it inserts a \"real\" TAB character.
+If `complete', TAB first tries to indent the current line, and if the line
+was already indented, then try to complete the thing at point.
+
Some programming language modes have their own variable to control this,
e.g., `c-tab-always-indent', and do not respect this variable."
:group 'indent
@@ -103,26 +106,32 @@ The function actually called to indent the line is determined by the value of
(eq this-command last-command))))
(insert-tab arg))
(t
- (let ((end-marker
- (and arg
- (save-excursion
- (forward-line 0) (forward-sexp) (point-marker))))
- (old-indent
- (current-indentation)))
+ (let ((old-tick (buffer-chars-modified-tick))
+ (old-point (point))
+ (old-indent (current-indentation)))
;; Indent the line.
(funcall indent-line-function)
- ;; If a prefix argument was given, rigidly indent the following
- ;; sexp to match the change in the current line's indentation.
- ;;
- (when arg
- (let ((indentation-change (- (current-indentation) old-indent)))
- (unless (zerop indentation-change)
- (save-excursion
- (forward-line 1)
- (when (< (point) end-marker)
- (indent-rigidly (point) end-marker indentation-change))))))))))
+ (cond
+ ;; If the text was already indented right, try completion.
+ ((and (eq tab-always-indent 'complete)
+ (eq old-point (point))
+ (eq old-tick (buffer-chars-modified-tick)))
+ (completion-at-point))
+
+ ;; If a prefix argument was given, rigidly indent the following
+ ;; sexp to match the change in the current line's indentation.
+ (arg
+ (let ((end-marker
+ (save-excursion
+ (forward-line 0) (forward-sexp) (point-marker)))
+ (indentation-change (- (current-indentation) old-indent)))
+ (save-excursion
+ (forward-line 1)
+ (when (and (not (zerop indentation-change))
+ (< (point) end-marker))
+ (indent-rigidly (point) end-marker indentation-change))))))))))
(defun insert-tab (&optional arg)
(let ((count (prefix-numeric-value arg)))