* Re: ampc back on elpa?
2016-05-14 16:31 ampc back on elpa? Cédric Chépied
@ 2016-05-14 14:48 ` Stefan Monnier
2016-05-25 6:07 ` Cédric Chépied
0 siblings, 1 reply; 16+ messages in thread
From: Stefan Monnier @ 2016-05-14 14:48 UTC (permalink / raw)
To: emacs-devel
> I don't know if this is the good mailing list for what I have to say but I
> wasn't able to find an elpa mailing list, only emacs-elpa-diffs.
This is the right place.
> My local version seems more recent than elpa's one. I have a better
> status window with progress bar.
IIRC the Christopher Schmidt decided to take ampc out of GNU ELPA
because he wanted to incorporate code from contributors who don't want
to sign the copyright paperwork we require for GNU ELPA.
So the "more recent" changes may not be usable as-is for GNU ELPA.
> I don't know how elpa is managed and what must do a maintainer,
(Some of) the answers should be in elpa.git's README file.
You could start by sending us the changes you've written. If you intend
to maintain the package (or if your changes total more than about 20
lines's worth of code), you'll also want to sign the
copyright paperwork. For that, fill the form below and email it
as instructed.
Stefan
Please email the following information to assign@gnu.org, and we
will send you the assignment form for your past and future changes.
Please use your full legal name (in ASCII characters) as the subject
line of the message.
----------------------------------------------------------------------
REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES
[What is the name of the program or package you're contributing to?]
Emacs
[Did you copy any files or text written by someone else in these changes?
Even if that material is free software, we need to know about it.]
[Do you have an employer who might have a basis to claim to own
your changes? Do you attend a school which might make such a claim?]
[For the copyright registration, what country are you a citizen of?]
[What year were you born?]
[Please write your email address here.]
[Please write your postal address here.]
[Which files have you changed so far, and which new files have you written
so far?]
^ permalink raw reply [flat|nested] 16+ messages in thread
* ampc back on elpa?
@ 2016-05-14 16:31 Cédric Chépied
2016-05-14 14:48 ` Stefan Monnier
0 siblings, 1 reply; 16+ messages in thread
From: Cédric Chépied @ 2016-05-14 16:31 UTC (permalink / raw)
To: emacs-devel
Hi,
I don't know if this is the good mailing list for what I have to say but I
wasn't able to find an elpa mailing list, only emacs-elpa-diffs.
I use ampc for a while, it was available in package list long ago. Then it
disappeared and I was not able to find sources. Hopefully I got a local version.
I recently updated my packages and saw ampc again. I installed it and saw this
in el file:
;; Comment: On Jan 2016, I couldn't get hold of Christopher Schmidt
;; nor could I find ampc anywhere, so I re-instated GNU ELPA's old version
;; and marked it as "maintainerless".
My local version seems more recent than elpa's one. I have a better status
window with progress bar.
I also added a search function because I couldn't find a better way to search a
song than marking all albums and perform a 'C-s' search in songs window.
I have tried to adapt my code so it can be byte-compiled with emacs -Q thanks to
this commit (bac85c0136ab02f79f8060ade4b63250a4ca0e15):
http://git.savannah.gnu.org/cgit/emacs/elpa.git/commit/packages/ampc/ampc.el?id=bac85c0136ab02f79f8060ade4b63250a4ca0e15
There is still a warning which could be fixed by this commit
http://git.savannah.gnu.org/cgit/emacs/elpa.git/commit/packages/ampc/ampc.el?id=bf9f1e11e6eddb61245b6be53b5f2dd53828adbd
But I don't know what ampc-highlight-current-song-mode is so I didn't try to
apply the patch.
My code is available here:
https://github.com/chep/ampc
I don't know how elpa is managed and what must do a maintainer, I don't know
ampc code either and there is no comment at all. In addition I'm not a lisp
expert. If you want to use/modify/delete my code do it. If you want me to become
the maintainer, tell me what I am supposed to do.
Regards,
--
Cédric Chépied
<cedric.chepied@gmail.com>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: ampc back on elpa?
2016-05-14 14:48 ` Stefan Monnier
@ 2016-05-25 6:07 ` Cédric Chépied
2016-05-25 8:32 ` Stefan Monnier
0 siblings, 1 reply; 16+ messages in thread
From: Cédric Chépied @ 2016-05-25 6:07 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
On Sat, 14 May 2016 16:48:01 +0200,
Stefan Monnier wrote:
> IIRC the Christopher Schmidt decided to take ampc out of GNU ELPA
> because he wanted to incorporate code from contributors who don't want
> to sign the copyright paperwork we require for GNU ELPA.
>
> So the "more recent" changes may not be usable as-is for GNU ELPA.
How can I know if they are?
The header does not contain any information about other contributors and
copyright is given to the FSF:
;;; ampc.el --- Asynchronous Music Player Controller -*- lexical-binding: t -*-
;; Copyright (C) 2011-2012 Free Software Foundation, Inc.
;; Author: Christopher Schmidt <christopher@ch.ristopher.com>
;; Maintainer: Christopher Schmidt <christopher@ch.ristopher.com>
;; Version: 0.2
;; Created: 2011-12-06
;; Keywords: ampc, mpc, mpd
;; Compatibility: GNU Emacs: 24.x
> > I don't know how elpa is managed and what must do a maintainer,
>
> (Some of) the answers should be in elpa.git's README file.
Thanks.
--
Cédric Chépied
<cedric.chepied@gmail.com>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: ampc back on elpa?
2016-05-25 6:07 ` Cédric Chépied
@ 2016-05-25 8:32 ` Stefan Monnier
2016-06-10 13:25 ` Cédric Chépied
0 siblings, 1 reply; 16+ messages in thread
From: Stefan Monnier @ 2016-05-25 8:32 UTC (permalink / raw)
To: Cédric Chépied; +Cc: emacs-devel
> How can I know if they are?
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).
Stefan
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: ampc back on elpa?
2016-05-25 8:32 ` Stefan Monnier
@ 2016-06-10 13:25 ` Cédric Chépied
2016-06-10 15:52 ` Stefan Monnier
2016-06-13 12:45 ` Stefan Monnier
0 siblings, 2 replies; 16+ messages in thread
From: Cédric Chépied @ 2016-06-10 13:25 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel, Cédric Chépied
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
<cedric.chepied@gmail.com>
From b5345c09de79e4ab1698be713562a339f38836a4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Ch=C3=A9pied?= <cedric.chepied@areva.com>
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
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: ampc back on elpa?
2016-06-10 13:25 ` Cédric Chépied
@ 2016-06-10 15:52 ` Stefan Monnier
2016-06-13 7:23 ` Cédric Chépied
2016-06-13 12:45 ` Stefan Monnier
1 sibling, 1 reply; 16+ messages in thread
From: Stefan Monnier @ 2016-06-10 15:52 UTC (permalink / raw)
To: Cédric Chépied; +Cc: emacs-devel
> I adapted my code to the elpa ampc version. Patch follows. I'm not
> a skilled lisp developer, feel free to comment.
I haven't looked at the code yet, but just to be sure: this patch is
made of code *you* wrote?
Stefan
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: ampc back on elpa?
2016-06-10 15:52 ` Stefan Monnier
@ 2016-06-13 7:23 ` Cédric Chépied
0 siblings, 0 replies; 16+ messages in thread
From: Cédric Chépied @ 2016-06-13 7:23 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel, Cédric Chépied
On Fri, 10 Jun 2016 17:52:44 +0200,
Stefan Monnier wrote:
> I haven't looked at the code yet, but just to be sure: this patch is
> made of code *you* wrote?
Yes, only *my* code.
--
Cédric Chépied
<cedric.chepied@gmail.com>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: ampc back on elpa?
2016-06-10 13:25 ` Cédric Chépied
2016-06-10 15:52 ` Stefan Monnier
@ 2016-06-13 12:45 ` Stefan Monnier
2016-06-15 9:53 ` Cédric Chépied
1 sibling, 1 reply; 16+ messages in thread
From: Stefan Monnier @ 2016-06-13 12:45 UTC (permalink / raw)
To: emacs-devel
> I adapted my code to the elpa ampc version. Patch follows. I'm not a skilled
> lisp developer, feel free to comment.
Looks pretty good, except for one spot that doesn't seem right. See below.
Stefan
> @@ -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)
Indentation looks odd here. Maybe a mix of spaces and tabs?
> (defmacro ampc-iterate-source-output (delimiter bindings pad-data &rest body)
> + "delimiter = what delimit command results in mpd response"
Thank you for helping document the code. Could you add a first line
describing of the general functionality? Also put `delimiter` in
all-caps since that's the convention used in Emacs for function/macro
arguments in docstrings.
> @@ -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)
Can you rewrite it to something like
(search
(unless (active-minibuffer-window)
;; Can't find a better way to check minibuffer
(let ((search (read-from-minibuffer "Keywords: ")))
(setq ampc-search-keywords
(unless (string= "" search) search))))
(when ampc-search-keywords
(ampc-send-command 'search nil "any"
(ampc-quote ampc-search-keywords))))
But in any case, this looks fishy. `ampc-update` doesn't seem like
a good place to have user interaction. Why do you need to
`read-from-minibuffer` *here* (BTW, I recommend you use `read-string`
instead)? I mean, why can't you set ampc-search-keywords elsewhere?
Stefan
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: ampc back on elpa?
2016-06-13 12:45 ` Stefan Monnier
@ 2016-06-15 9:53 ` Cédric Chépied
2016-06-15 13:35 ` Stefan Monnier
0 siblings, 1 reply; 16+ messages in thread
From: Cédric Chépied @ 2016-06-15 9:53 UTC (permalink / raw)
To: emacs-devel
Hi,
I must use gmail webclient :-/ I hope this email and the patch pasted
at the end will be readable.
On Mon, 13 Jun 2016 14:45:16 +0200,
Stefan Monnier wrote:
> > @@ -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)
>
> Indentation looks odd here. Maybe a mix of spaces and tabs?
Only spaces here. One extra space before ,(kbd "F")
Fixed in new patch below. Is that the problem you are talking about?
> > (defmacro ampc-iterate-source-output (delimiter bindings pad-data &rest body)
> > + "delimiter = what delimit command results in mpd response"
>
> Thank you for helping document the code. Could you add a first line
> describing of the general functionality? Also put `delimiter` in
> all-caps since that's the convention used in Emacs for function/macro
> arguments in docstrings.
I'm not documenting the code :-D I was just trying to understand it. I can't
document this macro because I don't really know what it does. I put `delimiter`
in all caps but I can't do more. Should I remove it?
> Can you rewrite it to something like
>
> (search
> (unless (active-minibuffer-window)
> ;; Can't find a better way to check minibuffer
> (let ((search (read-from-minibuffer "Keywords: ")))
> (setq ampc-search-keywords
> (unless (string= "" search) search))))
> (when ampc-search-keywords
> (ampc-send-command 'search nil "any"
> (ampc-quote ampc-search-keywords))))
>
> But in any case, this looks fishy. `ampc-update` doesn't seem like
> a good place to have user interaction. Why do you need to
> `read-from-minibuffer` *here* (BTW, I recommend you use `read-string`
> instead)? I mean, why can't you set ampc-search-keywords elsewhere?
Done. I removed code in ampc-update and added a new function ampc-start-search
binded to the 's' key in search view. No need to check minibuffer, using
read-string and your nice `(setq ampc-search-keywords (unless (string= ""
search) search)))` line.
Regards,
--
Cédric Chépied
<cedric.chepied@gmail.com>
From 64dfb675509d29653f0945abfd0619148deb6a25 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Ch=C3=A9pied?= <cedric.chepied@gmail.com>
Date: Wed, 15 Jun 2016 11:36:52 +0200
Subject: [PATCH] ampc: add search function
---
packages/ampc/ampc.el | 73 +++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 68 insertions(+), 5 deletions(-)
diff --git a/packages/ampc/ampc.el b/packages/ampc/ampc.el
index 7a28bc7..8134c5c 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:
@@ -161,6 +161,11 @@
;; MPD. To toggle the enabled property of the selected outputs, press `a'
;; (ampc-toggle-output-enabled) or `<mouse-3>'.
+;;; *** search view
+;; The search view contains the result of the last performed search. You can
+;; start a new search with the `s' key while in the search view or use M-x
+;; ampc-start-search. Use the `a' key to add a song displayed in result list.
+
;;; ** tagger
;; To start the tagging subsystem, press `I' (ampc-tagger). This key binding
;; works in every buffer associated with ampc. First, the command tries to
@@ -521,7 +526,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 +578,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)
@@ -602,6 +618,7 @@ modified."
(defconst ampc-tagger-version "0.1")
(defconst ampc-tagger-tags '(Title Artist Album Comment Genre Year Track))
+(defconst ampc-buffer-name " *ampc*")
;;; *** mode maps
(defvar ampc-mode-map
@@ -696,6 +713,16 @@ 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 "s") 'ampc-start-search)
+ (define-key map (kbd "<down-mouse-3>") 'ampc-mouse-add)
+ (define-key map (kbd "<mouse-3>") 'ampc-mouse-align-point)
+ map)
+ "Key map for search view")
+
(defvar ampc-outputs-mode-map
(let ((map (make-sparse-keymap)))
(suppress-keymap map)
@@ -732,6 +759,10 @@ modified."
(define-key map (kbd "C-c C-t") 'ampc-tagger-dired)
map))
+(defvar ampc-search-keywords
+ nil
+ "Ampc last performed search")
+
;;; **** menu
(easy-menu-define nil ampc-mode-map nil
`("ampc"
@@ -952,6 +983,7 @@ modified."
do (goto-char next)))))
(defmacro ampc-iterate-source-output (delimiter bindings pad-data &rest body)
+ "DELIMITER is the field that 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 +1017,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 +1345,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 +1543,10 @@ modified."
(ampc-send-command 'currentsong))
(playlists
(ampc-send-command 'listplaylists))
+ (search
+ (when ampc-search-keywords
+ (ampc-send-command 'search nil "any"
+ (ampc-quote
ampc-search-keywords))))
(current-playlist
(ampc-send-command 'playlistinfo))))))
(ampc-send-command 'status)
@@ -1983,6 +2023,27 @@ modified."
(defun ampc-handle-update ()
(message "Database update started"))
+(defun ampc-handle-search ()
+ "Uses mpd search result to fill search view"
+ (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-start-search ()
+ "Ask mpd to search for songs matching keywords"
+ (interactive)
+ (cl-assert (ampc-in-ampc-p))
+ (let ((search (read-string "Keywords: ")))
+ (setq ampc-search-keywords (unless (string= "" search) search))
+ (when ampc-search-keywords
+ (ampc-send-command 'search nil "any"
+ (ampc-quote ampc-search-keywords)))))
+
(defun ampc-handle-command (status)
(cond
((eq status 'error)
@@ -2018,7 +2079,9 @@ modified."
(listallinfo
(ampc-handle-listallinfo))
(outputs
- (ampc-fill-outputs))))
+ (ampc-fill-outputs))
+ (search
+ (ampc-handle-search))))
(unless ampc-outstanding-commands
(ampc-update)))))
@@ -3082,7 +3145,7 @@ default to the ones specified in `ampc-default-server'."
(unless ampc-connection
(let ((connection (open-network-stream "ampc"
(with-current-buffer
- (get-buffer-create " *ampc*")
+ (get-buffer-create
ampc-buffer-name)
(erase-buffer)
(current-buffer))
host
--
2.8.3
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: ampc back on elpa?
2016-06-15 9:53 ` Cédric Chépied
@ 2016-06-15 13:35 ` Stefan Monnier
2016-06-17 16:43 ` Cédric Chépied
0 siblings, 1 reply; 16+ messages in thread
From: Stefan Monnier @ 2016-06-15 13:35 UTC (permalink / raw)
To: emacs-devel
> Only spaces here. One extra space before ,(kbd "F")
> Fixed in new patch below. Is that the problem you are talking about?
No the problem I was talking about was in my head. I just fixed it
(lots more still to go, tho; it's can of hopeless in there, sorry).
> I'm not documenting the code :-D I was just trying to understand it.
I know. That's often the best way to document code.
> I can't document this macro because I don't really know what it does.
Oh well.
> I put `delimiter` in all caps but I can't do more. Should I remove it?
No, no, please don't remove it.
> Done. I removed code in ampc-update and added a new function
> ampc-start-search binded to the 's' key in search view. No need to
> check minibuffer, using read-string and your nice `(setq
> ampc-search-keywords (unless (string= "" search) search)))` line.
Looks good. I was about to install the change into elpa.git but I can't
find your name in the list of people who assigned copyright.
Have you signed the copyright paperwork?
If not, please fill the form below and send it as instructed to the FSF
so they can send you the relevant paperwork to sign.
In the mean time, here's a comment about:
+(defun ampc-start-search ()
+ "Ask mpd to search for songs matching keywords"
+ (interactive)
+ (cl-assert (ampc-in-ampc-p))
+ (let ((search (read-string "Keywords: ")))
This should look more like
(defun ampc-start-search (search)
"Ask mpd to search for songs matching keywords."
(interactive "sKeywords: ")
(cl-assert (ampc-in-ampc-p))
-- Stefan
Please email the following information to assign@gnu.org, and we
will send you the assignment form for your past and future changes.
Please use your full legal name (in ASCII characters) as the subject
line of the message.
----------------------------------------------------------------------
REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES
[What is the name of the program or package you're contributing to?]
Emacs
[Did you copy any files or text written by someone else in these changes?
Even if that material is free software, we need to know about it.]
[Do you have an employer who might have a basis to claim to own
your changes? Do you attend a school which might make such a claim?]
[For the copyright registration, what country are you a citizen of?]
[What year were you born?]
[Please write your email address here.]
[Please write your postal address here.]
[Which files have you changed so far, and which new files have you written
so far?]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: ampc back on elpa?
2016-06-15 13:35 ` Stefan Monnier
@ 2016-06-17 16:43 ` Cédric Chépied
2016-06-17 22:28 ` Stefan Monnier
0 siblings, 1 reply; 16+ messages in thread
From: Cédric Chépied @ 2016-06-17 16:43 UTC (permalink / raw)
To: emacs-devel
On Wed, 15 Jun 2016 15:35:43 +0200,
Stefan Monnier wrote:
> Looks good. I was about to install the change into elpa.git but I can't
> find your name in the list of people who assigned copyright.
> Have you signed the copyright paperwork?
Signed but not sent. I'm too lazy, post office is so far...
I'm sending it tomorrow.
> In the mean time, here's a comment about:
>
> +(defun ampc-start-search ()
> + "Ask mpd to search for songs matching keywords"
> + (interactive)
> + (cl-assert (ampc-in-ampc-p))
> + (let ((search (read-string "Keywords: ")))
>
> This should look more like
>
> (defun ampc-start-search (search)
> "Ask mpd to search for songs matching keywords."
> (interactive "sKeywords: ")
> (cl-assert (ampc-in-ampc-p))
I'm sending a new patch soon for this.
Thanks for the help.
--
Cédric Chépied
<cedric.chepied@gmail.com>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: ampc back on elpa?
2016-06-17 16:43 ` Cédric Chépied
@ 2016-06-17 22:28 ` Stefan Monnier
2016-06-20 11:47 ` Cédric Chépied
0 siblings, 1 reply; 16+ messages in thread
From: Stefan Monnier @ 2016-06-17 22:28 UTC (permalink / raw)
To: emacs-devel
>> Looks good. I was about to install the change into elpa.git but I can't
>> find your name in the list of people who assigned copyright.
>> Have you signed the copyright paperwork?
> Signed but not sent.
Great, thanks.
> I'm too lazy, post office is so far...
I suggest you lobby you local representative to move the post office
closer to your home.
Stefan
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: ampc back on elpa?
2016-06-17 22:28 ` Stefan Monnier
@ 2016-06-20 11:47 ` Cédric Chépied
2016-07-01 11:25 ` Cédric Chépied
0 siblings, 1 reply; 16+ messages in thread
From: Cédric Chépied @ 2016-06-20 11:47 UTC (permalink / raw)
To: emacs-devel
On Sat, 18 Jun 2016 00:28:23 +0200,
Stefan Monnier wrote:
> I suggest you lobby you local representative to move the post office closer to
> your home.
So I need money to corrupt him/her...
Here is my latest patch. I also added a progress bar (in another commit) in the
status window. I did it from scratch so I don't use Christopher Schmidt's
code. I need to test before sending it and I'll probably create a new thread,
the patch here is only for the search view.
--
Cédric Chépied
<cedric.chepied@gmail.com>
From c3870da8fcf453bf603ce339fbb08320af9d844d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Ch=C3=A9pied?= <cedric.chepied@gmail.com>
Date: Wed, 15 Jun 2016 11:36:52 +0200
Subject: [PATCH 1/2] ampc: add search function
---
packages/ampc/ampc.el | 72 +++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 67 insertions(+), 5 deletions(-)
diff --git a/packages/ampc/ampc.el b/packages/ampc/ampc.el
index 7a28bc7..c09323b 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:
@@ -161,6 +161,11 @@
;; MPD. To toggle the enabled property of the selected outputs, press `a'
;; (ampc-toggle-output-enabled) or `<mouse-3>'.
+;;; *** search view
+;; The search view contains the result of the last performed search. You can
+;; start a new search with the `s' key while in the search view or use M-x
+;; ampc-start-search. Use the `a' key to add a song displayed in result list.
+
;;; ** tagger
;; To start the tagging subsystem, press `I' (ampc-tagger). This key binding
;; works in every buffer associated with ampc. First, the command tries to
@@ -521,7 +526,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 +578,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)
@@ -602,6 +618,7 @@ modified."
(defconst ampc-tagger-version "0.1")
(defconst ampc-tagger-tags '(Title Artist Album Comment Genre Year Track))
+(defconst ampc-buffer-name " *ampc*")
;;; *** mode maps
(defvar ampc-mode-map
@@ -696,6 +713,16 @@ 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 "s") 'ampc-start-search)
+ (define-key map (kbd "<down-mouse-3>") 'ampc-mouse-add)
+ (define-key map (kbd "<mouse-3>") 'ampc-mouse-align-point)
+ map)
+ "Key map for search view")
+
(defvar ampc-outputs-mode-map
(let ((map (make-sparse-keymap)))
(suppress-keymap map)
@@ -732,6 +759,10 @@ modified."
(define-key map (kbd "C-c C-t") 'ampc-tagger-dired)
map))
+(defvar ampc-search-keywords
+ nil
+ "Ampc last performed search")
+
;;; **** menu
(easy-menu-define nil ampc-mode-map nil
`("ampc"
@@ -952,6 +983,7 @@ modified."
do (goto-char next)))))
(defmacro ampc-iterate-source-output (delimiter bindings pad-data &rest body)
+ "DELIMITER is the field that 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 +1017,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 +1345,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 +1543,10 @@ modified."
(ampc-send-command 'currentsong))
(playlists
(ampc-send-command 'listplaylists))
+ (search
+ (when ampc-search-keywords
+ (ampc-send-command 'search nil "any"
+ (ampc-quote ampc-search-keywords))))
(current-playlist
(ampc-send-command 'playlistinfo))))))
(ampc-send-command 'status)
@@ -1983,6 +2023,26 @@ modified."
(defun ampc-handle-update ()
(message "Database update started"))
+(defun ampc-handle-search ()
+ "Uses mpd search result to fill search view"
+ (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-start-search (search)
+ "Ask mpd to search for songs matching keywords"
+ (interactive "sKeywords: ")
+ (cl-assert (ampc-in-ampc-p))
+ (setq ampc-search-keywords (unless (string= "" search) search))
+ (when ampc-search-keywords
+ (ampc-send-command 'search nil "any"
+ (ampc-quote ampc-search-keywords))))
+
(defun ampc-handle-command (status)
(cond
((eq status 'error)
@@ -2018,7 +2078,9 @@ modified."
(listallinfo
(ampc-handle-listallinfo))
(outputs
- (ampc-fill-outputs))))
+ (ampc-fill-outputs))
+ (search
+ (ampc-handle-search))))
(unless ampc-outstanding-commands
(ampc-update)))))
@@ -3082,7 +3144,7 @@ default to the ones specified in `ampc-default-server'."
(unless ampc-connection
(let ((connection (open-network-stream "ampc"
(with-current-buffer
- (get-buffer-create " *ampc*")
+ (get-buffer-create ampc-buffer-name)
(erase-buffer)
(current-buffer))
host
--
2.8.3
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: ampc back on elpa?
2016-06-20 11:47 ` Cédric Chépied
@ 2016-07-01 11:25 ` Cédric Chépied
2016-07-27 13:58 ` Cédric Chépied
0 siblings, 1 reply; 16+ messages in thread
From: Cédric Chépied @ 2016-07-01 11:25 UTC (permalink / raw)
To: emacs-devel
Hi Stefan,
Now you should be able to find my name in the list of people who assigned
copyright.
Thanks,
--
Cédric Chépied
<cedric.chepied@gmail.com>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: ampc back on elpa?
2016-07-01 11:25 ` Cédric Chépied
@ 2016-07-27 13:58 ` Cédric Chépied
2016-07-27 14:40 ` Stefan Monnier
0 siblings, 1 reply; 16+ messages in thread
From: Cédric Chépied @ 2016-07-27 13:58 UTC (permalink / raw)
To: emacs-devel
Hi,
Here is a new patch for ampc. It shows a progress bar in the status output. I
don't know if there is something in emacs to display progress bars so I wrote my
own code for this.
--
Cédric Chépied
<cedric.chepied@gmail.com>
From 7279b36094aec5b6ec32a5d57cdf00e29e8476e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Ch=C3=A9pied?= <cedric.chepied@gmail.com>
Date: Fri, 17 Jun 2016 11:18:04 +0200
Subject: [PATCH 2/2] ampc: add current song time in status display
---
packages/ampc/ampc.el | 92 +++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 82 insertions(+), 10 deletions(-)
diff --git a/packages/ampc/ampc.el b/packages/ampc/ampc.el
index c09323b..c133337 100644
--- a/packages/ampc/ampc.el
+++ b/packages/ampc/ampc.el
@@ -548,21 +548,21 @@ modified."
,(kbd "J")
horizontal
(0.4 vertical
- (6 status)
+ (10 status)
(1.0 current-playlist ,@pl-prop))
,rs_a)
("Current playlist view (Genre|Album|Artist)"
,(kbd "M")
horizontal
(0.4 vertical
- (6 status)
+ (10 status)
(1.0 current-playlist ,@pl-prop))
,rs_b)
("Playlist view (Genre|Artist|Album)"
,(kbd "K")
horizontal
(0.4 vertical
- (6 status)
+ (10 status)
(1.0 vertical
(0.4 current-playlist ,@pl-prop)
(0.4 playlist ,@pl-prop)
@@ -572,7 +572,7 @@ modified."
,(kbd "<")
horizontal
(0.4 vertical
- (6 status)
+ (10 status)
(1.0 vertical
(0.4 current-playlist ,@pl-prop)
(0.4 playlist ,@pl-prop)
@@ -582,7 +582,7 @@ modified."
,(kbd "F")
horizontal
(0.4 vertical
- (6 status)
+ (10 status)
(1.0 current-playlist ,@pl-prop))
,search-view)
("Outputs view"
@@ -610,6 +610,7 @@ modified."
(defvar ampc-internal-db nil)
(defvar ampc-status nil)
+(defvar ampc-status-timer nil)
(defvar ampc-tagger-previous-configuration nil)
(defvar ampc-tagger-version-verified nil)
@@ -1860,7 +1861,7 @@ modified."
(erase-buffer)
(funcall (or (plist-get (cadr ampc-type) :filler)
(lambda (_)
- (insert (ampc-status t) "\n")))
+ (insert (ampc-status t (window-width (get-buffer-window))) "\n")))
ampc-status)
(ampc-set-dirty nil)))
@@ -2007,13 +2008,13 @@ modified."
(cl-callf2 assq-delete-all s ampc-status))))
(defun ampc-handle-current-song ()
- (ampc-fill-status-var (append ampc-status-tags '("Artist" "Title" "file")))
+ (ampc-fill-status-var (append ampc-status-tags '("Artist" "Title" "file" "Time")))
(ampc-fill-status)
(run-hook-with-args ampc-status-changed-hook ampc-status))
(defun ampc-handle-status ()
(ampc-fill-status-var '("volume" "repeat" "random" "consume" "xfade" "state"
- "song" "playlistlength"))
+ "song" "playlistlength" "elapsed"))
(ampc-with-buffer 'current-playlist
(if (fboundp 'font-lock-flush)
(font-lock-flush)
@@ -2810,7 +2811,70 @@ If ARG is omitted, use the selected entries in the current buffer."
(ampc-with-selection arg
(ampc-add-impl)))
-(defun ampc-status (&optional no-print)
+(defun ampc-restart-status-timer ()
+ (when ampc-status-timer
+ (cancel-timer ampc-status-timer)
+ (setq ampc-status-timer nil))
+ (setq ampc-status-timer
+ (run-at-time
+ nil
+ 0.9
+ (lambda ()
+ (when (ampc-on-p)
+ (ampc-send-command 'status))))))
+
+
+(defun ampc-time-to-progress-bar (elapsed total width)
+ "Creates a progess bar like this: |=========>----|
+ELAPSED is the number of seconds represented by '=' signs
+TOTAL is the number of seconds represented by the entire bar
+WIDTH is the max width of the bar. If < 2, 2 characters will be used anyway"
+ (setq width (- width 2)) ;; 2 characters for '||'
+
+ (let ((result "|"))
+ (when (> width 0)
+ (let* ((e (/ (* elapsed width) total)) ;; number of '=' signs
+ (r (- width e))) ;; number of '-' signs
+ (setq result (concat result
+ (make-string (max 0 (1- e)) ?=)
+ ">"
+ (make-string r ?-)))))
+
+ (concat result "|")))
+
+(defun ampc-current-song-time (elapsed total width)
+ "Creates an ASCII representation of elapsed time of the current song.
+ELAPSED is the current time of the song in seconds
+TOTAL is the total time of the song in seconds
+WIDTH is the max desired length of the result"
+ (setq elapsed (truncate elapsed))
+ (when (> elapsed total)
+ (setq elapsed total))
+
+ (let* ((hours (/ elapsed 3600))
+ (minutes (- (/ elapsed 60) (* 60 hours)))
+ (seconds (mod elapsed 60))
+ (result ""))
+ (when (> hours 0)
+ (setq result (format "%d:%s"
+ hours
+ (if (< minutes 10)
+ "0"
+ "")
+ )))
+ (setq result (format "%s%d:%s%d"
+ result
+ minutes
+ (if (< seconds 10)
+ "0"
+ "")
+ seconds))
+
+ (concat (ampc-time-to-progress-bar elapsed total (1- (- width (length result))))
+ " "
+ result)))
+
+(cl-defun ampc-status (&optional no-print (width 50))
"Display and return the information that is displayed in the status window.
If optional argument NO-PRINT is non-nil, just return the text.
If NO-PRINT is nil, the display may be delayed if ampc does not
@@ -2845,6 +2909,10 @@ have enough information yet."
(ampc-clean-tag
'Title
(cdr (assq 'Title ampc-status)))
+ "\n"
+ (ampc-current-song-time (string-to-number (cdr (assq 'elapsed ampc-status)))
+ (string-to-number (cdr (assq 'Time ampc-status)))
+ width)
"\n"))
"Volume: " (cdr (assq 'volume ampc-status)) "\n"
"Crossfade: " (cdr (assq 'xfade ampc-status))
@@ -3102,6 +3170,9 @@ ampc is connected to."
(delete-process ampc-connection))
(when ampc-working-timer
(cancel-timer ampc-working-timer))
+ (when ampc-status-timer
+ (cancel-timer ampc-status-timer)
+ (setq ampc-status-timer nil))
(ampc-suspend nil)
(setf ampc-connection nil
ampc-internal-db nil
@@ -3166,7 +3237,8 @@ default to the ones specified in `ampc-default-server'."
(run-hooks 'ampc-connected-hook)
(when suspend
(ampc-suspend))
- (ampc-filter (process-buffer ampc-connection) nil))
+ (ampc-filter (process-buffer ampc-connection) nil)
+ (ampc-restart-status-timer))
(provide 'ampc)
--
2.8.3
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: ampc back on elpa?
2016-07-27 13:58 ` Cédric Chépied
@ 2016-07-27 14:40 ` Stefan Monnier
0 siblings, 0 replies; 16+ messages in thread
From: Stefan Monnier @ 2016-07-27 14:40 UTC (permalink / raw)
To: emacs-devel
> Here is a new patch for ampc.
Thanks. Pushed,
Stefan
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2016-07-27 14:40 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-14 16:31 ampc back on elpa? Cédric Chépied
2016-05-14 14:48 ` Stefan Monnier
2016-05-25 6:07 ` Cédric Chépied
2016-05-25 8:32 ` Stefan Monnier
2016-06-10 13:25 ` Cédric Chépied
2016-06-10 15:52 ` Stefan Monnier
2016-06-13 7:23 ` Cédric Chépied
2016-06-13 12:45 ` Stefan Monnier
2016-06-15 9:53 ` Cédric Chépied
2016-06-15 13:35 ` Stefan Monnier
2016-06-17 16:43 ` Cédric Chépied
2016-06-17 22:28 ` Stefan Monnier
2016-06-20 11:47 ` Cédric Chépied
2016-07-01 11:25 ` Cédric Chépied
2016-07-27 13:58 ` Cédric Chépied
2016-07-27 14:40 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.