forked from mpdel/mpdel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mpdel-tablist.el
153 lines (109 loc) · 4.79 KB
/
mpdel-tablist.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
;;; mpdel-tablist.el --- Support representing MPD entities in tablists -*- lexical-binding: t; -*-
;; Copyright (C) 2018-2023 Damien Cassou
;; Author: Damien Cassou <[email protected]>
;; Keywords: multimedia
;; Url: https://github.com/mpdel/mpdel
;; Package-requires: ((emacs "25.1"))
;; Version: 2.1.0
;; 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 <https://www.gnu.org/licenses/>.
;;; Commentary:
;; This file provides some common ground for all MPDel
;; user-interfaces.
;;; Code:
(require 'libmpdel)
(require 'navigel)
(require 'mpdel-core)
;;; Customization
(defgroup mpdel-tablist nil
"Display and manipulate MPD through tablists."
:group 'libmpdel)
(defface mpdel-tablist-song-name-face
'((t . (:inherit default)))
"Face for song names in playlist.")
(defface mpdel-tablist-track-face
'((t . (:inherit default)))
"Face for track numbers in playlist.")
(defface mpdel-tablist-album-face
'((t . (:inherit default)))
"Face for album names in playlist.")
(defface mpdel-tablist-disk-face
'((t . (:inherit default)))
"Face for disk numbers in playlist.")
(defface mpdel-tablist-date-face
'((t . (:inherit default)))
"Face for dates in playlist.")
(defface mpdel-tablist-artist-face
'((t . (:inherit default)))
"Face for artist names in playlist.")
;;; `navigel' major-mode configuration
(navigel-method mpdel navigel-entity-tablist-mode ((_entity (eql artists)))
(mpdel-tablist-mode))
(navigel-method mpdel navigel-entity-tablist-mode ((_entity (eql albums)))
(mpdel-tablist-mode))
(navigel-method mpdel navigel-entity-tablist-mode ((_entity libmpdel-search-criteria))
(mpdel-tablist-mode))
(navigel-method mpdel navigel-entity-tablist-mode ((_entity libmpdel-filter))
(mpdel-tablist-mode))
(navigel-method mpdel navigel-entity-tablist-mode ((_entity libmpdel-artist))
(mpdel-tablist-mode))
(navigel-method mpdel navigel-entity-tablist-mode ((_entity libmpdel-album))
(mpdel-tablist-mode))
;;; `navigel' tabulated list configuration
(defun mpdel-tablist--album-format ()
"Return `tabulated-list-format' value for albums."
(vector (list "Name" 40 t)
(list "Artist" 0 t)))
(defun mpdel-tablist--song-format ()
"Return `tabulated-list-format' value for songs."
(vector (list "Title" 30 t)
(list "#" 6 nil)
(list "Album" 30 t)
(list "Disk" 4 t)
(list "Date" 5 t)
(list "Artist" 0 t)))
(navigel-method mpdel navigel-entity-to-columns ((entity libmpdel-album))
(vector (libmpdel-entity-name entity)
(libmpdel-artist-name entity)))
(navigel-method mpdel navigel-entity-to-columns ((song libmpdel-song))
(vector
(propertize (or (libmpdel-entity-name song) "") 'face 'mpdel-tablist-song-name-face)
(propertize (or (libmpdel-song-track song) "") 'face 'mpdel-tablist-track-face)
(propertize (or (libmpdel-album-name song) "") 'face 'mpdel-tablist-album-face)
(propertize (or (libmpdel-song-disc song) "") 'face 'mpdel-tablist-disk-face)
(propertize (or (libmpdel-entity-date song) "") 'face 'mpdel-tablist-date-face)
(propertize (or (libmpdel-artist-name song) "") 'face 'mpdel-tablist-artist-face)))
(navigel-method mpdel navigel-tablist-format ((_entity libmpdel-artist))
(mpdel-tablist--album-format))
(navigel-method mpdel navigel-tablist-format ((_entity libmpdel-album))
(mpdel-tablist--song-format))
(navigel-method mpdel navigel-tablist-format ((_entity libmpdel-search-criteria))
(mpdel-tablist--song-format))
(navigel-method mpdel navigel-tablist-format ((_entity libmpdel-filter))
(mpdel-tablist--song-format))
(navigel-method mpdel navigel-tablist-format ((_entity (eql current-playlist)))
(mpdel-tablist--song-format))
(navigel-method mpdel navigel-tablist-format ((_entity libmpdel-stored-playlist))
(mpdel-tablist--song-format))
;;; Major-mode
(defvar mpdel-tablist-mode-map
(let ((map (make-sparse-keymap)))
;; inherit from both `mpdel-core-map' and
;; `navigel-tablist-mode-map':
(set-keymap-parent
map
(make-composed-keymap mpdel-core-map navigel-tablist-mode-map))
(define-key map (kbd "k") #'tablist-do-delete)
map)
"Keybindings for `mpdel-core-tablist-mode'.")
(define-derived-mode mpdel-tablist-mode navigel-tablist-mode "MPDel Tablist")
(provide 'mpdel-tablist)
;;; mpdel-tablist.el ends here