Discussion:
[emms-help] [PATCH] * lisp/emms-playlist-sort.el: sort current buffer
Fran Burstall
2018-09-29 16:46:44 UTC
Permalink
The following patch makes the emms-sort-by-* functions sort the playlist
they are called from rather than the (possibly invisible) current playlist.

---
lisp/emms-playlist-sort.el | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/lisp/emms-playlist-sort.el b/lisp/emms-playlist-sort.el
index d9fc519..e23604b 100644
--- a/lisp/emms-playlist-sort.el
+++ b/lisp/emms-playlist-sort.el
@@ -1,6 +1,6 @@
;;; emms-playlist-sort.el --- sort emms playlist

-;; Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
Inc.
+;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2018 Free Software
Foundation, Inc.

;; Author: William Xu <***@gmail.com>

@@ -165,7 +165,7 @@ With a prefix argument, oldest first."

(defun emms-playlist-sort (predicate)
"Sort the playlist buffer by PREDICATE."
- (with-current-emms-playlist
+ (emms-with-inhibit-read-only-t
(emms-playlist-ensure-playlist-buffer)
(let ((current (emms-playlist-selected-track))
(tracks (nreverse
@@ -174,14 +174,12 @@ With a prefix argument, oldest first."
(delete-region (point-min) (point-max))
(run-hooks 'emms-playlist-cleared-hook)
(mapc 'emms-playlist-insert-track (sort tracks predicate))
- (let ((pos (text-property-any
- (point-min) (point-max) 'emms-track current)))
- (if pos
+ (let ((pos (when current (text-property-any (point-min) (point-max)
+ 'emms-track current))))
+ (if pos
(emms-playlist-select pos)
- (emms-playlist-first))
- ;; (emms-playlist-mode-center-current)
- (goto-char (point-min))
- ))))
+ (emms-playlist-first)))
+ (goto-char (point-min)))))

(defun emms-sort-natural-order-less-p (a b)
"Sort two tracks by natural order.
--
Pierre Neidhardt
2018-10-17 08:57:11 UTC
Permalink
Did anyone try this out?

Otherwise I'll review this when I have more time.
--
Pierre Neidhardt
https://ambrevar.xyz/
Fran Burstall
2018-10-17 09:48:25 UTC
Permalink
Well, I did ;-).

Probably a good idea if someone else did too!

---Fran
Post by Pierre Neidhardt
Did anyone try this out?
Otherwise I'll review this when I have more time.
--
Pierre Neidhardt
https://ambrevar.xyz/
Yoni Rabkin
2018-10-17 19:57:15 UTC
Permalink
Post by Fran Burstall
Well, I did ;-).
Probably a good idea if someone else did too!
Please go ahead and push to master and then we will all check it out
there.

More generally: if it works well on your local HEAD, isn't a major
change, and we aren't getting ready for a release, feel free to share it
on the master branch. Git is easy in this regard.
Post by Fran Burstall
---Fran
Did anyone try this out?
Otherwise I'll review this when I have more time.
--
Pierre Neidhardt
https://ambrevar.xyz/
_______________________________________________
Emms-help mailing list
https://lists.gnu.org/mailman/listinfo/emms-help
--
"Cut your own wood and it will warm you twice"
Fran Burstall
2018-10-17 20:04:56 UTC
Permalink
Done!
Post by Yoni Rabkin
Post by Fran Burstall
Well, I did ;-).
Probably a good idea if someone else did too!
Please go ahead and push to master and then we will all check it out
there.
More generally: if it works well on your local HEAD, isn't a major
change, and we aren't getting ready for a release, feel free to share it
on the master branch. Git is easy in this regard.
Post by Fran Burstall
---Fran
Did anyone try this out?
Otherwise I'll review this when I have more time.
--
Pierre Neidhardt
https://ambrevar.xyz/
_______________________________________________
Emms-help mailing list
https://lists.gnu.org/mailman/listinfo/emms-help
--
"Cut your own wood and it will warm you twice"
Yoni Rabkin
2018-10-17 20:13:56 UTC
Permalink
Seems to work fine; I've added a NEWS comment about it.

Thanks!
Post by Yoni Rabkin
Done!
Post by Fran Burstall
Well, I did ;-).
Probably a good idea if someone else did too!
Please go ahead and push to master and then we will all check it out
there.
More generally: if it works well on your local HEAD, isn't a major
change, and we aren't getting ready for a release, feel free to share it
on the master branch. Git is easy in this regard.
Post by Fran Burstall
---Fran
On Wed, 17 Oct 2018 at 09:57, Pierre Neidhardt <
     Did anyone try this out?
   
     Otherwise I'll review this when I have more time.
   
     --
     Pierre Neidhardt
     https://ambrevar.xyz/
_______________________________________________
Emms-help mailing list
https://lists.gnu.org/mailman/listinfo/emms-help
--
   "Cut your own wood and it will warm you twice"
--
"Cut your own wood and it will warm you twice"
Loading...