Last active
May 30, 2017 05:27
-
-
Save ShingoFukuyama/6a02a4cd5b80a4cf3477 to your computer and use it in GitHub Desktop.
emacs font change with overlay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; require ov.el (ver 1.0.5) | |
;; https://github.com/ShingoFukuyama/ov.el | |
(require 'ov) | |
(defvar my-ov-font-size nil) | |
(defun my-ov-font-size-change (ratio &optional update-all-buffer) | |
(let ((ov-sticky-rear t) | |
(ov-sticky-front t)) | |
(if update-all-buffer | |
(mapc (lambda (buffer) | |
(with-current-buffer (get-buffer buffer) | |
(ov-clear 'my-ov-font-size) | |
(ov-set (ov (point-min) (point-max)) | |
'face `(:height ,ratio) 'my-ov-font-size t))) | |
(buffer-list)) | |
(ov-clear 'my-ov-font-size) | |
(ov-set (ov (point-min) (point-max)) 'face `(:height ,ratio) 'my-ov-font-size t)))) | |
(defun my-ov-font-size-zoom-in (&optional prefix) | |
(interactive "P") | |
(unless my-ov-font-size | |
(setq my-ov-font-size (or (ignore-errors (face-attribute 'default :height)) 120))) | |
(my-ov-font-size-change | |
(setq my-ov-font-size (+ my-ov-font-size 10)) | |
(if prefix t nil))) | |
(defun my-ov-font-size-zoom-out (&optional prefix) | |
(interactive "P") | |
(unless my-ov-font-size | |
(setq my-ov-font-size (or (ignore-errors (face-attribute 'default :height)) 120))) | |
(my-ov-font-size-change | |
(setq my-ov-font-size (- my-ov-font-size 10)) | |
(if prefix t nil))) | |
(defun my-ov-font-size-zoom-for-new-buffer () | |
(unless my-ov-font-size | |
(setq my-ov-font-size (or (ignore-errors (face-attribute 'default :height)) 120))) | |
(if my-ov-font-size | |
(my-ov-font-size-change my-ov-font-size))) | |
(defun my-ov-font-size-zoom-reset () | |
(interactive) | |
(setq my-ov-font-size (or (ignore-errors (face-attribute 'default :height)) 120)) | |
(mapc (lambda (buffer) | |
(with-current-buffer (get-buffer buffer) | |
(ov-clear 'my-ov-font-size))) | |
(buffer-list))) | |
(add-hook 'after-change-major-mode-hook 'my-ov-font-size-zoom-for-new-buffer) | |
(global-set-key (kbd "C-c z i") 'my-ov-font-size-zoom-in) | |
(global-set-key (kbd "C-c z o") 'my-ov-font-size-zoom-out) | |
(global-set-key (kbd "C-c z r") 'my-ov-font-size-zoom-reset) | |
;; `C-u C-c z i' : change font size with all buffers | |
;; `C-u C-c z o' : change font size with all buffers | |
Author
ShingoFukuyama
commented
Jul 13, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment