dired-sidebar
dired-sidebar copied to clipboard
Dired-sidebar Custom font problem.
Even if I have (customize-set-variable 'dired-sidebar-use-custom-font t)
in my init file, sidebar fails to inherit my font. I found out that removing (buffer-face-mode-invoke 'variable-pitch t)
in the dired-sidebar-set-font
function fixes the font issue.
The variable-pitch
face can be customized too and if it is not then may be sidebar fails to inherit the custom fonts. Maybe you have more insights on this.
Looking at dired-sidebar-face in 'Customize' says it's not customizable. Maybe something broke in 29.1?
I'm guessing this is the same issue, but dired-sidebar-face
no longer honors the :background
property I had set to use a different color. I see that it was switched from a variable to a face sometime last year, but neither setting works. I'm still using Emacs 28.2.
I am currently using this until someone figures this out:
(when (member "Noto Sans" (font-family-list))
(defun my-set-dired-font-family ()
(face-remap-add-relative 'default :family "Noto Sans"))
(add-hook 'dired-mode-hook 'my-set-dired-font-family))
@jojojames Is this a bug or just a configuration issue? It seems like the user's choice of font for the sidebar either doesn't get applied at all, or does but gets clobbered immediately.
Hi, thanks very much for dired sidebar. I am experimenting with replacing treemacs with it (due to some issues on windows) and so far, so amazing. I have one question, which is related to this ticket I believe. I'd like to also customise my font, as the OP; but in my case, I just want to make the font size a couple of points smaller than the current size. Can someone provide an example of how to use dired-sidebar-face
please? I tried following on from @chainedghost above, e.g.:
(when (member "Noto Sans" (font-family-list))
(defun my-set-dired-font-family ()
(face-remap-add-relative 'default :family "Noto Sans"))
(add-hook 'dired-mode-hook 'my-set-dired-font-family))
but could not quite understand how this applies to changing the font in dired-sidebar I'm afraid. Many thanks for your time.
Actually, whilst checking your docs, I bumped into ibuffer-sidebar [1], which has a similar approach:
(use-package ibuffer-sidebar
:load-path "~/.emacs.d/fork/ibuffer-sidebar"
:ensure nil
:commands (ibuffer-sidebar-toggle-sidebar)
:config
(setq ibuffer-sidebar-use-custom-font t)
(setq ibuffer-sidebar-face `(:family "Helvetica" :height 140)))
I think I just need to play around with dired-sidebar-face
in a similar fashion. Cheers
[1] https://github.com/jojojames/ibuffer-sidebar?tab=readme-ov-file
Right, I think I just about got to the point of the original poster, and all my woes are indeed related to variable-pitch
. The implementation of ibuffer-sidebar
says:
(defun ibuffer-sidebar-set-font ()
"Customize font in `ibuffer-sidebar'.
Set font to a variable width (proportional) in the current buffer."
(interactive)
(setq-local buffer-face-mode-face ibuffer-sidebar-face)
(buffer-face-mode))
With this I can set the height with no problems. But the implementation of dired-sidebar
says:
(defun dired-sidebar-set-font ()
"Customize font in `dired-sidebar'.
Set font to a variable width (proportional) in the current buffer."
(interactive)
(require 'face-remap)
(setq-local buffer-face-mode-face 'dired-sidebar-face)
(buffer-face-mode-invoke 'variable-pitch t))
With this I cannot change the font size. However, when I do:
(defun dired-sidebar-set-font ()
"Customize font in `dired-sidebar'.
Set font to a variable width (proportional) in the current buffer."
(interactive)
(require 'face-remap)
(setq-local buffer-face-mode-face 'dired-sidebar-face)
;; (buffer-face-mode-invoke 'variable-pitch t)
(buffer-face-mode)
)
And then a couple of evals:
(setq dired-sidebar-face `(:height 70 :family "Source Code Pro"))
(dired-sidebar-set-font)
This produces the desired result:
Now, I must prefix all of this by saying I have no great knowledge of emacs lisp, so this hackery may all be very dodgy :-) but at least it works for me. Can you explain why dired-sidebar works differently from ibuffer-sidebar on this regard? Tia
Not sure why the implementations are different, it's been a few years since I wrote both but the ibuffer implementation should be newer. I copied it to dired-sidebar. https://github.com/jojojames/dired-sidebar/commit/573658021fd6e6cf032d789de29aca4e5dd258fd