GNU bug report logs - #33598
Optimizations for emacs-clang-format and emacs-clang-rename

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Tim Gesthuizen <tim.gesthuizen@HIDDEN>; dated Mon, 3 Dec 2018 13:49:01 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.

Message received at 33598 <at> debbugs.gnu.org:


Received: (at 33598) by debbugs.gnu.org; 13 Dec 2018 22:49:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Dec 13 17:49:54 2018
Received: from localhost ([127.0.0.1]:47022 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gXZnl-0008TE-O1
	for submit <at> debbugs.gnu.org; Thu, 13 Dec 2018 17:49:54 -0500
Received: from eggs.gnu.org ([208.118.235.92]:35266)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1gXZnj-0008T0-GN
 for 33598 <at> debbugs.gnu.org; Thu, 13 Dec 2018 17:49:52 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <ludo@HIDDEN>) id 1gXZnY-0005Q8-R5
 for 33598 <at> debbugs.gnu.org; Thu, 13 Dec 2018 17:49:44 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=disabled
 version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:45773)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1gXZnN-00050t-Nd; Thu, 13 Dec 2018 17:49:33 -0500
Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=32778 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1gXZnN-0003T7-2V; Thu, 13 Dec 2018 17:49:29 -0500
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Tim Gesthuizen <tim.gesthuizen@HIDDEN>,
 Pierre Neidhardt <mail@HIDDEN>
Subject: Re: [bug#33598] Optimizations for emacs-clang-format and
 emacs-clang-rename
References: <ddb74c8a-b135-1edb-a09e-dca07823c0a8@HIDDEN>
Date: Thu, 13 Dec 2018 23:49:27 +0100
In-Reply-To: <ddb74c8a-b135-1edb-a09e-dca07823c0a8@HIDDEN> (Tim Gesthuizen's
 message of "Mon, 3 Dec 2018 14:47:48 +0100")
Message-ID: <871s6l9h54.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 33598
Cc: 33598 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -6.0 (------)

Hello Tim,

Sorry for the delay, it looks like these patches fell through the
cracks!

Tim Gesthuizen <tim.gesthuizen@HIDDEN> skribis:

> the attached patches add optimizations to emacs-clang-format and
> emacs-clang-rename:
>
> - Only package the required elisp file in the source
> - Add a function for generating package definitions of packages
>   containing a single elisp file from the clang source.
>
> The patches make clear that the elisp file is the only thing required
> for building the package and should save some disk space as the packages
> do not need the full clang source tree.

Nice!  Pierre, could you take a look and apply them if they look good to yo=
u?

Thanks!

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#33598; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 3 Dec 2018 13:48:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Dec 03 08:48:15 2018
Received: from localhost ([127.0.0.1]:58774 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gToa6-0002iW-PV
	for submit <at> debbugs.gnu.org; Mon, 03 Dec 2018 08:48:15 -0500
Received: from eggs.gnu.org ([208.118.235.92]:53662)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <tim.gesthuizen@HIDDEN>) id 1gToa4-0002iJ-WB
 for submit <at> debbugs.gnu.org; Mon, 03 Dec 2018 08:48:13 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <tim.gesthuizen@HIDDEN>) id 1gToZx-0006sA-Us
 for submit <at> debbugs.gnu.org; Mon, 03 Dec 2018 08:48:07 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,FREEMAIL_FROM
 autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:58918)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <tim.gesthuizen@HIDDEN>)
 id 1gToZx-0006rz-QV
 for submit <at> debbugs.gnu.org; Mon, 03 Dec 2018 08:48:05 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:35033)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <tim.gesthuizen@HIDDEN>) id 1gToZu-0007lO-O9
 for guix-patches@HIDDEN; Mon, 03 Dec 2018 08:48:05 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <tim.gesthuizen@HIDDEN>) id 1gToZq-0006mY-DZ
 for guix-patches@HIDDEN; Mon, 03 Dec 2018 08:48:02 -0500
Received: from sonic302-20.consmr.mail.ir2.yahoo.com ([87.248.110.83]:41594)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <tim.gesthuizen@HIDDEN>)
 id 1gToZp-0006kU-TL
 for guix-patches@HIDDEN; Mon, 03 Dec 2018 08:47:58 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s2048;
 t=1543844876; bh=WYYiiPIet14MZbOzZ3GVdbTKhjp6+K7ndgZ5GDA5B8M=;
 h=To:From:Subject:Date:From:Subject;
 b=ZhMUc/UiNRtYbL+sxUTFxKi2TcnGEfCciXLbjS3puT0FGI8L6TVC/5DuA2ZnpcJ9YGgAuAliEYZaERHW+tqY4rF1HlADZT1tK3sNfMxhMcCECNlGJYHFtWI/x7/plhvStlqny1Z5MzrkvIkIk86Eb0y7lKGdepN5OqERXwWZYoOfEZkvMHN5lK20s+BEVqFetkt/mULf9K/+EB1ASGNAd+lp6f6G9n0x8SQwM877E4WI7wLvmXdqTMGNOfTVEG4irCM71eyYu3w4kDS3heX89GXGrEUcj7PLQmJpUF92niIPlfgag7ncFfuyHxqtKuWUE47hT8Ejk0tvzTCDSSKj7g==
X-YMail-OSG: 54t.iskVM1nRJHqaNuHCrHrG._gwRxTSQllR4Vu9rhJNNQT_i6uLTgc4aOgZ2DR
 ZUbjiPxRxLjxvp1JK4R43SooEaJcuVP0ZutOFn337HZqD.e7VUfdfM99IWfPl1TVBopDQouL3YWa
 O9kuA8GhjLP61K2eOTpYNrYTLKNvLSXEAM8zR0tgaHvTNSUlJbPXvcZ0q6g6xMeE2Y4I5OmZZ3m0
 BWdMNDCjwxQVgkgpRICD7D4IVTHVKOMryRRgE2WQhiM7xPmuzQXf6paGCUcXSlxmXhSADvr.JTUl
 C.k901J17Bx0sB6RcO1_aQDpf9k4yqzOZZTgGEB9D69ddm3Npafrr_d_zmpW4xUDmdUPOHyRK_i0
 uMHCZb5cy99zF2nKHRS6njHxUcReElkXvBngCXgi5_p0oyLD31CzHy3U8rIyJCWeCqDhtadIXu34
 pZChYYGFLGtSNcfBh9PGkJl1ZVENg1QL78.yUgWn1L22Wc.LTwqL1M0h253Xn7IUon1XY2gE7Zrj
 53v0.Q5qfa8p0tFA5PKj3T_jddfg46U8GHtGs2h9zI842kpYbSVSHV4WIuwxzaq1xJk9Zly5A2Ju
 sqoExAXhdDzDZ90G_edeSdpnEOqDtDJagKKY9Q5Rm2lqicC56dTv3bZLZGnnotD21Io5iH5GavgZ
 eIMGEyVvp3w18Ah6zR5Wcx1dKlMNvAuB.OM99RMviOeBKShG9rrKc5eBYeA6AePzGdltWgR55F0s
 BpfFRwdawunwnihkJAOX2t9Kh2QvL8ssDnBqf09LvCD66Q74rqBek4RDMG7zH.fbwQAW8NCOvOmr
 ujk2Lnp3p370MvLcLNZ6hnclFrDpDMMPo7T1o6PyLOmJfSjkgU62aDt0Zqx02PRzKmFFcE7pASjM
 BUcPn47kRMMiP7C.9Iayc3uDm5AIbKjKi_QxAfbvlBTQjx1F7elvccR0caqn40Nan8YlklZ4OHY2
 GTi6ros6BmTf6u9yLefBX7ebilO8CeafYw6E92Xnomfy_P8Mcj698rBDy6cgr48JU2RuXazfjeOb
 e4rA72XFjLK70K75pxI7UH3QojnDDaBvO8GfuALHq78Qhy57bhThNHt.w7.GjZJIjswmUPy1__T4
 6qImGlzGm
Received: from sonic.gate.mail.ne1.yahoo.com by
 sonic302.consmr.mail.ir2.yahoo.com with HTTP; Mon, 3 Dec 2018 13:47:56 +0000
Received: from p5B221942.dip0.t-ipconnect.de (EHLO [192.168.178.27])
 ([91.34.25.66])
 by smtp420.mail.ir2.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID
 cba66bd63d721f1f75562a94154c2dd5 for <guix-patches@HIDDEN>;
 Mon, 03 Dec 2018 13:47:51 +0000 (UTC)
To: guix-patches@HIDDEN
From: Tim Gesthuizen <tim.gesthuizen@HIDDEN>
Subject: Optimizations for emacs-clang-format and emacs-clang-rename
Message-ID: <ddb74c8a-b135-1edb-a09e-dca07823c0a8@HIDDEN>
Date: Mon, 3 Dec 2018 14:47:48 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.9.1
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha512;
 protocol="application/pgp-signature";
 boundary="8ri8gw03ePRZ0hyv10xG8hsXguz2jEw8I"
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.3 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.3 (-----)

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--8ri8gw03ePRZ0hyv10xG8hsXguz2jEw8I
Content-Type: multipart/mixed; boundary="6e0XEx4XazlYAWzA3EeHjBTXO8ymJwMtx";
 protected-headers="v1"
From: Tim Gesthuizen <tim.gesthuizen@HIDDEN>
To: guix-patches@HIDDEN
Message-ID: <ddb74c8a-b135-1edb-a09e-dca07823c0a8@HIDDEN>
Subject: Optimizations for emacs-clang-format and emacs-clang-rename

--6e0XEx4XazlYAWzA3EeHjBTXO8ymJwMtx
Content-Type: multipart/mixed;
 boundary="------------F8CB051DF55FEC9A30074256"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------F8CB051DF55FEC9A30074256
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi,
the attached patches add optimizations to emacs-clang-format and
emacs-clang-rename:

- Only package the required elisp file in the source
- Add a function for generating package definitions of packages
  containing a single elisp file from the clang source.

The patches make clear that the elisp file is the only thing required
for building the package and should save some disk space as the packages
do not need the full clang source tree.

Tim.

--------------F8CB051DF55FEC9A30074256
Content-Type: text/x-patch;
 name="0001-gnu-Shrink-source-for-emacs-clang-format.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
 filename="0001-gnu-Shrink-source-for-emacs-clang-format.patch"

=46rom 5d85956a30ff1bed8f7c529d4b760bb609ac4ab7 Mon Sep 17 00:00:00 2001
From: Tim Gesthuizen <tim.gesthuizen@HIDDEN>
Date: Fri, 30 Nov 2018 14:49:51 +0100
Subject: [PATCH 1/3] gnu: Shrink source for emacs-clang-format.

To build emacs-clang-format only the `clang-format.el` file is needed. In=

order to save disk space and make clear that this is the only file needed=

modify the downloaded source to only contain `clang-format.el`.

* gnu/packages/emacs.scm (emacs-clang-format): Add source snippet.
* gnu/packages/emacs.scm (emacs-clang-format): Modify phases.
---
 gnu/packages/llvm.scm | 58 ++++++++++++++++++++++++++++---------------
 1 file changed, 38 insertions(+), 20 deletions(-)

diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index dace546a4..e7dd6477a 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -461,28 +461,46 @@ code analysis tools.")
     (license license:bsd-3)))
=20
 (define-public emacs-clang-format
-  (package
-    (inherit clang)
-    (name "emacs-clang-format")
-    (build-system emacs-build-system)
-    (inputs
-     `(("clang" ,clang)))
-    (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (add-after 'unpack 'configure
-           (lambda* (#:key inputs #:allow-other-keys)
-             (let ((clang (assoc-ref inputs "clang")))
-               (copy-file "tools/clang-format/clang-format.el" "clang-fo=
rmat.el")
-               (emacs-substitute-variables "clang-format.el"
-                 ("clang-format-executable"
-                  (string-append clang "/bin/clang-format"))))
-             #t)))))
-    (synopsis "Format code using clang-format")
-    (description "This package allows to filter code through @code{clang=
-format}
+  (let ((target-file "clang-format.el"))
+    (package
+      (inherit clang)
+      (name "emacs-clang-format")
+      (source (let ((orig (package-source clang)))
+                (origin
+                  (method (origin-method orig))
+                  (uri (origin-uri orig))
+                  (sha256 (origin-sha256 orig))
+                  (modules '((guix build utils)
+                             (srfi srfi-1)
+                             (ice-9 ftw)))
+                  (snippet
+                   `(begin
+                      ;; Copy target file to source root and delete all =
other files
+                      (copy-file (string-append "tools/clang-format/" ,t=
arget-file)
+                                 ,target-file)
+                      (map delete-file-recursively
+                           (fold delete
+                                 (scandir ".")
+                                 '("." ".." ,target-file)))
+                      #t)))))
+      (build-system emacs-build-system)
+      (inputs
+       `(("clang" ,clang)))
+      (arguments
+       `(#:phases
+         (modify-phases %standard-phases
+           (add-after 'unpack 'configure
+             (lambda* (#:key inputs #:allow-other-keys)
+               (let ((clang (assoc-ref inputs "clang")))
+                 (emacs-substitute-variables ,target-file
+                   ("clang-format-executable"
+                    (string-append clang "/bin/clang-format"))))
+               #t)))))
+      (synopsis "Format code using clang-format")
+      (description "This package allows to filter code through @code{cla=
ng-format}
 to fix its formatting.  @code{clang-format} is a tool that formats
 C/C++/Obj-C code according to a set of style options, see
-@url{http://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))
+@url{http://clang.llvm.org/docs/ClangFormatStyleOptions.html}."))))
=20
 (define-public emacs-clang-rename
   (package
--=20
2.19.2


--------------F8CB051DF55FEC9A30074256
Content-Type: text/x-patch;
 name="0002-gnu-Shrink-source-for-emacs-clang-rename.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
 filename="0002-gnu-Shrink-source-for-emacs-clang-rename.patch"

=46rom 29a1992253908ea191ef0227462972f78ce20da3 Mon Sep 17 00:00:00 2001
From: Tim Gesthuizen <tim.gesthuizen@HIDDEN>
Date: Fri, 30 Nov 2018 15:01:10 +0100
Subject: [PATCH 2/3] gnu: Shrink source for emacs-clang-rename.

To build emacs-clang-rename only the `clang-rename.el` file is needed. In=

order to save disk space and make clear that this is the only file needed=

modify the downloaded source to only contain `clang-rename.el`.

* gnu/packages/emacs.scm (emacs-clang-rename): Add source snippet.
* gnu/packages/emacs.scm (emacs-clang-rename): Modify phases.
---
 gnu/packages/llvm.scm | 59 ++++++++++++++++++++++++++++---------------
 1 file changed, 39 insertions(+), 20 deletions(-)

diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index e7dd6477a..3eb0fb29f 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -503,23 +503,42 @@ C/C++/Obj-C code according to a set of style option=
s, see
 @url{http://clang.llvm.org/docs/ClangFormatStyleOptions.html}."))))
=20
 (define-public emacs-clang-rename
-  (package
-    (inherit clang)
-    (name "emacs-clang-rename")
-    (build-system emacs-build-system)
-    (inputs
-     `(("clang" ,clang)))
-    (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (add-after 'unpack 'configure
-           (lambda* (#:key inputs #:allow-other-keys)
-             (let ((clang (assoc-ref inputs "clang")))
-               (copy-file "tools/clang-rename/clang-rename.el" "clang-re=
name.el")
-               (emacs-substitute-variables "clang-rename.el"
-                 ("clang-rename-binary"
-                  (string-append clang "/bin/clang-rename"))))
-             #t)))))
-    (synopsis "Rename every occurrence of a symbol using clang-rename")
-    (description "This package renames every occurrence of a symbol at p=
oint
-using @code{clang-rename}.")))
+  (let ((target-file "clang-rename.el"))
+   (package
+     (inherit clang)
+     (name "emacs-clang-rename")
+     (source (let ((orig (package-source clang)))
+               (origin
+                 (method (origin-method orig))
+                 (uri (origin-uri orig))
+                 (sha256 (origin-sha256 orig))
+                 (file-name (string-append name
+                                           (package-version clang)))
+                 (modules '((guix build utils)
+                            (srfi srfi-1)
+                            (ice-9 ftw)))
+                 (snippet
+                  `(begin
+                     (copy-file (string-append "tools/clang-rename/" ,ta=
rget-file)
+                                ,target-file)
+                     (map delete-file-recursively
+                          (fold delete
+                                (scandir ".")
+                                '("." ".." ,target-file)))
+                     #t)))))
+     (build-system emacs-build-system)
+     (inputs
+      `(("clang" ,clang)))
+     (arguments
+      `(#:phases
+        (modify-phases %standard-phases
+          (add-after 'unpack 'configure
+            (lambda* (#:key inputs #:allow-other-keys)
+              (let ((clang (assoc-ref inputs "clang")))
+                (emacs-substitute-variables ,target-file
+                  ("clang-rename-binary"
+                   (string-append clang "/bin/clang-rename"))))
+              #t)))))
+     (synopsis "Rename every occurrence of a symbol using clang-rename")=

+     (description "This package renames every occurrence of a symbol at =
point
+using @code{clang-rename}."))))
--=20
2.19.2


--------------F8CB051DF55FEC9A30074256
Content-Type: text/x-patch;
 name="0003-gnu-Add-package-from-clang-elisp-file.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
 filename="0003-gnu-Add-package-from-clang-elisp-file.patch"

=46rom e4fdd028c0e71118073aee34c5976a4948b46511 Mon Sep 17 00:00:00 2001
From: Tim Gesthuizen <tim.gesthuizen@HIDDEN>
Date: Fri, 30 Nov 2018 15:13:51 +0100
Subject: [PATCH 3/3] gnu: Add package-from-clang-elisp-file

emacs-clang-format and emacs-clang-rename both are packages that are buil=
d by
extracting a single elisp file and building it as an emacs package.
This concept is encapsulated in the package-from-clang-elisp-file
function. This reduces repeating of concepts in the two package definitio=
ns.

* gnu/packages/llvm.scm (package-from-clang-elisp-file): New function
* gnu/packages/llvm.scm (emacs-clang-format): Use new function
* gnu/packages/llvm.scm (emacs-clang-rename): Use new function
---
 gnu/packages/llvm.scm | 138 +++++++++++++++++++-----------------------
 1 file changed, 61 insertions(+), 77 deletions(-)

diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 3eb0fb29f..ad71c967a 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -460,85 +460,69 @@ code analysis tools.")
      "This package provides a Python binding to LLVM for use in Numba.")=

     (license license:bsd-3)))
=20
+;;; Returns a package definition that packages an emacs-lisp file from t=
he
+;;; clang source. The package has the name PKGNAME and packages the file=

+;;; SRC-FILE from the clang source in its root directory with the name
+;;; TARGET-FILE where SUBST substitutions will be performed on the elisp=
 file
+;;; and SYN and DESC as the package synopsis an description.
+(define (package-from-clang-elisp-file pkgname src-file target-file subs=
t syn desc)
+  (package
+    (inherit clang)
+    (name pkgname)
+    (source (let ((orig (package-source clang)))
+              (origin
+                (method (origin-method orig))
+                (uri (origin-uri orig))
+                (sha256 (origin-sha256 orig))
+                (file-name (string-append pkgname "-" (package-version c=
lang)))
+                (modules '((guix build utils)
+                           (srfi srfi-1)
+                           (ice-9 ftw)))
+                (snippet
+                 `(begin
+                    ;; Copy target file to source root and delete all ot=
her files
+                    (copy-file (string-append ,src-file)
+                               ,target-file)
+                    (map delete-file-recursively
+                         (fold delete
+                               (scandir ".")
+                               '("." ".." ,target-file)))
+                    #t)))))
+    (build-system emacs-build-system)
+    (inputs
+     `(("clang" ,clang)))
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'configure
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let ((clang (assoc-ref inputs "clang")))
+               (emacs-substitute-variables ,target-file
+                 ,subst))
+             #t)))))
+    (synopsis syn)
+    (description desc)))
+
 (define-public emacs-clang-format
-  (let ((target-file "clang-format.el"))
-    (package
-      (inherit clang)
-      (name "emacs-clang-format")
-      (source (let ((orig (package-source clang)))
-                (origin
-                  (method (origin-method orig))
-                  (uri (origin-uri orig))
-                  (sha256 (origin-sha256 orig))
-                  (modules '((guix build utils)
-                             (srfi srfi-1)
-                             (ice-9 ftw)))
-                  (snippet
-                   `(begin
-                      ;; Copy target file to source root and delete all =
other files
-                      (copy-file (string-append "tools/clang-format/" ,t=
arget-file)
-                                 ,target-file)
-                      (map delete-file-recursively
-                           (fold delete
-                                 (scandir ".")
-                                 '("." ".." ,target-file)))
-                      #t)))))
-      (build-system emacs-build-system)
-      (inputs
-       `(("clang" ,clang)))
-      (arguments
-       `(#:phases
-         (modify-phases %standard-phases
-           (add-after 'unpack 'configure
-             (lambda* (#:key inputs #:allow-other-keys)
-               (let ((clang (assoc-ref inputs "clang")))
-                 (emacs-substitute-variables ,target-file
-                   ("clang-format-executable"
-                    (string-append clang "/bin/clang-format"))))
-               #t)))))
-      (synopsis "Format code using clang-format")
-      (description "This package allows to filter code through @code{cla=
ng-format}
+  (package-from-clang-elisp-file
+   "emacs-clang-format"
+   "tools/clang-format/clang-format.el"
+   "clang-format.el"
+   '("clang-format-executable"
+                    (string-append clang "/bin/clang-format"))
+   "Format code using clang-format"
+   "This package allows to filter code through @code{clang-format}
 to fix its formatting.  @code{clang-format} is a tool that formats
 C/C++/Obj-C code according to a set of style options, see
-@url{http://clang.llvm.org/docs/ClangFormatStyleOptions.html}."))))
+@url{http://clang.llvm.org/docs/ClangFormatStyleOptions.html}."))
=20
 (define-public emacs-clang-rename
-  (let ((target-file "clang-rename.el"))
-   (package
-     (inherit clang)
-     (name "emacs-clang-rename")
-     (source (let ((orig (package-source clang)))
-               (origin
-                 (method (origin-method orig))
-                 (uri (origin-uri orig))
-                 (sha256 (origin-sha256 orig))
-                 (file-name (string-append name
-                                           (package-version clang)))
-                 (modules '((guix build utils)
-                            (srfi srfi-1)
-                            (ice-9 ftw)))
-                 (snippet
-                  `(begin
-                     (copy-file (string-append "tools/clang-rename/" ,ta=
rget-file)
-                                ,target-file)
-                     (map delete-file-recursively
-                          (fold delete
-                                (scandir ".")
-                                '("." ".." ,target-file)))
-                     #t)))))
-     (build-system emacs-build-system)
-     (inputs
-      `(("clang" ,clang)))
-     (arguments
-      `(#:phases
-        (modify-phases %standard-phases
-          (add-after 'unpack 'configure
-            (lambda* (#:key inputs #:allow-other-keys)
-              (let ((clang (assoc-ref inputs "clang")))
-                (emacs-substitute-variables ,target-file
-                  ("clang-rename-binary"
-                   (string-append clang "/bin/clang-rename"))))
-              #t)))))
-     (synopsis "Rename every occurrence of a symbol using clang-rename")=

-     (description "This package renames every occurrence of a symbol at =
point
-using @code{clang-rename}."))))
+  (package-from-clang-elisp-file
+   "emacs-clang-rename"
+   "tools/clang-rename/clang-rename.el"
+   "clang-rename.el"
+   '("clang-rename-binary"
+                   (string-append clang "/bin/clang-rename"))
+   "Rename every occurrence of a symbol using clang-rename"
+   "This package renames every occurrence of a symbol at point
+using @code{clang-rename}."))
--=20
2.19.2


--------------F8CB051DF55FEC9A30074256--

--6e0XEx4XazlYAWzA3EeHjBTXO8ymJwMtx--

--8ri8gw03ePRZ0hyv10xG8hsXguz2jEw8I
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCgAdFiEEKUiC5+8BRKEri5fa0uWPaa77GdUFAlwFNAUACgkQ0uWPaa77
GdUkugf9G0EIc6l1RM8mKKUNbggh/Orn4I9NLU6d/7X+2Pihco6q4LRTcJW2GxtN
xm9oO5yCKW5G9bm2GmhiCewZ1lkoO3uR/xPMa0LLObGmeijQ8YwkSd1gUN0KPUyV
MEjKCL+NKiXZfl1v2atUAAg52J8qJ3I4sWlglLnuPdVV8iute4LFbRfuP6FvrFOv
t3N1G3wx162Bqd7yQjhT2Bwaqa+6FkoXP6IPkZKYY18uMDdv5EkmYAXj5puPwjX5
/P/sPnGzJz0+3j2lmu+LsM5UoVZUmfZFtga7CQc17PHSVRoOn8BifQezQNF8G81G
n7H2NWgt0ROsiaTvpcp7lBPLizQ1Ig==
=AB+f
-----END PGP SIGNATURE-----

--8ri8gw03ePRZ0hyv10xG8hsXguz2jEw8I--




Acknowledgement sent to Tim Gesthuizen <tim.gesthuizen@HIDDEN>:
New bug report received and forwarded. Copy sent to guix-patches@HIDDEN. Full text available.
Report forwarded to guix-patches@HIDDEN:
bug#33598; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Thu, 13 Dec 2018 23:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.