如何在emacs中将font-size设置为评估值?

问题描述 投票:0回答:3

我是emacs lisp的新手,并尝试将关键字值设置为评估表达式,如下所示:

(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(default ((t (:height (+ 70 70)))))
)

请注意,最初高度是静态值140,它运作良好。但是,当我将其更改为表达式时,它与msg失败:

error: Default face height not absolute and positive, +, 70, 70

我尝试这个的原因是我在不同屏幕尺寸的多台计算机上共享相同的.emacs文件。所以我的最终目标是根据屏幕尺寸计算字体大小。

将关键字值设置为表达式的正确方法是什么?

emacs elisp
3个回答
1
投票

你可以做法律清单所说的,这是完全合理的。如果您想在自定义之外执行此操作:

(set-face-attribute 'default nil :height (+ 70 70))

不需要quasiquotes,因为首先没有引用表达式。


0
投票

我有类似的设置,我不断插拔我的显示器并使用Mac Retina显示器。

我发现default-text-scale效果很好。如果你的设置使用use-package这里是我配置的。

(use-package default-text-scale
    :ensure t
    :config
    (setq default-text-scale-amount 8)
    :bind
    ;; Plus makes it better
    ("M-+" . default-text-scale-increase)
    ;; Underscore makes it smaller (- is already bound)
    ("M-_" . default-text-scale-decrease))

它不能解决您的具体问题,但它适用于调整字体大小的所有窗口。如果你需要出席,它会派上用场。


0
投票

您可以执行您尝试执行的操作,但使用的是获得评估的代码,而不是quote不受评估影响的代码。例如,使用反引号表达式:将引号更改为反引号,并在要评估的sexp之前添加逗号。

(custom-set-faces
 `(default ((t (:height ,(+ 70 70))))))

这相当于:

(custom-set-faces
 (list 'default (list (list t (list :height (+ 70 70))))))
© www.soinside.com 2019 - 2024. All rights reserved.