Function: mpc-describe-song

mpc-describe-song is an interactive and byte-compiled function defined in mpc.el.gz.

Signature

(mpc-describe-song FILE)

Documentation

Show details of the selected song or FILE in the MPC song viewer.

If there is no song at point then information about the currently playing song is displayed.

Probably introduced at or before Emacs version 31.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/mpc.el.gz
(defun mpc-describe-song (file)
  "Show details of the selected song or FILE in the MPC song viewer.

If there is no song at point then information about the currently
playing song is displayed."
  (interactive
   ;; Handle being called from the context menu.  In that case you want
   ;; to see details for the song you clicked on to invoke the menu not
   ;; whatever `point' happens to be on at that time.
   (list (when-let* ((event last-nonmenu-event)
                     ((listp event))
                     (position (nth 1 (event-start event))))
           (get-text-property position 'mpc-file))))
  (let ((tags (or (when (and file (stringp file))
                    (mpc-proc-cmd-to-alist (list "search" "file" file)))
                  (when-let* (((string= (buffer-name) "*MPC-Songs*"))
                              (file (get-text-property (point) 'mpc-file)))
                    (mpc-proc-cmd-to-alist (list "search" "file" file)))
                  (when (assoc 'file mpc-status) mpc-status)))
        (buffer "*MPC Song Viewer*"))
    (when tags
      (with-current-buffer (get-buffer-create buffer)
        (special-mode)
        (visual-line-mode)
        (let ((inhibit-read-only t))
          (erase-buffer)
          (make-vtable
           :columns `(( :name "Tag"
                        :align right
                        :min-width 3
                        :displayer
                        ,(lambda (tag &rest _)
                           (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-table-value)
                             (propertize "empty" 'face 'mpc-table-empty)))))
           :objects (mapcar
                     (lambda (tag)
                       (pcase tag
                         ("Bitrate"
                          (list tag (let ((bitrate (alist-get 'bitrate tags)))
                                      (when bitrate
                                        (format "%s kpbs" bitrate)))))
                         ("Duration" (list tag (mpc-secs-to-time
                                                (alist-get 'duration tags))))
                         ("File" (list tag (alist-get 'file tags)))
                         ;; Concatenate all the values of tags which may
                         ;; occur multiple times.
                         ((or "Composer" "Genre" "Performer")
                          (list tag (mapconcat
                                     (lambda (val) (cdr val))
                                     (seq-filter
                                      (lambda (val) (eq (car val) (intern tag)))
                                      tags)
                                     "; ")))
                         (_ (list tag (alist-get (intern tag) tags)))))
                     mpc-song-viewer-tags))
          (goto-char (point-min))))
      (pop-to-buffer buffer '((display-buffer-reuse-window
                               display-buffer-same-window)
                              (reusable-frames . t))))))