Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs is it possible to get the action of C-x C- - (reduce buffer font size) in emacs lisp?

Tags:

emacs

elisp

I'd like to reduce the default font size for a buffer using Emacs lisp.

At the moment I am running a process based buffer as a small emacs-lisp based application, I want the font size to reduce in the same way as C-x C-- does, when the app creates it's buffer.

The app has it's own major mode, so should I just set a custom basic face instead?

(note: I tried doing C-x ESC ESC but it showed the command executed before C-x C-- instead.)

like image 280
ocodo Avatar asked Dec 13 '22 18:12

ocodo


2 Answers

Thanks to dmckee, Help does of course tell me the command that C-x C-- executes...

The lisp to reduce is...

(text-scale-adjust -1)

to enlarge...

(text-scale-adjust 1)

to reset to default...

(text-scale-adjust 0)

Emacs also provides (which FYI text-scale-adjust wraps):

(text-scale-increase INC)  
;;INC is number of steps to increase

(text-scale-decrease DEC) 
;;DEC is number of steps to decrease
like image 178
ocodo Avatar answered Apr 06 '23 00:04

ocodo


In general C-h k [key combination] will tell you what a particular key combination is bound to. My emacs has C-x C--, undefined, but it is version 22.3.1. Perhaps you are using version 23.

like image 25
dmckee --- ex-moderator kitten Avatar answered Apr 06 '23 01:04

dmckee --- ex-moderator kitten