-
Notifications
You must be signed in to change notification settings - Fork 33
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
add: a text property for display string in the right margin #44
add: a text property for display string in the right margin #44
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The feature is fine, but text display based on window width calculations is too flaky (what happens if you resize the window during a session?). A better approach is to use a text overlay, as in radian-software/ctrlf#32 (comment).
I failed to figure it out. The code I gave in radian-software/ctrlf#32 (comment) displays a very wide space, and from the manual, seems that's its only usage. I didn't find other display property of overlay that allows right aligning text. Could you explain a bit more about how this should be done? |
Sorry, didn't realize that example was not an appropriate one. It is in fact possible, though: It uses a "pixel specification" in the Here's what the overlays look like in that package: |
Thanks for the example, the trick is neat :D Please see if this can be merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- looks good
- some minor suggestions
- can you suggest a code snippet that demonstrates the functionality so I can test it?
- we should have an entry in the CHANGELOG
Thank you for the help!
fed5830
to
d4b7cb4
Compare
Done.
This is a simple test: (completing-read
"Hi: "
(list
(propertize "item1"
'selectrum-candidate-display-right-margin "annotation1"
'selectrum-candidate-display-prefix "prefix1 ")
(propertize "item2"
'selectrum-candidate-display-right-margin "annotation2"
'selectrum-candidate-display-prefix "prefix2 "))) And this is a command I want to implement using this feature: (defun insert-unicode-char (&optional count)
(interactive "p")
(let ((selectrum-preprocess-candidates-function
(lambda (collection)
(selectrum--map-destructive
(lambda (name)
(let ((code (char-from-name name)))
(propertize
name
'selectrum-candidate-full
(format "%c" code name code)
'selectrum-candidate-display-prefix
(format "%06X " code)
'selectrum-candidate-display-right-margin
(format "%c" code))))
collection))))
(call-interactively #'insert-char))) |
See #14
The right margin text is displayed in the same line:
or in a new line, when the space is not enough: