From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#10053: Wrong use of minibuffer-completion-table in tmm-add-prompt Date: Tue, 15 Nov 2011 21:26:17 -0500 Message-ID: References: <8739dpzmz3.fsf@gmail.com> <87fwhp2hko.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1321410451 5878 80.91.229.12 (16 Nov 2011 02:27:31 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 16 Nov 2011 02:27:31 +0000 (UTC) Cc: 10053@debbugs.gnu.org To: Thierry Volpiatto Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 16 03:27:27 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RQVDg-0005jQ-KU for geb-bug-gnu-emacs@m.gmane.org; Wed, 16 Nov 2011 03:27:24 +0100 Original-Received: from localhost ([::1]:41259 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQVDf-0004q6-W2 for geb-bug-gnu-emacs@m.gmane.org; Tue, 15 Nov 2011 21:27:23 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:36322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQVDc-0004pk-TS for bug-gnu-emacs@gnu.org; Tue, 15 Nov 2011 21:27:21 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RQVDb-00045W-Ld for bug-gnu-emacs@gnu.org; Tue, 15 Nov 2011 21:27:20 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:49641) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQVDb-00045S-It for bug-gnu-emacs@gnu.org; Tue, 15 Nov 2011 21:27:19 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1RQVEH-0001db-Kz for bug-gnu-emacs@gnu.org; Tue, 15 Nov 2011 21:28:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 16 Nov 2011 02:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10053 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 10053-submit@debbugs.gnu.org id=B10053.13214104336233 (code B ref 10053); Wed, 16 Nov 2011 02:28:01 +0000 Original-Received: (at 10053) by debbugs.gnu.org; 16 Nov 2011 02:27:13 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RQVDU-0001cS-Nc for submit@debbugs.gnu.org; Tue, 15 Nov 2011 21:27:13 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RQVDS-0001cC-1V for 10053@debbugs.gnu.org; Tue, 15 Nov 2011 21:27:11 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgsFAPAew05MCqs//2dsb2JhbABDp06CI4EGgXIBAQQBViMFCws0EhQYDSSIFbk7ihcEiBSZcIRK X-IronPort-AV: E=Sophos;i="4.69,518,1315195200"; d="scan'208";a="148168347" Original-Received: from 76-10-171-63.dsl.teksavvy.com (HELO pastel.home) ([76.10.171.63]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 15 Nov 2011 21:26:21 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id C9BDD5936A; Tue, 15 Nov 2011 21:26:17 -0500 (EST) In-Reply-To: <87fwhp2hko.fsf@gmail.com> (Thierry Volpiatto's message of "Tue, 15 Nov 2011 22:37:11 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.91 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Tue, 15 Nov 2011 21:28:01 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:53962 Archived-At: > If i use in tmm-add-prompt: > (all-completions "" minibuffer-completion-table) > instead of > (mapcar 'car minibuffer-completion-table) > i have no error, and a completions buffer with a list of buffers. But the error is that tmm-add-prompt should not be run in that case. It should only be run when you use tmm-prompt or tmm-menubar. I see a small error in tmm.el which could explain why tmm-add-prompt lingers on minibuffer-setup-hook longer than desired. I've installed the patch below, please see if it helps. Stefan === modified file 'lisp/tmm.el' --- lisp/tmm.el 2011-01-25 04:08:28 +0000 +++ lisp/tmm.el 2011-11-16 02:19:47 +0000 @@ -37,7 +37,6 @@ ;;; The following will be localized, added only to pacify the compiler. (defvar tmm-short-cuts) (defvar tmm-old-mb-map nil) -(defvar tmm-old-comp-map) (defvar tmm-c-prompt nil) (defvar tmm-km-list) (defvar tmm-next-shortcut-digit) @@ -158,7 +157,7 @@ (let ((gl-str "Menu bar") ;; The menu bar itself is not a menu keymap ; so it doesn't have a name. tmm-km-list out history history-len tmm-table-undef tmm-c-prompt - tmm-old-mb-map tmm-old-comp-map tmm-short-cuts + tmm-old-mb-map tmm-short-cuts chosen-string choice (not-menu (not (keymapp menu)))) (run-hooks 'activate-menubar-hook) @@ -219,23 +218,16 @@ (setq history-len (length history)) (setq history (append history history history history)) (setq tmm-c-prompt (nth (- history-len 1 index-of-default) history)) - (add-hook 'minibuffer-setup-hook 'tmm-add-prompt) - (if default-item - (setq out (car (nth index-of-default tmm-km-list))) - (save-excursion - (unwind-protect (setq out + (if default-item + (car (nth index-of-default tmm-km-list)) + (minibuffer-with-setup-hook #'tmm-add-prompt (completing-read (concat gl-str " (up/down to change, PgUp to menu): ") tmm-km-list nil t nil (cons 'history - (- (* 2 history-len) index-of-default)))) - (remove-hook 'minibuffer-setup-hook 'tmm-add-prompt) - (if (get-buffer "*Completions*") - (with-current-buffer "*Completions*" - (use-local-map tmm-old-comp-map) - (bury-buffer (current-buffer))))))))) + (- (* 2 history-len) index-of-default)))))))) (setq choice (cdr (assoc out tmm-km-list))) (and (null choice) (> (length out) (length tmm-c-prompt)) @@ -270,7 +262,7 @@ choice))))) (defun tmm-add-shortcuts (list) - "Adds shortcuts to cars of elements of the list. + "Add shortcuts to cars of elements of the list. Takes a list of lists with a string as car, returns list with shortcuts added to these cars. Stores a list of all the shortcuts in the free variable `tmm-short-cuts'." @@ -362,7 +354,6 @@ (set-buffer-modified-p nil))) (defun tmm-add-prompt () - (remove-hook 'minibuffer-setup-hook 'tmm-add-prompt) (add-hook 'minibuffer-exit-hook 'tmm-delete-map nil t) (unless tmm-c-prompt (error "No active menu entries")) @@ -387,9 +378,7 @@ (save-selected-window (other-window 1) ; Electric-pop-up-window does ; not work in minibuffer - (Electric-pop-up-window "*Completions*") - (with-current-buffer "*Completions*" - (setq tmm-old-comp-map (tmm-define-keys nil)))) + (Electric-pop-up-window "*Completions*")) (insert tmm-c-prompt)) (defun tmm-delete-map () @@ -424,16 +413,18 @@ (exit-minibuffer))))) (defun tmm-goto-completions () + "Jump to the completions buffer." (interactive) (let ((prompt-end (minibuffer-prompt-end))) (setq tmm-c-prompt (buffer-substring prompt-end (point-max))) + ;; FIXME: Why? (delete-region prompt-end (point-max))) (switch-to-buffer-other-window "*Completions*") (search-forward tmm-c-prompt) (search-backward tmm-c-prompt)) (defun tmm-get-keymap (elt &optional in-x-menu) - "Prepends (DOCSTRING EVENT BINDING) to free variable `tmm-km-list'. + "Prepend (DOCSTRING EVENT BINDING) to free variable `tmm-km-list'. The values are deduced from the argument ELT, that should be an element of keymap, an `x-popup-menu' argument, or an element of `x-popup-menu' argument (when IN-X-MENU is not-nil).