[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ampc back on elpa?
From: |
Cédric Chépied |
Subject: |
Re: ampc back on elpa? |
Date: |
Fri, 10 Jun 2016 15:25:46 +0200 |
User-agent: |
Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (Gojō) APEL/10.8 EasyPG/1.0.0 Emacs/25.1.50 (x86_64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) |
On Wed, 25 May 2016 10:32:26 +0200,
Stefan Monnier wrote:
> You'd have to check the VCS history for that.
>
> Maybe your code was actually in GNU ELPA (i.e. maybe I just messed up the
> restore, bringing back to life an older revision than the latest).
I adapted my code to the elpa ampc version. Patch follows. I'm not a skilled
lisp developer, feel free to comment.
Regards,
--
Cédric Chépied
<address@hidden>
>From b5345c09de79e4ab1698be713562a339f38836a4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Ch=C3=A9pied?= <address@hidden>
Date: Fri, 10 Jun 2016 15:04:38 +0200
Subject: [PATCH] ampc: add search function
---
packages/ampc/ampc.el | 57 +++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 53 insertions(+), 4 deletions(-)
diff --git a/packages/ampc/ampc.el b/packages/ampc/ampc.el
index 7a28bc7..30f7aa1 100644
--- a/packages/ampc/ampc.el
+++ b/packages/ampc/ampc.el
@@ -76,11 +76,11 @@
;; selected window for its window setup, customise `ampc-use-full-frame' to a
;; non-nil value.
;;
-;; ampc offers three independent views which expose different parts of the user
+;; ampc offers independent views which expose different parts of the user
;; interface. The current playlist view, the default view at startup, may be
;; accessed using the `J' key (that is `S-j'). The playlist view may be
;; accessed using the `K' key. The outputs view may be accessed by pressing
-;; `L'.
+;; `L'. The search view may be accessed using the `F' key (find).
;;; *** current playlist view
;; The playlist view looks like this:
@@ -521,7 +521,11 @@ modified."
(pl-prop '(:properties (("Title" :min 15 :max 40)
("Artist" :min 15 :max 40)
("Album" :min 15 :max 40)
- ("Time" :width 6)))))
+ ("Time" :width 6))))
+ (search-view '(1.0 search :properties (("Track" :title "#" :width 4)
+ ("Title" :min 15 :max 40)
+ ("Artist" :min 15 :max 40)
+ ("Album" :min 15 :max 40)))))
`((tagger
horizontal
(0.65 files-list
@@ -569,6 +573,13 @@ modified."
(0.4 playlist ,@pl-prop)
(1.0 playlists)))
,rs_b)
+ ("Search view"
+ ,(kbd "F")
+ horizontal
+ (0.4 vertical
+ (6 status)
+ (1.0 current-playlist ,@pl-prop))
+ ,search-view)
("Outputs view"
,(kbd "L")
outputs :properties (("outputname" :title "Name" :min 10 :max 30)
@@ -696,6 +707,14 @@ modified."
(define-key map (kbd "<mouse-3>") 'ampc-mouse-align-point)
map))
+(defvar ampc-search-mode-map
+ (let ((map (make-sparse-keymap)))
+ (suppress-keymap map)
+ (define-key map (kbd "a") 'ampc-add)
+ (define-key map (kbd "<down-mouse-3>") 'ampc-mouse-add)
+ (define-key map (kbd "<mouse-3>") 'ampc-mouse-align-point)
+ map))
+
(defvar ampc-outputs-mode-map
(let ((map (make-sparse-keymap)))
(suppress-keymap map)
@@ -732,6 +751,10 @@ modified."
(define-key map (kbd "C-c C-t") 'ampc-tagger-dired)
map))
+(defvar ampc-search-keywords
+ nil
+ "Ampc last search performed")
+
;;; **** menu
(easy-menu-define nil ampc-mode-map nil
`("ampc"
@@ -952,6 +975,7 @@ modified."
do (goto-char next)))))
(defmacro ampc-iterate-source-output (delimiter bindings pad-data &rest body)
+ "delimiter = what delimit command results in mpd response"
(declare (indent 2) (debug t))
`(let ((output-buffer (current-buffer))
(tags (cl-loop for (tag . props) in
@@ -985,6 +1009,8 @@ modified."
(define-derived-mode ampc-tag-song-mode ampc-item-mode "ampc-ts")
+(define-derived-mode ampc-search-mode ampc-item-mode "ampc-search")
+
(define-derived-mode ampc-current-playlist-mode ampc-playlist-mode "ampc-cpl"
(setq font-lock-defaults `(((ampc-find-current-song
(1 'ampc-current-song-mark-face)
@@ -1311,6 +1337,8 @@ modified."
((current-playlist playlist outputs))
(playlists
(ampc-update-playlist))
+ (search
+ (message "Don't know what to do here"))
((song tag)
(cl-loop
for w in
@@ -1507,6 +1535,14 @@ modified."
(ampc-send-command 'currentsong))
(playlists
(ampc-send-command 'listplaylists))
+ (search
+ (if (active-minibuffer-window) ;can't find a better
way to check minibuffer
+ (when ampc-search-keywords
+ (ampc-send-command 'search nil "any"
(ampc-quote ampc-search-keywords)))
+ (let ((search (read-from-minibuffer "Keywords: ")))
+ (unless (string= "" search)
+ (setq ampc-search-keywords search)
+ (ampc-send-command 'search nil "any"
(ampc-quote search))))))
(current-playlist
(ampc-send-command 'playlistinfo))))))
(ampc-send-command 'status)
@@ -1983,6 +2019,17 @@ modified."
(defun ampc-handle-update ()
(message "Database update started"))
+(defun ampc-handle-search ()
+ (ampc-fill-skeleton 'search
+ (ampc-iterate-source-output
+ "file"
+ (file)
+ (cl-loop for (tag . tag-regexp) in tags
+ collect (ampc-clean-tag tag (ampc-extract tag-regexp)))
+ `(,file)
+ )))
+
+
(defun ampc-handle-command (status)
(cond
((eq status 'error)
@@ -2018,7 +2065,9 @@ modified."
(listallinfo
(ampc-handle-listallinfo))
(outputs
- (ampc-fill-outputs))))
+ (ampc-fill-outputs))
+ (search
+ (ampc-handle-search))))
(unless ampc-outstanding-commands
(ampc-update)))))
--
2.8.3
- Re: ampc back on elpa?,
Cédric Chépied <=