Emacs user interface for Music Player Daemon (https://www.musicpd.org/), a flexible, powerful, server-side application for playing music.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

před 4 měsíci
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. ;;; mpdel-tablist.el --- Support representing MPD entities in tablists -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 2018-2019 Damien Cassou
  3. ;; Author: Damien Cassou <damien@cassou.me>
  4. ;; Keywords: multimedia
  5. ;; Url: https://gitlab.petton.fr/mpdel/mpdel
  6. ;; Package-requires: ((emacs "25.1"))
  7. ;; Version: 1.0.0
  8. ;; This program is free software; you can redistribute it and/or modify
  9. ;; it under the terms of the GNU General Public License as published by
  10. ;; the Free Software Foundation, either version 3 of the License, or
  11. ;; (at your option) any later version.
  12. ;; This program is distributed in the hope that it will be useful,
  13. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;; GNU General Public License for more details.
  16. ;; You should have received a copy of the GNU General Public License
  17. ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. ;;; Commentary:
  19. ;; This file provides some common ground for all MPDel
  20. ;; user-interfaces.
  21. ;;; Code:
  22. (require 'libmpdel)
  23. (require 'navigel)
  24. (require 'mpdel-core)
  25. ;;; Customization
  26. (defgroup mpdel-tablist nil
  27. "Display and manipulate MPD through tablists."
  28. :group 'libmpdel)
  29. (defface mpdel-tablist-song-name-face
  30. '((t . (:inherit default)))
  31. "Face for song names in playlist.")
  32. (defface mpdel-tablist-track-face
  33. '((t . (:inherit default)))
  34. "Face for track numbers in playlist.")
  35. (defface mpdel-tablist-album-face
  36. '((t . (:inherit default)))
  37. "Face for album names in playlist.")
  38. (defface mpdel-tablist-disk-face
  39. '((t . (:inherit default)))
  40. "Face for disk numbers in playlist.")
  41. (defface mpdel-tablist-date-face
  42. '((t . (:inherit default)))
  43. "Face for dates in playlist.")
  44. (defface mpdel-tablist-artist-face
  45. '((t . (:inherit default)))
  46. "Face for artist names in playlist.")
  47. ;;; `navigel' major-mode configuration
  48. (navigel-method mpdel navigel-entity-tablist-mode ((_entity (eql artists)))
  49. (mpdel-tablist-mode))
  50. (navigel-method mpdel navigel-entity-tablist-mode ((_entity (eql albums)))
  51. (mpdel-tablist-mode))
  52. (navigel-method mpdel navigel-entity-tablist-mode ((_entity libmpdel-search-criteria))
  53. (mpdel-tablist-mode))
  54. (navigel-method mpdel navigel-entity-tablist-mode ((_entity libmpdel-filter))
  55. (mpdel-tablist-mode))
  56. (navigel-method mpdel navigel-entity-tablist-mode ((_entity libmpdel-artist))
  57. (mpdel-tablist-mode))
  58. (navigel-method mpdel navigel-entity-tablist-mode ((_entity libmpdel-album))
  59. (mpdel-tablist-mode))
  60. ;;; `navigel' tabulated list configuration
  61. (defun mpdel-tablist--album-format ()
  62. "Return `tabulated-list-format' value for albums."
  63. (vector (list "Name" 40 t)
  64. (list "Artist" 0 t)))
  65. (defun mpdel-tablist--song-format ()
  66. "Return `tabulated-list-format' value for songs."
  67. (vector (list "Title" 30 t)
  68. (list "#" 6 nil)
  69. (list "Album" 30 t)
  70. (list "Disk" 4 t)
  71. (list "Date" 5 t)
  72. (list "Artist" 0 t)))
  73. (navigel-method mpdel navigel-entity-to-columns ((entity libmpdel-album))
  74. (vector (libmpdel-entity-name entity)
  75. (libmpdel-artist-name entity)))
  76. (navigel-method mpdel navigel-entity-to-columns ((song libmpdel-song))
  77. (vector
  78. (propertize (or (libmpdel-entity-name song) "") 'face 'mpdel-tablist-song-name-face)
  79. (propertize (or (libmpdel-song-track song) "") 'face 'mpdel-tablist-track-face)
  80. (propertize (or (libmpdel-album-name song) "") 'face 'mpdel-tablist-album-face)
  81. (propertize (or (libmpdel-song-disc song) "") 'face 'mpdel-tablist-disk-face)
  82. (propertize (or (libmpdel-entity-date song) "") 'face 'mpdel-tablist-date-face)
  83. (propertize (or (libmpdel-artist-name song) "") 'face 'mpdel-tablist-artist-face)))
  84. (navigel-method mpdel navigel-tablist-format ((_entity libmpdel-artist))
  85. (mpdel-tablist--album-format))
  86. (navigel-method mpdel navigel-tablist-format ((_entity libmpdel-album))
  87. (mpdel-tablist--song-format))
  88. (navigel-method mpdel navigel-tablist-format ((_entity libmpdel-search-criteria))
  89. (mpdel-tablist--song-format))
  90. (navigel-method mpdel navigel-tablist-format ((_entity libmpdel-filter))
  91. (mpdel-tablist--song-format))
  92. (navigel-method mpdel navigel-tablist-format ((_entity (eql current-playlist)))
  93. (mpdel-tablist--song-format))
  94. (navigel-method mpdel navigel-tablist-format ((_entity libmpdel-stored-playlist))
  95. (mpdel-tablist--song-format))
  96. ;;; Major-mode
  97. (defvar mpdel-tablist-mode-map
  98. (let ((map (make-sparse-keymap)))
  99. ;; inherit from both `mpdel-core-map' and
  100. ;; `navigel-tablist-mode-map':
  101. (set-keymap-parent
  102. map
  103. (make-composed-keymap mpdel-core-map navigel-tablist-mode-map))
  104. (define-key map (kbd "k") #'tablist-do-delete)
  105. map)
  106. "Keybindings for `mpdel-core-tablist-mode'.")
  107. (define-derived-mode mpdel-tablist-mode navigel-tablist-mode "MPDel Tablist")
  108. (provide 'mpdel-tablist)
  109. ;;; mpdel-tablist.el ends here