(sort-orders minibuffer-completions-sort-orders)
(cpred minibuffer-completion-predicate)
(ctable minibuffer-completion-table)
- (action (minibuffer-completion-action)))
+ (action (minibuffer-action)))
(when last (setcdr last nil))
(define-key map "\M-<" 'minibuffer-beginning-of-buffer)
(define-key map "\C-x\M-k" 'minibuffer-kill-from-history)
(define-key map "\C-x\M-h" 'minibuffer-alternate-history)
- ;; Put RET last so that it is shown in doc strings in preference to
- ;; C-j, when using the \\[exit-minibuffer] notation.
- (define-key map "\n" 'exit-minibuffer)
+ (define-key map "\C-xj" 'minibuffer-set-action)
+ (define-key map "\n" 'minibuffer-apply)
(define-key map "\r" 'exit-minibuffer))
(defvar-keymap minibuffer-local-completion-map
"C-x C->" #'minibuffer-last-completion
"C-x n" 'minibuffer-narrow-completions-map
"C-x /" #'minibuffer-set-completion-styles
- "C-x j" #'minibuffer-set-completion-action
"C-x ~" #'minibuffer-toggle-exceptional-candidates
"C-x C-a" #'minibuffer-toggle-completions-annotations
"C-x C-." #'minibuffer-auto-completion-mode
- "C-j" #'minibuffer-apply
"C-p" #'minibuffer-previous-line-or-completion
"C-n" #'minibuffer-next-line-or-completion
"C-%" #'minibuffer-query-apply)
(define-obsolete-function-alias 'internal-complete-buffer
'completion-buffer-name-table "30.1")
-(defvar-local minibuffer-completion-action nil)
-
-(defvar-local minibuffer-completion-command nil
- "The command currently reading input from the minibuffer.")
+(defvar-local minibuffer-action nil)
(defun minibuffer-current-input ()
(let* ((beg-end (minibuffer--completion-boundaries))
((symbolp action) (minibuffer--get-action action))
(t (cons symbol action)))))
-(defun minibuffer-completion-action ()
- "Return the completion action function for the current minibuffer."
- (or minibuffer-completion-action
- (and minibuffer-completion-command
- (symbolp minibuffer-completion-command)
- (minibuffer--get-action minibuffer-completion-command))))
+(defvar-local current-minibuffer-command nil
+ "Command that invoked the current minibuffer.")
+
+(defun minibuffer-record-command ()
+ (setq-local current-minibuffer-command this-command))
+
+(defvar-local minibuffer-prompt-indications-overlay nil)
+
+(defun minibuffer-update-prompt-indications ()
+ (let ((cmp minibuffer-completion-table)
+ (act (minibuffer-action)))
+ (if (not (or cmp act))
+ (when (overlayp minibuffer-prompt-indications-overlay)
+ (delete-overlay minibuffer-prompt-indications-overlay)
+ (setq-local minibuffer-prompt-indications-overlay nil))
+ (unless (overlayp minibuffer-prompt-indications-overlay)
+ (setq-local minibuffer-prompt-indications-overlay
+ (make-overlay (point-min) (point-min))))
+ (overlay-put
+ minibuffer-prompt-indications-overlay 'before-string
+ ;; TODO: Make indicators clickable, and indicate strictness.
+ (apply #'propertize
+ (concat
+ (when-let ((desc (cdr (minibuffer-action))))
+ (propertize "<" 'help-echo
+ (concat
+ "mouse-2, \\<minibuffer-local-map>\\[minibuffer-apply]: "
+ desc)))
+ (when minibuffer-completion-table
+ (propertize ">" 'help-echo "Completion available"))
+ " ")
+ (append minibuffer-prompt-properties
+ (list 'front-sticky t 'rear-nonsticky t 'field t)))))))
+
+(add-hook 'minibuffer-setup-hook #'minibuffer-record-command)
+(add-hook 'minibuffer-setup-hook #'minibuffer-update-prompt-indications 95)
+
+(defun minibuffer-action ()
+ "Return the minibuffer action function for the current minibuffer."
+ (or minibuffer-action
+ (when-let* ((cmd current-minibuffer-command)
+ (cmd (car (last (cons cmd (function-alias-p cmd))))))
+ (when (symbolp cmd) (minibuffer--get-action cmd)))))
(defun minibuffer-apply (input &optional prefix)
"Apply ACTION to current minibuffer INPUT prefixed by PREFIX."
(list input prefix))
minibuffer-mode)
(funcall
- (or (car (minibuffer-completion-action))
- (user-error "No applicable action"))
+ (or (car (minibuffer-action)) (user-error "No applicable action"))
(concat prefix input))
(when-let ((buf (get-buffer completions-buffer-name))
(win (get-buffer-window buf 0)))
(message "Done"))))))
(defvar minibuffer-action-history nil
- "History list for `minibuffer-set-completion-action'.")
+ "History list for `minibuffer-set-action'.")
-(defun minibuffer-set-completion-action (action-fn)
- "Set minibuffer completion action of current minibuffer to ACTION-FN."
+(defun minibuffer-set-action (action-fn)
+ "Set minibuffer action function of current minibuffer to ACTION-FN."
(interactive
(let ((enable-recursive-minibuffers t))
(list (completing-read "Action function: " obarray #'fboundp
nil nil 'minibuffer-action-history)))
minibuffer-mode)
(when (stringp action-fn) (setq action-fn (read action-fn)))
- (setq-local minibuffer-completion-action
+ (setq-local minibuffer-action
(cons action-fn
(or (and (symbolp action-fn)
(cdr (minibuffer--get-action action-fn)))
- "custom action"))))
+ "custom action")))
+ (minibuffer-update-prompt-indications))
;;; Old-style completion, used in Emacs-21 and Emacs-22.
(number-to-string md))))
(?{ . ,(if (< 1 (minibuffer-depth)) "<" ""))
(?} . ,(if (< 1 (minibuffer-depth)) ">" "")))))
- (setq-local minibuffer-completion-command
- (car (last (cons this-command
- (function-alias-p this-command)))))
(setq-local minibuffer-completion-table collection)
(setq-local minibuffer-completion-predicate predicate)
;; FIXME: Remove/rename this var, see the next one.