feat(emacs.d): Add functions & bindings to manage global font size
This makes it possible to quickly adjust the size of text in all frames using one keyboard shortcut. Each of these functions understands a prefix argument to mean "please only operate on the current buffer", hence the following bindings and effects: Global: * `C-=`: Increase the global font size (chosen because `+` lies on the `=` key) * `C--`: Decrease the global font size * `C-x C-0`: Restore the global default font size Local: * `C-u C-=`: Increase the local font size * `C-u C--`: Decrease the local font size * `C-u C-x C-0`: Restore the local default font size
This commit is contained in:
		
							parent
							
								
									caf23a9e2a
								
							
						
					
					
						commit
						be28071e56
					
				
					 2 changed files with 33 additions and 4 deletions
				
			
		|  | @ -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) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue