The Lambda Lab
/
projects
/
emus.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
df12ead
)
Added function to restart the emus process.
author
plugd
<plugd@thelambdalab.xyz>
Tue, 12 Apr 2022 12:21:31 +0000
(14:21 +0200)
committer
plugd
<plugd@thelambdalab.xyz>
Tue, 12 Apr 2022 12:21:31 +0000
(14:21 +0200)
emus.el
patch
|
blob
|
history
diff --git
a/emus.el
b/emus.el
index
08df9f5
..
2b02cd9
100644
(file)
--- a/
emus.el
+++ b/
emus.el
@@
-136,6
+136,19
@@
be used by `emus--load-library'."
(unless emus--proc-in-use
(apply #'emus--send-cmd-raw cmd args)))
(unless emus--proc-in-use
(apply #'emus--send-cmd-raw cmd args)))
+(defun emus-kill-process ()
+ "Kill any existing mpg123 process."
+ (let ((emus-process (get-process "emus-process")))
+ (if emus-process
+ (kill-process emus-process))))
+
+(defun emus-restart ()
+ "Restart emus, regardless of current state."
+ (interactive)
+ (emus-kill-process)
+ (setq emus-state 'stopped
+ emus--proc-in-use nil
+ emus-tracks nil))
;;; Library
;;
;;; Library
;;
@@
-191,7
+204,7
@@
Once the library is initialized, the function THEN is called."
(setq emus--proc-in-use t)
(emus--suspend-cp)
(setq emus-state 'stopped)
(setq emus--proc-in-use t)
(emus--suspend-cp)
(setq emus-state 'stopped)
- (setq emus-tracks
(emus--make-tracks-from-playlist-files (emus-get-playlist-files))
)
+ (setq emus-tracks
nil
)
(let ((proc (emus-get-process))
(tagstr "")
(filenames (emus-get-audio-files)))
(let ((proc (emus-get-process))
(tagstr "")
(filenames (emus-get-audio-files)))
@@
-208,6
+221,7
@@
Once the library is initialized, the function THEN is called."
(set-process-filter proc nil)
(setq emus-tracks (reverse emus-tracks))
(emus--sort-tracks)
(set-process-filter proc nil)
(setq emus-tracks (reverse emus-tracks))
(emus--sort-tracks)
+ (emus--add-tracks-from-playlist-files)
(unless emus-current-track
(setq emus-current-track (car emus-tracks)))
(funcall then)
(unless emus-current-track
(setq emus-current-track (car emus-tracks)))
(funcall then)
@@
-233,9
+247,9
@@
Once the library is initialized, the function THEN is called."
(found-title (setq title found-title)))))
(emus-make-track artist album title filename)))
(found-title (setq title found-title)))))
(emus-make-track artist album title filename)))
-(defun emus--
make-tracks-from-playlist-files (filenames
)
+(defun emus--
add-tracks-from-playlist-files (
)
(let ((tracks nil))
(let ((tracks nil))
- (dolist (filename
filenames
)
+ (dolist (filename
(emus-get-playlist-files)
)
(let ((artist "Playlists")
(album (file-name-base filename))
(title nil)
(let ((artist "Playlists")
(album (file-name-base filename))
(title nil)
@@
-257,7
+271,7
@@
Once the library is initialized, the function THEN is called."
(setq tracks (cons (emus-make-track artist album (or title filename) filename)
tracks))
(setq title nil))))))
(setq tracks (cons (emus-make-track artist album (or title filename) filename)
tracks))
(setq title nil))))))
-
tracks
))
+
(setq emus-tracks (append emus-tracks (reverse tracks)))
))
(defun emus--sort-tracks ()
"Sort the library tracks according to artist and album.
(defun emus--sort-tracks ()
"Sort the library tracks according to artist and album.
@@
-272,11
+286,7
@@
by the filesystem."
(let ((album1 (emus-track-album r1))
(album2 (emus-track-album r2)))
(string< album1 album2))
(let ((album1 (emus-track-album r1))
(album2 (emus-track-album r2)))
(string< album1 album2))
- (if (equal artist1 "Playlists")
- t
- (if (equal artist2 "Playlists")
- nil
- (string< artist1 artist2)))))))))
+ (string< artist1 artist2)))))))
(defmacro emus--with-library (&rest body)
"Evaluate BODY with the library initialized."
(defmacro emus--with-library (&rest body)
"Evaluate BODY with the library initialized."
@@
-702,6
+712,11
@@
Used to update browser display when `emus-current-track' and/or `emus-state' cha
map)
"Keymap for emus browser.")
map)
"Keymap for emus browser.")
+(defun emus-restart ()
+ "Restart emus."
+ (interactive)
+ (emus-kill-process))
+
(define-derived-mode emus-browser-mode special-mode "emus-browser"
"Major mode for EMUS music player file browser."
(setq-local buffer-invisibility-spec nil))
(define-derived-mode emus-browser-mode special-mode "emus-browser"
"Major mode for EMUS music player file browser."
(setq-local buffer-invisibility-spec nil))