Emacs Lisp的有趣错误
在试图简化init.el时,我决定将一些功能从丑陋的cond树中移除。为了消除某些决策,我构建了两个助手函数:Emacs Lisp的有趣错误,emacs,lisp,elisp,Emacs,Lisp,Elisp,在试图简化init.el时,我决定将一些功能从丑陋的cond树中移除。为了消除某些决策,我构建了两个助手函数: (defun abstract-screen-width () (cond ((eq 'x window-system) (x-display-pixel-width)) ((eq 'ns window-system) (display-pixel-width)) )) (defun perfect-font-size (pixels) (co
(defun abstract-screen-width ()
(cond ((eq 'x window-system) (x-display-pixel-width))
((eq 'ns window-system) (display-pixel-width))
))
(defun perfect-font-size (pixels)
(cond ((eq 'x window-system) (cond ((<= pixels 1024) 100)
((<= pixels 1366) 110)
((> pixels 1366) 120)))
((eq 'ns window-system) (cond ((<= pixels 1024) 110)
((<= pixels 1280) 120)
((> pixels 1280) 140)))))
自定义集合在工作时面向调用
(custom-set-faces
'(default ((t (:inherit nil :stipple nil :inverse-video nil :box nil
:strike-through nil :overline nil
:underline nil :slant normal :weight normal
:height 130 :width normal
:family "IBM 3270"))))
'(linum ((t (:inherit default :foreground "#777" :height 130)))))
但我的“更好”版本
没有。它给出了一个“默认面高度不是绝对和正的”错误。faces.el和cus-face.el中的源代码帮助不大。有什么提示吗?表达式
'(default ((t (:inherit nil :stipple nil :inverse-video nil :box nil
:strike-through nil :overline nil
:underline nil :slant normal :weight normal
:height (perfect-font-size (abstract-screen-width)) :width normal
:family "IBM 3270"))))
全部引用,即,(完美字体大小(抽象屏幕宽度))
不会被评估。请改为尝试反向报价:
`(default ((t (:inherit nil :stipple nil :inverse-video nil :box nil
:strike-through nil :overline nil
:underline nil :slant normal :weight normal
:height ,(perfect-font-size (abstract-screen-width)) :width normal
:family "IBM 3270"))))
(注意回勾和逗号)。这个错误只是emacs告诉您的一种方式,它更喜欢列表中的数字
(完美字体大小(抽象屏幕宽度))
顺便说一句,您可以使用显示像素宽度
而不是抽象屏幕宽度
。正确。我不知道为什么我使用x-display-pixel-width,也许显示像素宽度在很久以前就出现了一个错误-这个init.el已经陪伴我十多年了。。。
'(default ((t (:inherit nil :stipple nil :inverse-video nil :box nil
:strike-through nil :overline nil
:underline nil :slant normal :weight normal
:height (perfect-font-size (abstract-screen-width)) :width normal
:family "IBM 3270"))))
`(default ((t (:inherit nil :stipple nil :inverse-video nil :box nil
:strike-through nil :overline nil
:underline nil :slant normal :weight normal
:height ,(perfect-font-size (abstract-screen-width)) :width normal
:family "IBM 3270"))))