unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: tsuucat via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 44093@debbugs.gnu.org
Subject: bug#44093: [PATCH] some patches for lisp/mpc.el
Date: Tue, 20 Oct 2020 16:32:26 +0900	[thread overview]
Message-ID: <312AE1F0-BCAD-43C2-B078-507549FA400E@icloud.com> (raw)

I made three small patches for lisp/mpc.el.

1.
I noticed M-x mpc-playlist-delete always messages “Deleted 1 songs”
even if playlist queue has more than one songs.
This is because mpc-cmd-delete’s sort modifies songs-poss by side
effect. Using copy-sequence fixes this. (also fix mpc-cmd-move for
same reason)

diff --git a/lisp/mpc.el b/lisp/mpc.el
index d22b7ab450..e5f5984a33 100644
--- a/lisp/mpc.el
+++ b/lisp/mpc.el
@@ -849,7 +849,7 @@ mpc-cmd-delete
                          ;; Sort them from last to first, so the renumbering
                          ;; caused by the earlier deletions don't affect
                          ;; later ones.
-                         (sort song-poss '>))))
+                         (sort (copy-sequence song-poss) '>))))
     (if (stringp playlist)
         (puthash (cons 'Playlist playlist) nil mpc--find-memoize)))

@@ -873,7 +873,7 @@ mpc-cmd-move
               ;; Sort them from last to first, so the renumbering
               ;; caused by the earlier deletions affect
               ;; later ones a bit less.
-              (sort song-poss '>))))
+              (sort (copy-sequence song-poss) '>))))
     (if (stringp playlist)
         (puthash (cons 'Playlist playlist) nil mpc--find-memoize))))

2.
M-x mpc-songs-jump-to doesn’t update *MPC-Status* buffer.
Use mpc-cmd-play.

diff --git a/lisp/mpc.el b/lisp/mpc.el
index d22b7ab450..a0f79e0492 100644
--- a/lisp/mpc.el
+++ b/lisp/mpc.el
@@ -819,8 +819,8 @@ mpc-cmd-pause
 (defun mpc-cmd-status ()
   (mpc-proc-cmd-to-alist "status"))

-(defun mpc-cmd-play ()
-  (mpc-proc-cmd "play")
+(defun mpc-cmd-play (&optional sn)
+  (mpc-proc-cmd (if sn (list "play" sn) "play"))
   (mpc-status-refresh))

 (defun mpc-cmd-seekcur (time)
@@ -2089,7 +2089,7 @@ mpc-songs-jump-to
      ((null (with-current-buffer plbuf (re-search-forward re nil t)))
       ;; song-file only appears once in the playlist: no ambiguity,
       ;; we're good to go!
-      (mpc-proc-cmd (list "play" sn)))
+      (mpc-cmd-play sn))
      (t
       ;; The song appears multiple times in the playlist.  If the current
       ;; buffer holds not only the destination song but also the current
@@ -2125,7 +2125,7 @@ mpc-songs-jump-to

3.
M-x mpc-stop clears playlist queue. So updating *MPC-Songs* buffer
is useful.

diff --git a/lisp/mpc.el b/lisp/mpc.el
index d22b7ab450..405e669660 100644
--- a/lisp/mpc.el
+++ b/lisp/mpc.el
@@ -2391,6 +2391,7 @@ mpc-stop
   (interactive)
   (mpc-cmd-stop)
   (mpc-cmd-clear)
+  (mpc-songs-refresh)
   (mpc-status-refresh))

 (defun mpc-pause ()


Please review these patches.

Do I have to squash these patches to one commit?

--
tsuucat




             reply	other threads:[~2020-10-20  7:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-20  7:32 tsuucat via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2020-10-20 11:22 ` bug#44093: [PATCH] some patches for lisp/mpc.el Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=312AE1F0-BCAD-43C2-B078-507549FA400E@icloud.com \
    --to=bug-gnu-emacs@gnu.org \
    --cc=44093@debbugs.gnu.org \
    --cc=tsuucat@icloud.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).