Closed orontee closed 4 months ago
From: Matthias Meulien @.***> Date: Sat, 11 May 2024 04:29:17 -0700
Context
I am used to apply a scale factor (.7) to
line-number-face
. But enablingspacious-padding
overwrite this customization. Is there any way to preserve such customization?
Maybe something like this will do it?
(defun my-custom-faces-after-spacious-padding ()
"Set face attributes after `spacious-padding-mode'.
Add this to the `spacious-padding-mode-hook'."
;; Add more `set-face-attribute' calls here
(set-face-attribute 'line-number nil :height 0.7))
(add-hook 'spacious-padding-mode-hook #'my-custom-faces-after-spacious-padding)
-- Protesilaos Stavrou https://protesilaos.com
Thank you Protesilaos! One should add:
(add-hook 'after-make-frame-functions #'my-custom-faces-after-spacious-padding)
From: Matthias Meulien @.***> Date: Sat, 11 May 2024 05:55:43 -0700
Thank you Protesilaos! One should add:
(add-hook 'after-make-frame-functions #'my-custom-faces-after-spacious-padding)
Right!
-- Protesilaos Stavrou https://protesilaos.com
It doesn't work anymore, too bad...
GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.16.0)
(defun my-custom-faces-after-spacious-padding (&optional frame)
"Set face attributes after `spacious-padding-mode'.
Add this to the `spacious-padding-mode-hook'."
;; Add more `set-face-attribute' calls here
(set-face-attribute 'line-number (or frame (window-frame)) :height 0.7))
(add-hook 'spacious-padding-mode-hook #'my-custom-faces-after-spacious-padding)
(add-hook 'after-make-frame-functions #'my-custom-faces-after-spacious-padding)
From: Matthias Meulien @.***> Date: Sat, 8 Jun 2024 05:51:49 -0700
It doesn't work anymore, too bad...
Can you please tell me more about this? Or maybe show a screenshot? There may be something else that is overriding that face. It seems to work on my end.
-- Protesilaos Stavrou https://protesilaos.com
I confirm that on my side it now works too (emacs 30.0.60, spacious-padding 0.5.0).
Sorry for being so long to reply.
From: Matthias Meulien @.***> Date: Thu, 15 Aug 2024 01:48:50 -0700
I confirm that on my side it now works too (emacs 30.0.60, spacious-padding 0.5.0).
Very well!
Sorry for being so long to reply.
No worries!
-- Protesilaos Stavrou https://protesilaos.com
I think I now have a recipe to show that it doesn't always work.
I have customized the line-number
face to a height value of 0.8. And there's the following lines in the "init.el" file:
(when (locate-library "spacious-padding")
(require 'spacious-padding)
(defun my-custom-faces-after-spacious-padding (&optional frame)
"Set face attributes after `spacious-padding-mode'.
Add this to the `spacious-padding-mode-hook'."
;; Add more `set-face-attribute' calls here
(set-face-attribute 'line-number (or frame (window-frame)) :height 0.8))
(add-hook 'spacious-padding-mode-hook #'my-custom-faces-after-spacious-padding)
(add-hook 'after-make-frame-functions #'my-custom-faces-after-spacious-padding)
(spacious-padding-mode))
I start Emacs, no desktop. I open a buffer A in the initial frame F1, then M-x display-line-numbers-mode
. Everything looks good.
Then I create a new frame (C-x 5 2
). A new frame F2 is created, showing buffer A. Line numbers have the right height there. But look at the buffer A in frame F1: The line numbers have height 1!
EDIT: A silly fix is to set the face attribute for all frames:
(defun my-custom-faces-after-spacious-padding (&optional frame)
"Set face attributes after `spacious-padding-mode'.
Add this to the `spacious-padding-mode-hook'."
;; Add more `set-face-attribute' calls here
(dolist (frame (frame-list))
(set-face-attribute 'line-number frame :height 0.8)))
From: Matthias Meulien @.***> Date: Mon, 26 Aug 2024 08:18:08 -0700
[... 8 lines elided]
(defun my-custom-faces-after-spacious-padding (&optional frame) "Set face attributes after `spacious-padding-mode'.
Add this to the
spacious-padding-mode-hook'." ;; Add more
set-face-attribute' calls here (set-face-attribute 'line-number (or frame (window-frame)) :height 0.8))(add-hook 'spacious-padding-mode-hook #'my-custom-faces-after-spacious-padding) (add-hook 'after-make-frame-functions #'my-custom-faces-after-spacious-padding) (spacious-padding-mode))
[... 5 lines elided]
This is a strange case. Since you want line numbers to always be smaller, why not do it unconditionally instead of passing a FRAME to 'set-face-attribute'? If you give it 'nil', it will change the face across all frames. So you can have something like this:
(defun my-custom-faces-after-spacious-padding (&rest _)
"Set face attributes after `spacious-padding-mode'.
Add this to the `spacious-padding-mode-hook'."
;; Add more `set-face-attribute' calls here
(set-face-attribute 'line-number nil :height 0.8))
The '&rest _' means that the function accepts an arbitrary number of arguments but will ignore them all. So it will work with hooks that pass arguments, for example.
-- Protesilaos Stavrou https://protesilaos.com
:+1: I wasn't aware of the possible nil
value for the FRAME attribute to set-face-attribute
. Thanks!
From: Matthias Meulien @.***> Date: Mon, 2 Sep 2024 04:23:23 -0700
:+1: I wasn't aware of the possible
nil
value for the FRAME attribute toset-face-attribute
. Thanks!
You are welcome!
Also, this is happening with or without a theme? I suspect it is the latter scenario.
-- Protesilaos Stavrou https://protesilaos.com
Also, this is happening with or without a theme? I suspect it is the latter scenario.
Are you joking? I am hooked to modus themes! One is always enabled.
From: Matthias Meulien @.***> Date: Mon, 2 Sep 2024 07:20:44 -0700
Also, this is happening with or without a theme? I suspect it is the latter scenario.
Ate you joking? I am hooked to modus themes! One is always enabled.
Haha! Well, I was thinking it might be because when no theme is enabled, the 'custom-set-faces' we use internally overrides the underlying face's styles instead of appending to them. Whereas with a theme, this does not happen.
As your case, I do not know what the cause is. But it is good that we figured it out.
-- Protesilaos Stavrou https://protesilaos.com
Context
I am used to apply a scale factor (.7) to
line-number-face
. But enablingspacious-padding
overwrite this customization. Is there any way to preserve such customization?