[PATCH] gnu: Add emacs-wakatime-mode.

  • Open
  • quality assurance status badge
Details
4 participants
  • Hilton Chain
  • Liliana Marie Prikler
  • Christopher Baines
  • Nicolas Goaziou
Owner
unassigned
Submitted by
Hilton Chain
Severity
normal
H
H
Hilton Chain wrote on 25 Nov 2022 02:15
(address . guix-patches@gnu.org)(name . Hilton Chain)(address . hako@ultrarare.space)
20221125011530.12585-1-hako@ultrarare.space
* gnu/packages/emacs-xyz.scm (emacs-wakatime-mode): New variable.
---
gnu/packages/emacs-xyz.scm | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)

Toggle diff (43 lines)
diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index e941064d07..a6002efa51 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -34160,6 +34160,36 @@ (define-public emacs-semi-epg
EasyPG and latest Emacs.")
(license license:gpl2+))))

+(define-public emacs-wakatime-mode
+ ;; No release since May 5, 2015.
+ (let ((version "1.0.2") ;32a0154cd4bbd525d354997e6b12c6a9726d0b43, not tagged
+ (revision "55")
+ (commit "ef923829912c3854d230834f81083814b7c9d992"))
+ (package
+ (name "emacs-wakatime-mode")
+ (version (git-version version revision commit))
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/wakatime/wakatime-mode")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0m29817s2din4n42pflvzg2538i91s0n06y78pf8q94qf0mfspcl"))))
+ (build-system emacs-build-system)
+ (arguments
+ (list #:phases
+ #~(modify-phases %standard-phases
+ ;; XXX: WakaTime hasn't packaged in Guix yet.
+ (delete 'patch-el-files))))
+ (home-page "https://wakatime.com/emacs")
+ (synopsis "Automatic time tracking extension for Emacs using WakaTime")
+ (description
+ "@code{wakatime-mode} is an Emacs plugin for automatic time tracking
+and metrics generated from your programming activity.")
+ (license license:gpl3+))))
+
(define-public emacs-wanderlust
;; No release since Jan 15, 2010.
;; FIXME: Building with emacs-next-pgtk would yield a void variable related

base-commit: 5eb2995c006283fc0b649f10a6d002580ccac8d6
--
2.38.1
N
N
Nicolas Goaziou wrote on 26 Nov 2022 11:21
(name . Hilton Chain via Guix-patches via)(address . guix-patches@gnu.org)
87edtqc8xq.fsf@nicolasgoaziou.fr
Hello,

Hilton Chain via Guix-patches via <guix-patches@gnu.org> writes:

Toggle quote (2 lines)
> * gnu/packages/emacs-xyz.scm (emacs-wakatime-mode): New variable.

Thank you.

Toggle quote (6 lines)
> +(define-public emacs-wakatime-mode
> + ;; No release since May 5, 2015.
> + (let ((version "1.0.2") ;32a0154cd4bbd525d354997e6b12c6a9726d0b43, not tagged
> + (revision "55")
> + (commit "ef923829912c3854d230834f81083814b7c9d992"))

You can insert "1.0.2" directly in `version' field below instead of
binding it beforehand.

Toggle quote (19 lines)
> + (package
> + (name "emacs-wakatime-mode")
> + (version (git-version version revision commit))
> + (source (origin
> + (method git-fetch)
> + (uri (git-reference
> + (url "https://github.com/wakatime/wakatime-mode")
> + (commit commit)))
> + (file-name (git-file-name name version))
> + (sha256
> + (base32
> + "0m29817s2din4n42pflvzg2538i91s0n06y78pf8q94qf0mfspcl"))))
> + (build-system emacs-build-system)
> + (arguments
> + (list #:phases
> + #~(modify-phases %standard-phases
> + ;; XXX: WakaTime hasn't packaged in Guix yet.
> + (delete 'patch-el-files))))

Wouldn't it make sense to package WakaTime first, then?

Could you also run tests?

Toggle quote (6 lines)
> + (synopsis "Automatic time tracking extension for Emacs using WakaTime")
> + (description
> + "@code{wakatime-mode} is an Emacs plugin for automatic time tracking
> +and metrics generated from your programming activity.")

WakaTime mode is an Emacs minor mode for automatic...

Regards,
--
Nicolas Goaziou
C
C
Christopher Baines wrote on 28 Nov 2022 10:02
tag 59552 moreinfo
(address . control@debbugs.gnu.org)
8735a3laer.fsf@cbaines.net
tags 59552 + moreinfo
quit
H
H
Hilton Chain wrote on 15 Jul 2023 17:01
[PATCH v2 0/1] gnu: Add emacs-wakatime-mode.
(address . 59552@debbugs.gnu.org)
cover.1689427041.git.hako@ultrarare.space
Hello Guix!

After looking through waktime-mode's source and Guix's build phases, I think
it's OK to add the package first without packaging the wakatime-cli program.

(Actually I managed to package all the dependencies of that go program locally,
but it eventually failed to build without a clear error...)

For the package definition itself, phase 'patch-el-files is still deleted
because of the following error:

Toggle snippet (10 lines)
In guix/build/emacs-build-system.scm:
148:13 3 (loop (#(" ((file-exists-p (format \"/bin/%s\" …" …)) …)
In ice-9/boot-9.scm:
1685:16 2 (raise-exception _ #:continuable? _)
1685:16 1 (raise-exception _ #:continuable? _)
1685:16 0 (raise-exception _ #:continuable? _)
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
patch-el-files: unable to locate "%s"

I added a comment before suggesting that wakatime-cli is not available, but
that was inaccurate. The real cause is that 'patch-el-files can't handle the
following code:

Toggle snippet (9 lines)
(defun wakatime-find-binary (program)
"Find the full path to an executable program."
(cond
[...]
((file-exists-p (format "/bin/%s" program))
(format "/bin/%s" program))
[...]))

This seems to be a bug of the phase, as it shouldn't handle unformatted
"/bin/%s" at all. And for the function finding an executable, it's
unnecessary to patch it, then I think it's fine to delete the phase.

And finally, it's wakatime-mode-test.el, the cases are so outdated that none
of them could pass... There's no Makefile for 'check phase to run the test
either, so no need to adjust for it.

As a result, I think it's OK to add the package first without packaging the
wakatime-cli program.

Hilton Chain (1):
gnu: Add emacs-wakatime-mode.

gnu/packages/emacs-xyz.scm | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)


base-commit: 01412c6c6a98e4da10676560638640d0f33e1a02
--
2.41.0
H
H
Hilton Chain wrote on 15 Jul 2023 17:05
[PATCH v2 1/1] gnu: Add emacs-wakatime-mode.
(name . Hilton Chain)(address . hako@ultrarare.space)
39e1399d86945de7920239aebabbb0894ad03f6e.1689427041.git.hako@ultrarare.space
* gnu/packages/emacs-xyz.scm (emacs-wakatime-mode): New variable.
---
gnu/packages/emacs-xyz.scm | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)

Toggle diff (43 lines)
diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index 480096fb50..84baf7ea32 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -37153,6 +37153,36 @@ (define-public emacs-mpv
process via its IPC interface.")
(license license:gpl3+))))
+(define-public emacs-wakatime-mode
+ ;; No release since May 5, 2015.
+ (let ((commit "ef923829912c3854d230834f81083814b7c9d992")
+ (revision "55"))
+ (package
+ (name "emacs-wakatime-mode")
+ ;; 1.0.2 on commit 32a0154cd4bbd525d354997e6b12c6a9726d0b43, not tagged
+ (version (git-version "1.0.2" revision commit))
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/wakatime/wakatime-mode")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0m29817s2din4n42pflvzg2538i91s0n06y78pf8q94qf0mfspcl"))))
+ (build-system emacs-build-system)
+ (arguments
+ (list #:phases
+ #~(modify-phases %standard-phases
+ ;; 'patch-el-files errors at "/bin/%s"
+ (delete 'patch-el-files))))
+ (home-page "https://wakatime.com/emacs")
+ (synopsis "Automatic time tracking extension for Emacs using WakaTime")
+ (description
+ "WakaTime mode is an Emacs minor mode for automatic time tracking and
+metrics generated from your programming activity.")
+ (license license:gpl3+))))
+
(define-public emacs-apel-lb
;; No release since Jun 15, 2010.
(let ((version "10.8") ;tag chise-base-0_25
--
2.41.0
L
L
Liliana Marie Prikler wrote on 16 Jul 2023 09:17
Re: [bug#59552] [PATCH v2 0/1] gnu: Add emacs-wakatime-mode.
797011fcc7b4dc7f7b291e2a28e28b4e2f902017.camel@gmail.com
Am Samstag, dem 15.07.2023 um 23:01 +0800 schrieb Hilton Chain:
Toggle quote (14 lines)
> --8<---------------cut here---------------start------------->8---
> (defun wakatime-find-binary (program)
>   "Find the full path to an executable program."
>   (cond
>     [...]
>     ((file-exists-p (format "/bin/%s" program))
>       (format "/bin/%s" program))
>     [...]))
> --8<---------------cut here---------------end--------------->8---
>
> This seems to be a bug of the phase, as it shouldn't handle
> unformatted
> "/bin/%s" at all.  And for the function finding an executable, it's
> unnecessary to patch it, then I think it's fine to delete the phase.
I think this should be 
(or (executable-find program) 
(cdr-safe (assoc program <some hardcoded table>))
where some hardcoded table contains stubs to fill in via 
(search-input-file …)

Cheers
H
H
Hilton Chain wrote on 18 Jul 2023 18:35
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)
875y6hyy7m.wl-hako@ultrarare.space
On Sun, 16 Jul 2023 15:17:01 +0800,
Liliana Marie Prikler wrote:
Toggle quote (6 lines)
> I think this should be 
> (or (executable-find program) 
> (cdr-safe (assoc program <some hardcoded table>))
> where some hardcoded table contains stubs to fill in via 
> (search-input-file …)

Thank you for the suggestion!

Sorry for the incomplete information, the PROGRAM argument is actually
nonsense because `wakatime-find-binary' is not a user-facing function
and is called with a fixed value of "wakatime-cli", so it's not
appropriate to use an alist.

Other (hardcoded) values are actually handled as conditions within the
function.

I tried replacing the conditions with yours, except for the `cdr-safe'
line, which is replaced by a `locate-file', and it seems to work fine.
The new function does not contain a "/bin/[...]" so 'patch-el-files
won't handle it.

This may not be expected but I think it's enough to improve the
function itself.

I'll send a patch to upstream and send v3 later.

Thanks
?