-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Fix text align for buffer-face-mode
#20
Conversation
Wow, it seemed you are using variable pitch font for programming, thats cool. The I will keep this PR open and use the modified version in my Emacs config for now. |
No, those are the default for
Yes, this is not trivial. I have spent countless hours but still haven't found the ideal solution. 😓 |
I see, I think my fix should work for mono fonts when using I am using In emacs-lsp/lsp-ui#184 (comment) there's a function to do with the variable pitch font but kind of heavy. I think my fix is enough for most cases when using mono fonts. |
I've been using my fix since then (Ubuntu 22.04, using Wayland and variable-width fonts), flawlessy. I didn't even know this bug hadn't been fixed yet. |
How about something like? (defun sideline--align-right (str offset)
"Align sideline STR from the right of the window.
Argument OFFSET is additional calculation from the right alignment."
(let ((graphic-p (display-graphic-p))
(fringes (window-fringes)))
(list (+
;; If the sideline text is displayed without at least 1 pixel gap from the right fringe and
;; overflow-newline-into-fringe is not true, emacs will line wrap it.
(if (and graphic-p
(> (nth 1 fringes) 0)
(not overflow-newline-into-fringe))
1
0)
(* (window-font-width)
(+ offset (if graphic-p
;; If right fringe deactivated add 1 offset
(if (= 0 (nth 1 fringes)) 1 0)
1)
(sideline--str-len str)))))))
It won't work if you have wide characters. The above patch should fix this as well. |
This version works well for me. Thanks! |
Thank you! |
When we use
buffer-face-mode
and set different font other than the default font, the text align of sideline is incorrect, like this:After this fix, it would looks like:
See also: emacs-lsp/lsp-ui#184