From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 16 15:06:10 2025 Received: (at submit) by debbugs.gnu.org; 16 Feb 2025 20:06:10 +0000 Received: from localhost ([127.0.0.1]:37813 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tjku1-0004Ty-N3 for submit@debbugs.gnu.org; Sun, 16 Feb 2025 15:06:09 -0500 Received: from lists.gnu.org ([2001:470:142::17]:43650) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tjktx-0004T9-N1 for submit@debbugs.gnu.org; Sun, 16 Feb 2025 15:06:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tjktr-0001cl-4T for bug-gnu-emacs@gnu.org; Sun, 16 Feb 2025 15:05:59 -0500 Received: from fout-a2-smtp.messagingengine.com ([103.168.172.145]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tjktp-0005jw-BV for bug-gnu-emacs@gnu.org; Sun, 16 Feb 2025 15:05:58 -0500 Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfout.phl.internal (Postfix) with ESMTP id 4F36C1380950 for ; Sun, 16 Feb 2025 15:05:56 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Sun, 16 Feb 2025 15:05:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pub.pink; h=cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:message-id:mime-version:reply-to:subject :subject:to:to; s=fm3; t=1739736356; x=1739822756; bh=cW03F/fxBU iRF2J8JH96hOWn4xybpkg9GA4AYMnsZ08=; b=pKJE+FY3Mj6gdgllj+MeMmmCME cKCob/B+gakIfm+KKB+/8E5wMlF4LKKnUOn8lUB8YvlnFbhDdmgIngOqNcvgbYeL uq3MKLByNDrEhe183XIC4cnXHgARaRwvB36moxWzSPgVNySseaGDAJgeiNZIUEmp IYaMfoAJ0N9LUUOlrZJC9DZknAIe04oZsSrk3J5b7KiuHJNQYxl7r/+p1KlxJC9n LKB+tQC6LyB8x8IgdxeKswSLxIzCja9gqw3/PNsBPPA5gJjxeSY6efA92taIGFwW gR0Jp/UHpd9mnL7OHAwUoYk5fUesmCCspFk/qWXSauc+GZS4dH2ATz0V98gA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1739736356; x=1739822756; bh=cW03F/fxBUiRF2J8JH96hOWn4xybpkg9GA4 AYMnsZ08=; b=WNIGYG70pgo9Awu0dr3yo2ESRx023/x3qBJxd7M59jIqmP6Z4wI 5BIQJj0IMrT2ySqDduj2emvYa91VOcyHgmaQILJWz9/9c8SooFNvRwTeWhflVKCI XEQ4E7ocswRZ6bZZMcopb+uQ65DVlvG7TSZ6KbJPc4cXsmN25zpMu28zvqNmZWXO OEymmgiLAlgU+mWq2zV0NzOwfVR9qUuLLvYgXhfYGPbhBIF/GsQJX+oB0vfaWCZV dEbZHXJNrcTvuNRJ0d7h4gEbVixrXEAolBRW2XIPcYl+7dtrJg1XFjDiuW57EtzS Xfi0m/CVyD2Qpk7OMCDYxJ4MaJox5DzyXGA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdehieefkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhephffvuf ffkfggtgfgsehtqhertddttdejnecuhfhrohhmpehjmhesphhusgdrphhinhhknecuggft rfgrthhtvghrnhepjeffhfeftdduleegtdejjeeljeelgfetvefhuefhtedvlefgvdffhf dvkeevhfeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhho mhepjhhmsehpuhgsrdhpihhnkhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtph houhhtpdhrtghpthhtohepsghughdqghhnuhdqvghmrggtshesghhnuhdrohhrgh X-ME-Proxy: Feedback-ID: i74194916:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sun, 16 Feb 2025 15:05:55 -0500 (EST) From: jm@pub.pink To: bug-gnu-emacs@gnu.org Subject: [PATCH] Add MPD stats viewer to 'mpc' X-Debbugs-Cc: Stefan Monnier Date: Sun, 16 Feb 2025 14:05:55 -0600 Message-ID: <8734gdu02k.fsf@pub.pink> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=103.168.172.145; envelope-from=jm@pub.pink; helo=fout-a2-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.3 (/) Tags: patch This adds a viewer for mpd stats. I wasn=E2=80=99t sure about what to do with the faces; reuse the existing names or add more so went with rename but don=E2=80=99t mind any of the options. From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 16 15:09:38 2025 Received: (at 76350) by debbugs.gnu.org; 16 Feb 2025 20:09:38 +0000 Received: from localhost ([127.0.0.1]:37847 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tjkxO-0004i5-B0 for submit@debbugs.gnu.org; Sun, 16 Feb 2025 15:09:38 -0500 Received: from fout-a2-smtp.messagingengine.com ([103.168.172.145]:44387) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tjkxL-0004hR-Mq for 76350@debbugs.gnu.org; Sun, 16 Feb 2025 15:09:36 -0500 Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id 8749A1380950; Sun, 16 Feb 2025 15:09:30 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Sun, 16 Feb 2025 15:09:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pub.pink; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1739736570; x=1739822970; bh=iUhgx8466O y0hMJreHYQTsSgfLc+YorSmgKfu8VtjLs=; b=a+ffjarJrVGqa41zmD6FdVYwwa gVGZs7/smJwm4e1/LZ3kjtkBuupNJ8NteqYZ+UGNUeU55gei7XRz8fr520HLrdln f9cGqA1FyCNdGPujkGKoXF22Es1nEDekJdEwbqI8mMS79HGlu3Kclzn5Y0540Jv8 J56ysnqkOm+ntpOd3FDvJR6R1bEadCQeuHyUkHUH4yL4xmV6BnvyeE46TGUy367o YnqyAtcROJOnXe3b/7oybYX6Bo7nzP9LnG6VMCy/nNn7uZ0mZK1I+7dk61D9X5mX XaFCWs/09bDvBmi3FMF7Z6sG6B+0CmE5x6Ns5VbYGut7s/IjV4UGzKoIf45w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1739736570; x=1739822970; bh=iUhgx8466Oy0hMJreHYQTsSgfLc+YorSmgK fu8VtjLs=; b=lCa2kE+1bbyYrOhZ7vPsjlEUdFzhhOcl5Xcx1TmmgTJBBCvyFjP XmoO89du4jtUKkSsCAvWyc+MslDvFNcZFK6HJw2fJnOYqMrLlmB66EAzIbrYLGjH NJFfcYImAyuOlQe+jjaWlAq7B0/ppk6p9RKFMg6Sh4rUAIeTAPDg0aKRRG0qQZDT bkVT9XYBB/2znXDVJPgDiY80SYeU3WCpTSRcrE8gRl4OjzEnFrVuG5WZkXogWdtT NEa2Ye0Ino/Wfldm2sBg6QIY+o84BYpfH7alkVGzsG4o6X/PA6OzqEB4rcO4JI2b ghrO7ghb/SmrrplXu8L+WCmoNi1fwk53Kig== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdehieegtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpehffgfhvfevufffjgfkgggtsehmtderredtreej necuhfhrohhmpehjmhesphhusgdrphhinhhknecuggftrfgrthhtvghrnhepudfhkeehge evjeeftdffieehtdelvdefueetjeeuleehvdejjeetudevgefgjeevnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepjhhmsehpuhgsrdhpihhnkh dpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepmhho nhhnihgvrhesihhrohdruhhmohhnthhrvggrlhdrtggrpdhrtghpthhtohepjeeifeehtd esuggvsggsuhhgshdrghhnuhdrohhrgh X-ME-Proxy: Feedback-ID: i74194916:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 16 Feb 2025 15:09:29 -0500 (EST) References: <8734gdu02k.fsf@pub.pink> User-agent: mu4e 1.10.8; emacs 31.0.50 From: jm@pub.pink To: 76350@debbugs.gnu.org Subject: Re: bug#76350: [PATCH] Add MPD stats viewer to 'mpc' Date: Sun, 16 Feb 2025 14:08:38 -0600 In-reply-to: <8734gdu02k.fsf@pub.pink> Message-ID: <87v7t9slc6.fsf@pub.pink> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 76350 Cc: Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-MPD-stats-viewer-to-mpc-Bug-76350.patch >From 29a0a567e0bc0543f6f40643e6d788407050ef24 Mon Sep 17 00:00:00 2001 From: john muhl Date: Tue, 5 Nov 2024 10:24:28 -0600 Subject: [PATCH] Add MPD stats viewer to 'mpc' (Bug#76350) * lisp/mpc.el (mpc-mpd-stats): New command. (mpc-mode-menu): Add menu item. (mpc-mpd-stats-date-format, mpc-mpd-stats-duration-format): New option. (mpc--mpd-stats-date, mpc--mpd-stats-duration): New function. (mpc-song-viewer-value, mpc-song-viewer-tag): (mpc-song-viewer-empty): Remove face. (mpc-table-value, mpc-table-key, mpc-table-empty): New face. (mpc-describe-song): Use new table face names. --- etc/NEWS | 12 +++++++-- lisp/mpc.el | 73 +++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 72 insertions(+), 13 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 6d934b2029c..6a698627f6a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1134,8 +1134,16 @@ of seconds. Crossfading can be toggled using the command This command displays information about the currently playing song or song at point in the "*MPC-Songs*" buffer. The list of tags to display can be customized using the new user option 'mpc-song-viewer-tags' and -the appearance of the list with the new faces 'mpc-song-viewer-tag', -'mpc-song-viewer-value', and 'mpc-song-viewer-empty'. +the appearance of the list with the new faces 'mpc-table-key', +'mpc-table-value', and 'mpc-table-empty'. + +--- +*** New command 'mpc-mpd-stats'. +This command displays information about the connected MPD server. The +appearance of the list can be customized with the new faces +'mpc-table-key' and 'mpc-table-value'. The formatting of displayed +dates and durations can be customized using the new user options +'mpc-mpd-stats-date-format' and 'mpc-mpd-stats-duration-format'. ** VC diff --git a/lisp/mpc.el b/lisp/mpc.el index e25983e48c9..a0e2866d2e0 100644 --- a/lisp/mpc.el +++ b/lisp/mpc.el @@ -93,6 +93,8 @@ (require 'cl-lib) +(require 'let-alist) + (require 'notifications) (require 'vtable) @@ -1212,6 +1214,7 @@ mpc-mode-menu :selected (alist-get 'xfade mpc-status)] "--" ["Add new browser" mpc-tagbrowser] + ["MPD Stats" mpc-mpd-stats] ["Update DB" mpc-update] ["Quit" mpc-quit])) @@ -2874,17 +2877,17 @@ mpc-notifications-notify ;;; Song Viewer ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defface mpc-song-viewer-value +(defface mpc-table-value '((t (:inherit vtable))) - "Face for tag values in the MPC song viewer.") + "Face for values in MPC tables.") -(defface mpc-song-viewer-tag - '((t (:inherit (mpc-song-viewer-value bold)))) - "Face for tag types in the MPC song viewer.") +(defface mpc-table-key + '((t (:inherit (mpc-table-value bold)))) + "Face for keys in MPC tables.") -(defface mpc-song-viewer-empty - '((t (:inherit (mpc-song-viewer-value italic shadow)))) - "Face for empty tag values in the MPC song viewer.") +(defface mpc-table-empty + '((t (:inherit (mpc-table-value italic shadow)))) + "Face for empty values in MPC tables.") (defcustom mpc-song-viewer-tags '("Title" "Artist" "Album" "Performer" "Composer" @@ -2929,15 +2932,15 @@ mpc-describe-song :min-width 3 :displayer (lambda (tag &rest _) - (propertize tag 'face 'mpc-song-viewer-tag))) + (propertize tag 'face 'mpc-table-key))) ( :name "Value" :align left :min-width 5 :displayer (lambda (value &rest _) (if (and value (not (string-blank-p value))) - (propertize value 'face 'mpc-song-viewer-value) - (propertize "empty" 'face 'mpc-song-viewer-empty))))) + (propertize value 'face 'mpc-table-value) + (propertize "empty" 'face 'mpc-table-empty))))) :objects (mapcar (lambda (tag) (pcase tag @@ -2964,6 +2967,54 @@ mpc-describe-song display-buffer-same-window) (reusable-frames . t)))))) +;;; Stats viewer ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defcustom mpc-mpd-stats-date-format "%c" + "Format used for dates in `mpc-mpd-stats'. +See `format-time-string' for formatting details." + :version "31.1" + :type 'string) + +(defcustom mpc-mpd-stats-duration-format "%Y, %D, %z%h:%.2m:%.2s" + "Format used for durations in `mpc-mpd-stats'. +See `format-seconds' for formatting details." + :version "31.1" + :type 'string) + +(defun mpc--mpd-stats-date (seconds) + "Format SECONDS as a date for display by `mpc-mpd-stats'." + (format-time-string mpc-mpd-stats-date-format (string-to-number seconds))) + +(defun mpc--mpd-stats-duration (seconds) + "Format SECONDS as a duration for display by `mpc-mpd-stats'." + (format-seconds mpc-mpd-stats-duration-format (string-to-number seconds))) + +(defun mpc-mpd-stats () + "Display stats about the connected MPD instance." + (interactive) + (let ((buffer "*MPC Stats Viewer*")) + (with-current-buffer (get-buffer-create buffer) + (special-mode) + (let ((inhibit-read-only t)) + (erase-buffer) + (make-vtable + :columns '((:name "MPD Stats" :align right) "") + :formatter (lambda (value column &rest _) + (propertize value 'face (if (= column 0) + 'mpc-table-key + 'mpc-table-value))) + :objects (let-alist (mpc-proc-cmd-to-alist (list "stats")) + `(("Artists" ,.artists) + ("Albums" ,.albums) + ("Songs" ,.songs) + ("Play Time" ,(mpc--mpd-stats-duration .playtime)) + ("Uptime" ,(mpc--mpd-stats-duration .uptime)) + ("DB Play Time" ,(mpc--mpd-stats-duration .db_playtime)) + ("DB Updated" ,(mpc--mpd-stats-date .db_update)))))) + (pop-to-buffer buffer '((display-buffer-reuse-window) + (reusable-frames . t) + (window-height . 10)))))) + ;;; Toplevel ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defcustom mpc-frame-alist '((name . "MPC") (tool-bar-lines . 1) -- 2.48.1 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable jm@pub.pink writes: > Tags: patch > > This adds a viewer for mpd stats. > > I wasn=E2=80=99t sure about what to do with the faces; reuse the existing > names or add more so went with rename but don=E2=80=99t mind any of the > options. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 16 23:58:26 2025 Received: (at 76350) by debbugs.gnu.org; 17 Feb 2025 04:58:26 +0000 Received: from localhost ([127.0.0.1]:40931 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tjtD8-0008S0-9A for submit@debbugs.gnu.org; Sun, 16 Feb 2025 23:58:26 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:7206) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tjtD5-0008R9-5K for 76350@debbugs.gnu.org; Sun, 16 Feb 2025 23:58:23 -0500 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id ED7D5100154; Sun, 16 Feb 2025 23:58:16 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1739768295; bh=CLQq2REAoC5TKWWV73bK6m5dclDZA7Cu+BhM/eZw8/s=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Rg4Rso+z2AvDeQ+/0Qb4XNXAGAjHD/3HJwaKR7+9tKzIllh/FEAgbSkncodPWTU8Q h7TNwWhxr4IFw7uZuxv3vphIe8/HN3DEh3tiolnBd3A42tdgzXYwPFhstXyP60gJFv vHO2Uo49C3F92hOSu69DR189QsDomqQosyJEIp0bieEom0PdOdx1lkS0IDqADkV29/ OUtLDq07cWKeVHKa8v69THuruBOn0yPIG6y4ninoYWhKBZjSR/H7sw2qhbbsVNoKxE LxzdTwOuw1G9h8lkByPrZt6y9v2Md1skuP78MBkb2BpXyXxfF3AxXnpE9cnKAgErW0 g/LNs+ZeylWeA== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id CA2CE100034; Sun, 16 Feb 2025 23:58:15 -0500 (EST) Received: from alfajor (unknown [104.247.242.5]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 9DA80120315; Sun, 16 Feb 2025 23:58:15 -0500 (EST) From: Stefan Monnier To: jm@pub.pink Subject: Re: bug#76350: [PATCH] Add MPD stats viewer to 'mpc' In-Reply-To: <87v7t9slc6.fsf@pub.pink> (jm@pub.pink's message of "Sun, 16 Feb 2025 14:08:38 -0600") Message-ID: References: <8734gdu02k.fsf@pub.pink> <87v7t9slc6.fsf@pub.pink> Date: Sun, 16 Feb 2025 23:58:14 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.091 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76350 Cc: 76350@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > I wasn=E2=80=99t sure about what to do with the faces; reuse the existing > names or add more so went with rename but don=E2=80=99t mind any of the > options. Rename seems fine to me. > +*** New command 'mpc-mpd-stats'. I think I'd rather call it `mpc-server-stats`. > ["Add new browser" mpc-tagbrowser] > + ["MPD Stats" mpc-mpd-stats] Same here, "Server stats". > +;;; Stats viewer ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;; > + > +(defcustom mpc-mpd-stats-date-format "%c" > + "Format used for dates in `mpc-mpd-stats'. > +See `format-time-string' for formatting details." > + :version "31.1" > + :type 'string) > + > +(defcustom mpc-mpd-stats-duration-format "%Y, %D, %z%h:%.2m:%.2s" > + "Format used for durations in `mpc-mpd-stats'. > +See `format-seconds' for formatting details." > + :version "31.1" > + :type 'string) Do we need this level of customization? I think I'd be happy to hardcode those settings (maybe with `defvar/defconst` with a "--" in the name). > + :objects (let-alist (mpc-proc-cmd-to-alist (list "stats")) > + `(("Artists" ,.artists) > + ("Albums" ,.albums) > + ("Songs" ,.songs) > + ("Play Time" ,(mpc--mpd-stats-duration .playtime)) > + ("Uptime" ,(mpc--mpd-stats-duration .uptime)) > + ("DB Play Time" ,(mpc--mpd-stats-duration .db_play= time)) > + ("DB Updated" ,(mpc--mpd-stats-date .db_update))))= )) But here I'd be tempted not to hardcode the list, so it will always print all the info returned by the server: - Maybe have a generic heuristic to make the keys pretty (e.g. turn "albums" into "Albums" and "db_update" into "DB Update") - Provide ad-hoc elements for those specific entries where we want to prettify the raw value before displaying it (i.e. where we want to apply `mpc--mpd-stats-duration` or `mpc--mpd-stats-date`). WDYT? Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 17 20:04:02 2025 Received: (at 76350) by debbugs.gnu.org; 18 Feb 2025 01:04:02 +0000 Received: from localhost ([127.0.0.1]:51613 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tkC1p-0005Tt-Dx for submit@debbugs.gnu.org; Mon, 17 Feb 2025 20:04:02 -0500 Received: from fout-b7-smtp.messagingengine.com ([202.12.124.150]:51407) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tkC1l-0005Sy-HH for 76350@debbugs.gnu.org; Mon, 17 Feb 2025 20:03:59 -0500 Received: from phl-compute-02.internal (phl-compute-02.phl.internal [10.202.2.42]) by mailfout.stl.internal (Postfix) with ESMTP id 99BF61140100; Mon, 17 Feb 2025 20:03:51 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Mon, 17 Feb 2025 20:03:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pub.pink; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1739840631; x=1739927031; bh=V5MUc7Bio0 nbpt48HjStZN4zJhfB2sD+iex/g5IRe+k=; b=x1azi9XTRIuQrrJsr/qnYQfNuE GXxU+RnZgtIs4kOmzifApY0cU8HvM1LyieCG7nsYnMY2e0fYN4iR3xsl+b9cqw9q DJunoT6m7+dy7bxGPyS51PQ76U3EytOMJs1rBSDb0pBucvtvMInpb6vHK0dnbdi+ 8KKLQ5GushGT6tIJnNjwqemgqI2Yp7Obggf+IeLrQTbxsuxdc+YJTRBhYGsGyFqw ZTHA1KQQZ68IVWjT/E17Slnu4d7LO62K+GcfI4yZrb1PSfJgQYJ1GNwDztX2L6oB djjeEqx7Hzo+fBem9PTVp6H/0yB1TVKhtXW87DH1JSghv1lUtwvH3ptG9Ggw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1739840631; x=1739927031; bh=V5MUc7Bio0nbpt48HjStZN4zJhfB2sD+iex /g5IRe+k=; b=XenOQel3lc+Nc+ymqDwDRMUJB3SHqES1e0CbKHNFEFLQEVkYljt WWgsubBhsdbSN3Cc+36uRZMetiDCWlBVXhsQcLigBayF2RP7IoitVRT+MaxPDC2M NSpgHA6HMiDCFCWI/mIk84iS2Q0UynMczdRhFfBVFrwS5o7RH+9BHNNmLE2Nh+CF M05LzjFfhKQQXhjKH+IZlIGpITQ24ql9MB+p8ZkVe78rDR3YpQXsrpQG6AOCyeeQ 8ZpFqpIk8VpN+QChi+Z+QiLTQgz+46BNyCKDCIEZkp7jBt6k45MIf9qSwjPxhjQi 4PfwE3g+WTpCk4zgIyucEW4h036lJsXkpuQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdehleelfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpehffgfhvfevufffjgfkgggtsehmtderredtredt necuhfhrohhmpehjohhhnhcumhhuhhhluceojhhmsehpuhgsrdhpihhnkheqnecuggftrf grthhtvghrnhepudeftdetledugeelvdefhffhieelteeklefhhfehkeeugffgffdtjefg hefglefhnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epjhhmsehpuhgsrdhpihhnkhdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphho uhhtpdhrtghpthhtohepjeeifeehtdesuggvsggsuhhgshdrghhnuhdrohhrghdprhgtph htthhopehmohhnnhhivghrsehirhhordhumhhonhhtrhgvrghlrdgtrg X-ME-Proxy: Feedback-ID: i74194916:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 17 Feb 2025 20:03:50 -0500 (EST) References: <8734gdu02k.fsf@pub.pink> <87v7t9slc6.fsf@pub.pink> User-agent: mu4e 1.10.8; emacs 31.0.50 From: john muhl To: Stefan Monnier Subject: Re: bug#76350: [PATCH] Add MPD stats viewer to 'mpc' Date: Mon, 17 Feb 2025 15:03:51 -0600 In-reply-to: Message-ID: <878qq483nu.fsf@pub.pink> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.4 (/) X-Debbugs-Envelope-To: 76350 Cc: 76350@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.6 (/) --=-=-= Content-Type: text/plain Stefan Monnier writes: >> +;;; Stats viewer ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >> + >> +(defcustom mpc-mpd-stats-date-format "%c" >> + "Format used for dates in `mpc-mpd-stats'. >> +See `format-time-string' for formatting details." >> + :version "31.1" >> + :type 'string) >> + >> +(defcustom mpc-mpd-stats-duration-format "%Y, %D, %z%h:%.2m:%.2s" >> + "Format used for durations in `mpc-mpd-stats'. >> +See `format-seconds' for formatting details." >> + :version "31.1" >> + :type 'string) > > Do we need this level of customization? I hope not. >> + :objects (let-alist (mpc-proc-cmd-to-alist (list "stats")) >> + `(("Artists" ,.artists) >> + ("Albums" ,.albums) >> + ("Songs" ,.songs) >> + ("Play Time" ,(mpc--mpd-stats-duration .playtime)) >> + ("Uptime" ,(mpc--mpd-stats-duration .uptime)) >> + ("DB Play Time" ,(mpc--mpd-stats-duration .db_playtime)) >> + ("DB Updated" ,(mpc--mpd-stats-date .db_update)))))) > > But here I'd be tempted not to hardcode the list, so it will always > print all the info returned by the server: > > - Maybe have a generic heuristic to make the keys pretty (e.g. turn > "albums" into "Albums" and "db_update" into "DB Update") > - Provide ad-hoc elements for those specific entries where we want to > prettify the raw value before displaying it (i.e. where we want to > apply `mpc--mpd-stats-duration` or `mpc--mpd-stats-date`). > > WDYT? Sounds good. How about the attached? --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-MPD-stats-viewer-to-mpc-Bug-76350.patch >From a9de8d5f9bed2b569c0146a5afacccac469b819e Mon Sep 17 00:00:00 2001 From: john muhl Date: Tue, 5 Nov 2024 10:24:28 -0600 Subject: [PATCH] Add MPD stats viewer to 'mpc' (Bug#76350) * lisp/mpc.el (mpc-server-stats): New command. (mpc-mode-menu): Add menu item. (mpc--server-stats-date, mpc--server-stats-duration): New variable. (mpc--server-stats-date, mpc--server-stats-duration): (mpc--server-stats-format): New function. (mpc-song-viewer-value, mpc-song-viewer-tag): (mpc-song-viewer-empty): Remove face. (mpc-table-value, mpc-table-key, mpc-table-empty): New face. (mpc-describe-song): Use new table face names. --- etc/NEWS | 10 ++++++-- lisp/mpc.el | 73 +++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 70 insertions(+), 13 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 6d934b2029c..309fea79ce0 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1134,8 +1134,14 @@ of seconds. Crossfading can be toggled using the command This command displays information about the currently playing song or song at point in the "*MPC-Songs*" buffer. The list of tags to display can be customized using the new user option 'mpc-song-viewer-tags' and -the appearance of the list with the new faces 'mpc-song-viewer-tag', -'mpc-song-viewer-value', and 'mpc-song-viewer-empty'. +the appearance of the list with the new faces 'mpc-table-key', +'mpc-table-value', and 'mpc-table-empty'. + +--- +*** New command 'mpc-server-stats'. +This command displays information about the connected MPD server. The +appearance of the list can be customized with the new faces +'mpc-table-key' and 'mpc-table-value'. ** VC diff --git a/lisp/mpc.el b/lisp/mpc.el index e25983e48c9..e639129d86a 100644 --- a/lisp/mpc.el +++ b/lisp/mpc.el @@ -1212,6 +1212,7 @@ mpc-mode-menu :selected (alist-get 'xfade mpc-status)] "--" ["Add new browser" mpc-tagbrowser] + ["Server Stats" mpc-server-stats] ["Update DB" mpc-update] ["Quit" mpc-quit])) @@ -2874,17 +2875,17 @@ mpc-notifications-notify ;;; Song Viewer ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defface mpc-song-viewer-value +(defface mpc-table-value '((t (:inherit vtable))) - "Face for tag values in the MPC song viewer.") + "Face for values in MPC tables.") -(defface mpc-song-viewer-tag - '((t (:inherit (mpc-song-viewer-value bold)))) - "Face for tag types in the MPC song viewer.") +(defface mpc-table-key + '((t (:inherit (mpc-table-value bold)))) + "Face for keys in MPC tables.") -(defface mpc-song-viewer-empty - '((t (:inherit (mpc-song-viewer-value italic shadow)))) - "Face for empty tag values in the MPC song viewer.") +(defface mpc-table-empty + '((t (:inherit (mpc-table-value italic shadow)))) + "Face for empty values in MPC tables.") (defcustom mpc-song-viewer-tags '("Title" "Artist" "Album" "Performer" "Composer" @@ -2929,15 +2930,15 @@ mpc-describe-song :min-width 3 :displayer (lambda (tag &rest _) - (propertize tag 'face 'mpc-song-viewer-tag))) + (propertize tag 'face 'mpc-table-key))) ( :name "Value" :align left :min-width 5 :displayer (lambda (value &rest _) (if (and value (not (string-blank-p value))) - (propertize value 'face 'mpc-song-viewer-value) - (propertize "empty" 'face 'mpc-song-viewer-empty))))) + (propertize value 'face 'mpc-table-value) + (propertize "empty" 'face 'mpc-table-empty))))) :objects (mapcar (lambda (tag) (pcase tag @@ -2964,6 +2965,56 @@ mpc-describe-song display-buffer-same-window) (reusable-frames . t)))))) +;;; Stats viewer ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defvar mpc--server-stats-date "%c" + "Format used for dates in `mpc-server-stats'. +See `format-time-string' for formatting details.") + +(defvar mpc--server-stats-duration "%Y, %D, %z%h:%.2m:%.2s" + "Format used for durations in `mpc-server-stats'. +See `format-seconds' for formatting details.") + +(defun mpc--server-stats-date (seconds) + "Format SECONDS as a date for display by `mpc-server-stats'." + (format-time-string mpc--server-stats-date (string-to-number seconds))) + +(defun mpc--server-stats-duration (seconds) + "Format SECONDS as a duration for display by `mpc-server-stats'." + (format-seconds mpc--server-stats-duration (string-to-number seconds))) + +(defun mpc--server-stats-format (stat) + "Format STAT data for display by `mpc-server-stats'." + (let ((key (seq-reduce (lambda (string from-to) + (string-replace (car from-to) (cdr from-to) string)) + '(("Db_" . "DB_") ("_" . " ")) + (capitalize (symbol-name (car stat))))) + (val (cdr stat))) + (list key (cond + ((string-match-p "time\\'" key) (mpc--server-stats-duration val)) + ((string-match-p "date\\'" key) (mpc--server-stats-date val)) + (t val))))) + +(defun mpc-server-stats () + "Display stats about the connected MPD server." + (interactive) + (let ((buffer "*MPC Stats Viewer*")) + (with-current-buffer (get-buffer-create buffer) + (special-mode) + (let ((inhibit-read-only t)) + (erase-buffer) + (make-vtable + :columns '((:name "Server Stats" :align right :min-width 10) "") + :formatter (lambda (value column &rest _) + (propertize value 'face (if (= column 0) + 'mpc-table-key + 'mpc-table-value))) + :objects (mapcar #'mpc--server-stats-format + (mpc-proc-cmd-to-alist (list "stats"))))) + (pop-to-buffer buffer '((display-buffer-reuse-window) + (reusable-frames . t) + (window-height . 10)))))) + ;;; Toplevel ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defcustom mpc-frame-alist '((name . "MPC") (tool-bar-lines . 1) -- 2.48.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 17 22:41:14 2025 Received: (at 76350-done) by debbugs.gnu.org; 18 Feb 2025 03:41:15 +0000 Received: from localhost ([127.0.0.1]:52540 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tkETy-0002I0-IS for submit@debbugs.gnu.org; Mon, 17 Feb 2025 22:41:14 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:1329) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tkETw-0002HN-Rh for 76350-done@debbugs.gnu.org; Mon, 17 Feb 2025 22:41:13 -0500 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 45803100040; Mon, 17 Feb 2025 22:41:07 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1739850062; bh=mm2Y7J4arBiCRxUfwU7hksO7817rRR9FyPbfAmt7AQw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=JkcnyZxqeiKTmzasOX85aBvn+Uwk8t1kh9+GCxz5q5doz6KdST2wwfh4JPcWLeXHS lrPued8YKpQ6303gYgOv00qkdm7e6Nm6a3ujK0ZlJAu7o6a92OqUeTwwc6fkxIGvuZ VGLPydmBZVd+HBidA5xgtdPrt9F+AM6alQZWlUnGCEpiSPj/215dtqulhtK4Sc2zCi im2SVSGZWuU8jqRXQ16GYX/BcjB+vSk4RMuK0orrZtToMpJWObp484phvoME/bOfkU 1zihJL462itwCFCNcXfICebyHxnREYScw8DpO6oEkWwBmBugyj+EuE5GqAHzscIwkE 7F6CIdIQPiT0g== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 8FD0210002E; Mon, 17 Feb 2025 22:41:02 -0500 (EST) Received: from alfajor (unknown [104.247.242.5]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 6476A1200C7; Mon, 17 Feb 2025 22:41:02 -0500 (EST) From: Stefan Monnier To: john muhl Subject: Re: bug#76350: [PATCH] Add MPD stats viewer to 'mpc' In-Reply-To: <878qq483nu.fsf@pub.pink> (john muhl's message of "Mon, 17 Feb 2025 15:03:51 -0600") Message-ID: References: <8734gdu02k.fsf@pub.pink> <87v7t9slc6.fsf@pub.pink> <878qq483nu.fsf@pub.pink> Date: Mon, 17 Feb 2025 22:41:02 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.157 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76350-done Cc: 76350-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Sounds good. How about the attached? Pushed to `master`, thanks! Stefan From unknown Thu Aug 14 21:48:50 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 18 Mar 2025 11:24:33 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator