2

这个想法是重新定义set-face-attribute,以便它正常设置面部属性,但:weight属性应始终设置为normal(我认为默认值)。有了这个,我希望一劳永逸地禁用 Emacs 中的粗体字体。

我懂了:

(fset 'original-set-face-attribute (symbol-function 'set-face-attribute))

(defun set-face-attribute (face frame &rest args)
  (progn
    (original-set-face-attribute face frame args)))

到目前为止,它不起作用。如果我这样做,(make-face-bold 'default)我会得到Wrong type argument: symbolp, (:weight bold). 我认为我要做的是:weight从参数列表中删除包含的 元素args

4

3 回答 3

3

这里有一些代码让你开始:

(defadvice set-face-attribute
    (before no-bold (face frame &rest args) activate)
  (setq args
        (mapcar (lambda(x) (if (eq x 'bold) 'normal x))
                args)))

我在大多数情况下都看到了这项工作,除了basic-facesdon't call set-face-attribute,例如error面部。

于 2013-12-19T13:07:54.087 回答
2

按照 Aaron 的建议,这是另一个使用 face-remap-add-relative.

(defun remap-faces-default-attributes ()
  (let ((family (face-attribute 'default :family))
        (height (face-attribute 'default :height)))
    (mapcar (lambda (face)
              (face-remap-add-relative
               face :family family :weight 'normal :height height))
          (face-list))))

(when (display-graphic-p)
  (add-hook 'minibuffer-setup-hook 'remap-faces-default-attributes)
  (add-hook 'change-major-mode-after-body-hook 'remap-faces-default-attributes))

这个摆脱了无处不在的粗体字体,也摆脱了可变宽度字体,并将所有面设置为相同的高度。基本上它就像在终端窗口中运行 Emacs,除了更多的颜色。

于 2013-12-19T23:02:37.180 回答
0

好吧!我改进了 abo-abo 的解决方案,这就是我想出的:

(defadvice set-face-attribute
  (before ignore-attributes (face frame &rest args) activate)
  (setq args
        (apply 'nconc
               (mapcar (lambda (i)
                         (let ((attribute (nth i args))
                               (value (nth (1+ i) args)))
                           (if (not (memq attribute
                                          set-face-ignore-attributes))
                               (list attribute value))))
                       (number-sequence 0 (1- (length args)) 2)))))

(setq set-face-ignore-attributes '(:weight :height :box))

它禁用大多数字体的:height,:weight:box属性(可以通过set-face-ignore-attributes变量配置)。为此,它必须在init.el设置字体属性之前的最开始。

于 2013-12-19T17:19:25.303 回答