Subject: Re: [bug#36999] [PATCH] gnu: Add emacs-forge.

From: Oleg Pyhalov <[email-masked]>
Date: Sun, 18 Aug 2019 18:49:29 +0300

Hi Kyle,

Kyle Meyer <[email-masked]> writes:

> Hi Oleg,
>
> Oleg Pyhalov <[email-masked]> writes:
>
> [...]
>
>> New Magit requires https://github.com/magit/libegit2 which I try to
>> build, but stuck.  I succeeded to build ‘libgit2.so’ and load it in
>> Emacs, but ‘featurep’ procedure says that feature is not loaded.

I mean ‘libegit2.so’, apologies for a typo.

> I haven't been following this thread closely, but in case it's useful:
> Building Magit should work without libegit2 if you set
> BUILD_MAGIT_LIBGIT to false.

Oh, nice.  Apparently we could avoid libegit2 at all for now.  I get a
working Forge by finding a commit in Magit which intoduced a procedure
required to open GitLab issue content.

I need a time to test Magit and Forge behavior for some days and could
merge it if no issues discovered.  Latest patches attached here.

From 6f4ab7861321232c8786446904df4ffc53323bf9 Mon Sep 17 00:00:00 2001
From: Brian Leung <[email-masked]>
Date: Wed, 14 Aug 2019 08:04:20 +0200
Subject: [PATCH 1/3] gnu: emacs-ghub: Update to 3.2.0-1.7d59937.

* gnu/packages/emacs-xyz.scm (emacs-ghub): Update to 3.2.0-1.7d59937.

Signed-off-by: Oleg Pykhalov <[email-masked]>
---
 gnu/packages/emacs-xyz.scm | 62 ++++++++++++++++++++------------------
 1 file changed, 32 insertions(+), 30 deletions(-)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index adab7d87d2..82c811a2d6 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -521,39 +521,41 @@ deliver data to mobile and web apps.")
    (license license:gpl3+)))
 
 (define-public emacs-ghub
-  (package
-    (name "emacs-ghub")
-    (version "3.2.0")
-    (source (origin
-              (method git-fetch)
-              (uri (git-reference
-                     (url "https://github.com/magit/ghub")
-                     (commit (string-append "v" version))))
-              (file-name (git-file-name name version))
-              (sha256
-               (base32
-                "0lp52qygyavddl1lrgsyb6mq7hcf9h89dy2pzya3mb2va49f0vvl"))))
-    (build-system emacs-build-system)
-    (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (add-before 'install 'make-info
-           (lambda _
-             (invoke "make" "info"))))))
-    (native-inputs
-     `(("texinfo" ,texinfo)))
-    (propagated-inputs
-     `(("dash" ,emacs-dash)
-       ("graphql" ,emacs-graphql)
-       ("treepy" ,emacs-treepy)))
-    (home-page "https://github.com/magit/ghub")
-    (synopsis "Emacs client libraries for the APIs of various Git forges")
-    (description
-     "Ghub provides basic support for using the APIs of various Git forges from
+  ;; We need a newer commit to avoid problems in emacs-forge.
+  (let ((commit "7d59937d7782d0062216130a4d059b45e8396f82")
+        (revision "1"))
+    (package
+      (name "emacs-ghub")
+      (version (git-version "3.2.0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/magit/ghub")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "1ngb61nij9gznqplwg1fmr1vq1czry759hmdibzngl4wqhxpfsjq"))))
+      (build-system emacs-build-system)
+      (arguments
+       `(#:phases
+         (modify-phases %standard-phases
+           (add-before 'install 'make-info
+             (lambda _
+               (invoke "make" "info"))))))
+      (native-inputs
+       `(("texinfo" ,texinfo)))
+      (propagated-inputs
+       `(("dash" ,emacs-dash)
+         ("treepy" ,emacs-treepy)))
+      (home-page "https://github.com/magit/ghub")
+      (synopsis "Emacs client libraries for the APIs of various Git forges")
+      (description
+       "Ghub provides basic support for using the APIs of various Git forges from
 Emacs packages.  It supports the REST APIs of Github, Github GraphQL, Gitlab,
 Gitea, Gogs and Bitbucket.  It abstracts access to API resources using only a
 handful of functions that are not resource-specific.")
-    (license license:gpl3+)))
+      (license license:gpl3+))))
 
 (define-public emacs-scribble-mode
   (let ((commit "34e9e5edb921813b6483e0fefa848efb6ee4b314")
-- 
2.22.1

From 1fa9f804e62aadcd693aac2edf17ae65bc8f2544 Mon Sep 17 00:00:00 2001
From: Oleg Pykhalov <[email-masked]>
Date: Wed, 14 Aug 2019 23:12:48 +0300
Subject: [PATCH 2/3] gnu: emacs-magit: Update to 2.90.1-1.c761d28.

* gnu/packages/emacs-xyz.scm (emacs-magit): Update to 2.90.1-1.c761d28.
---
 gnu/packages/emacs-xyz.scm | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index 82c811a2d6..b483f42032 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -262,21 +262,28 @@ on stdout instead of using a socket as the Emacsclient does.")
     (license license:gpl3+)))
 
 (define-public emacs-magit
-  ;; Version 2.90.1 has trouble loading the transient library,
-  ;; so we use a more recent commit that fixes it.
-  (let ((commit "b4aec016b5577afa8d889f258b499814d1bb1d94"))
+  ;; `magit-setup-buffer' macro introduced in c761d28d and required in
+  ;; `emacs-forge'.
+  (let ((commit "c761d28d49e5238037512b898db0ec9b40d85770"))
     (package
       (name "emacs-magit")
       (version (git-version "2.90.1" "1" commit))
       (source (origin
                 (method git-fetch)
                 (uri (git-reference
-                      (url "https://github.com/magit/magit")
+                      (url "https://github.com/magit/magit.git")
                       (commit commit)))
                 (file-name (git-file-name name version))
                 (sha256
                  (base32
-                  "0zl7v6z0y50pcgqsf2r8c1k3r5nwjad9ba7r6sgrnf4rc62br7jv"))))
+                  "16qx0404l05q1m6w7y5j8ck1z5nfmpinm00w0p2yh1hn5zzwy6dd"))
+                (modules '((guix build utils)))
+                (snippet
+                 '(begin
+                    ;; Fix syntax error
+                    (substitute* "lisp/magit-extras.el"
+                      (("rev\\)\\)\\)\\)\\)\\)") "rev)))))"))
+                    #t))))
       (build-system gnu-build-system)
       (native-inputs `(("texinfo" ,texinfo)
                        ("emacs" ,emacs-minimal)))
-- 
2.22.1

From b3c501b00ba335ef9182ecfb1345b014feab9af3 Mon Sep 17 00:00:00 2001
From: Oleg Pykhalov <[email-masked]>
Date: Sat, 10 Aug 2019 19:17:12 +0300
Subject: [PATCH 3/3] gnu: Add emacs-forge.

* gnu/packages/emacs-xyz.scm (emacs-forge): New variable.
---
 gnu/packages/emacs-xyz.scm | 79 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index b483f42032..d907ee5375 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -15856,6 +15856,85 @@ command\", but because it always involves at least two commands (a prefix and
 a suffix) we prefer to call it just a \"transient\".")
       (license license:gpl3+))))
 
+(define-public emacs-forge
+  (let ((commit "a60bd64056ec910fdbd1400dd8f583b8eec6145b"))
+    (package
+      (name "emacs-forge")
+      (version (git-version "0.1.0" "1" commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/magit/forge.git")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32
+           "1dhpsnb82mxpv3krf3apsbcirlcizw3g9gac9sfn0fad20qjwpgj"))))
+      (build-system gnu-build-system)
+      (native-inputs
+       `(("texinfo" ,texinfo)
+         ("emacs" ,emacs-minimal)))
+      (propagated-inputs
+       `(("emacs-closql" ,emacs-closql)
+         ("emacs-dash" ,emacs-dash)
+         ("emacs-emacsql-sqlite" ,emacs-emacsql)
+         ("emacs-ghub" ,emacs-ghub)
+         ("emacs-let-alist" ,emacs-let-alist)
+         ("emacs-magit" ,emacs-magit)
+         ("emacs-markdown-mode" ,emacs-markdown-mode)
+         ("emacs-transient" ,emacs-transient)))
+      (arguments
+       `(#:tests? #f ;no tests
+         #:modules ((srfi srfi-26)
+                    (guix build gnu-build-system)
+                    ((guix build emacs-build-system) #:prefix emacs:)
+                    (guix build utils)
+                    (guix build emacs-utils))
+         #:imported-modules (,@%gnu-build-system-modules
+                             (guix build emacs-build-system)
+                             (guix build emacs-utils))
+         #:phases
+         (modify-phases %standard-phases
+           (delete 'configure)
+           (delete 'install)
+           (add-after 'unpack 'delete-doc-targets
+             (lambda _
+               (substitute* "./Makefile"
+                 (("lisp docs") "lisp"))))
+           (add-after 'delete-doc-targets 'emacs-set-emacs-load-path
+             (assoc-ref emacs:%standard-phases 'set-emacs-load-path))
+           (add-after 'emacs-set-emacs-load-path 'chdir-lisp
+             (lambda _
+               (chdir "lisp")))
+           (add-after 'chdir-lisp 'emacs-install
+             (assoc-ref emacs:%standard-phases 'install))
+           (add-after 'emacs-install 'emacs-make-autoloads
+             (assoc-ref emacs:%standard-phases 'make-autoloads))
+           (add-after 'build 'install-elc
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (el-dir (string-append
+                               out "/share/emacs/site-lisp/guix.d/forge-"
+                               ,version)))
+                 (for-each (cut install-file <> el-dir)
+                           (find-files "." "\\.elc"))
+                 #t)))
+           (add-after 'install-elc 'install-doc
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (info (string-append out "/share/info")))
+                 (with-directory-excursion "../docs"
+                   (invoke "makeinfo" "forge.texi")
+                   (install-file "forge.info" info)
+                   #t)))))))
+      (home-page "https://github.com/magit/ghub/")
+      (synopsis "Access Git forges from Magit")
+      (description
+       "Work with Git forges, such as Github and Gitlab, from the comfort of
+Magit and the rest of Emacs.")
+      (license license:gpl3+))))
+
 (define-public emacs-matcha
   (let ((commit "c7df5cf5cdac9ae369e241342389ccda0205eab9"))
     (package
-- 
2.22.1