How do I set a mode-specific font?

To elaborate on this, I want a generic solution that allows me to assign special fonts to all major modes.
Another thing I have tried is to find the frame for the current buffer (see code below). This doesn't work either, because although the current buffer exists, it seems like it doesn't have a window yet (or walk-windows ignores it.)


What to do?

---

(defun find-all-frames-internal (buffer)
  (let ((frames nil))
    (walk-windows '(lambda (wind)
                     (if (eq (window-buffer wind) buffer)
                       (let ((frm (window-frame wind)))
                         (unless (memq frm frames)
                           (push frm frames)))))
                  nil t)
    frames))

(add-hook  'after-change-major-mode-hook
          (lambda ()
           ;; this doesn't work yet
;; somehow, the window doesn't exist at this point :(
;; the current-buffer is correct
            (setq fr (car (find-all-frames-internal (current-buffer))))
        
(if fr  
           (case major-mode
          ('text-mode
             (select-frame fr)
                (set-frame-font "fontset-lucida14")
)))))



_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

Reply via email to