"Face for highlighting input separators in multi-input minibuffers."
:version "30.1")
+(defface crm-prompt-indicator-highlight
+ '((t :inherit mode-line-highlight))
+ "Face for minibuffer multi-inputs prompt indicator when mouse is over it.")
+
(defun crm-highlight-separators (beg end &optional _)
"Highlight current minibuffer input separators between BEG and END."
(let* ((bob (minibuffer-prompt-end))
"C-x ," #'crm-change-separator
"C-," #'crm-complete-and-insert-separator)
+(defcustom crm-prompt-indicator "+"
+ "String to show in minibuffer prompt when reading multiple inputs."
+ :type 'string
+ :version "31.1"
+ :group 'minibuffer
+ :risky t)
+
+(defvar crm-prompt-indicator-format
+ '(completing-read-multiple-mode
+ (:propertize crm-prompt-indicator
+ help-echo "Reading multiple inputs"
+ mouse-face crm-prompt-indicator-highlight)))
+
+(put 'crm-prompt-indicator-format 'risky-local-variable t)
+
(define-minor-mode completing-read-multiple-mode
"Minor mode for reading multiple strings in the minibuffer."
:interactive nil
(progn
(add-hook 'completion-setup-hook #'crm-completions-setup 10 t)
(add-hook 'after-change-functions #'crm-highlight-separators nil t)
+ (setq-local minibuffer-extra-prompt-indicators-format
+ (list "" 'crm-prompt-indicator-format
+ minibuffer-extra-prompt-indicators-format))
(crm-highlight-separators (minibuffer-prompt-end) (point-max)))
(remove-hook 'completion-setup-hook #'crm-completions-setup t)
(remove-hook 'after-change-functions #'crm-highlight-separators t)
(mapc #'delete-overlay
(seq-filter (lambda (ov) (overlay-get ov 'crm-separator))
- (overlays-in (minibuffer-prompt-end) (point-max))))))
+ (overlays-in (minibuffer-prompt-end) (point-max)))))
+ (minibuffer-update-prompt-indicators))
(defun crm--table (table s p a)
(let ((beg 0))
(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
- "\\<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)))))))
+(defvar-local minibuffer-prompt-indicators-overlay nil)
+
+(defface minibuffer-action-prompt-indicator-highlight
+ '((t :inherit mode-line-highlight))
+ "Face for minibuffer action prompt indicator when mouse is over it.")
+
+(defface minibuffer-completion-prompt-indicator-highlight
+ '((t :inherit mode-line-highlight))
+ "Face for minibuffer completion prompt indicator when mouse is over it.")
+
+(defcustom minibuffer-action-prompt-indicator "<"
+ "String to show in minibuffer prompt when there's an available action."
+ :type 'string
+ :version "31.1"
+ :group 'minibuffer
+ :risky t)
+
+(defcustom minibuffer-completion-prompt-indicator ">"
+ "String to show in minibuffer prompt when completion is available."
+ :type 'string
+ :version "31.1"
+ :group 'minibuffer
+ :risky t)
+
+(defvar minibuffer-action-prompt-indicator-format
+ '(:eval
+ (when-let ((desc (cdr (minibuffer-action))))
+ (propertize
+ minibuffer-action-prompt-indicator
+ 'help-echo (concat "\\<minibuffer-local-map>\\[minibuffer-apply]: " desc)
+ 'mouse-face 'minibuffer-action-prompt-indicator-highlight))))
+
+(defvar minibuffer-extra-prompt-indicators-format nil)
+
+(defvar minibuffer-completion-prompt-indicator-format
+ '(minibuffer-completion-table
+ (:propertize minibuffer-completion-prompt-indicator
+ help-echo "Completion available"
+ mouse-face minibuffer-completion-prompt-indicator-highlight)))
+
+(dolist (sym '(minibuffer-action-prompt-indicator-format
+ minibuffer-extra-prompt-indicators-format
+ minibuffer-completion-prompt-indicator-format))
+ (put sym 'risky-local-variable t))
+
+(defvar minibuffer-prompt-indicators-format
+ '(""
+ minibuffer-action-prompt-indicator-format
+ minibuffer-extra-prompt-indicators-format
+ minibuffer-completion-prompt-indicator-format)
+ "Mode line construct used for formatting minibuffer prompt indicators.")
+
+(defun minibuffer-update-prompt-indicators ()
+ (unless (overlayp minibuffer-prompt-indicators-overlay)
+ (setq-local minibuffer-prompt-indicators-overlay
+ (make-overlay (point-min) (point-min))))
+ (let ((ind (format-mode-line minibuffer-prompt-indicators-format 'minibuffer-prompt)))
+ (unless (or (string-empty-p ind) (string-suffix-p " " ind))
+ (setq ind (concat ind " ")))
+ (overlay-put minibuffer-prompt-indicators-overlay 'before-string ind)))
(add-hook 'minibuffer-setup-hook #'minibuffer-record-command)
-(add-hook 'minibuffer-setup-hook #'minibuffer-update-prompt-indications 95)
+(add-hook 'minibuffer-setup-hook #'minibuffer-update-prompt-indicators 95)
(defun minibuffer-action ()
"Return the minibuffer action function for the current minibuffer."
(or (and (symbolp action-fn)
(cdr (minibuffer--get-action action-fn)))
"custom action")))
- (minibuffer-update-prompt-indications))
+ (minibuffer-update-prompt-indicators))
;;; Old-style completion, used in Emacs-21 and Emacs-22.