Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] A customization mechanism for ivy-height #1531

Closed
wants to merge 2 commits into from

Conversation

@mookid
Copy link
Contributor

commented Apr 14, 2018

fix #1527

Summary of changes:

ivy.el:

  • ivy-height-alist: new variable.

counsel.el:

  • (counsel-el, counsel--generic, counsel-git-log): make height customizable.
  • (counsel-yank-pop-height, counsel-evil-registers-height): kill now useless variable.
  • (counsel-yank-pop-height, counsel-evil-registers-height): make now useless variable obsolete.
  • (counsel-yank-pop, counsel-evil-registers): adapt to ivy-height-alist.

Discussion

It's always quite nice to get rid of magic numbers.
Should we get rid of the customization variables? (probably not, this is just proof of concept).

TODO

  • We should probably say something in the changelog about the change.
  • #1146
  • maybe #831
  • add version number for the make-obsolete-variable calls
ivy.el: a customization mechanism for ivy-height.
* ivy-height-alist: new variable.

counsel.el:
* (counsel-el, counsel--generic, counsel-git-log): make height customizable.
* (counsel-yank-pop-height, counsel-evil-registers-height): kill now useless variable.
* (counsel-yank-pop, counsel-evil-registers): adapt to ivy-height-alist.
:predicate pred
:initial-input str
:action #'ivy-completion-in-region-action)))

(add-to-list 'ivy-height-alist '(counsel-el . 7))

This comment has been minimized.

Copy link
@basil-conto

basil-conto Apr 14, 2018

Collaborator

The docstring of add-to-list says

This is handy to add some elements to configuration variables,
but please do not abuse it in Elisp code, where you are usually
better off using ‘push’ or ‘cl-pushnew’.

This comment has been minimized.

Copy link
@mookid

mookid Apr 14, 2018

Author Contributor

it's precisely configuration stuff.

This comment has been minimized.

Copy link
@basil-conto

basil-conto Apr 15, 2018

Collaborator

@mookid While you're not wrong, and it shouldn't make a difference here, "configuration" generally refers to user customisations, i.e. init file code. In particular, add-to-list can misbehave under lexical scope/extent.

counsel.el Outdated
@@ -3207,11 +3212,6 @@ A is the left hand side, B the right hand side."
:group 'ivy
:type 'string)

(defcustom counsel-yank-pop-height 5

This comment has been minimized.

Copy link
@basil-conto

basil-conto Apr 14, 2018

Collaborator

Probably best to mark this as obsolete and point to ivy-height-alist instead via make-obsolete-variable. Ditto for other removed user options.

ivy.el Outdated
"Number of lines for the minibuffer window."
"Number of lines for the minibuffer window.
Also see `ivy-height-alist'."

This comment has been minimized.

Copy link
@basil-conto

basil-conto Apr 14, 2018

Collaborator

"See also" seems to be more common than "Also see", FWIW.

ivy.el Outdated
(defcustom ivy-height-alist nil
"An alist to customize `ivy-height'.
It is a list of (CALLER . HEIGHT). CALLER is either a caller of

This comment has been minimized.

Copy link
@basil-conto

basil-conto Apr 14, 2018

Collaborator

is either a caller of ivy-read

Should "either" be removed from the sentence? If not, what is the alternative value?

ivy.el Outdated
(assq t ivy-display-functions-alist))))))
(height
(if caller
(let ((try-assoc (assoc caller ivy-height-alist)))

This comment has been minimized.

Copy link
@basil-conto

basil-conto Apr 14, 2018

Collaborator

How about the name "entry" instead of "try-assoc"?

amend
counsel.el:
    * (counsel-yank-pop-height, counsel-evil-registers-height): make now useless variable obsolete.

@abo-abo abo-abo closed this in 1181d0f Apr 15, 2018

@abo-abo

This comment has been minimized.

Copy link
Owner

commented Apr 15, 2018

Nice work, I've merged the current changes. And now I see in the comments that you planned to make more changes:) Feel free to do them in a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.