emacs-devel
[Top][All Lists]
Advanced

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

Re: Change `set-frame-font' to allow keeping of frame size


From: Ehud Karni
Subject: Re: Change `set-frame-font' to allow keeping of frame size
Date: Tue, 8 Apr 2003 22:16:59 +0300

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, 07 Apr 2003 22:30:28 -0400, Richard Stallman <address@hidden> wrote:
> 
>     If optional KEEP-SIZE is non nil the current frame size (in pixels)
>     is kept by adjusting the frame `height' and `width' parameters"
> 
> It should say explicitly what the default behavior is, rather than
> making the user try to guess.  Also, it needs to say "non-nil",
> not "non nil".
> 
> Aside from that, I think the optional feature is ok, but asking a question
> is obnoxious.  Would you please make it test the prefix arg instead?

Here is the new definition:

(defun set-frame-font (font-name &optional keep-size)
  "Set the font of the selected frame to FONT-NAME.
When called interactively, prompt for the name of the font to use.
To get the frame's current default font, use `frame-parameters'.

The default behavior is to keep the numbers of lines and columns in
the frame, thus may change its pixel size. If optional KEEP-SIZE is
non-nil (interactively, prefix argument) the current frame size (in
pixels) is kept by adjusting the numbers of the lines and columns."
  (interactive
   (let* ((completion-ignore-case t)
          (font (completing-read "Font name: "
                         (mapcar #'list
                                 ;; x-list-fonts will fail with an error
                                 ;; if this frame doesn't support fonts.
                                 (x-list-fonts "*" nil (selected-frame))))))
     (list font current-prefix-arg)))
  (let (fht fwd)
    (if keep-size
        (setq fht (* (frame-parameter nil 'height) (frame-char-height))
              fwd (* (frame-parameter nil 'width)  (frame-char-width))))
    (modify-frame-parameters (selected-frame)
                             (list (cons 'font font-name)))
    (if keep-size
        (modify-frame-parameters
         (selected-frame)
         (list (cons 'height (round fht (frame-char-height)))
               (cons 'width (round fwd (frame-char-width)))))))
  (run-hooks 'after-setting-font-hook 'after-setting-font-hooks))


Ehud.


- -- 
 Ehud Karni           Tel: +972-3-7966-561  /"\
 Mivtach - Simon      Fax: +972-3-7966-667  \ /  ASCII Ribbon Campaign
 Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
 http://www.mvs.co.il  FAX:  1-815-5509341  / \
 mailto:address@hidden                  Better  Safe  Than  Sorry
-----BEGIN PGP SIGNATURE-----
Comment: use http://www.keyserver.net/ to get my key (and others)

iD8DBQE+kyArLFvTvpjqOY0RApQlAJwIBVHXgaTcwDX1MVzuYukwDQ0lNQCdFRUT
XtIplxLWM5eGZnxshLMQ1jw=
=lGa4
-----END PGP SIGNATURE-----




reply via email to

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