emacs-devel
[Top][All Lists]
Advanced

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

Re: set font size with ctrl-mouse wheel?


From: Peter Brett
Subject: Re: set font size with ctrl-mouse wheel?
Date: Thu, 30 Jul 2009 15:02:44 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Neal Becker <address@hidden> writes:

> It is becoming fairly standard to use ctrl+mouse-wheel to increase/decrease 
> font size.

It is?  A quick straw poll of editors and other dev tools:

gvim             n
gedit            n
nedit            n
Bluefish         n
cssed                  y
geany                  y
quanta           n
SciTE                  y
Eclipse          n
xml-copy-editor        y
Kmail            n
Kile             n   
GNU TeXMACS      n

...indicates that by "fairly standard" you mean "some applications do it".

> It'd be great if emacs could do this.

It can.  This should get you started. [*]

(defvar text-height-scale-factor 0.2)

(defun scale-text-height (s)
  "Scale the current text height"
  (set-face-attribute 'default nil :height
    (truncate (* s (face-attribute 'default :height)))))
(defun reduce-text-height ()
  "Reduce the text height"
  (interactive)
  (scale-text-height (- 1.0 text-height-scale-factor)))
(defun increase-text-height ()
  "Increase the text height"
  (interactive)
  (scale-text-height (+ 1.0 text-height-scale-factor)))

(global-set-key [C-mouse-4] 'reduce-text-height)
(global-set-key [C-mouse-5] 'increase-text-height)


Best wishes,

                                          Peter

[*] Someone will be along shortly to explain how I could have achieved
    this in less than half as much ELisp.

-- 
Peter Brett <address@hidden>
Remote Sensing Research Group
Surrey Space Centre





reply via email to

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