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
Closed

Conversation

mookid
Copy link
Contributor

@mookid mookid 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-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))
Copy link
Collaborator

@basil-conto basil-conto Apr 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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’.

Copy link
Contributor Author

@mookid mookid Apr 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's precisely configuration stuff.

Copy link
Collaborator

@basil-conto basil-conto Apr 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link
Collaborator

@basil-conto basil-conto Apr 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'."
Copy link
Collaborator

@basil-conto basil-conto Apr 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"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
Copy link
Collaborator

@basil-conto basil-conto Apr 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)))
Copy link
Collaborator

@basil-conto basil-conto Apr 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

counsel.el:
    * (counsel-yank-pop-height, counsel-evil-registers-height): make now useless variable obsolete.
@abo-abo
Copy link
Owner

@abo-abo abo-abo 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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants