unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* A suggestion on `x-select-font'
@ 2008-06-24  2:48 Herbert Euler
  2008-06-24  7:27 ` Herbert Euler
  0 siblings, 1 reply; 5+ messages in thread
From: Herbert Euler @ 2008-06-24  2:48 UTC (permalink / raw)
  To: emacs-devel


Currently, in the popped dialog, the pre-chosen family is always the
family of the font of the current selected frame.  I suggest that if
buffer-face-mode is enabled for a buffer, set the family to the family
of the buffer's font, as this is what most other application does.

Regards,
Guanpeng Xu
_________________________________________________________________
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE




^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: A suggestion on `x-select-font'
  2008-06-24  2:48 A suggestion on `x-select-font' Herbert Euler
@ 2008-06-24  7:27 ` Herbert Euler
  2008-06-27  8:50   ` Herbert Euler
  0 siblings, 1 reply; 5+ messages in thread
From: Herbert Euler @ 2008-06-24  7:27 UTC (permalink / raw)
  To: emacs-devel


> if buffer-face-mode is enabled for a buffer,

Sorry this is not accurate.  Perhaps a more accurate description is
"if `face-remapping-alist' for a buffer is non-nil".

Regards,
Guanpeng Xu
_________________________________________________________________
Connect to the next generation of MSN Messenger 
http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline



^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: A suggestion on `x-select-font'
  2008-06-24  7:27 ` Herbert Euler
@ 2008-06-27  8:50   ` Herbert Euler
  2008-06-27  9:16     ` Jason Rumney
  0 siblings, 1 reply; 5+ messages in thread
From: Herbert Euler @ 2008-06-27  8:50 UTC (permalink / raw)
  To: emacs-devel


[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.

Regards,
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 ****
  	      (choice
  	       ;; 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))))))))
  
  \f
  ;;; Bindings for mouse commands.
--- 2527,2554 ----
  	      (choice
  	       ;; 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)))))))))
  
  \f
  ;;; Bindings for mouse commands.

_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A suggestion on `x-select-font'
  2008-06-27  8:50   ` Herbert Euler
@ 2008-06-27  9:16     ` Jason Rumney
  2008-06-27 10:52       ` Herbert Euler
  0 siblings, 1 reply; 5+ messages in thread
From: Jason Rumney @ 2008-06-27  9:16 UTC (permalink / raw)
  To: Herbert Euler; +Cc: emacs-devel

Herbert Euler wrote:

> 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:

These problems might be avoided by making x-select-font take the default
selection as an argument. Actually I suggest the following signature:

(defun x-select-font (&optional frame default-font must-match)

Where default font is a font-spec/entity/object to use as the initial
selection, and must-match is a font-spec for filtering the list of
available fonts (eg by specifiying charset, fixed width fonts only,
bold, italic etc).





^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: A suggestion on `x-select-font'
  2008-06-27  9:16     ` Jason Rumney
@ 2008-06-27 10:52       ` Herbert Euler
  0 siblings, 0 replies; 5+ messages in thread
From: Herbert Euler @ 2008-06-27 10:52 UTC (permalink / raw)
  To: Jason Rumney; +Cc: emacs-devel


>> 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:
> 
> These problems might be avoided by making x-select-font take the default
> selection as an argument. Actually I suggest the following signature:
> 
> (defun x-select-font (&optional frame default-font must-match)
> 
> Where default font is a font-spec/entity/object to use as the initial
> selection, and must-match is a font-spec for filtering the list of
> available fonts (eg by specifiying charset, fixed width fonts only,
> bold, italic etc).

Ah, that's a better idea.  But instead of having to be only a
font-spec, I think it might make sense if must-match can be also a
function, which returns a list of fonts when called with no argument.
Is this worthy implementing?

Regards,
Guanpeng Xu
_________________________________________________________________
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-06-27 10:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-24  2:48 A suggestion on `x-select-font' Herbert Euler
2008-06-24  7:27 ` Herbert Euler
2008-06-27  8:50   ` Herbert Euler
2008-06-27  9:16     ` Jason Rumney
2008-06-27 10:52       ` Herbert Euler

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).