Fix broken scale font micro-state in Emacs 24.4
This commit is contained in:
parent
d60dffda1c
commit
c58dcfc5b5
2 changed files with 31 additions and 30 deletions
|
@ -459,51 +459,52 @@ kill internal buffers too."
|
|||
(add-to-list 'default-frame-alist (cons 'font fontstr))
|
||||
(set-default-font fontstr)))
|
||||
|
||||
(defun spacemacs/scale-font-size (direction)
|
||||
"Set a temporary overlay map to easily change the font size.
|
||||
DIRECTION is any number where:
|
||||
- a positive number increase the size of the font
|
||||
- a negative number decrease the size of the font
|
||||
- 0 reset the font size to its default value"
|
||||
(interactive)
|
||||
(defun spacemacs/scale-font-size-overlay-map ()
|
||||
"Set a temporary overlay map to easily change the font size."
|
||||
(set-temporary-overlay-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(define-key map (kbd "+")
|
||||
'(lambda () (interactive)
|
||||
(spacemacs/scale-up-or-down-font-size 1)))
|
||||
(define-key map (kbd "-")
|
||||
'(lambda () (interactive)
|
||||
(spacemacs/scale-up-or-down-font-size -1)))
|
||||
(define-key map (kbd "=")
|
||||
'(lambda () (interactive) (spacemacs/reset-font-size)))
|
||||
map) t)
|
||||
(if (eq direction 0)
|
||||
(spacemacs/reset-font-size)
|
||||
(spacemacs/scale-up-or-down-font-size direction)))
|
||||
(define-key map (kbd "+") 'spacemacs/scale-up-font)
|
||||
(define-key map (kbd "-") 'spacemacs/scale-down-font)
|
||||
(define-key map (kbd "=") 'spacemacs/reset-font-size)
|
||||
map) t))
|
||||
|
||||
(defun spacemacs/font-scaling-micro-state-doc ()
|
||||
"Display a short documentation in the mini buffer."
|
||||
(message "Scale Font micro-state:
|
||||
(echo "Scale Font micro-state:
|
||||
+ to scale up
|
||||
- to scale down
|
||||
= to reset
|
||||
Press any other key to exit."))
|
||||
|
||||
(spacemacs/font-scaling-micro-state-doc)
|
||||
|
||||
(defun spacemacs/scale-up-or-down-font-size (direction)
|
||||
"Scale the font. If DIRECTION is positive or zero the font is scaled up,
|
||||
otherwise it is scaled down."
|
||||
(interactive)
|
||||
(let ((scale 0.5))
|
||||
(if (< direction 0)
|
||||
(text-scale-decrease scale)
|
||||
(text-scale-increase scale))
|
||||
(spacemacs/font-scaling-micro-state-doc)))
|
||||
(if (eq direction 0)
|
||||
(text-scale-set 0)
|
||||
(if (< direction 0)
|
||||
(text-scale-decrease scale)
|
||||
(text-scale-increase scale))))
|
||||
(spacemacs/scale-font-size-overlay-map)
|
||||
(spacemacs/font-scaling-micro-state-doc))
|
||||
|
||||
(defun spacemacs/scale-up-font ()
|
||||
"Scale up the font."
|
||||
(interactive)
|
||||
(spacemacs/scale-up-or-down-font-size 1))
|
||||
|
||||
(defun spacemacs/scale-down-font ()
|
||||
"Scale up the font."
|
||||
(interactive)
|
||||
(spacemacs/scale-up-or-down-font-size -1))
|
||||
|
||||
(defun spacemacs/reset-font-size ()
|
||||
"Reset the font size (apply a scale of 0)."
|
||||
"Reset the font size."
|
||||
(interactive)
|
||||
(text-scale-set 0)
|
||||
(spacemacs/font-scaling-micro-state-doc))
|
||||
(spacemacs/scale-up-or-down-font-size 0))
|
||||
|
||||
(defmacro spacemacs//diminish (mode lighter)
|
||||
"Diminish MODE name in mode line to LIGHTER."
|
||||
|
|
|
@ -143,9 +143,9 @@
|
|||
"ww" 'other-window)
|
||||
;; text -----------------------------------------------------------------------
|
||||
(evil-leader/set-key
|
||||
"x=" (lambda () (interactive) (spacemacs/scale-font-size 0))
|
||||
"x+" (lambda () (interactive) (spacemacs/scale-font-size 1))
|
||||
"x-" (lambda () (interactive) (spacemacs/scale-font-size -1))
|
||||
"x=" 'spacemacs/reset-font-size
|
||||
"x+" 'spacemacs/scale-up-font
|
||||
"x-" 'spacemacs/scale-down-font
|
||||
"xdw" 'delete-trailing-whitespace
|
||||
"xtc" 'transpose-chars
|
||||
"xtl" 'transpose-lines
|
||||
|
|
Reference in a new issue