From 431750aa12aa2bf0eacb9457459966c2cf235ec8 Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Tue, 5 Jul 2022 15:29:45 +0200 Subject: [PATCH] [Emacs] Round transparency parameter to a nicer value --- org/config/emacs.org | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/org/config/emacs.org b/org/config/emacs.org index 614d18e..3fd7104 100644 --- a/org/config/emacs.org +++ b/org/config/emacs.org @@ -1088,13 +1088,18 @@ windows. This one allows me to manipulate my Emacs frames’ background transparency. #+begin_src emacs-lisp +(defun my/transparency-round (val) + "Round VAL to the nearest tenth of an integer." + (/ (round (* 10 val)) 10.0)) + (defun my/increase-frame-alpha-background () "Increase current frame’s alpha background." (interactive) (set-frame-parameter nil 'alpha-background - (min 1.0 - (+ (frame-parameter nil 'alpha-background) 0.1))) + (my/transparency-round + (min 1.0 + (+ (frame-parameter nil 'alpha-background) 0.1)))) (message "%s" (frame-parameter nil 'alpha-background))) (defun my/decrease-frame-alpha-background () @@ -1102,8 +1107,9 @@ transparency. (interactive) (set-frame-parameter nil 'alpha-background - (max 0.0 - (- (frame-parameter nil 'alpha-background) 0.1))) + (my/transparency-round + (max 0.0 + (- (frame-parameter nil 'alpha-background) 0.1)))) (message "%s" (frame-parameter nil 'alpha-background))) (defhydra my/modify-frame-alpha-background ()