-
Notifications
You must be signed in to change notification settings - Fork 1
Home
D Groth edited this page Apr 6, 2023
·
1 revision
Here we share some examples for better use of MicroEmacs.
Many editors offer the possibility to increase or decrease the fontsize of your text editor by using Ctrl-Plus or Ctrl-Minus.
Let's implement this using the MicroEmacs macro language:
First we need a list of fonts through which we cycle, usually ordered by size. I create my one as described in this Gist.
set-variable %fonts-ubuntu "|-freetype-ubuntu mono-medium-r-normal--14-100-100-100-p-61-iso10646-1|"
set-variable %fonts-ubuntu &linsert %fonts-ubuntu 1 "-freetype-ubuntu mono-medium-r-normal--17-120-100-100-p-74-iso10646-1"
set-variable %fonts-ubuntu &linsert %fonts-ubuntu 2 "-freetype-ubuntu mono-medium-r-normal--19-140-100-100-p-82-iso10646-1"
set-variable %fonts-ubuntu &linsert %fonts-ubuntu 3 "-freetype-ubuntu mono-medium-r-normal--22-160-100-100-p-94-iso10646-1"
set-variable %fonts-ubuntu &linsert %fonts-ubuntu 4 "-freetype-ubuntu mono-medium-r-normal--25-180-100-100-p-107-iso10646-1"
set-variable %fonts-ubuntu &linsert %fonts-ubuntu 5 "-freetype-ubuntu mono-medium-r-normal--28-200-100-100-p-119-iso10646-1"
set-variable %fonts-ubuntu &linsert %fonts-ubuntu 6 "-freetype-ubuntu mono-medium-r-normal--30-220-100-100-p-131-iso10646-1"
set-variable %fonts-ubuntu &linsert %fonts-ubuntu 7 "-freetype-ubuntu mono-medium-r-normal--33-240-100-100-p-140-iso10646-1"
; the current index
set-variable %font-index 2
Now we need two functions which are bind to Control-Plus and Control-Minus to increment or decrement the current font index and pick the font to configure MicroEmacs.
define-macro font-inc
!if &equal %font-index 7
500 ml-write "Largest font!"
!else
set-variable %font-index &inc %font-index 1
set-variable #l1 &lget %fonts-ubuntu %font-index
change-font #l1
!endif
!emacro
define-macro font-dec
!if &equal %font-index 1
500 ml-write "Smallest font!"
!else
set-variable %font-index &dec %font-index 1
set-variable #l1 &lget %fonts-ubuntu %font-index
change-font #l1
!endif
!emacro
global-bind-key "font-inc" "C-+"
global-bind-key "font-dec" "C--"
; just to set the first font
font-inc
Voila, now we can cycle through different font sizes by pressing Ctrl-Plus
and Ctrl-Minus
.