Skip to content

Commit

Permalink
[#35] Allow fixed-height minibuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
raxod502 committed Apr 18, 2020
1 parent 1fd1234 commit 894c4be
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ The format is based on [Keep a Changelog].
retrieve history elements. The Isearch entry-point bindings now work
properly in Selectrum too, except that they allow you to select a
history element using Selectrum. See [#49].
* You can now cause the minibuffer to always have the same height,
even if there are fewer candidates, by enabling
`selectrum-fix-minibuffer-height` ([#35]).

### Enhancements
* In `read-file-name`, when a default is provided (for example in the
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ matching and case-insensitive matching.
* By default, ten candidates are shown in the minibuffer at any given
time. You can customize that by changing
`selectrum-num-candidates-displayed`.
* Normally `selectrum-num-candidates-displayed` acts as just a
maximum for the height of the minibuffer. You might prefer for
the minibuffer to *always* have that height, even if there are
fewer candidates. This behavior may be achieved by setting
`selectrum-fix-minibuffer-height` to a non-nil value.
* The currently selected candidate is highlighted with the face
`selectrum-current-candidate`. If you don't like the color, you can
adjust it to taste.
Expand Down
12 changes: 11 additions & 1 deletion selectrum.el
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ This option is a workaround for 2 problems:
wrapping."
:type 'integer)

(defcustom selectrum-fix-minibuffer-height nil
"Non-nil means the minibuffer always has the same height.
Even if there are fewer candidates."
:type 'boolean)

;;;; Utility functions

;;;###autoload
Expand Down Expand Up @@ -667,7 +672,12 @@ just rendering it to the screen and then checking."
selectrum-right-margin-padding)))
right-margin))
(push ol selectrum--right-margin-overlays))))
(cl-incf index))))
(cl-incf index))
;; Simplest way to grow the minibuffer to size is to just
;; insert some extra newlines :P
(when selectrum-fix-minibuffer-height
(dotimes (_ (- selectrum-num-candidates-displayed index))
(insert "\n")))))
(add-text-properties bound (point-max) '(read-only t))
(setq selectrum--end-of-input-marker (set-marker (make-marker) bound))
(set-marker-insertion-type selectrum--end-of-input-marker t)
Expand Down

0 comments on commit 894c4be

Please sign in to comment.