branch: externals/ampc commit c2eb1d02c88b144cd303a06a1fa948399c61be12 Author: Christopher Schmidt <christop...@ch.ristopher.com> Commit: Chong Yidong <c...@gnu.org>
* ampc: Update version to 0.1.1. --- ampc.el | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 80 insertions(+), 22 deletions(-) diff --git a/ampc.el b/ampc.el index a35025077b..c376cb71a4 100644 --- a/ampc.el +++ b/ampc.el @@ -4,7 +4,7 @@ ;; Author: Christopher Schmidt <christop...@ch.ristopher.com> ;; Maintainer: Christopher Schmidt <christop...@ch.ristopher.com> -;; Version: 0.1 +;; Version: 0.1.1 ;; Created: 2011-12-06 ;; Keywords: mpc ;; Compatibility: GNU Emacs: 24.x @@ -47,7 +47,7 @@ ;; To invoke ampc, call the command `ampc', e.g. via M-x ampc RET. Once ampc is ;; connected to the daemon, it creates its window configuration in the selected ;; window. To make ampc use the full frame rather than the selected window, -;; customize `ampc-use-full-frame'. +;; customise `ampc-use-full-frame'. ;; ;; ampc offers three independent views which expose different parts of the user ;; interface. The current playlist view, the default view at startup, may be @@ -96,6 +96,14 @@ ;; five. To add the selected song to the playlist, press `a' (ampc-add). This ;; key binding works in tag browsers as well. Calling ampc-add in a tag browser ;; adds all songs filtered up to the selected browser to the playlist. +;; +;; The tag browsers of the (default) current playlist view (accessed via `J') +;; are `Genre' (window 3), `Artist' (window 4) and `Album' (window 5). The key +;; `M' may be used to fire up a slightly modified current playlist view. There +;; is no difference to the default current playlist view other than that the tag +;; browsers filter to `Genre' (window 3), `Album' (window 4) and `Artist' +;; (window 5). Metaphorically speaking, the order of the `grep' filters defined +;; by the tag browsers is different. ;;; *** playlist view ;; The playlist view resembles the current playlist view. The window, which @@ -106,6 +114,9 @@ ;; current playlist now modify the selected (stored) playlist. The list of ;; stored playlists is the only view in ampc that may have only one marked ;; entry. +;; +;; Again, the key `;' may be used to setup a playlist view with a different +;; order of tag browsers. ;;; *** outputs view ;; The outputs view contains a single list which shows the configured outputs of @@ -113,8 +124,9 @@ ;; (ampc-toggle-output-enabled). ;;; *** global keys -;; ampc defines the following global keys, which may be used in every window -;; associated with ampc: +;; Aside from `J', `M', `K', `;' and `L', which may be used to select different +;; views, ampc defines the following global keys, which may be used in every +;; window associated with ampc: ;; ;; `k' (ampc-toggle-play): Toggle play state. If mpd does not play a song ;; already, start playing the song at point if the current buffer is the @@ -146,6 +158,20 @@ ;; ;; `T' (ampc-trigger-update): Trigger a database update. ;; `q' (ampc-quit): Quit ampc. +;; +;; The keymap of ampc is designed to fit the QWERTY United States keyboard +;; layout. If you use another keyboard layout, feel free to modify +;; ampc-mode-map. For example, I use a regular QWERTZ German keyboard (layout), +;; so I modify ampc-mode-map in my init.el like this: +;; +;; (require 'ampc) +;; (flet ((substitute-ampc-key +;; (from to) +;; (define-key ampc-mode-map to (lookup-key ampc-mode-map from)) +;; (define-key ampc-mode-map from nil))) +;; (substitute-ampc-key (kbd "y") (kbd "z")) +;; (substitute-ampc-key (kbd "M-y") (kbd "M-z")) +;; (substitute-ampc-key (kbd "<") (kbd ";"))) ;;; Code: ;;; * code @@ -200,24 +226,37 @@ This hook is called as the first thing when ampc is started." ;;; *** internal variables (defvar ampc-views - (let ((rs '(1.0 vertical - (0.7 horizontal - (0.33 tag :tag "Genre" :id 1) - (0.33 tag :tag "Artist" :id 2) - (1.0 tag :tag "Album" :id 3)) - (1.0 song :properties (("Track" :title "#") - ("Title" :offset 6) - ("Time" :offset 26))))) - (pl-prop '(("Title") - ("Artist" :offset 20) - ("Album" :offset 40) - ("Time" :offset 60)))) + (let* ((songs '(1.0 song :properties (("Track" :title "#") + ("Title" :offset 6) + ("Time" :offset 26)))) + (rs_a `(1.0 vertical + (0.7 horizontal + (0.33 tag :tag "Genre" :id 1) + (0.33 tag :tag "Artist" :id 2) + (1.0 tag :tag "Album" :id 3)) + ,songs)) + (rs_b `(1.0 vertical + (0.7 horizontal + (0.33 tag :tag "Genre" :id 1) + (0.33 tag :tag "Album" :id 2) + (1.0 tag :tag "Artist" :id 3)) + ,songs)) + (pl-prop '(("Title") + ("Artist" :offset 20) + ("Album" :offset 40) + ("Time" :offset 60)))) `((,(kbd "J") horizontal (0.4 vertical (6 status) (1.0 current-playlist :properties ,pl-prop)) - ,rs) + ,rs_a) + (,(kbd "M") + horizontal + (0.4 vertical + (6 status) + (1.0 current-playlist :properties ,pl-prop)) + ,rs_b) (,(kbd "K") horizontal (0.4 vertical @@ -225,7 +264,15 @@ This hook is called as the first thing when ampc is started." (1.0 vertical (0.8 playlist :properties ,pl-prop) (1.0 playlists))) - ,rs) + ,rs_a) + (,(kbd "<") + horizontal + (0.4 vertical + (6 status) + (1.0 vertical + (0.8 playlist :properties ,pl-prop) + (1.0 playlists))) + ,rs_b) (,(kbd "L") outputs :properties (("outputname" :title "Name") ("outputenabled" :title "Enabled" :offset 10)))))) @@ -246,6 +293,7 @@ This hook is called as the first thing when ampc is started." (make-variable-buffer-local 'ampc-dirty) (defvar ampc-internal-db nil) +(defvar ampc-internal-db-format nil) (defvar ampc-status nil) ;;; *** mode maps @@ -716,7 +764,7 @@ This hook is called as the first thing when ampc is started." (playlist (ampc-update-playlist)) ((tag song) - (if ampc-internal-db + (if (equal ampc-internal-db-format (ampc-tags)) (ampc-fill-tag-song) (ampc-send-command 'listallinfo))) (status @@ -1046,7 +1094,7 @@ This hook is called as the first thing when ampc is started." when (string-match "^changed: \\(.*\\)$" subsystem) do (case (intern (match-string 1 subsystem)) (database - (setf ampc-internal-db nil) + (setf ampc-internal-db-format nil) (ampc-set-dirty 'tag t) (ampc-set-dirty 'song t)) (output @@ -1077,13 +1125,23 @@ This hook is called as the first thing when ampc is started." "ampc supports MPD 0.15.0 and later")))) (defun ampc-fill-internal-db () - (setf ampc-internal-db (ampc-create-tree)) + (setf ampc-internal-db (ampc-create-tree) + ampc-internal-db-format (ampc-tags)) (loop while (search-forward-regexp "^file: " nil t) do (save-restriction (ampc-narrow-entry) (ampc-fill-internal-db-entry))) (ampc-fill-tag-song)) +(defun ampc-tags () + (loop for w in (ampc-windows) + for tag = (with-current-buffer (window-buffer w) + (when (eq (car ampc-type) 'tag) + (plist-get (cdr ampc-type) :tag))) + when tag + collect tag + end)) + (defun ampc-fill-internal-db-entry () (loop with data-buffer = (current-buffer) @@ -1612,7 +1670,7 @@ ampc is connected to." (setf ampc-connection nil ampc-buffers nil ampc-all-buffers nil - ampc-internal-db nil + ampc-internal-db-format nil ampc-working-timer nil ampc-outstanding-commands nil ampc-status nil)