fordon_greeman / voidfiles

Branch: 2079ec5
Switch branches/tags
main
theidioticdev add emacs 2079ec5 23h ago
86 lines · 2.6 KB Raw Blame History
1 ;; emms-mode-line-icon.el --- show an icon in the Emacs mode-line -*- lexical-binding: t; -*-
2
3 ;; Copyright (C) 2006-2021 Free Software Foundation, Inc.
4
5 ;; Version: 1.1
6 ;; Keywords: emms
7
8 ;; Author: Daniel Brockman <daniel@brockman.se>
9 ;; Maintainer: Lucas Bonnet <lucas@rincevent.net>
10
11 ;; This file is part of EMMS.
12
13 ;; EMMS is free software; you can redistribute it and/or
14 ;; modify it under the terms of the GNU General Public License
15 ;; as published by the Free Software Foundation; either version 3
16 ;; of the License, or (at your option) any later version.
17
18 ;; EMMS is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with EMMS; if not, write to the Free Software Foundation,
25 ;; Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
26
27 ;; Commentary:
28
29 ;; This EMMS extension shows an icon in the mode-line next to the
30 ;; info-tag.
31
32 ;; Code:
33
34 (require 'emms-mode-line)
35
36
37 (defvar emms-mode-line-icon-enabled-p t
38 "Disable icon display when NIL.")
39
40 (defvar emms-mode-line-icon-color "black"
41 "Color of the little icon displayed in the mode-line.")
42
43 (defvar emms-mode-line-icon-before-format ""
44 "String to put before the icon, in the mode-line.
45 For example, if you want to have something like :
46 \[ <icon> Foo - The Foo Song ]
47 You should set it to \"[\", and set emms-mode-line-format to \"%s ]\"")
48
49 (defun emms-mode-line-icon-generate (color)
50 `(image :type xpm :ascent center :data ,(concat "/* XPM */
51 static char *note[] = {
52 /* width height num_colors chars_per_pixel */
53 \" 10 11 2 1\",
54 /* colors */
55 \". c " color "\",
56 \"# c None s None\",
57 /* pixels */
58 \"###...####\",
59 \"###.#...##\",
60 \"###.###...\",
61 \"###.#####.\",
62 \"###.#####.\",
63 \"#...#####.\",
64 \"....#####.\",
65 \"#..######.\",
66 \"#######...\",
67 \"######....\",
68 \"#######..#\"};")))
69
70 (defun emms-mode-line-icon-function ()
71 (if emms-mode-line-icon-enabled-p
72 (concat " "
73 emms-mode-line-icon-before-format
74 (emms-propertize "NP:" 'display
75 (emms-mode-line-icon-generate
76 emms-mode-line-icon-color))
77 (emms-mode-line-playlist-current))
78 (emms-mode-line-playlist-current)))
79
80 (setq emms-mode-line-mode-line-function #'emms-mode-line-icon-function)
81
82 ;; This is needed for text properties to work in the mode line.
83 (put 'emms-mode-line-string 'risky-local-variable t)
84
85 (provide 'emms-mode-line-icon)
86 ;;; emms-mode-line-icone.el ends here