From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/80001 Path: news.gmane.org!not-for-mail From: Kan-Ru Chen Newsgroups: gmane.emacs.gnus.general Subject: [PATCH] ecomplete.el: Use a local keymap to handle bindings Date: Thu, 22 Sep 2011 21:37:06 +0800 Message-ID: <1316698626-6525-1-git-send-email-kanru@kanru.info> NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1316698688 10154 80.91.229.12 (22 Sep 2011 13:38:08 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 22 Sep 2011 13:38:08 +0000 (UTC) Cc: Lars Magne Ingebrigtsen , Julien Danjou , Kan-Ru Chen To: ding@gnus.org Original-X-From: ding-owner+M28295@lists.math.uh.edu Thu Sep 22 15:38:04 2011 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1R6jTW-0003bS-Jr for ding-account@gmane.org; Thu, 22 Sep 2011 15:38:02 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1R6jTD-0006jV-It; Thu, 22 Sep 2011 08:37:43 -0500 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1R6jTB-0006jI-Ou for ding@lists.math.uh.edu; Thu, 22 Sep 2011 08:37:41 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1R6jSr-0005ts-M7 for ding@lists.math.uh.edu; Thu, 22 Sep 2011 08:37:41 -0500 Original-Received: from mail-gx0-f172.google.com ([209.85.161.172]) by quimby.gnus.org with esmtp (Exim 4.72) (envelope-from ) id 1R6jSq-0007a5-2E; Thu, 22 Sep 2011 15:37:20 +0200 Original-Received: by gxk19 with SMTP id 19so3091106gxk.17 for ; Thu, 22 Sep 2011 06:37:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer; bh=RlP9iCZZ21xQFTa8tnDVx8zB0fzC8WypRmHvPBu+Bhg=; b=Angi5YZb9SCHYT+7N88XIDdlYKAhuRzYsYF3ZtIpE2BLDpJHw+U4x1cKhx1TCTx+LV iE0KZE+27W7ExE2qAVorRXntaTyUBCs74Wi5qrviwzmeojB+0KFBvIJMoop7s+QjJA61 6x3SaTXciPrIkMH/bvp5pYi1Jinxm0w54mPE4= Original-Received: by 10.236.192.231 with SMTP id i67mr13307071yhn.87.1316698633685; Thu, 22 Sep 2011 06:37:13 -0700 (PDT) Original-Received: from isil.kanru.info (118-168-134-126.dynamic.hinet.net. [118.168.134.126]) by mx.google.com with ESMTPS id z23sm11596062yhl.1.2011.09.22.06.37.10 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 22 Sep 2011 06:37:11 -0700 (PDT) Original-Received: from kanru by isil.kanru.info with local (Exim 4.76) (envelope-from ) id 1R6jSd-0001hm-HW; Thu, 22 Sep 2011 21:37:07 +0800 X-Mailer: git-send-email 1.7.6.3 X-Spam-Score: -2.9 (--) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:80001 Archived-At: --- 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 + + * ecomplete.el (ecomplete-display-matches): Use a local keymap to + handle bindings. + 2011-09-21 Lars Magne Ingebrigtsen * 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