[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: toggle-variable-pitch
From: |
Thien-Thi Nguyen |
Subject: |
Re: toggle-variable-pitch |
Date: |
Thu, 19 Sep 2013 10:04:16 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
() Thien-Thi Nguyen <address@hidden>
() Thu, 19 Sep 2013 07:30:15 +0200
Here is a command that toggles ‘variable-pitch’ face:
(defun toggle-variable-pitch () ...)
Ah, the dangers of pre-caffeine posting. It turns out that
this command reimplements ‘buffer-face-mode’, poorly. It is
poor because invocation though a key sequence (after binding)
does not immediately update the screen, as does invocation
via ‘M-x’. The difference is a call to ‘force-window-update’.
So, to try to show that even an Ignorant Fool can improve,
here is the revised command, now suitable for keybinding:
(defun toggle-variable-pitch ()
"Toggle use of face `variable-pitch'.
This works by frobbing `face-remapping-alist'."
(interactive)
(let ((spec '(default variable-pitch)))
(set (make-local-variable 'face-remapping-alist)
(if (member spec face-remapping-alist)
(delete spec face-remapping-alist)
(cons spec face-remapping-alist))))
(force-window-update (current-buffer)))
BTW, the other difference is this command does not sully
the mode line w/ a camel-case minor mode "lighter", a Very
Important consideration from a certain aesthetic POV... :-D
--
Thien-Thi Nguyen
GPG key: 4C807502
(if you're human and you know it)
read my lisp: (responsep (questions 'technical)
(not (via 'mailing-list)))
=> nil
pgpCa83deBWKP.pgp
Description: PGP signature