Fonts 如何在emacs中将字体大小设置为评估值?

Fonts 如何在emacs中将字体大小设置为评估值?,fonts,emacs,Fonts,Emacs,我是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,

我是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,它运行良好。但是,当我将其更改为表达式时,它失败了,消息为:

error: Default face height not absolute and positive, +, 70, 70
我之所以尝试这样做,是因为我在多台屏幕大小不同的计算机上共享相同的.emacs文件。所以我的最终目标是根据屏幕大小计算字体大小


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

你可以完全按照lawlist所说的去做,这是完全合理的。如果要在“自定义”之外执行此操作,请执行以下操作:

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

不需要Quasikotes,因为表达式一开始就没有引用。

我有类似的设置,我不断地插入和拔出显示器,并使用Mac视网膜显示器

我发现默认的文本比例工作得很好。如果您的安装程序使用use软件包,这里就是我配置的

(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))

它不能解决您的特定问题,但它可以跨所有窗口调整字体大小。如果您需要演示,它会派上用场。

您可以做您想做的事情,但使用的是经过计算的代码,而不是受引号保护的代码。例如,使用反引号表达式:将引号更改为反引号,并在要计算的sexp之前加逗号

(custom-set-faces
 `(default ((t (:height ,(+ 70 70))))))
这相当于:

自定义集面 列表的默认列表t列表:高度+70
如果手动更改自定义部分,则如果使用内置方法再次保存自定义部分,这些更改可能会丢失。例如,可以计算70+70到140,但下次通过常规内置方法保存自定义时,该值将为140,而不是拼写为70+70。也就是说,您可以尝试将单引号更改为反勾号,并在要计算的部分之前放置逗号;i、 例如,try:`defaultt:height,+70。请参阅:您可以在自定义之外执行此操作。@lawlist谢谢。很有魅力