From 3c7624d8f553ad910cb8380c353253c8b19e4c02 Mon Sep 17 00:00:00 2001 From: Lars Tveito Date: Wed, 16 Mar 2016 00:11:47 +0100 Subject: [PATCH] Rewrote global-scale --- init.org | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/init.org b/init.org index 1965827..7829f2e 100644 --- a/init.org +++ b/init.org @@ -891,22 +891,30 @@ generalized (or maybe be substituted by a package if it's out there). #+BEGIN_SRC emacs-lisp - (defun global-scale-default () - (interactive) - (set-face-attribute 'default nil :font "Inconsolata-14")) + (lexical-let* ((default (face-attribute 'default :height)) + (size default)) + + (defun global-scale-default () + (interactive) + (setq size default) + (global-scale-internal size)) - (lexical-let ((size 14)) (defun global-scale-up () (interactive) - (set-face-attribute - 'default nil - :font (concat "Inconsolata-" (number-to-string (incf size))))) + (global-scale-internal (incf size 20))) (defun global-scale-down () (interactive) - (set-face-attribute - 'default nil - :font (concat "Inconsolata-" (number-to-string (decf size)))))) + (global-scale-internal (decf size 20))) + + (defun global-scale-internal (arg) + (set-face-attribute 'default nil :height arg) + (set-temporary-overlay-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "C-=") 'global-scale-up) + (define-key map (kbd "C-+") 'global-scale-up) + (define-key map (kbd "C--") 'global-scale-down) + (define-key map (kbd "C-0") 'global-scale-default) map)))) #+END_SRC * Mode specific