Commit 5d1ac394 authored by Chong Yidong's avatar Chong Yidong
Browse files

Adapt nXML mode to Emacs 24 completion scheme.

* lisp/nxml/nxml-mode.el (nxml-mode-map): Do not bind C-RET.
(nxml-completion-at-point-function): New function.
(nxml-mode): Use it.
(nxml-bind-meta-tab-to-complete-flag): Default to t.

Fixes: debbugs:6776
parent 292112ed
...@@ -771,6 +771,11 @@ See MH-E-NEWS for details. ...@@ -771,6 +771,11 @@ See MH-E-NEWS for details.
--- ---
** mpc.el: Can use pseudo tags of the form tag1|tag2 as a union of two tags. ** mpc.el: Can use pseudo tags of the form tag1|tag2 as a union of two tags.
** nXML mode no longer binds C-RET to `nxml-complete'.
Completion is now performed via `completion-at-point', bound to M-TAB.
If `nxml-bind-meta-tab-to-complete-flag' is non-nil (the default),
this performs tag completion.
--- ---
** Prolog mode has been completely revamped, with lots of additional ** Prolog mode has been completely revamped, with lots of additional
functionality such as more intelligent indentation, electricity, support for functionality such as more intelligent indentation, electricity, support for
......
2012-03-12 Chong Yidong <cyd@gnu.org> 2012-03-12 Chong Yidong <cyd@gnu.org>
* nxml/nxml-mode.el (nxml-mode-map): Do not bind C-RET (Bug#6776).
(nxml-completion-at-point-function): New function.
(nxml-mode): Use it.
(nxml-bind-meta-tab-to-complete-flag): Default to t.
* emacs-lisp/package.el (package-unpack, package-unpack-single): * emacs-lisp/package.el (package-unpack, package-unpack-single):
Load generated autoloads file before byte compiling (Bug#10970). Load generated autoloads file before byte compiling (Bug#10970).
(package--make-autoloads-and-compile): New helper fun. (package--make-autoloads-and-compile): New helper fun.
......
...@@ -86,18 +86,9 @@ as the first attribute on the previous line." ...@@ -86,18 +86,9 @@ as the first attribute on the previous line."
:group 'nxml :group 'nxml
:type 'integer) :type 'integer)
(defcustom nxml-bind-meta-tab-to-complete-flag (not window-system) (defcustom nxml-bind-meta-tab-to-complete-flag t
"Non-nil means bind M-TAB in `nxml-mode-map' to `nxml-complete'. "Non-nil means to use nXML completion in \\[completion-at-point]."
C-return will be bound to `nxml-complete' in any case.
M-TAB gets swallowed by many window systems/managers, and
`documentation' will show M-TAB rather than C-return as the
binding for `nxml-complete' when both are bound. So it's better
to bind M-TAB only when it will work."
:group 'nxml :group 'nxml
:set (lambda (sym flag)
(set-default sym flag)
(when (and (boundp 'nxml-mode-map) nxml-mode-map)
(define-key nxml-mode-map "\M-\t" (and flag 'nxml-complete))))
:type 'boolean) :type 'boolean)
(defcustom nxml-prefer-utf-16-to-utf-8-flag nil (defcustom nxml-prefer-utf-16-to-utf-8-flag nil
...@@ -418,9 +409,7 @@ reference.") ...@@ -418,9 +409,7 @@ reference.")
(define-key map "\C-c\C-o" nxml-outline-prefix-map) (define-key map "\C-c\C-o" nxml-outline-prefix-map)
(define-key map [S-mouse-2] 'nxml-mouse-hide-direct-text-content) (define-key map [S-mouse-2] 'nxml-mouse-hide-direct-text-content)
(define-key map "/" 'nxml-electric-slash) (define-key map "/" 'nxml-electric-slash)
(define-key map [C-return] 'nxml-complete) (define-key map "\M-\t" 'completion-at-point)
(when nxml-bind-meta-tab-to-complete-flag
(define-key map "\M-\t" 'nxml-complete))
map) map)
"Keymap for nxml-mode.") "Keymap for nxml-mode.")
...@@ -479,7 +468,7 @@ the start-tag, point, and end-tag are all left on separate lines. ...@@ -479,7 +468,7 @@ the start-tag, point, and end-tag are all left on separate lines.
If `nxml-slash-auto-complete-flag' is non-nil, then inserting a `</' If `nxml-slash-auto-complete-flag' is non-nil, then inserting a `</'
automatically inserts the rest of the end-tag. automatically inserts the rest of the end-tag.
\\[nxml-complete] performs completion on the symbol preceding point. \\[completion-at-point] performs completion on the symbol preceding point.
\\[nxml-dynamic-markup-word] uses the contents of the current buffer \\[nxml-dynamic-markup-word] uses the contents of the current buffer
to choose a tag to put around the word preceding point. to choose a tag to put around the word preceding point.
...@@ -555,6 +544,8 @@ Many aspects this mode can be customized using ...@@ -555,6 +544,8 @@ Many aspects this mode can be customized using
(nxml-clear-inside (point-min) (point-max)) (nxml-clear-inside (point-min) (point-max))
(nxml-with-invisible-motion (nxml-with-invisible-motion
(nxml-scan-prolog))))) (nxml-scan-prolog)))))
(add-hook 'completion-at-point-functions
#'nxml-completion-at-point-function nil t)
(add-hook 'after-change-functions 'nxml-after-change nil t) (add-hook 'after-change-functions 'nxml-after-change nil t)
(add-hook 'change-major-mode-hook 'nxml-cleanup nil t) (add-hook 'change-major-mode-hook 'nxml-cleanup nil t)
...@@ -1654,6 +1645,11 @@ depend on `nxml-completion-hook'." ...@@ -1654,6 +1645,11 @@ depend on `nxml-completion-hook'."
(ding) (ding)
(message "Cannot complete in this context"))) (message "Cannot complete in this context")))
(defun nxml-completion-at-point-function ()
"Call `nxml-complete' to perform completion at point."
(when nxml-bind-meta-tab-to-complete-flag
#'nxml-complete))
;;; Movement ;;; Movement
(defun nxml-forward-balanced-item (&optional arg) (defun nxml-forward-balanced-item (&optional arg)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment