Subject: Re: [bug#30884] Status: [PATCH 0/6] gnu: Add emacs-epkg.

From: Maxim Cournoyer <[email-masked]>
Date: Wed, 18 Apr 2018 22:07:56 -0400

Hello again,

Maxim Cournoyer <[email-masked]> writes:

> Hi Oleg,
>
> Oleg Pykhalov <[email-masked]> writes:
>
>> Hello Ludovic,
>>
>> Thank you for review!
>>
>> I've applied all your suggestions except ‘set-emacs-load-path’.  First
>> of all this procedure is not exported.
>
> Phases are typically not exported individually, but as an alist of all
> the phases of the build system, as `%standard-phases'.

[...]

> As `set-emacs-load-path' is a phase itself, it expects to be called as
> such, with keyworded arguments. It would be simpler to just insert the
> phase as in:

> ;; Add this to the define-module top level definition:
> ;; (define-module (gnu packages emacs)
> ;; ...
> ;; #:use-module ((guix build emacs-build-system) #:prefix emacs:)
> ;; ...

Actually, you don't want to import this at the top-level of the
emacs.scm module but rather specify the import using the #:modules
argument passed to the build system. Here's a complete example (not yet
merged in master, currently under review):

--8<---------------cut here---------------start------------->8---
(define-public emacs-pdf-tools
  (package
    (name "emacs-pdf-tools")
    (version "0.80")
    (source (origin
              (method url-fetch)
              (uri (string-append
                    "https://github.com/politza/pdf-tools/archive/v"
                    version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "06imydn3a92vr57azpn1zhqc14kxyyslmyi9ldsyphan9b724gb6"))))
    (build-system gnu-build-system)
    (arguments
     `(#:tests? #f ; there are no tests
       #:modules ((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
         ;; Build server side using 'gnu-build-system'.
         (add-after 'unpack 'enter-server-dir
           (lambda _ (chdir "server") #t))
         (add-after 'enter-server-dir 'autogen
           (lambda _
             (zero? (system* "bash" "autogen.sh"))))

         ;; Build emacs side using 'emacs-build-system'.
         (add-after 'compress-documentation 'enter-lisp-dir
           (lambda _ (chdir "../lisp") #t))
         (add-after 'enter-lisp-dir 'emacs-patch-variables
           (lambda* (#:key outputs #:allow-other-keys)
             ;; Set path to epdfinfo program.
             (emacs-substitute-variables "pdf-info.el"
               ("pdf-info-epdfinfo-program"
                (string-append (assoc-ref outputs "out")
                               "/bin/epdfinfo")))
             ;; Set 'pdf-tools-handle-upgrades' to nil to avoid "auto
             ;; upgrading" that pdf-tools tries to perform.
             (emacs-substitute-variables "pdf-tools.el"
               ("pdf-tools-handle-upgrades" '()))))
         (add-after 'emacs-patch-variables 'set-emacs-load-path
           (assoc-ref emacs:%standard-phases 'set-emacs-load-path))
         (add-after 'set-emacs-load-path 'emacs-install
           (assoc-ref emacs:%standard-phases 'install))
         (add-after 'emacs-install 'emacs-build
           (assoc-ref emacs:%standard-phases 'build))
         (add-after 'emacs-install 'emacs-make-autoloads
           (assoc-ref emacs:%standard-phases 'make-autoloads)))))
    (native-inputs `(("autoconf" ,autoconf)
                     ("automake" ,automake)
                     ("pkg-config" ,pkg-config)
                     ("emacs" ,emacs-minimal)))
    (inputs `(("poppler" ,poppler)
              ("cairo" ,cairo)
              ("glib" ,glib)
              ("libpng" ,libpng)
              ("zlib" ,zlib)))
    (propagated-inputs `(("tablist" ,emacs-tablist)))
    (synopsis "Emacs support library for PDF files")
    (description
     "PDF Tools is, among other things, a replacement of DocView for PDF
files.  The key difference is that pages are not pre-rendered by
e.g. ghostscript and stored in the file-system, but rather created on-demand
and stored in memory.")
    (home-page "https://github.com/politza/pdf-tools")
    (license license:gpl3+)))
--8<---------------cut here---------------end--------------->8---

HTH,

Maxim