From patchwork Sun Jan 6 21:29:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tim Gesthuizen X-Patchwork-Id: 688 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 45DBF16A22; Sun, 6 Jan 2019 21:30:17 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from listsout.gnu.org (listsout.gnu.org [208.118.235.17]) by mira.cbaines.net (Postfix) with ESMTP id 5FB1F16A1C for ; Sun, 6 Jan 2019 21:30:16 +0000 (GMT) Received: from localhost ([127.0.0.1]:54763 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggFzr-0003ob-VT for patchwork@mira.cbaines.net; Sun, 06 Jan 2019 16:30:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggFzg-0003mm-FX for guix-patches@gnu.org; Sun, 06 Jan 2019 16:30:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggFzf-0006l3-11 for guix-patches@gnu.org; Sun, 06 Jan 2019 16:30:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:48102) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ggFze-0006ky-SD for guix-patches@gnu.org; Sun, 06 Jan 2019 16:30:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ggFze-0000Kv-OM for guix-patches@gnu.org; Sun, 06 Jan 2019 16:30:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#33598] Optimizations for emacs-clang-format and emacs-clang-rename Resent-From: Tim Gesthuizen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 06 Jan 2019 21:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33598 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: Pierre Neidhardt Received: via spool by 33598-submit@debbugs.gnu.org id=B33598.15468101881226 (code B ref 33598); Sun, 06 Jan 2019 21:30:02 +0000 Received: (at 33598) by debbugs.gnu.org; 6 Jan 2019 21:29:48 +0000 Received: from localhost ([127.0.0.1]:47379 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ggFzL-0000JV-Bl for submit@debbugs.gnu.org; Sun, 06 Jan 2019 16:29:48 -0500 Received: from sonic310-13.consmr.mail.ir2.yahoo.com ([77.238.177.34]:35742) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ggFzD-0000JB-U3 for 33598@debbugs.gnu.org; Sun, 06 Jan 2019 16:29:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s2048; t=1546810170; bh=XawciInZjsLmEt2lXg+OTVL3VCeM458DjhZJdvACGoM=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=FlL7KhJyaeLTteqmJUdHUEvHrOBEIRpHioH4ZsUOtRg/519AP2hBD3MY0ovHt+dyvcBYTfvmpfrhKxpAZfGu4tifY/056zVU6qJt36uoJ/3l+zOXlS1wiU5i5NdhImGHqWwEZkAumWzqPiCHMbAlFegsF43vJsH5wnnIbZ0sheZaZgo5LXxcwHJuMPwh36SPqdJDm542AVdS6Rskl2hpS7PxvNytgbJJzxE6K9FrzxqrT3LNMFW4lmPOsbXc6j+eba2KpYgLZhsrt7USwIJgINTMmAH23MBL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V7G4idSUtzT_oBIQeJ8zqU3TqA60UU9TodzogPH Buuio5kBKjVDJMt5a5Gh_ZgLqKR9uGLSaAq523DqcnvjiWQnWGTU1XE8iBpC14eEbClRYxy5ZSJ9 ZDTcrDmE- Received: from sonic.gate.mail.ne1.yahoo.com by sonic310.consmr.mail.ir2.yahoo.com with HTTP; Sun, 6 Jan 2019 21:29:30 +0000 Received: from p3EE27950.dip0.t-ipconnect.de (EHLO [192.168.178.27]) ([62.226.121.80]) by smtp426.mail.ir2.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 5a8254c614db457a410d4ba24de0f33e; Sun, 06 Jan 2019 21:29:28 +0000 (UTC) References: <871s6l9h54.fsf@gnu.org> <87r2ekea1u.fsf@ambrevar.xyz> <04daca2a-705d-6255-85bd-48132879f5a8@yahoo.de> <87lg4se6wf.fsf@ambrevar.xyz> <8d15b1a4-5f0b-28aa-a3d9-78520431b8ef@yahoo.de> <87imzwe2d3.fsf@ambrevar.xyz> <2df7cbf3-81d5-7d50-35d7-f3b369d1ac0e@yahoo.de> <87ftuth0d7.fsf@ambrevar.xyz> <14de0933-fddc-94d0-d75a-cdf4b49fce1a@yahoo.de> <87wonhipbw.fsf@ambrevar.xyz> From: Tim Gesthuizen Openpgp: preference=signencrypt Autocrypt: addr=tim.gesthuizen@yahoo.de; prefer-encrypt=mutual; keydata= mQENBFrE7N0BCAC7s3lBzEf8MPAiqYjlD8Z/9TrwMEy2gLZifF3wTgIFVSOujb5gcceS3I64 qur9lCPJycxzl9dOVOBXycXZNMjSrd1VXsmBoBmR54NOOE526eCwfjkbbNhAJ5hPAwGDOvIs s2xKbIBcqfrdNnHIrZt0ohueX6RxEc6HhVTh79GwUjCaux4Jfs0NfNH+We1hyINqMKnIHQ1D kycgyFj1w0HkJiNNZSgKGNeSvqDA4gV/g9uVy25XQA/hsCBHU1teJiSfM8aVw8PA41eUsl9L pCeCTWjWwW+VQWNs5y4I3ZEpY1CAZ/C9OrbCBzNs1ssAT2aOhV3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fJDaPEoHSwUs++gFSqaIkS/dLQ0LTL/DBp jKsed8FfV8Ubv/M0AoD8cixAmJLnxlt3G1gLBBkAlv0F53bIdAGJMBJZsZ+1HmzFazknGIR0 LgHZ28PK/QWPwE5gRkIzwTD+hrKJjGcBMach2ZbcAvo47rrRYW1ukbN6L1L5mvTSCh2Gitgp ewig0IiavSVkL3uWpPvAqmr9N9zk/qrHk1EgV+hzNriJhUitpMgrgZQfHYRm4LIhsmJm9TOT N3SWwT0= Message-ID: <792d34a0-b048-b84f-b7b8-d9d996da2a28@yahoo.de> Date: Sun, 6 Jan 2019 22:29:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <87wonhipbw.fsf@ambrevar.xyz> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 33598@debbugs.gnu.org Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hi Pierre, thank you for reviewing! On 06.01.19 20:00, Pierre Neidhardt wrote: > Hi Tim, > > I just reviewed your patch. Looks pretty good overall, thanks! > > A few things: > >> +(export package-elisp-from-package) > > This should be placed at the beginning of the file in the (define-module... > See bootstrap.scm. As the new function can be defined with a normal lambda and not a lambda* I just used define-public. >> +;;; Returns a package definition that packages an emacs-lisp file from the >> +;;; SRCPKG source. The package has the name PKGNAME and packages the file >> +;;; SRC-FILE from the source in its root directory as TARGET-FILE or the >> +;;; basename of SRC-FILE where INPUTS NATIVE-INPUTS and PROPAGATED-INPUTS are >> +;;; added as package inputs and SUBSTITUTIONS substitutions will be performed >> +;;; on the elisp file and SYNOPSIS and DESCRIPTION as the package synopsis and >> +;;; description. >> +(define* (package-elisp-from-package > > Move the ";;;" comment to a docstring, e.g. > > --8<---------------cut here---------------start------------->8--- > (define* (package-elisp-from-package > ...) > "Return ..." > --8<---------------cut here---------------end--------------->8--- Done. >> +;;; Returns a package definition that packages an emacs-lisp file from the > > "Return", not "Returns". > >> +;;; SRCPKG source. The package has the name PKGNAME and packages the file > > Separate sentences with two spaces. Done. >> + srcpkg pkgname src-file > > Prefer complete words over abbreviations. Here I'd suggest > > source-package > name > source-file Done. name is called package-name. >> + (synopsis (if synopsis >> + synopsis >> + (package-synopsis srcpkg))) >> + (description (if description >> + description >> + (package-description srcpkg)))))) > > A more Lispy way: > > --8<---------------cut here---------------start------------->8--- > + (synopsis (or synopsis > + (package-synopsis srcpkg))) > + (description (or description > + (package-description srcpkg)))))) > --8<---------------cut here---------------end--------------->8--- Obsolete as this is now moved again to the final package definition. Thanks for the tip :) I'm still quite new to scheme. > Regarding the function parameters, I would turn SOURCE-FILE into SOURCE-FILES to > make it more generic. Indeed, the Emacs library could very well be split over > multiple files. > > One thing I'm not too sure about is the replication of the structure fields as > keys. > I think it's easier to ignore those and let the user define them as follows: > > --8<---------------cut here---------------start------------->8--- > (define-public emacs-clang-rename > (package > (inherit (package-elisp-from-package > clang > "emacs-clang-rename" > "tools/clang-rename/clang-rename.el")) > (arguments ...))) > --8<---------------cut here---------------end--------------->8--- I was also thinking about this. But with stuffing everything into the function to evaluate to the final definition made multiple files difficult as it would complicate the data structure for substitutions. As this is not part of the function this is not a problem anymore. Maybe we could make the function even more generic if we would just let it modify the origin object. > Makes sense? This would also be more robust in case the package structure > changes someday. > > Finally, rebase your changes so that you directly use the last function, no > need for the clang-specific function to appear in the history of commits. Done. Patches are attached. Tim. From 012ba2f96b16d54e0e1c23ee912c8a219355216c Mon Sep 17 00:00:00 2001 From: Tim Gesthuizen Date: Fri, 4 Jan 2019 22:34:56 +0100 Subject: [PATCH 2/2] gnu: Use package-elisp-from-package for clangs emacs lisp files Use package-elisp-from-package for emacs-clang-format and emacs-clang-rename. Also remove package-from-clang-elisp-file as it is not needed anymore. * gnu/packages/llvm.scm (emacs-clang-format): Use package-elisp-from-package * gnu/packages/llvm.scm (emacs-clang-rename): Use package-elisp-from-package * gnu/packages/llvm.scm (package-from-clang-elisp-file): Remove function --- gnu/packages/llvm.scm | 65 +++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index 6dab9c519..32d7ef81b 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -8,7 +8,7 @@ ;;; Copyright © 2018 Marius Bakke ;;; Copyright © 2018 Tobias Geerinckx-Rice ;;; Copyright © 2018 Efraim Flashner -;;; Copyright © 2018 Tim Gesthuizen +;;; Copyright © 2018, 2019 Tim Gesthuizen ;;; Copyright © 2018 Pierre Neidhardt ;;; ;;; This file is part of GNU Guix. @@ -39,6 +39,7 @@ #:use-module (gnu packages gcc) #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker #:use-module (gnu packages compression) + #:use-module (gnu packages emacs) #:use-module (gnu packages libffi) #:use-module (gnu packages perl) #:use-module (gnu packages python) @@ -481,22 +482,21 @@ code analysis tools.") (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-format.el") - (emacs-substitute-variables "clang-format.el" - ("clang-format-executable" - (string-append clang "/bin/clang-format")))) - #t))))) + (inherit (package-elisp-from-package + clang + "emacs-clang-format" + '("tools/clang-format/clang-format.el"))) + (inputs `(("clang" ,clang))) + (arguments `(#:phases + (modify-phases %standard-phases + (add-after 'unpack 'configure + (lambda* (#:key inputs #:allow-other-keys) + (chmod "clang-format.el" #o644) + (emacs-substitute-variables "clang-format.el" + ("clang-format-executable" + (string-append (assoc-ref inputs "clang") + "/bin/clang-format"))) + #t))))) (synopsis "Format code using clang-format") (description "This package allows to filter code through @code{clang-format} to fix its formatting. @code{clang-format} is a tool that formats @@ -505,22 +505,21 @@ C/C++/Obj-C code according to a set of style options, see (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-rename.el") - (emacs-substitute-variables "clang-rename.el" - ("clang-rename-binary" - (string-append clang "/bin/clang-rename")))) - #t))))) + (inherit (package-elisp-from-package + clang + "emacs-clang-rename" + '("tools/clang-rename/clang-rename.el"))) + (inputs `(("clang" ,clang))) + (arguments `(#:phases + (modify-phases %standard-phases + (add-after 'unpack 'configure + (lambda* (#:key inputs #:allow-other-keys) + (chmod "clang-rename.el" #o644) + (emacs-substitute-variables "clang-rename.el" + ("clang-rename-binary" + (string-append (assoc-ref inputs "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}."))) -- 2.20.1