From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Thierry Volpiatto <thierry.volpiatto@gmail.com>
Cc: 10053@debbugs.gnu.org
Subject: bug#10053: Wrong use of minibuffer-completion-table in tmm-add-prompt
Date: Tue, 15 Nov 2011 21:26:17 -0500 [thread overview]
Message-ID: <jwvty64hl20.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87fwhp2hko.fsf@gmail.com> (Thierry Volpiatto's message of "Tue, 15 Nov 2011 22:37:11 +0100")
> 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).
next prev parent reply other threads:[~2011-11-16 2:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-15 10:41 bug#10053: Wrong use of minibuffer-completion-table in tmm-add-prompt Thierry Volpiatto
2011-11-15 20:27 ` Stefan Monnier
2011-11-15 21:37 ` Thierry Volpiatto
2011-11-16 2:26 ` Stefan Monnier [this message]
2011-11-16 8:27 ` Thierry Volpiatto
2011-11-16 13:32 ` Stefan Monnier
2011-11-16 16:36 ` Thierry Volpiatto
2011-11-16 18:50 ` Stefan Monnier
2011-11-16 21:05 ` Thierry Volpiatto
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvty64hl20.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=10053@debbugs.gnu.org \
--cc=thierry.volpiatto@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.