unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
blob ec62a9cbd9a85873b0e9bae28546af3682b5c463 2691 bytes (raw)
name: lisp/toggle-light-dark-theme.el 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
 
;;; toggle-light-dark-theme.el -- Toggle dark and light theme  -*- lexical-binding: t -*-
;;
;; Copyright (C) 2020 Free Software Foundation, Inc.
;;
;; Author: Caio Henrique <caio.hcs0@gmail.com>
;; Maintainer: emacs-devel@gnu.org
;; Keywords: faces
;; Package: emacs

;; This file is part of GNU Emacs.

;; GNU Emacs 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.

;; GNU Emacs 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 GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; This file provides a function to toggle between a light and a dark
;; theme, the two themes can be specified with customize-option, the
;; function is added to the menu bar.

;;; Code:

(defgroup toggle-light-dark-theme nil
  "Toggle light dark theme"
  :group 'faces)

(defun toggle-light-dark-theme--custom-choices (theme)
  "Used to create the choice widget options of the
toggle-light-dark-theme custom variables."
  `(const :tag ,(symbol-name theme) ,theme))

(defcustom toggle-light-dark-theme-light-theme 'modus-operandi
  "The light theme used by the function `toggle-light-dark-theme'."
  :group 'toggle-light-dark-theme
  :type `(choice ,@(mapcar #'toggle-light-dark-theme--custom-choices
			   (custom-available-themes))))

(defcustom toggle-light-dark-theme-dark-theme 'tango-dark
  "The dark theme used by the function `toggle-light-dark-theme'."
  :group 'toggle-light-dark-theme
  :type `(choice ,@(mapcar #'toggle-light-dark-theme--custom-choices
			   (custom-available-themes))))

(defvar toggle-light-dark-theme--current-theme 'light)

;;;###autoload
(defun toggle-light-dark-theme ()
  "Disables all custom enabled themes and then toggles between a
light and a dark theme, which are the values of the variables
`toggle-light-dark-theme-light-theme' and
`toggle-light-dark-theme-dark-theme'."
  (interactive)
  (mapc #'disable-theme custom-enabled-themes)
  (cond ((eq toggle-light-dark-theme--current-theme 'light)
	 (load-theme toggle-light-dark-theme-dark-theme)
	 (setq toggle-light-dark-theme--current-theme 'dark))
	(t
	 (load-theme toggle-light-dark-theme-light-theme)
	 (setq toggle-light-dark-theme--current-theme 'light))))

(provide 'toggle-light-dark-theme)

;;; toggle-light-dark-theme.el ends here

debug log:

solving 29966c7c9b ...
found 29966c7c9b in https://yhetil.org/emacs-devel/871rj30vzq.fsf@gmail.com/

applying [1/1] https://yhetil.org/emacs-devel/871rj30vzq.fsf@gmail.com/
diff --git a/lisp/toggle-light-dark-theme.el b/lisp/toggle-light-dark-theme.el
new file mode 100644
index 0000000000..29966c7c9b

Checking patch lisp/toggle-light-dark-theme.el...
Applied patch lisp/toggle-light-dark-theme.el cleanly.

index at:
100644 ec62a9cbd9a85873b0e9bae28546af3682b5c463	lisp/toggle-light-dark-theme.el

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).