-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsvg-mode-line-themes.el
91 lines (79 loc) · 3.12 KB
/
svg-mode-line-themes.el
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
;;; svg-mode-line-themes.el --- SVG-based themes for mode-line
;;; Version: 0.1.3
;;; Package-Requires: ((xmlgen "0.4"))
;;; Author: sabof
;;; URL: https://github.com/sabof/svg-mode-line-themes
;;; Commentary:
;; The project is hosted at https://github.com/sabof/svg-mode-line-themes
;; The latest version, and all the relevant information can be found there.
;;; License:
;; This file is NOT part of GNU Emacs.
;;
;; 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 2, 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 ; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Code:
(require 'nadvice nil t)
(require 'svg-mode-line-themes-core)
(require 'svg-mode-line-themes-widgets)
(require 'svg-mode-line-themes-diesel)
(require 'svg-mode-line-themes-bio-diesel)
(require 'svg-mode-line-themes-nasa)
(require 'svg-mode-line-themes-black-crystal)
(when (and (default-value 'mode-line-format)
(not (assoc 'default smt/themes)))
(setq smt/themes
(acons 'default (default-value 'mode-line-format)
smt/themes)))
(setq smt/current-theme 'diesel)
;;;###autoload
(defun* smt/next-theme ()
(interactive)
(assert (> (length smt/themes) 1))
(let* (( position (position smt/current-theme smt/themes :key 'car))
( next-theme
(or (car (nth (1+ position) smt/themes))
(car (nth 0 smt/themes)))))
(setq smt/current-theme next-theme)
(when (eq 'archetype smt/current-theme)
(smt/next-theme)
(return-from smt/next-theme))
(force-mode-line-update)
(message "Current mode-line theme: %s" next-theme)))
;;;###autoload
(defun smt/set-theme (theme)
(interactive
(list (intern (completing-read
"Set mode-line theme to: "
(mapcar 'symbol-name (remove 'archetype (mapcar 'car smt/themes))) nil t))))
(setq smt/current-theme theme)
(force-mode-line-update))
;;;###autoload
(defun* smt/enable (&optional use-header-line)
(unless (image-type-available-p 'svg)
(display-warning 'svg-mode-line-themes "SVG support is not available")
(return-from smt/enable))
(set-default (if use-header-line
'header-line-format
'mode-line-format)
'(:eval (smt/modeline-format)))
(if (and (boundp 'pre-redisplay-function)
(fboundp 'add-function))
(add-function :before
pre-redisplay-function
'smt/register-user-location)
(add-hook 'post-command-hook 'smt/register-user-location))
(force-mode-line-update))
(provide 'svg-mode-line-themes)
;;; svg-mode-line-themes.el ends here