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: Fri, 10 Jun 2016 15:25:46 +0200 Message-ID: <575abfdd.697ac20a.d9403.5ca0@mx.google.com> References: <573736bd.442cc20a.8d117.ffff9cd7@mx.google.com> <5745411e.aaf0c20a.8e140.4623@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 1465565176 9753 80.91.229.3 (10 Jun 2016 13:26:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 10 Jun 2016 13:26:16 +0000 (UTC) Cc: emacs-devel@gnu.org, =?ISO-8859-1?Q?C=E9dric_Ch=E9pied?= To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 10 15:26:14 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 1bBMRr-0005EW-Vi for ged-emacs-devel@m.gmane.org; Fri, 10 Jun 2016 15:26:08 +0200 Original-Received: from localhost ([::1]:41141 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBMRq-0000gu-5i for ged-emacs-devel@m.gmane.org; Fri, 10 Jun 2016 09:26:06 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55948) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBMRf-0000eG-S9 for emacs-devel@gnu.org; Fri, 10 Jun 2016 09:25:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bBMRb-0006CL-BT for emacs-devel@gnu.org; Fri, 10 Jun 2016 09:25:54 -0400 Original-Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]:35532) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBMRb-0006BK-0q for emacs-devel@gnu.org; Fri, 10 Jun 2016 09:25:51 -0400 Original-Received: by mail-wm0-x22e.google.com with SMTP id v199so148832157wmv.0 for ; Fri, 10 Jun 2016 06:25:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:to:cc:subject:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=9j6b7ggMzcAqZJzbivu9KpHky/i6vdtNpLi/QYy/QwY=; b=k5vgxeTih4oOUOz9CCO4CMkXPOKpjNLBeetEFilPG8gljfrX3pmEB9gfAh0cEZ5g+D 4Dz38zhJLrNDj0fRSj52Y9oTGS1NSBwFgi5bhkTwFNfMstB11S22OTr7Z5dXw2sT/4OX jfQ2h1RPFqt8HwZqmZKSPoBEvphbLmjZO6h8YqtRnbrU8HsqA5rM536yJHfQo3V5DA9n 6KpaKhPdawP0nSjpWdCqsTSSeU2zOr5Mv68sm1oNA/y2M/xC4n6/etbCLyNOCNVGHoqh XOIpVZwSCoXdGt6GB41nxUJ/nrs15Qn0YhgXkGWyZAa02NdyH78+BSy4aJEUDRb2QCOG pJgQ== 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:cc:subject:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=9j6b7ggMzcAqZJzbivu9KpHky/i6vdtNpLi/QYy/QwY=; b=N2lo/30c3hHjFqGSIk7VNc2+u5YbrB0wMX8xa0rlsuqASwA2sc1g93mkeoIVoA96Y3 vqnNfou2f7dsxGv6cJFu3bFNhc5DeyIRyXAhmEbJAOwyAfFJ+C0UOHv5kW22mPBYAnXZ R03hHeRp49qMjnsbBFhfAzbZ9INx/dgAxhucjp5pgVWrphAgWhdRghDj6A4dd+JiVvr8 YNI13WIHYY0Xn9Y2gq4UHtKC6K8TiO2MCbrp55tVpBWC9aID8Htimxr6ssJJiSFNAk3K A8DETDqyjmw/47CqMLUnL7bVFoJy2GQzUUx0EeqAx1kcSUSuArP3TNkypYs4Ht9ecqRu IIOA== X-Gm-Message-State: ALyK8tK0LLm82mKI2EHBMtjGlgNVWBQvs3t0qq6+P0p31SUQyNaO2L9sedcaThP1GIAEcA== X-Received: by 10.28.38.5 with SMTP id m5mr3417818wmm.82.1465565150321; Fri, 10 Jun 2016 06:25:50 -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 lr9sm12344913wjb.39.2016.06.10.06.25.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Jun 2016 06:25:49 -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::22e 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:204273 Archived-At: 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 >From b5345c09de79e4ab1698be713562a339f38836a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Ch=C3=A9pied?= 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 "") '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 "") 'ampc-mouse-add) + (define-key map (kbd "") '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