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

Change line spacing but vertically centered? #10502

Closed
nocksock opened this issue Mar 20, 2018 · 4 comments
Closed

Change line spacing but vertically centered? #10502

nocksock opened this issue Mar 20, 2018 · 4 comments

Comments

@nocksock
Copy link

I don't like having the lines that close to each other, so I found (setq line-spacing 0.25) which has the desired effect, with one little detail missing: the text is aligned to the top:

screen shot 2018-03-20 at 16 01 42

Is there a way to get that line vertically centered too?

@duianto
Copy link
Collaborator

duianto commented Mar 22, 2018

This SO question discusses this issue:
https://stackoverflow.com/questions/26437034/emacs-line-height

Adding text properties seems to be the closest solution:

(add-text-properties (point-min) (point-max)
                     '(line-spacing 0.25 line-height 1.25))

When I just tested it, then the line spacing/height doesn't change on the last line. Maybe it only works if there's a line below.

The answer here:
https://emacs.stackexchange.com/questions/30711/robust-way-of-applying-line-height-everywhere

states that:

Emacs doesn't have a very sophisticated or complete rendering model.

And suggests:

If you want something that's even nicer, I recommend diving into the rendering code and changing it so that line-spacing can be a list of two numbers, one for space below and one for space above the line. Then push that change out to the mailing list and see what they think of it.

So if your up for the challenge 😄

@nocksock
Copy link
Author

This SO question discusses this issue:
stackoverflow.com/questions/26437034/emacs-line-height

I've found that one too, and as you noticed yourself, it works - but basically just once. :D

If you want something that's even nicer, I recommend diving into the rendering code and changing it so that line-spacing can be a list of two numbers, one for space below and one for space above the line. Then push that change out to the mailing list and see what they think of it.

So if your up for the challenge

I wouldn't even know where to start - especially being (as of now) completely unfamiliar with lisp that's beyond configuring spacemacs. 😅

@bmag
Copy link
Collaborator

bmag commented Jul 12, 2018

This issue popped up in the gitter chat, so I'm just letting you know about the default-text-properties variable I found. Setting it like so should produce the desired spacing, except for the last line of the file:

(setq default-text-properties '(line-spacing 0.25 line-height 1.25))

But that also affects the minibuffer, so maybe a better solution is:

(defun set-bigger-spacing ()
  (setq-local default-text-properties '(line-spacing 0.25 line-height 1.25)))
(add-hook 'text-mode-hook 'set-bigger-spacing)
(add-hook 'prog-mode-hook 'set-bigger-spacing)

Anyway, this isn't really Spacemacs related, so I'm closing the issue. You're welcome to add the info to one of the SO questions - those threads usually have more visibility than Spacemacs issues and it will help more Emacs users.

@bmag bmag closed this as completed Jul 12, 2018
@bmag bmag added the - Forum - label Jul 12, 2018
@sebastiansturm
Copy link

there's a vertical-centering patch that may or may not be merged into emacs master (not sure about the current status): https://www.reddit.com/r/emacs/comments/cxywtc/i_wrote_a_patch_to_vertically_center_the_line/
https://lists.gnu.org/archive/html/emacs-devel/2019-08/msg00659.html
https://github.com/sollidsnake/emacs/

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

No branches or pull requests

4 participants