From cf746b38963c1c5bba9a87acd9e8d012fc0a9189 Mon Sep 17 00:00:00 2001
From: jao <jao@gnu.org>
Date: Sun, 15 May 2022 20:30:28 +0100
Subject: whitespace and nits

---
 lib/media/jao-mpris.el |  19 ++--
 lib/net/randomsig.el   | 275 ++++++++++++++++++++++++-------------------------
 2 files changed, 148 insertions(+), 146 deletions(-)

(limited to 'lib')

diff --git a/lib/media/jao-mpris.el b/lib/media/jao-mpris.el
index 2537fa8..47a35a7 100644
--- a/lib/media/jao-mpris.el
+++ b/lib/media/jao-mpris.el
@@ -93,7 +93,8 @@
 ;;;###autoload
 (defun jao-mpris-reset ()
   (interactive)
-  (setq jao-mpris-track-string ""))
+  (setq jao-mpris-track-string ""
+        jao-mpris--current nil))
 
 (defun jao-mpris--get (k &optional l)
   (when-let (v (alist-get k (or l jao-mpris--current)))
@@ -154,20 +155,22 @@
       (jao-minibuffer-add-msg-variable 'jao-mpris-track-string (- order))
     (jao-minibuffer-add-variable 'jao-mpris-track-string order)))
 
-(defun jao-mpris--handler (_iname properties &rest _args)
+(defun jao-mpris--handler (iname properties &rest _args)
   (let ((inhibit-message t))
-    (message "Received properties: %S from %s" properties _iname))
+    (message "Received properties: %S from %s" properties iname))
   (when-let (md (caadr (assoc "Metadata" properties)))
     (let ((tno (caadr (assoc "xesam:trackNumber" md)))
           (tlt (caadr (assoc "xesam:title" md)))
           (art (caadr (assoc "xesam:artist" md)))
           (alb (caadr (assoc "xesam:album" md)))
           (len (caadr (assoc "mpris:length" md))))
-      (jao-mpris--set-current 'track tno)
-      (jao-mpris--set-current 'title tlt)
-      (jao-mpris--set-current 'artist art)
-      (jao-mpris--set-current 'album alb)
-      (jao-mpris--set-current 'length len)))
+      (if (string= (or tlt "") "TIDAL")
+          (jao-mpris-reset)
+        (jao-mpris--set-current 'track tno)
+        (jao-mpris--set-current 'title tlt)
+        (jao-mpris--set-current 'artist art)
+        (jao-mpris--set-current 'album alb)
+        (jao-mpris--set-current 'length len))))
   (when-let (st (caadr (assoc "PlaybackStatus" properties)))
     (jao-mpris--set-current 'status st)
     (when (string= st "Stopped")
diff --git a/lib/net/randomsig.el b/lib/net/randomsig.el
index 71f31e1..cb37694 100644
--- a/lib/net/randomsig.el
+++ b/lib/net/randomsig.el
@@ -194,12 +194,12 @@ The files are searched in `randomsig-dir', if they don't have absolute paths.
 The signatures have to be separated by lines matching
 `randomsig-delimiter-pattern' at the beginning."
   :type '(choice
-	  (repeat
-	   :tag "List of filenames"
-	   (string :tag "filename"))
-	  (function
-	   :tag "function returning the signature files"
-	   :value randomsig-search-sigfiles))
+          (repeat
+           :tag "List of filenames"
+           (string :tag "filename"))
+          (function
+           :tag "function returning the signature files"
+           :value randomsig-search-sigfiles))
   :group 'randomsig)
 
 (defcustom randomsig-delimiter "-- "
@@ -228,8 +228,8 @@ You have to change `randomsig-delimiter-pattern', too, if you change this."
   "*Static string to be inserted above every random signature.
 You probably want to have a newline at the end of it."
   :type '(choice
-	  (const :tag "none" nil)
-	  (string))
+          (const :tag "none" nil)
+          (string))
   :group 'randomsig)
 
 
@@ -265,14 +265,14 @@ You probably want to have a newline at the end of it."
 (defun randomsig-files-to-list (files)
   ;; return a list of strings
   (cond ((listp files) files)
-	((and (symbolp files)
-	      (fboundp files))
+        ((and (symbolp files)
+              (fboundp files))
          (randomsig-files-to-list (funcall files)))
-	((and (symbolp files)
-	      (boundp files))
+        ((and (symbolp files)
+              (boundp files))
          (randomsig-files-to-list (symbol-value files)))
-	((stringp files) (list files))
-	(t nil)))
+        ((stringp files) (list files))
+        (t nil)))
 
 (defun randomsig-prompt (&optional prompt)
   ;; Prompt for a signature file.
@@ -285,13 +285,13 @@ You probably want to have a newline at the end of it."
   ;; save possibly local variables `randomsig-files' and `randomsig-dir'
   (let ((sigfiles randomsig-files) (sigdir randomsig-dir))
     (if (get-buffer buffer-name)
-	(progn
-	  (set-buffer buffer-name)
-	  (setq buffer-read-only nil)
-	  (delete-region (point-min) (point-max)))
+        (progn
+          (set-buffer buffer-name)
+          (setq buffer-read-only nil)
+          (delete-region (point-min) (point-max)))
       (progn
-	(get-buffer-create buffer-name)
-	(set-buffer buffer-name)))
+        (get-buffer-create buffer-name)
+        (set-buffer buffer-name)))
     (set (make-local-variable 'randomsig-files) sigfiles)
     (set (make-local-variable 'randomsig-dir) sigdir))
 
@@ -309,34 +309,33 @@ You probably want to have a newline at the end of it."
      (lambda (fname)
 
        (let ((pos (point-max)))
-	 ;;(add-to-list 'randomsig-buffer-file-pos-list (cons fname pos) t)
-					; this does not work with XEmacs
-	 (goto-char pos)
-	 (insert-file-contents (expand-file-name fname randomsig-dir))
-	 ;; No delimiter at the beginning? Insert one.
-	 (unless (string-match randomsig-delimiter-pattern
-			       (buffer-substring (goto-char pos)
-						 (line-end-position)))
-	   (goto-char pos)
-	   (insert randomsig-delimiter)
-	   (insert "\n")
-	   ;; Correct position...
-	   (setq pos (+ pos (length randomsig-delimiter) 1)))
-
-	 (setq randomsig-buffer-file-pos-list
-	       (append randomsig-buffer-file-pos-list
-		       (list (cons fname pos))))
-	 (goto-char (point-max))
- 	 (unless (and (char-before)
- 		      (char-equal (char-before) ?\n)) ; Newline?
- 	   (insert "\n"))))
+         ;;(add-to-list 'randomsig-buffer-file-pos-list (cons fname pos) t)
+                                        ; this does not work with XEmacs
+         (goto-char pos)
+         (insert-file-contents (expand-file-name fname randomsig-dir))
+         ;; No delimiter at the beginning? Insert one.
+         (unless (string-match randomsig-delimiter-pattern
+                               (buffer-substring (goto-char pos)
+                                                 (line-end-position)))
+           (goto-char pos)
+           (insert randomsig-delimiter)
+           (insert "\n")
+           ;; Correct position...
+           (setq pos (+ pos (length randomsig-delimiter) 1)))
+
+         (setq randomsig-buffer-file-pos-list
+               (append randomsig-buffer-file-pos-list
+                       (list (cons fname pos))))
+         (goto-char (point-max))
+         (unless (and (char-before)
+                      (char-equal (char-before) ?\n)) ; Newline?
+           (insert "\n"))))
      sigfiles)
     (set-buffer-modified-p nil)
     (setq buffer-read-only t)
     (current-buffer)))
 
 
-
 (defun randomsig-insert-signature (sig)
   ;; Insert SIG as signature in current buffer
   (save-excursion
@@ -353,8 +352,8 @@ You probably want to have a newline at the end of it."
   (goto-char (point-min))
   (if (re-search-forward "^-- $" nil t)
       (progn
-	(forward-line 1)
-	t)
+        (forward-line 1)
+        t)
     (progn
       (goto-char (point-max))
       nil)))
@@ -383,28 +382,28 @@ Else a signature out of `randomsig-files' will be choosen."
     (goto-char (point-min))
     (let '(count 0) 'selected
 
-	 ;; Count number of signatures
-	 (while (search-forward-regexp randomsig-delimiter-pattern nil t)
-	   (setq count (1+ count)))
+         ;; Count number of signatures
+         (while (search-forward-regexp randomsig-delimiter-pattern nil t)
+           (setq count (1+ count)))
 
-	 ;; Select random signature out out these
-	 (setq selected (1+ (random count)))
-	 (goto-char (point-min))
-	 (if (search-forward-regexp randomsig-delimiter-pattern nil t selected)
-	     (forward-char))
+         ;; Select random signature out out these
+         (setq selected (1+ (random count)))
+         (goto-char (point-min))
+         (if (search-forward-regexp randomsig-delimiter-pattern nil t selected)
+             (forward-char))
 
-	 ;; Cut signature and return it
-	 (let '(here (point)) 'signature-string
+         ;; Cut signature and return it
+         (let '(here (point)) 'signature-string
 
-	      (if (not (search-forward-regexp randomsig-delimiter-pattern
-					      nil t))
-		  (goto-char (point-max))
-		(beginning-of-line))
-	      (setq signature-string
-		    (concat randomsig-static-string
-			    (buffer-substring here (point))))
-	      (kill-buffer randomsig-buffer-name)
-	      signature-string))))
+              (if (not (search-forward-regexp randomsig-delimiter-pattern
+                                              nil t))
+                  (goto-char (point-max))
+                (beginning-of-line))
+              (setq signature-string
+                    (concat randomsig-static-string
+                            (buffer-substring here (point))))
+              (kill-buffer randomsig-buffer-name)
+              signature-string))))
 
 
 (defun randomsig-replace-sig (arg)
@@ -417,8 +416,8 @@ that should be used"
     (randomsig-replace-signature
      (randomsig-signature
       (if arg
-	  (randomsig-prompt "read from signature-lib: ")
-	randomsig-files)))))
+          (randomsig-prompt "read from signature-lib: ")
+        randomsig-files)))))
 
 
 
@@ -429,32 +428,32 @@ When called with prefix, let the user edit the signature before saving"
   (interactive "P")
   (save-excursion
     (let '(signature-string
-	   (if (randomsig-mark-active-p)
-
-	       (buffer-substring (point) (mark))
-
-	     (progn
-	       (if (randomsig-goto-signature)
-		   (let `(here (point))
-		     (goto-char (point-max))
-		     (while (char-equal (char-before) 10)
-		       (backward-char))
-		     (buffer-substring here (point)))
-		 nil))))
+           (if (randomsig-mark-active-p)
+
+               (buffer-substring (point) (mark))
+
+             (progn
+               (if (randomsig-goto-signature)
+                   (let `(here (point))
+                     (goto-char (point-max))
+                     (while (char-equal (char-before) 10)
+                       (backward-char))
+                     (buffer-substring here (point)))
+                 nil))))
       (when signature-string
-	(if arg
-	    (progn
-	      ;; make sure this is nil...
-	      (setq randomsig-select-edit-bufferpos nil)
-	      (randomsig-edit signature-string))
-	  (randomsig-write-signature signature-string))))))
+        (if arg
+            (progn
+              ;; make sure this is nil...
+              (setq randomsig-select-edit-bufferpos nil)
+              (randomsig-edit signature-string))
+          (randomsig-write-signature signature-string))))))
 
 
 (defun randomsig-write-signature (signature-string)
   (set-buffer (find-file-noselect
-	       (expand-file-name
-		(randomsig-prompt "Write to signature-lib: ")
-		randomsig-dir)))
+               (expand-file-name
+                (randomsig-prompt "Write to signature-lib: ")
+                randomsig-dir)))
 
   (goto-char (point-max))
   (insert (concat randomsig-delimiter "\n"))
@@ -483,20 +482,20 @@ If FILE is given, only FILE and its subdirectory will be searched."
     (setq file ""))
 
   (if (or (string-match "\\(/\\|^\\)\\(\\.\\|\\.\\.\\)$" file)
-	  (string-match randomsig-search-unwanted file))
+          (string-match randomsig-search-unwanted file))
       ;; unwanted...
       nil
 
     (let '(path (expand-file-name file randomsig-dir))
       (if (file-directory-p path)
-	  (mapcan (lambda (f)
-		    (randomsig-search-sigfiles (if (string= file "")
-						   f
-						 (concat file "/" f))))
-		  (directory-files path))
-	(if (file-regular-p path)
-	    (list file)
-	  nil)))))
+          (mapcan (lambda (f)
+                    (randomsig-search-sigfiles (if (string= file "")
+                                                   f
+                                                 (concat file "/" f))))
+                  (directory-files path))
+        (if (file-regular-p path)
+            (list file)
+          nil)))))
 
 
 ;;; Commands/Function for randomsig-edit-mode
@@ -518,33 +517,33 @@ If FILE is given, only FILE and its subdirectory will be searched."
       (error "Not in select buffer previously"))
   (set-buffer randomsig-buffer-name)
   (let* ((fname (randomsig-buffer-which-file))
-	 (sig_end
-	  ;; point in selection buffer, where signature ends
-	  (progn
-	    (if (search-forward-regexp randomsig-delimiter-pattern nil t)
-		(search-backward-regexp randomsig-delimiter-pattern nil nil))
-	    (point)))
-	 (sig_start
-	  ;; point in selection buffer, where signature starts
-	  (progn
-	    (if (search-backward-regexp randomsig-delimiter-pattern nil t)
-		(progn
-		  (search-forward-regexp randomsig-delimiter-pattern nil nil)
-		  (forward-char)))
-	    (point)))
-	 (f_start
-	  ;; point in selection buffer, where signature file starts
-	  (- (cdr (assoc fname randomsig-buffer-file-pos-list))
-	     (point-min)))
-	 ;; point in file, where Signature starts/ends
-	 (f_sig_start (- sig_start f_start))
-	 (f_sig_end (- sig_end f_start))
-	 ;; old signature
-	 (old_sig (randomsig-signature-at-point)))
+         (sig_end
+          ;; point in selection buffer, where signature ends
+          (progn
+            (if (search-forward-regexp randomsig-delimiter-pattern nil t)
+                (search-backward-regexp randomsig-delimiter-pattern nil nil))
+            (point)))
+         (sig_start
+          ;; point in selection buffer, where signature starts
+          (progn
+            (if (search-backward-regexp randomsig-delimiter-pattern nil t)
+                (progn
+                  (search-forward-regexp randomsig-delimiter-pattern nil nil)
+                  (forward-char)))
+            (point)))
+         (f_start
+          ;; point in selection buffer, where signature file starts
+          (- (cdr (assoc fname randomsig-buffer-file-pos-list))
+             (point-min)))
+         ;; point in file, where Signature starts/ends
+         (f_sig_start (- sig_start f_start))
+         (f_sig_end (- sig_end f_start))
+         ;; old signature
+         (old_sig (randomsig-signature-at-point)))
     (set-buffer (find-file-noselect (expand-file-name fname randomsig-dir)))
 
     (if (not (string= old_sig (buffer-substring f_sig_start f_sig_end)))
-	(error "Signature file has changed"))
+        (error "Signature file has changed"))
     (delete-region f_sig_start f_sig_end)
     (goto-char f_sig_start)
     (insert signature)
@@ -555,9 +554,9 @@ If FILE is given, only FILE and its subdirectory will be searched."
 (defun randomsig-edit-done ()
   (interactive)
   (let ((signature-string (buffer-string))
-	(edit-buffer (current-buffer)))
+        (edit-buffer (current-buffer)))
     (if randomsig-select-edit-bufferpos
-	(randomsig-replace-signature-in-signature-files signature-string)
+        (randomsig-replace-signature-in-signature-files signature-string)
       (randomsig-write-signature signature-string))
     (kill-buffer edit-buffer)))
 
@@ -592,14 +591,14 @@ You most likely do not want to call `randomsig-edit-mode' directly.
   ;; Return the signature at current cursor position
   (save-excursion
     (if (search-backward-regexp randomsig-delimiter-pattern nil t)
-	(forward-line))
+        (forward-line))
     (let ((beginning (point)))
       (if (search-backward-regexp randomsig-delimiter-pattern nil t)
-	  (forward-line))
+          (forward-line))
       (if (not (search-forward-regexp randomsig-delimiter-pattern
-				      nil t))
-	  (goto-char (point-max))
-	(beginning-of-line))
+                                      nil t))
+          (goto-char (point-max))
+        (beginning-of-line))
       (buffer-substring beginning (point)))))
 
 
@@ -633,7 +632,7 @@ with the signature at the current position, and quit selection."
   (set-buffer randomsig-buffer-name)
   (let ((pos (point)))
     (randomsig-read-signatures-to-buffer randomsig-buffer-name
-					 randomsig-loaded-files)
+                                         randomsig-loaded-files)
     (goto-char pos)))
 
 
@@ -646,13 +645,13 @@ with the signature at the current position, and quit selection."
 
 (defun randomsig-buffer-which-file ()
   (let ((p 0)
-	(fname "")
-	(l randomsig-buffer-file-pos-list))
+        (fname "")
+        (l randomsig-buffer-file-pos-list))
     (while (progn
-	     (setq fname (car (car l)))
-	     (setq l (cdr l))
-	     (setq p (cdr (car l)))
-	     (and l (<= p (point)))))
+             (setq fname (car (car l)))
+             (setq l (cdr l))
+             (setq p (cdr (car l)))
+             (and l (<= p (point)))))
     fname))
 
 
@@ -679,10 +678,10 @@ You most likely do not want to call `randomsig-select-mode' directly; use
   (and (not (boundp 'xemacs-codename))
        (>= emacs-major-version 21)
        (setq mode-line-buffer-identification
-	     '(:eval (format "%-12s"
-			     (concat "["
-				     (randomsig-buffer-which-file)
-				     "]"))))))
+             '(:eval (format "%-12s"
+                             (concat "["
+                                     (randomsig-buffer-which-file)
+                                     "]"))))))
 
 (defun randomsig-select-sig (arg)
   "Select a new signature from a list.
@@ -698,7 +697,7 @@ that should be used."
    (randomsig-read-signatures-to-buffer
     randomsig-buffer-name
     (if arg
-	(randomsig-prompt "read from signature-lib: ")
+        (randomsig-prompt "read from signature-lib: ")
       randomsig-files)))
   (goto-char 0)
   (forward-line)
-- 
cgit v1.2.3