From 5988bd2708b4db612dbfcc74920e3c1c1029a34a Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 15 Aug 2002 00:12:30 +0000 Subject: [PATCH] (imenu-always-use-completion-buffer-p): Make obsolete. (imenu-use-popup-menu, imenu-eager-completion-buffer): New vars. (imenu-space-replacement): Allow nil value. (imenu--completion-buffer): Use new vars and simplify. Fix handling of minibuffer-setup-hook. Use minibuffer-completion-help instead of rolling our own. (imenu-choose-buffer-index): Use the new var. --- lisp/ChangeLog | 20 +++++++++++-- lisp/imenu.el | 78 ++++++++++++++++++++++++-------------------------- 2 files changed, 55 insertions(+), 43 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cb91fb16499..2f914c2f1a7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,18 @@ +2002-08-14 Stefan Monnier + + * emacs-lisp/find-func.el (find-function-search-for-symbol): + Use find-file-hook instead of find-file-hooks. + + * imenu.el (imenu-always-use-completion-buffer-p): Make obsolete. + (imenu-use-popup-menu, imenu-eager-completion-buffer): New vars. + (imenu-space-replacement): Allow nil value. + (imenu--completion-buffer): Use new vars and simplify. + Fix handling of minibuffer-setup-hook. + Use minibuffer-completion-help instead of rolling our own. + (imenu-choose-buffer-index): Use the new var. + + * startup.el (command-line): Load custom-file if not done yet. + 2002-08-15 David Kastrup * net/ange-ftp.el (ange-ftp-wipe-file-entries): Fix type mismatch; @@ -5,9 +20,8 @@ 2002-08-14 Kenichi Handa - * select.el (xselect-convert-to-string): If TYPE is non-nil, - encode the selection data string. Always return cons of type and - string. + * select.el (xselect-convert-to-string): If TYPE is non-nil, encode + the selection data string. Always return cons of type and string. (selection-converter-alist): Add (UTF8_STRING . xselect-convert-to-string). diff --git a/lisp/imenu.el b/lisp/imenu.el index 30f93836740..3b06925c334 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el @@ -104,17 +104,26 @@ This variable is buffer-local." :type 'integer :group 'imenu) -(defcustom imenu-always-use-completion-buffer-p nil - "*Set this to non-nil for displaying the index in a completion buffer. - -`never' means never automatically display a listing of any kind. -A value of nil (the default) means display the index as a mouse menu -if the mouse was used to invoke `imenu'. -Another non-nil value means always display the index in a completion buffer." - :type '(choice (const :tag "On Mouse" nil) - (const :tag "Never" never) - (other :tag "Always" t)) - :group 'imenu) +(defvar imenu-always-use-completion-buffer-p nil) +(make-obsolete-variable 'imenu-always-use-completion-buffer-p + 'imenu-use-popup-menu "21.4") + +(defcustom imenu-use-popup-menu + (if imenu-always-use-completion-buffer-p + (not (eq imenu-always-use-completion-buffer-p 'never)) + 'on-mouse) + "Use a popup menu rather than a minibuffer prompt. +If nil, always use a minibuffer prompt. +If t, always use a popup menu, +If `on-mouse' use a popup menu when `imenu' was invoked with the mouse." + :type '(choice (const :tag "On Mouse" on-mouse) + (const :tag "Never" nil) + (other :tag "Always" t))) + +(defcustom imenu-eager-completion-buffer + (not (eq imenu-always-use-completion-buffer-p 'never)) + "If non-nil, eagerly popup the completion buffer." + :type 'boolean) (defcustom imenu-after-jump-hook nil "*Hooks called after jumping to a place in the buffer. @@ -164,7 +173,7 @@ which case you might as well set this to nil." "*The replacement string for spaces in index names. Used when presenting the index in a completion buffer to make the names work as tokens." - :type 'string + :type '(choice string (const nil)) :group 'imenu) (defcustom imenu-level-separator ":" @@ -857,37 +866,26 @@ Returns t for rescan and otherwise a position number." (let ((name (thing-at-point 'symbol)) choice (prepared-index-alist - (mapcar - (lambda (item) - (cons (subst-char-in-string ?\ (aref imenu-space-replacement 0) - (car item)) - (cdr item))) - index-alist))) + (if (not imenu-space-replacement) index-alist + (mapcar + (lambda (item) + (cons (subst-char-in-string ?\ (aref imenu-space-replacement 0) + (car item)) + (cdr item))) + index-alist)))) (when (stringp name) (setq name (or (imenu-find-default name prepared-index-alist) name))) (cond (prompt) ((and name (imenu--in-alist name prepared-index-alist)) (setq prompt (format "Index item (default %s): " name))) (t (setq prompt "Index item: "))) - (if (eq imenu-always-use-completion-buffer-p 'never) - (setq name (completing-read prompt - prepared-index-alist - nil t nil 'imenu--history-list name)) - (save-window-excursion - ;; Display the completion buffer - (with-output-to-temp-buffer "*Completions*" - (display-completion-list - (all-completions "" prepared-index-alist ))) - (let ((minibuffer-setup-hook - (function - (lambda () - (let ((buffer (current-buffer))) - (with-current-buffer "*Completions*" - (setq completion-reference-buffer buffer))))))) - ;; Make a completion question - (setq name (completing-read prompt - prepared-index-alist - nil t nil 'imenu--history-list name))))) + (let ((minibuffer-setup-hook minibuffer-setup-hook)) + ;; Display the completion buffer. + (if (not imenu-eager-completion-buffer) + (add-hook 'minibuffer-setup-hook 'minibuffer-completion-help)) + (setq name (completing-read prompt + prepared-index-alist + nil t nil 'imenu--history-list name))) (cond ((not (stringp name)) nil) ((string= name (car imenu--rescan-item)) t) (t @@ -923,7 +921,7 @@ select from ALIST. With no index alist ALIST, it calls `imenu--make-index-alist' to create the index alist. -If `imenu-always-use-completion-buffer-p' is non-nil, then the +If `imenu-use-popup-menu' is non-nil, then the completion buffer is always used, no matter if the mouse was used or not. @@ -941,8 +939,8 @@ The returned value is of the form (INDEX-NAME . INDEX-POSITION)." (while (eq result t) (setq index-alist (if alist alist (imenu--make-index-alist))) (setq result - (if (and mouse-triggered - (not imenu-always-use-completion-buffer-p)) + (if (and imenu-use-popup-menu + (or (eq imenu-use-popup-menu t) mouse-triggered)) (imenu--mouse-menu index-alist last-nonmenu-event) (imenu--completion-buffer index-alist prompt))) (and (eq result t) -- 2.39.5