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

How about a selectrum-candidate-displayed instead of a suffix and prefix? #14

Closed
AmaiKinono opened this issue Jan 30, 2020 · 4 comments
Closed

Comments

@AmaiKinono
Copy link
Contributor

I'm working on a command that inserts a unicode character. It looks like this:

insert-unicode

I'm not gonna use this layout because it looks bad when the width of my frame is not enough. But I discovered some problem when implementing it. I have to do something like this to make the display right:

;; `name' is the name of the character, `code' is its code point.
(propertize
 name
 'selectrum-candidate-display-prefix
 (format "%06X " code)
 'selectrum-candidate-display-suffix
 (concat (make-string (- 84 (length name)) ?\s)
         (format "%c" code)))

which is not elegant. After looking into selectrum's code I found that the prefix and suffix is used only for build the displayed form. so how about using one selectrum-candidate-displayed instead, so I can just do:

(propertize
 name
 'selectrum-candidate-displayed
 (format "%06X %-84s %c" code name code))

Also, the candidate itself may not appear in its original form in some commands (I don't have an example now). By doing this we also make these commands possible.

@raxod502
Copy link
Member

There is an explicit reason I don't allow users to fully customize the display appearance, which is that getting highlighting to work correctly in this case is much more difficult. If there is a prefix and suffix, then currently to highlight we simply highlight the raw candidate and then add the prefix and suffix. If all we get for display is an arbitrarily transformed candidate string, it's not clear how to highlight it correctly in general.

I would be fine with adding a new text property that allows you to specify a string that is displayed at the right margin. This would not cause any of the above problems, and would solve your concern (plus would allow the width to be automatically recomputed when the frame is resized).

@AmaiKinono
Copy link
Contributor Author

AmaiKinono commented Feb 7, 2020

I thought about this for a while. Maybe we can use lists for left/right margin properties, so we can have multiple things in both margins.

You can have a look at ivy-rich. I bet in the future, someone will want to invent similar things with selectrum, or least have icons displayed at left margin (maybe using all-the-icons). If we use lists, they can just push whatever they want to them.

@raxod502
Copy link
Member

raxod502 commented Feb 9, 2020

I would be okay with there being one or more optional text properties that allow you to add extra information to be displayed in separate columns in either margin, as long as the user is responsible for providing maximum/minimum width information and relative priorities for the fields, so that the logic in Selectrum remains simple.

@AmaiKinono
Copy link
Contributor Author

I'll close this since #44 is merged. If in the future we need a more sophisticated solution (like using lists for prefix and right margin text), we could track it using a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants