unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Nice hack if you're using my face-remapping-alist patch
@ 2004-05-22 21:59 Miles Bader
  0 siblings, 0 replies; only message in thread
From: Miles Bader @ 2004-05-22 21:59 UTC (permalink / raw)


;; I find displaying mail/gnus in a variable-pitch font is especially nice,
;; if it's easy to toggle on/off, and you have a nice variable-pitch font
;; (I didn't, until I started using this; the variable-pitch font-family
;; I'm using, btw, is "charter" (which I think is a standard X font(?)),
;; with a :height scale of 1.1).

;;; This allows variable-width text to be turned on or off conveniently
;;; in a buffer:

(define-minor-mode variable-pitch-mode
  "Variable-pitch default-face mode."
  :lighter " VarPitch"
  (when (boundp 'face-remapping-alist)
    (let ((default-remapping (assq 'default face-remapping-alist))
	  (remappings face-remapping-alist))
      (cond ((and default-remapping (not variable-pitch-mode))
	     (setq remappings (remq default-remapping remappings)))
	    ((and variable-pitch-mode (null default-remapping))
	     (setq remappings (cons '(default variable-pitch) remappings))))
      (unless (eq remappings face-remapping-alist)
	(set (make-local-variable 'face-remapping-alist) remappings)
	(force-window-update (current-buffer))))))

(defun turn-on-variable-pitch-mode ()
  "Turn on `variable-pitch-mode'."
  (interactive)
  (variable-pitch-mode t))

(global-set-key "\C-cv" 'variable-pitch-mode)

;;; Turn it on by default in some modes:

;; mail sending:
(add-hook 'message-mode-hook 'turn-on-variable-pitch-mode)
(add-hook 'mail-mode-hook 'turn-on-variable-pitch-mode)

;; mail/news reading:
(add-hook 'gnus-article-mode-hook 'turn-on-variable-pitch-mode)

(defun gnus-summary-toggle-variable-pitch-mode ()
  (interactive)
  (with-current-buffer gnus-article-buffer
    (variable-pitch-mode 'toggle)))

;; Bind "F" to toggle variable-pitch-mode in the article buffer
;; (warning, "F" already has a standard binding, so change at will)
(add-hook 'gnus-summary-mode-hook
          (lambda ()
            (local-set-key "F" 'gnus-summary-toggle-variable-pitch-mode)))

;; -Miles
-- 
97% of everything is grunge

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-05-22 21:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-22 21:59 Nice hack if you're using my face-remapping-alist patch Miles Bader

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).