与Emacs Lisp有趣的错误

rba*_*ffy 3 lisp emacs 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)
  (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)))))
Run Code Online (Sandbox Code Playgroud)

并且它们很好地结合并按照它们被调用的方式调用它们工作正常.

(perfect-font-size (abstract-screen-width))
130
Run Code Online (Sandbox Code Playgroud)

自定义set-faces调用正常工作

(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)))))
Run Code Online (Sandbox Code Playgroud)

但我的"更好"的版本

(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 (perfect-font-size (abstract-screen-width)) :width normal
                                :family "IBM 3270"))))
        '(linum ((t (:inherit default :foreground "#777" :height 120)))))
Run Code Online (Sandbox Code Playgroud)

没有.它给出了"默认面高度不是绝对和正面"错误.faces.el和cus-face.el中的消息来源并没多大帮助.任何提示?

Dir*_*irk 9

表达方式

'(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"))))
Run Code Online (Sandbox Code Playgroud)

引用全文,即(perfect-font-size (abstract-screen-width))不予评估.尝试反引用:

`(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"))))
Run Code Online (Sandbox Code Playgroud)

(注意反引号和逗号).错误只是emacs告诉你的方式,它首选了一个获得列表的数字(perfect-font-size (abstract-screen-width))