From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?C=E9dric_Ch=E9pied?= Newsgroups: gmane.emacs.devel Subject: Re: ampc back on elpa? Date: Mon, 20 Jun 2016 13:47:17 +0200 Message-ID: <5767d7d0.cf2d1c0a.1c4a7.38a5@mx.google.com> References: <573736bd.442cc20a.8d117.ffff9cd7@mx.google.com> <5745411e.aaf0c20a.8e140.4623@mx.google.com> <575abfdd.697ac20a.d9403.5ca0@mx.google.com> <576428ac.aa29c20a.20e25.fffff88b@mx.google.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1466423302 29250 80.91.229.3 (20 Jun 2016 11:48:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 20 Jun 2016 11:48:22 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jun 20 13:48:15 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bExga-0001Zd-PF for ged-emacs-devel@m.gmane.org; Mon, 20 Jun 2016 13:48:13 +0200 Original-Received: from localhost ([::1]:42937 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bExgZ-0007jK-QO for ged-emacs-devel@m.gmane.org; Mon, 20 Jun 2016 07:48:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bExfz-0007fT-82 for emacs-devel@gnu.org; Mon, 20 Jun 2016 07:47:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bExfv-00025C-2Y for emacs-devel@gnu.org; Mon, 20 Jun 2016 07:47:34 -0400 Original-Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]:38271) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bExfu-000250-NR for emacs-devel@gnu.org; Mon, 20 Jun 2016 07:47:30 -0400 Original-Received: by mail-wm0-x230.google.com with SMTP id r201so57912222wme.1 for ; Mon, 20 Jun 2016 04:47:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:to:subject:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=/XgMFg25CB0rdHpTGEAlD+JY2DQw/X0KMasbvWe56A0=; b=cG5R39qIxmLvVQh8gPOndMysFeoWzr4JY3UsT9bquz+5swoh+IwGHlyflRgCLHhDPx rAxaKTuwA1VFbkgdWe+oBD1HbBNWIH8rStNZSBmuEUXFDbrqoU9HHKebFIdgnvc79kCT 4cFBEVgFE+OlIkHYaaseSvspTQrl0wkLNAi0X4oapzpnAaMrTu824OrPb0IcmY7s6+Nf Ye3ivTl4F92vhQJEWXIZcwYdc/2zvpw1kLfqGJxg2WnzsNHns70u3EEO/BrtNRmoWc7E VpAHKxWIbgcSF7Zv2xmqFgB57eC9xC14iRow3JhbA9KWDxui6qBZOa1Blwc7KZXHnzlC Nd2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:to:subject:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=/XgMFg25CB0rdHpTGEAlD+JY2DQw/X0KMasbvWe56A0=; b=AiIEQMkMMMVy5zrj4HJvpMEo2NQoYqOc2d4D4GDoOv1BJ2fIjI2gEXGoPgkJnHmTE2 r4ttwNkjeVVlYNRUT4W5fSm5cPlbK1uPqbEEJYITgF2usSHf3dusg2nYIRPHj4HX3BAy Zl6dxQlV4eO3HHTjIJ0ZlB+rWcFkJ31azIqewO7EVgu359wufQjofN8CVL+m/tzUznuJ 9+t6zunj8AntyyPS8sgoyuEZPY9eoeHK0XjoQz5NsU4MaOVkqwony3PGUTtH1TX5OC4J 9tbSqg3/i+ZUOS1oTMFpitRw5+8qkFT3A4MiqPXZxRXc7PJpmAx1ZmM+fvJeH1gt8+yg iohw== X-Gm-Message-State: ALyK8tISDxn+EKh9CPaIVNomlvBYhnTxaxpR5fbhxwSZBqpAW1PNVJpbPM+kFp6jwikTzg== X-Received: by 10.194.178.199 with SMTP id da7mr14032333wjc.123.1466423249330; Mon, 20 Jun 2016 04:47:29 -0700 (PDT) Original-Received: from Aman.gmail.com (149.165.146.77.rev.sfr.net. [77.146.165.149]) by smtp.gmail.com with ESMTPSA id t198sm13162230wmt.16.2016.06.20.04.47.27 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Jun 2016 04:47:28 -0700 (PDT) In-Reply-To: User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL/10.8 EasyPG/1.0.0 Emacs/25.1.50 (x86_64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::230 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:204577 Archived-At: 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 >From c3870da8fcf453bf603ce339fbb08320af9d844d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Ch=C3=A9pied?= 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 `'. +;;; *** 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 "") '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 "") 'ampc-mouse-add) + (define-key map (kbd "") '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