From: Ken Manheimer Date: Tue, 9 Feb 2016 11:02:26 +0000 (-0500) Subject: Rough stab at using tabulated-list-mode for minibuffer-completion-help X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/378b866d860092bef7c75153bd6150612131a817 Rough stab at using tabulated-list-mode for minibuffer-completion-help A few big problems with what's implemented here: - looks like tabulated-list-mode is incongruous with temp display operation. - using flet is no good - it's deprecated - but cl-flet lexical scoping doesn't have needed effect. --- diff --git a/multishell.el b/multishell.el index 8d19a0510..8e1902991 100644 --- a/multishell.el +++ b/multishell.el @@ -603,6 +603,36 @@ completions." (append multishell-history active-names) multishell-history))) +(defvar multishell-local-must-match-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map minibuffer-local-must-match-map) + (define-key map (kbd "?") 'multishell-minibuffer-completion-help) + (define-key map (kbd " ") 'multishell-minibuffer-complete-word) + (define-key map [tab] 'multishell-read-minibuffer-complete) + map)) + +(defun multishell-minibuffer-completion-help (&optional start end) + "Multishell version of `minibuffer-completion-help'." + (interactive) + ;; Call all-completions on minibuffer-completion-table and + ;; minibuffer-completion-predicate + ;; Display using (with-output-to-temp-buffer "*Completions*" + ;; ... ) + (minibuffer-completion-help start end)) +(defun multishell-minibuffer-complete-word () + "Multishell version of `minibuffer-completion-help'." + (interactive) + (minibuffer-complete-word)) + +(defun multishell-display-completion-list (completions) + (let* ((completions-extracted + (mapcar #'(lambda (text) + (set-text-properties 0 (length text) nil text) + text) + completions)) + (multishell-history completions-extracted)) + (multishell-list-mode))) + (defun multishell-read-unbracketed-entry (prompt &optional initial no-record) "PROMPT for shell buffer name, sans asterisks. @@ -616,17 +646,21 @@ Input and completion can include associated path, if any. Return what's provided, if anything, else nil." (let* ((was-multishell-history multishell-history) (candidates (multishell-all-entries 'active-duplicated)) - (got (completing-read prompt - ;; COLLECTION: - (reverse candidates) - ;; PREDICATE: - nil - ;; REQUIRE-MATCH: - 'confirm - ;; INITIAL-INPUT - initial - ;; HIST: - 'multishell-history))) +;; (minibuffer-local-must-match-map multishell-local-must-match-map) + (got (flet ((display-completion-list + (completions) + (multishell-display-completion-list completions))) + (completing-read prompt + ;; COLLECTION: + (reverse candidates) + ;; PREDICATE: + nil + ;; REQUIRE-MATCH: + 'confirm + ;; INITIAL-INPUT + initial + ;; HIST: + 'multishell-history)))) (when no-record (setq multishell-history was-multishell-history)) (if (not (string= got ""))