Gnus development mailing list
 help / color / mirror / Atom feed
* [PATCH] ecomplete.el: Use a local keymap to handle bindings
@ 2011-09-22 13:37 Kan-Ru Chen
  2011-09-26 15:14 ` Julien Danjou
  2011-09-26 19:03 ` Lars Magne Ingebrigtsen
  0 siblings, 2 replies; 8+ messages in thread
From: Kan-Ru Chen @ 2011-09-22 13:37 UTC (permalink / raw)
  To: ding; +Cc: Lars Magne Ingebrigtsen, Julien Danjou, Kan-Ru Chen

---
 lisp/ChangeLog    |    5 +++++
 lisp/ecomplete.el |   27 ++++++++++++++++++---------
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1984ead..c89cb59 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2011-09-22  Kan-Ru Chen  <kanru@kanru.info>
+
+	* ecomplete.el (ecomplete-display-matches): Use a local keymap to
+	handle bindings.
+
 2011-09-21  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
 	* message.el (message-indent-citation): Really make sure there's a
diff --git a/lisp/ecomplete.el b/lisp/ecomplete.el
index 6a47b11..08b7323 100644
--- a/lisp/ecomplete.el
+++ b/lisp/ecomplete.el
@@ -123,15 +123,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
-- 
1.7.6.3




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ecomplete.el: Use a local keymap to handle bindings
  2011-09-22 13:37 [PATCH] ecomplete.el: Use a local keymap to handle bindings Kan-Ru Chen
@ 2011-09-26 15:14 ` Julien Danjou
  2011-09-26 17:59   ` Kan-Ru Chen
  2011-09-26 19:03 ` Lars Magne Ingebrigtsen
  1 sibling, 1 reply; 8+ messages in thread
From: Julien Danjou @ 2011-09-26 15:14 UTC (permalink / raw)
  To: Kan-Ru Chen; +Cc: ding, Lars Magne Ingebrigtsen

[-- Attachment #1: Type: text/plain, Size: 126 bytes --]

On Thu, Sep 22 2011, Kan-Ru Chen wrote:

Does this one works on XEmacs and is mergeable as it is? :)

-- 
Julien Danjou

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ecomplete.el: Use a local keymap to handle bindings
  2011-09-26 15:14 ` Julien Danjou
@ 2011-09-26 17:59   ` Kan-Ru Chen
  0 siblings, 0 replies; 8+ messages in thread
From: Kan-Ru Chen @ 2011-09-26 17:59 UTC (permalink / raw)
  To: ding

Julien Danjou <julien@danjou.info> writes:

> On Thu, Sep 22 2011, Kan-Ru Chen wrote:
>
> Does this one works on XEmacs and is mergeable as it is? :)

Yes! I've tested it on XEmacs 21.4.22 :)

-- 
Kanru



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ecomplete.el: Use a local keymap to handle bindings
  2011-09-22 13:37 [PATCH] ecomplete.el: Use a local keymap to handle bindings Kan-Ru Chen
  2011-09-26 15:14 ` Julien Danjou
@ 2011-09-26 19:03 ` Lars Magne Ingebrigtsen
  2011-09-26 21:00   ` Lars Magne Ingebrigtsen
  1 sibling, 1 reply; 8+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-09-26 19:03 UTC (permalink / raw)
  To: Kan-Ru Chen; +Cc: ding, Julien Danjou

Kan-Ru Chen <kanru@kanru.info> writes:

> +	* ecomplete.el (ecomplete-display-matches): Use a local keymap to
> +	handle bindings.

Thanks; applied.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ecomplete.el: Use a local keymap to handle bindings
  2011-09-26 19:03 ` Lars Magne Ingebrigtsen
@ 2011-09-26 21:00   ` Lars Magne Ingebrigtsen
  2011-09-27  5:08     ` Kan-Ru Chen
  0 siblings, 1 reply; 8+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-09-26 21:00 UTC (permalink / raw)
  To: Kan-Ru Chen; +Cc: ding

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> Kan-Ru Chen <kanru@kanru.info> writes:
>
>> +	* ecomplete.el (ecomplete-display-matches): Use a local keymap to
>> +	handle bindings.
>
> Thanks; applied.

Unfortunately, it didn't work under XEmacs, so I reverted it. 

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ecomplete.el: Use a local keymap to handle bindings
  2011-09-26 21:00   ` Lars Magne Ingebrigtsen
@ 2011-09-27  5:08     ` Kan-Ru Chen
  2011-09-27  5:09       ` [PATCHv3] " Kan-Ru Chen
  2011-10-06 21:33       ` [PATCH] " Lars Magne Ingebrigtsen
  0 siblings, 2 replies; 8+ messages in thread
From: Kan-Ru Chen @ 2011-09-27  5:08 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: ding

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>
>> Kan-Ru Chen <kanru@kanru.info> writes:
>>
>>> +	* ecomplete.el (ecomplete-display-matches): Use a local keymap to
>>> +	handle bindings.
>>
>> Thanks; applied.
>
> Unfortunately, it didn't work under XEmacs, so I reverted it. 

Oh, I'm sorry. Could I have a third chance?

Tested with:

 ./configure EMACS=xemacs21-mule
 make clean fail-on-warning

-- 
Kanru



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCHv3] ecomplete.el: Use a local keymap to handle bindings
  2011-09-27  5:08     ` Kan-Ru Chen
@ 2011-09-27  5:09       ` Kan-Ru Chen
  2011-10-06 21:33       ` [PATCH] " Lars Magne Ingebrigtsen
  1 sibling, 0 replies; 8+ messages in thread
From: Kan-Ru Chen @ 2011-09-27  5:09 UTC (permalink / raw)
  To: ding; +Cc: Lars Magne Ingebrigtsen, Kan-Ru Chen

---
 lisp/ChangeLog    |    5 +++++
 lisp/ecomplete.el |   32 +++++++++++++++++++++++---------
 2 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1984ead..c89cb59 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2011-09-22  Kan-Ru Chen  <kanru@kanru.info>
+
+	* ecomplete.el (ecomplete-display-matches): Use a local keymap to
+	handle bindings.
+
 2011-09-21  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
 	* message.el (message-indent-citation): Really make sure there's a
diff --git a/lisp/ecomplete.el b/lisp/ecomplete.el
index 6a47b11..5d1c46b 100644
--- a/lisp/ecomplete.el
+++ b/lisp/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
-- 
1.7.6.3




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ecomplete.el: Use a local keymap to handle bindings
  2011-09-27  5:08     ` Kan-Ru Chen
  2011-09-27  5:09       ` [PATCHv3] " Kan-Ru Chen
@ 2011-10-06 21:33       ` Lars Magne Ingebrigtsen
  1 sibling, 0 replies; 8+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-10-06 21:33 UTC (permalink / raw)
  To: Kan-Ru Chen; +Cc: ding

Kan-Ru Chen <kanru@kanru.info> writes:

> Oh, I'm sorry. Could I have a third chance?

Thanks; applied.  :-)

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-10-06 21:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-22 13:37 [PATCH] ecomplete.el: Use a local keymap to handle bindings Kan-Ru Chen
2011-09-26 15:14 ` Julien Danjou
2011-09-26 17:59   ` Kan-Ru Chen
2011-09-26 19:03 ` Lars Magne Ingebrigtsen
2011-09-26 21:00   ` Lars Magne Ingebrigtsen
2011-09-27  5:08     ` Kan-Ru Chen
2011-09-27  5:09       ` [PATCHv3] " Kan-Ru Chen
2011-10-06 21:33       ` [PATCH] " Lars Magne Ingebrigtsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).