emms-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[emms-help] [PATCH] * lisp/emms-playlist-sort.el: sort current buffer


From: Fran Burstall
Subject: [emms-help] [PATCH] * lisp/emms-playlist-sort.el: sort current buffer
Date: Sat, 29 Sep 2018 17:46:44 +0100

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 <address@hidden>
 
@@ -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.
-- 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]