3

在尝试简化我的 init.el 时,我决定将一些功能从丑陋的条件树中移出。为了摆脱一些决策,我构建了两个辅助函数:

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

而且它们很好地结合在一起,并按照它们被调用的方式调用它们工作正常。

(perfect-font-size (abstract-screen-width))
130

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

但我的“更好”版本

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

没有。它给出了“默认面高不是绝对和积极的”错误。faces.el 和 cus-face.el 中的来源并没有太大帮助。有什么提示吗?

4

1 回答 1

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

被完整引用,即(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"))))

(注意反引号和逗号)。该错误只是 emacs 告诉您的方式,它更喜欢获得列表的数字(perfect-font-size (abstract-screen-width))

于 2012-05-13T16:25:50.037 回答