Initial commit

This commit is contained in:
2026-03-26 01:01:07 -07:00
commit 972ac68fba

88
transparency-el.el Normal file
View File

@@ -0,0 +1,88 @@
;;; transparency.el --- a viewing mode for books and novels. -*- lexical-binding: t; -*-
;; Copyright (C) 2019 Robert Rose
;; Author: Robert Rose <overclucker@gmail.com>
;; Keywords: lisp eww novel book
;; Version: 0.0.1
;; Package-Requires ((emacs "24"))
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Toggles transparency on and off with `transparency-toggle'. Customize how it looks in `transparency'
;; custom group.
;;; Code:
(defvar transparency-state nil
"Reflects the current state of transparency.")
(defvar transparency-original-faces '()
"Stores original faces while transparency is enable.")
(defgroup transparency nil
"Custom group for transparency package.")
(defcustom transparency-alpha 50
"The level of transparency used."
:type 'integer
:group 'transparency)
(defcustom transparency-faces
'((default :background "#444")
(default :foreground "grey75")
(fringe :background "#444")
(mode-line :background "#444")
(mode-line :foreground "grey75")
(mode-line :box nil)
(mode-line-inactive :background "#444")
(mode-line-inactive :foreground "grey50")
(mode-line-inactive :box nil))
"Faces used when transparency is enabled."
:type '(alist face)
:group 'transparency)
(setq alpha-prop (if (>= emacs-major-version 29)
'alpha-background
'alpha))
(defun transparency-modface (FPV)
"Sets new and returns old FPV"
(let* ((face (pop FPV))
(prop (pop FPV))
(val (pop FPV))
(prev (face-attribute face prop)))
(set-face-attribute face nil prop val)
`(,face ,prop ,prev)))
(defun transparency-toggle ()
"better alpha toggle transparency"
(interactive)
(if transparency-state
(progn
(set-frame-parameter nil alpha-prop 100)
;; (set-frame-parameter nil 'alpha-background 100)
(mapcar 'transparency-modface transparency-original-faces)
(setq transparency-state nil))
(set-frame-parameter nil alpha-prop transparency-alpha)
(setq transparency-original-faces
(mapcar 'transparency-modface transparency-faces))
(setq transparency-state t)))
(provide 'transparency)
;;; transparency.el ends here