Emacs: Write to Minibuffer

11 hours ago 1

Here is a function definition to write anything to the current minibuffer

(defun write-to-minibuffer (text) "writes to minibuffer" (let ((output (or (when (stringp text) text) (format "%S" text)))) (ignore-errors (with-current-buffer (window-buffer (minibuffer-window)) (read-only-mode -1) (widen) (erase-buffer) (end-of-buffer) (insert output) (read-only-mode 1)))))

Now one can "print" a plain string to the minibuffer:

(write-to-minibuffer "Hello World")

And one can also write coloful(propertized) strings to the minibuffer

(write-to-minibuffer (propertize "Hello World" 'face (list :background "#E76F0F" :foreground "#FFFFFF")))
Read Entire Article