[PATCH] lisp/emms-mark.el: Fix bug in `emms-mark-mode' when in empty buffers

Kierin Bell <[email protected]>
Newsgroups gmane.emacs.emms.user
Message-ID <[email protected]>
lisp/emms-mark.el (emms-mark-mode): Do not set
`emms-playlist-buffer-p' to t before calling `emms-playlist-mode' in
`emms-mark-mode'.  Otherwise, when `emms-mark-mode' is called in an
empty buffer, `emms-playlist-mode-startup' will erroneously call
`emms-playlist-select-first', causing the error "No first track".
Specifically, this error happens when
`emms-playlist-default-major-mode' is set to `emms-mark-mode' in an
Emacs startup file, as per the Emms manual, and then the user runs a
command like `emms-add-directory'.
---
This patch fixes a bug that causes an error when following instructions in the Emms manual to set `emms-playlist-default-major-mode' to `emms-mark-mode'. To reproduce:

Run emacs -Q

(require 'emms-setup)
(emms-all)
(setq emms-playlist-default-major-mode 'emms-mark-mode)

Run command `emms-add-directory-tree' as normal to get error.

The use of `emms-playlist-buffer-p' looks to be a bit inconsistent and confusing in the code, but as far as I can tell, my patch hasn't broken anything!

 emms-mark.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emms-mark.el b/emms-mark.el
index b640e12..a32760b 100644
--- a/emms-mark.el
+++ b/emms-mark.el
@@ -260,9 +260,9 @@ this function collects the result of FUNC."
       nil
 
     ;; start emms-playlist-mode exactly once
-    (setq emms-playlist-buffer-p t)
     (unless (eq major-mode 'emms-playlist-mode)
       (emms-playlist-mode))
+    (setq emms-playlist-buffer-p t)
 
     ;; use inherited keymap
     (set-keymap-parent emms-mark-mode-map (current-local-map))
-- 
2.39.2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.