Subject: [bug#28805] [PATCH] gnu: Add emacs-org-plus-contrib.

From: Christopher Baines <[email-masked]>
Date: Sun, 15 Oct 2017 21:11:23 +0100

On Sun, 15 Oct 2017 21:44:29 +0200
[email-masked] (Ludovic Courtès) wrote:

> > +(define-public emacs-org-contrib
> > +  (package
> > +    (inherit emacs-org)
> > +    (name "emacs-org-contrib")
> > +    (source (origin
> > +              (method url-fetch)
> > +              (uri (string-append "http://orgmode.org/elpa/org-plus-contrib-"
> > +                                  (package-version emacs-org) ".tar"))
> > +              (sha256
> > +               (base32
> > +                "1ya4kah8kg13ka3gpsw8hn6y8358843g986p1bgw5w77n9bgbwsl"))))
> > +    (arguments
> > +     `(#:phases
> > +       (modify-phases %standard-phases
> > +         (add-after 'install 'delete-org-files
> > +           (lambda* (#:key inputs outputs #:allow-other-keys)
> > +             (use-modules (ice-9 ftw))  
> 
> Please use #:modules instead of this inner ‘use-modules’ form (it has
> wacky semantic and could be deprecated in the future.)
> 
> > +             (let ((out (assoc-ref outputs "out")))
> > +               (for-each
> > +                (lambda (file)
> > +                  (if (and (not (string-prefix? "." file))
> > +                           (file-exists? file))
> > +                      (delete-file
> > +                       (string-append
> > +                        out
> > +                        "/share/emacs/site-lisp/guix.d/org-contrib-"
> > +                        ,(package-version emacs-org)
> > +                        "/"
> > +                        file))))
> > +                (scandir
> > +                 (string-append
> > +                  (assoc-ref inputs "emacs-org")
> > +                  "/share/emacs/site-lisp/guix.d/org-"
> > +                  ,(package-version emacs-org))))))))))  
> 
> For clarity, what about first buildign up the list of files to delete,
> and then actually deleting them?
> 
>   (let* (…
>          (org+contrib (map basename (find-files out)))
>          (org         (map basename (find-files org)))
>          (duplicates  (lset-intersection string=? org+contrib org)))
>     (with-directory-excursion (string-append out …)
>       (for-each delete-file duplicates))
>     #t)
> 
> WDYT?

That is nice :) I've attached an updated patch.
From 43ad9a4e6db6f4f94d2b2f63cbd9b729f5d4e607 Mon Sep 17 00:00:00 2001
From: Christopher Baines <[email-masked]>
Date: Wed, 11 Oct 2017 14:46:47 +0100
Subject: [PATCH] gnu: Add emacs-org-contrib.

* gnu/packages/emacs.scm (emacs-org-contrib): New variable.
---
 gnu/packages/emacs.scm | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 7661855a8..6e9c2a19d 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -4099,6 +4099,49 @@ also is an authoring system with unique support for literate programming and
 reproducible research.")
     (license license:gpl3+)))
 
+(define-public emacs-org-contrib
+  (package
+    (inherit emacs-org)
+    (name "emacs-org-contrib")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "http://orgmode.org/elpa/org-plus-contrib-"
+                                  (package-version emacs-org) ".tar"))
+              (sha256
+               (base32
+                "1ya4kah8kg13ka3gpsw8hn6y8358843g986p1bgw5w77n9bgbwsl"))))
+    (arguments
+     `(#:modules ((guix build emacs-build-system)
+                  (guix build utils)
+                  (guix build emacs-utils)
+                  (ice-9 ftw)
+                  (srfi srfi-1))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'install 'delete-org-files
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (org (assoc-ref inputs "emacs-org"))
+                    (contrib-files
+                     (map basename (find-files out)))
+                    (org+contrib-files
+                     (map basename (find-files org)))
+                    (duplicates (lset-intersection
+                                 string=? contrib-files org+contrib-files)))
+               (with-directory-excursion
+                   (string-append
+                    out "/share/emacs/site-lisp/guix.d/org-contrib-"
+                    ,(package-version emacs-org))
+                 (for-each delete-file duplicates))))))))
+    (propagated-inputs
+     `(("emacs-org" ,emacs-org)))
+    (synopsis "Contributed packages to Org-mode")
+    (description "Org is an Emacs mode for keeping notes, maintaining TODO
+lists, and project planning with a fast and effective plain-text system.
+
+This package is equivilent to org-plus-contrib, but only includes additional
+files that you would find in @file{contrib/} from the git repository.")))
+
 (define-public emacs-flx
   (package
     (name "emacs-flx")
-- 
2.14.2