about summary refs log tree commit diff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/emacs/config/bindings.el5
-rw-r--r--tools/emacs/config/functions.el32
2 files changed, 33 insertions, 4 deletions
diff --git a/tools/emacs/config/bindings.el b/tools/emacs/config/bindings.el
index a45c8d4707..e77af33895 100644
--- a/tools/emacs/config/bindings.el
+++ b/tools/emacs/config/bindings.el
@@ -1,6 +1,7 @@
 ;; Font size
-(define-key global-map (kbd "C-+") 'text-scale-increase)
-(define-key global-map (kbd "C--") 'text-scale-decrease)
+(define-key global-map (kbd "C-=") 'increase-default-text-scale) ;; '=' because there lies '+'
+(define-key global-map (kbd "C--") 'decrease-default-text-scale)
+(define-key global-map (kbd "C-x C-0") 'set-default-text-scale)
 
 ;; What does <tab> do? Well, it depends ...
 (define-key prog-mode-map (kbd "<tab>") #'company-indent-or-complete-common)
diff --git a/tools/emacs/config/functions.el b/tools/emacs/config/functions.el
index 4c8aa162cf..193e1a7412 100644
--- a/tools/emacs/config/functions.el
+++ b/tools/emacs/config/functions.el
@@ -1,5 +1,3 @@
-(require 's)
-
 (defun load-file-if-exists (filename)
   (if (file-exists-p filename)
       (load filename)))
@@ -219,4 +217,34 @@
                       (getenv "USER"))
                     todo))))
 
+;; Custom text scale adjustment functions that operate on the entire instance
+(defun modify-text-scale (factor)
+  (set-face-attribute 'default nil
+                      :height (+ (* factor 5) (face-attribute 'default :height))))
+
+(defun increase-default-text-scale (prefix)
+  "Increase default text scale in all Emacs frames, or just the
+  current frame if PREFIX is set."
+
+  (interactive "P")
+  (if prefix (text-scale-increase 1)
+    (modify-text-scale 1)))
+
+(defun decrease-default-text-scale (prefix)
+  "Increase default text scale in all Emacs frames, or just the
+  current frame if PREFIX is set."
+
+  (interactive "P")
+  (if prefix (text-scale-decrease 1)
+    (modify-text-scale -1)))
+
+(defun set-default-text-scale (prefix &optional to)
+  "Set the default text scale to the specified value, or the
+  default. Restores current frame's text scale only, if PREFIX is
+  set."
+
+  (interactive "P")
+  (if prefix (text-scale-adjust 0)
+    (set-face-attribute 'default nil :height (or to 120))))
+
 (provide 'functions)