diff options
-rw-r--r-- | count.el | 42 |
1 files changed, 34 insertions, 8 deletions
@@ -27,20 +27,26 @@ (defvar counting-buffer-name "*Count*" "The name of the buffer within which to count.") -(defvar count-mode-value 0 +(defvar counting-font-step 10 + "The proportion by which the counting value font size is +increased.") + +(defvar-local count-mode-value 0 "The value of the current count.") (define-derived-mode count-mode special-mode "Count" "Major mode for counting." - (setq text-scale-mode-amount 10) - (text-scale-mode 1) (count-refresh) (set 'cursor-type nil)) -(define-key count-mode-map (vector 'up) #'count-up) -(define-key count-mode-map (vector 'down) #'count-down) -(define-key count-mode-map (vector ?r) #'count-refresh) -(define-key count-mode-map (vector ?o) #'count-reset) +(let ((map count-mode-map)) + (define-key map (vector 'up) #'count-up) + (define-key map (vector 'down) #'count-down) + (define-key map (vector ?r) #'count-refresh) + (define-key map (vector ?o) #'count-reset) + (define-key map (vector ?=) #'count-enlarge) + (define-key map (vector ?-) #'count-shrink)) + (defun count-start-or-switch () "Start counting in an old buffer if possible." @@ -65,7 +71,9 @@ (let* ((number-str (format "%d" number)) (number-str-width (* (string-pixel-width number-str) ;; account for the remapping - (expt 1.2 10))) + (expt + text-scale-mode-step + counting-font-step))) (space-width (string-pixel-width (string #x20))) (padding (/ (- (window-pixel-width) (* 2 space-width) number-str-width) @@ -85,6 +93,8 @@ (cond ((derived-mode-p 'count-mode) (let ((inhibit-read-only t)) + (setq text-scale-mode-amount counting-font-step) + (text-scale-mode 1) (delete-region (point-min) (point-max)) (insert (count-make-pad-string count-mode-value)))) ((user-error @@ -110,5 +120,21 @@ (setq count-mode-value 0) (count-refresh)) +(defun count-enlarge (&optional arg) + "Increase the font size by ARG steps. +The size of one step is defined by `text-scale-mode-step'." + (interactive "p") + (setq arg (cond ((null arg) 1) ((prefix-numeric-value arg)))) + (setq counting-font-step (+ counting-font-step arg)) + (count-refresh)) + +(defun count-shrink (&optional arg) + "Decrease the font size by ARG steps. +The size of one step is defined by `text-scale-mode-step'." + (interactive "p") + (setq arg (cond ((null arg) 1) ((prefix-numeric-value arg)))) + (setq counting-font-step (- counting-font-step arg)) + (count-refresh)) + (provide 'count) ;;; count.el ends here |