0

Here's my function:

(defun scroller-down ()
  "Scrolling down conditional for buffer and minibuffer."
  (interactive)
  (if (active-minibuffer-window)
      (ivy-scroll-down-command)
    (scroll-down-command)))

(defun scroller-up ()
  "Scrolling up conditional for buffer and minibuffer."
  (interactive)
  (if (active-minibuffer-window)
      (ivy-scroll-up-command)
    (scroll-up-command)))

This function determines if the minibuffer is open.
If it is open and the cursor is in it, it will scroll in the minibuffer.
However, if it is open and the cursor is not in it, it will neither scroll in the minibuffer, nor the current buffer that the cursor is in.

My goal is to determine which scroll to use depending on if the cursor is in the minibuffer or not.
Is there a variable that returns true if the cursor position is in the minibuffer?

Also is there a better way to condense this function into one, and use a cond to check if a certain key is pressed, thus activating the appropriate scroll function??

  • 1
    By "cursor is in the minibuffer" I think you mean that the minibuffer has the input focus. It might help to provide a step-by-step recipe, starting from emacs -Q, describing what you see at each step and what you expected to see instead. – Drew Apr 23 '18 at 1:10
  • 2
    I have been using the function (minibufferp) for several years now to help me know programmatically when to change the color of the minibuffer-prompt face and the default face in the minibuffer when I move in and out of it; and, then I use (with-selected-window (minibuffer-window) ...) to do my stuff within that window. Perhaps that combination can either help, or inspire you ... minibufferp had an optional argument for BUFFER. [Return t if BUFFER is a minibuffer. No argument or nil as argument means use current buffer as BUFFER. BUFFER can be a buffer or a buffer name.] – lawlist Apr 23 '18 at 3:29
  • 1
    Indeed, active-minibuffer-window doesn't care whether the active minibuffer window is selected or not. @lawlist, you should post the minibufferp details as an answer. – phils Apr 23 '18 at 4:03
1

The function minibufferp contains a doc-string that states:  "Return t if BUFFER is a minibuffer. No argument or nil as argument means use current buffer as BUFFER. BUFFER can be a buffer or a buffer name."

To act upon a minibuffer window, I find it helpful to use (with-selected-window (minibuffer-window) ...)

  • minibufferp is exactly what I needed. – John DeBord Apr 23 '18 at 5:13

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.