I want my minibuffer prompt to be in bigger font, so I've added this to my .emacs:

(defun my-minibuffer-setup ()
  (set (make-local-variable 'face-remapping-alist)
       '((default :height 1.5))))

(add-hook 'minibuffer-setup-hook 'my-minibuffer-setup)

It looks like this:

However, when I press C-s, the font size is the default 1 for some reason.

How to make the i-search prompt also in larger size?

up vote 8 down vote accepted

This is because isearch does not use the minibuffer to read input from the user, rather it simply updates the echo area with the characters entered during isearch. Please note that the minibuffer and the echo area are different. From the GNU Emacs Manual

The echo area is used for displaying error messages (see Errors), for messages made with the message primitive, and for echoing keystrokes. It is not the same as the minibuffer, despite the fact that the minibuffer appears (when active) in the same place on the screen as the echo area.

As such minibuffer-setup-hook is never executed during isearch since the minibuffer is never setup.

In this specific case, isearch-mode sets overriding-terminal-map to isearch-mode-map which binds all characters from in ascii range 32 to 255 to isearch-printing-char which updates the isearch prompt by echoing the new prompt.

If you follow the calls, you will find that isearch-update is used to update the prompt which isearch-message-function (if defined) to update the prompt otherwise it falls back to isearch-message. So a solution might be to set isearch-message-function to a custom function which calls message with a propertized string with face property set to custom face with desired height.

Following implements the idea mentioned in the previous paragraph, most of it is copied directly from the function isearch-message except for the last part where the string passed to message is propertized to have a larger height.

(defun my-isearch-message (&optional c-q-hack ellipsis)
  ;; Generate and print the message string.
  (let ((cursor-in-echo-area ellipsis)
        (m isearch-message)
        (fail-pos (isearch-fail-pos t)))
    ;; Highlight failed part
    (when fail-pos
      (setq m (copy-sequence m))
      (add-text-properties fail-pos (length m) '(face isearch-fail) m)
      ;; Highlight failed trailing whitespace
      (when (string-match " +$" m)
        (add-text-properties (match-beginning 0) (match-end 0)
                             '(face trailing-whitespace) m)))
    (setq m (concat
             (isearch-message-prefix ellipsis isearch-nonincremental)
             m
             (isearch-message-suffix c-q-hack)))
    (if c-q-hack m (let ((message-log-max nil)) (message "%s" (propertize m 'face  '(:inherit default :height 1.5)))))))

(setq isearch-message-function #'my-isearch-message)
  • I see. Thank you very much! – katspaugh Sep 28 '15 at 13:47
  • 1
    @katspaugh I have added an example of setting isearch-message-function – Iqbal Ansari Sep 29 '15 at 4:01

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.