2

I have a huge screen, looking down at the minibuffer and then back and forth between my code and the minibuffer (e.g. if I'm isearching) is somewhat annoying. As such I'm wondering if there is a way to mirror minibuffer contents at point.

I realize this might be complicated since the minibuffer becomes the active buffer, and so point becomes the point in the minibuffer.

One idea of path to solution: is there a way to detect when entering minibuffer? To then detect what buffer we come from?

  • See minibuffer-setup-hook: "run just after entry to minibuffer". See also minibuffer-active-p. See also completion-reference-buffer. You can also give the minibuffer its own frame, and (re)position that frame near point. – Drew Mar 8 '18 at 18:37
  • Thanks! I posted a solution but it's not great. I'll update it if I manage to write something better. – Manux Mar 8 '18 at 19:01
1

Here's one possible solution, it's not super elegant so I'll try the looking at giving the minibuffer its own frame instead.

It basically makes an overlay near point that shows the minibuffer's contents after each change.

(setq mb-catch-buf nil)
(setq mb-catch-overlay nil)

(defun mb-catch-change-hook (change-beg change-end prev-len)
  (let ((string (concat (minibuffer-prompt)
                        (minibuffer-contents))))
    (overlay-put mb-catch-overlay 'after-string string)
    ))


(defun mb-catch-setup ()
  (let ((buf (other-buffer (current-buffer) 1)))
    (setq mb-catch-buf buf)
    (save-current-buffer
      (set-buffer buf)
      (setq mb-catch-overlay
            (make-overlay (point) (+ 1 (point)))))
    (add-hook 'after-change-functions 'mb-catch-change-hook)))

(defun mb-catch-exit ()
  (delete-overlay mb-catch-overlay)
  (remove-hook 'after-change-functions 'mb-catch-hook))

(add-hook 'minibuffer-setup-hook 'mb-catch-setup)
(add-hook 'minibuffer-exit-hook 'mb-catch-exit)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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