summaryrefslogtreecommitdiff
path: root/lisp/gnus/ecomplete.el
diff options
context:
space:
mode:
authorGnus developers <ding@gnus.org>2011-10-06 22:11:15 +0000
committerKatsumi Yamaoka <yamaoka@jpl.org>2011-10-06 22:11:15 +0000
commit465d0300d4ffdaf2d816f79f76716ba3406ac869 (patch)
tree5810cfd93a08bc315391ffb9eda6a12c20fc462f /lisp/gnus/ecomplete.el
parent0181e1939ea39ceaf54e4cfd95858a5fcfb4f0c7 (diff)
downloademacs-465d0300d4ffdaf2d816f79f76716ba3406ac869.tar.gz
Merge changes made in Gnus trunk.
gnus.texi (Gnus Utility Functions): Add more references and explanations (bug#9683). ecomplete.el (ecomplete-display-matches): Use a local keymap to handle bindings. gnus-win.el (gnus-configure-windows): Protect against reading ephemeral groups outside of Gnus.
Diffstat (limited to 'lisp/gnus/ecomplete.el')
-rw-r--r--lisp/gnus/ecomplete.el32
1 files changed, 23 insertions, 9 deletions
diff --git a/lisp/gnus/ecomplete.el b/lisp/gnus/ecomplete.el
index 6a47b119f10..5d1c46bc2f6 100644
--- a/lisp/gnus/ecomplete.el
+++ b/lisp/gnus/ecomplete.el
@@ -27,6 +27,11 @@
(eval-when-compile
(require 'cl))
+(eval-when-compile
+ (when (featurep 'xemacs)
+ ;; The `kbd' macro requires that the `read-kbd-macro' macro is available.
+ (require 'edmacro)))
+
(defgroup ecomplete nil
"Electric completion of email addresses and the like."
:group 'mail)
@@ -123,15 +128,24 @@
(message "%s" matches)
nil)
(setq highlight (ecomplete-highlight-match-line matches line))
- (while (not (memq (setq command (read-event highlight)) '(? return)))
- (cond
- ((eq command ?\M-n)
- (setq line (min (1+ line) max-lines)))
- ((eq command ?\M-p)
- (setq line (max (1- line) 0))))
- (setq highlight (ecomplete-highlight-match-line matches line)))
- (when (eq command 'return)
- (nth line (split-string matches "\n")))))))
+ (let ((local-map (make-sparse-keymap))
+ selected)
+ (define-key local-map (kbd "RET")
+ (lambda () (setq selected (nth line (split-string matches "\n")))))
+ (define-key local-map (kbd "M-n")
+ (lambda () (setq line (min (1+ line) max-lines))))
+ (define-key local-map (kbd "M-p")
+ (lambda () (setq line (max (1- line) 0))))
+ (let ((overriding-local-map local-map))
+ (while (and (null selected)
+ (setq command (read-key-sequence highlight))
+ (lookup-key local-map command))
+ (apply (key-binding command) nil)
+ (setq highlight (ecomplete-highlight-match-line matches line))))
+ (if selected
+ (message selected)
+ (message "Abort"))
+ selected)))))
(defun ecomplete-highlight-match-line (matches line)
(with-temp-buffer