[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: A suggestion on `x-select-font'

From: Herbert Euler
Subject: RE: A suggestion on `x-select-font'
Date: Fri, 27 Jun 2008 16:50:01 +0800

[It was sent several days ago but there's no reply.  I wrote a patch
today, but am not sure it is the right one.]

The attached patch does what I suggested: It makes the font chooser in
Emacs more like other X appications by setting the user selected font
in the font chooser dialog.  There are several problems in it, though:

  - Not only the frame font has been reset, but also the frame size.
    Perhaps this is because I'm not setting the frame's font in a
    right way.

  - When the buffer uses a different font than the default one and
    when the font dialog is popped, the main frame of Emacs is blank,
    whereas it displayed the buffer text before this change.

  - Sometimes the font in the font dialog is still not what the user
    chooses for a particular buffer.  I can't figure out why.

Having the changes in `mouse-appearance-menu' instead of
`x-select-font', the advantage is that the handling of the event (the
way that the buffer in which the event occurred can be found) is
nearer to where it occured.  And because `mouse-appearance-menu' is a
Lisp-level function, this way seems more flexible.  (All because
`x-select-font' needs to know as little about the event as possible.)

The disadvantage is that the use of expensive `unwind-protect' would
not be necessary if the font is chosen at the C level.

How do you think about this proposal?  Thanks.

Guanpeng Xu

*** mouse.el.~1.342.~   2008-06-24 13:37:06.000000000 +0800
--- mouse.el    2008-06-27 16:11:35.000000000 +0800
*** 2527,2537 ****
               ;; Either choice == 'x-select-font, or choice is a
               ;; symbol whose name is a font.
!              (buffer-face-mode-invoke (font-face-attributes
!                                        (if (eq choice 'x-select-font)
!                                            (x-select-font)
!                                          (symbol-name choice)))
!                                       t (interactive-p))))))))
  ;;; Bindings for mouse commands.
--- 2527,2554 ----
               ;; Either choice == 'x-select-font, or choice is a
               ;; symbol whose name is a font.
!              (let ((font
!                     (if (eq choice 'x-select-font)
!                         (let ((buf (window-buffer
!                                     (posn-window
!                                      (event-start event)))))
!                           (with-current-buffer buf
!                             (if (null face-remapping-alist)
!                                 (x-select-font)
!                               (let ((oldfont (frame-parameter nil 'font))
!                                     (newfont (face-font 'default)))
!                                 (unwind-protect
!                                     (progn
!                                       (modify-frame-parameters
!                                        nil
!                                        `((font . ,newfont)))
!                                       (x-select-font))
!                                   (modify-frame-parameters
!                                    nil
!                                    `((font . ,oldfont))))))))
!                       (symbol-name choice))))
!                (buffer-face-mode-invoke (font-face-attributes font)
!                                         t (interactive-p)))))))))
  ;;; Bindings for mouse commands.

News, entertainment and everything you care about at Live.com. Get it now!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]