~protesilaos/tmr

4 2

Re: Error when timer finishes: Error running timer ‘tmr--complete’: (invalid-function (sound tmr-sound-file))

Details
Message ID
<DM6PR08MB6106DCE5E884266FBBA42405A1A49@DM6PR08MB6106.namprd08.prod.outlook.com>
DKIM signature
missing
Download raw message
So, I managed to mangle the function for playing sounds:

---

;; NOTE 2022-04-21: Emacs has a `play-sound' function but it only
;; supports .wav and .au formats.  Also, it does not work on all
;; platforms and Emacs needs to be compiled --with-sound capabilities.
;;;###autoload
(defun tmr-sound-play (&optional _timer)
  "Play `tmr-sound-file' using the 'ffplay' executable (ffmpeg).
TIMER is unused."
  (when-let* ((tmr-sound-file))
    (when (file-exists-p tmr-sound-file)
      (unless (executable-find "ffplay")
        (user-error "Cannot play %s without `ffplay'" tmr-sound-file))
      (call-process-shell-command
       (format "ffplay -nodisp -autoexit %s >/dev/null 2>&1" tmr-sound-file) nil 0))))

---

That seems to work when I set a timer. I'm not sure if this breaks anything, though.

Thanks

Nathan DeGruchy
nathan@degruchy.org
https://degruchy.org/
https://linkedin.com/in/ndegruchy

Re: Error when timer finishes: Error running timer ‘tmr--complete’: (invalid-function (sound tmr-sound-file))

Details
Message ID
<87sfoe1or0.fsf@protesilaos.com>
In-Reply-To
<DM6PR08MB6106DCE5E884266FBBA42405A1A49@DM6PR08MB6106.namprd08.prod.outlook.com> (view parent)
DKIM signature
pass
Download raw message
> From: "Nathan R. DeGruchy" <nathan@degruchy.org>
> Date: Wed, 08 Jun 2022 21:14:22 +0000
>
> So, I managed to mangle the function for playing sounds:

> [... 18 lines elided]

>
> That seems to work when I set a timer. I'm not sure if this breaks anything, though.

Hello Nathan,

Your change looks good.  Do you want to prepare a patch for it or shall
I do it from here?

[ If you don't know how to format a patch, I can help you. ]

All the best,
Protesilaos (or simply "Prot")

-- 
Protesilaos Stavrou
https://protesilaos.com
Details
Message ID
<SN6PR08MB6112C75B4F2196EB821B9B31A1A79@SN6PR08MB6112.namprd08.prod.outlook.com>
In-Reply-To
<87sfoe1or0.fsf@protesilaos.com> (view parent)
DKIM signature
missing
Download raw message
Good morning!

I believe I can format a patch. I cloned your repo to make changes on my end.

Try this.

From: Protesilaos Stavrou <info@protesilaos.com>
Sent: Wednesday, June 8, 2022 23:48
To: Nathan R. DeGruchy <nathan@degruchy.org>; ~protesilaos/tmr@lists.sr.ht <~protesilaos/tmr@lists.sr.ht>
Subject: Re: Error when timer finishes: Error running timer ‘tmr--complete’: (invalid-function (sound tmr-sound-file)) 
 
> From: "Nathan R. DeGruchy" <nathan@degruchy.org>
> Date: Wed, 08 Jun 2022 21:14:22 +0000
>
> So, I managed to mangle the function for playing sounds:

> [... 18 lines elided]

>
> That seems to work when I set a timer. I'm not sure if this breaks anything, though.

Hello Nathan,

Your change looks good.  Do you want to prepare a patch for it or shall
I do it from here?

[ If you don't know how to format a patch, I can help you. ]

All the best,
Protesilaos (or simply "Prot")

-- 
Protesilaos Stavrou
https://protesilaos.com
Details
Message ID
<SN6PR08MB6112D83F6E1B54446047A16DA1A79@SN6PR08MB6112.namprd08.prod.outlook.com>
In-Reply-To
<SN6PR08MB6112C75B4F2196EB821B9B31A1A79@SN6PR08MB6112.namprd08.prod.outlook.com> (view parent)
DKIM signature
missing
Download raw message
Patch: +4 -4
Ah, needs to be inline.

From 4f52f8ad9cdf1ff9165b0f193d124d890937396e Mon Sep 17 00:00:00 2001
From: Nathan DeGruchy <nathan@degruchy.org>
Date: Wed, 8 Jun 2022 17:17:40 -0400
Subject: [PATCH] 'Fixes' sound playback for the timer. Dunno if this breaks
 anything.

---
 tmr-sound.el | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tmr-sound.el b/tmr-sound.el
index 540b833..6b60c3c 100644
--- a/tmr-sound.el
+++ b/tmr-sound.el
@@ -56,12 +56,12 @@ If nil, don't play any sound."
(defun tmr-sound-play (&optional _timer)
  "Play `tmr-sound-file' using the 'ffplay' executable (ffmpeg).
TIMER is unused."
  (when-let* ((sound tmr-sound-file))
    (when (file-exists-p sound)
  (when-let* ((tmr-sound-file))
    (when (file-exists-p tmr-sound-file)
      (unless (executable-find "ffplay")
        (user-error "Cannot play %s without `ffplay'" sound))
        (user-error "Cannot play %s without `ffplay'" tmr-sound-file))
      (call-process-shell-command
       (format "ffplay -nodisp -autoexit %s >/dev/null 2>&1" sound) nil 0))))
       (format "ffplay -nodisp -autoexit %s >/dev/null 2>&1" tmr-sound-file) nil 0))))

(provide 'tmr-sound)
;;; tmr-sound.el ends here



From: Nathan R. DeGruchy <nathan@degruchy.org>
Sent: Thursday, June 9, 2022 08:30
To: Protesilaos Stavrou <info@protesilaos.com>; ~protesilaos/tmr@lists.sr.ht <~protesilaos/tmr@lists.sr.ht>
Subject: Re: Error when timer finishes: Error running timer ‘tmr--complete’: (invalid-function (sound tmr-sound-file)) 
 
Good morning!

I believe I can format a patch. I cloned your repo to make changes on my end.

Try this.

From: Protesilaos Stavrou <info@protesilaos.com>
Sent: Wednesday, June 8, 2022 23:48
To: Nathan R. DeGruchy <nathan@degruchy.org>; ~protesilaos/tmr@lists.sr.ht <~protesilaos/tmr@lists.sr.ht>
Subject: Re: Error when timer finishes: Error running timer ‘tmr--complete’: (invalid-function (sound tmr-sound-file)) 
 
> From: "Nathan R. DeGruchy" <nathan@degruchy.org>
> Date: Wed, 08 Jun 2022 21:14:22 +0000
>
> So, I managed to mangle the function for playing sounds:

> [... 18 lines elided]

>
> That seems to work when I set a timer. I'm not sure if this breaks anything, though.

Hello Nathan,

Your change looks good.  Do you want to prepare a patch for it or shall
I do it from here?

[ If you don't know how to format a patch, I can help you. ]

All the best,
Protesilaos (or simply "Prot")

-- 
Protesilaos Stavrou
https://protesilaos.com

Re: Error when timer finishes: Error running timer ‘tmr--complete’: (invalid-function (sound tmr-sound-file))

Details
Message ID
<87k09qhtew.fsf@protesilaos.com>
In-Reply-To
<SN6PR08MB6112C75B4F2196EB821B9B31A1A79@SN6PR08MB6112.namprd08.prod.outlook.com> (view parent)
DKIM signature
pass
Download raw message
> From: "Nathan R. DeGruchy" <nathan@degruchy.org>
> Date: Thu, 09 Jun 2022 12:30:55 +0000
>
> Good morning!
>
> I believe I can format a patch. I cloned your repo to make changes on my end.
>
> Try this.

It works, thank you!  Though before I commit the change, I must ask you
to run a couple of quick tests.

I noticed that the original code was not using 'when-let*' properly.
Perhaps this combined with your Emacs build was causing the problem.

Does either of those forms work?

    (when-let ((sound tmr-sound-file))
      (when (file-exists-p sound)
        (unless (executable-find "ffplay")
          (user-error "Cannot play %s without `ffplay'" sound))
        (call-process-shell-command
         (format "ffplay -nodisp -autoexit %s >/dev/null 2>&1" sound) nil 0)))

In the above we simply change 'when-let*' to 'when-let'.  While in the
following we also get rid of the subsequent 'when'.

    (when-let ((sound tmr-sound-file)
               ((file-exists-p sound)))
      (unless (executable-find "ffplay")
        (user-error "Cannot play %s without `ffplay'" sound))
      (call-process-shell-command
       (format "ffplay -nodisp -autoexit %s >/dev/null 2>&1" sound) nil 0))

-- 
Protesilaos Stavrou
https://protesilaos.com
Reply to thread Export thread (mbox)