unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Add Emacs PDF tools
@ 2015-07-05 17:59 Ricardo Wurmus
  2015-07-06 13:40 ` Alex Kost
  0 siblings, 1 reply; 5+ messages in thread
From: Ricardo Wurmus @ 2015-07-05 17:59 UTC (permalink / raw)
  To: Guix-devel

[-- Attachment #1: 0001-gnu-Add-emacs-pdf-tools.patch --]
[-- Type: text/x-patch, Size: 3813 bytes --]

From 1f5f4de3da2f8158884116746ed00435a317b6c6 Mon Sep 17 00:00:00 2001
From: Ricardo Wurmus <rekado@elephly.net>
Date: Sun, 5 Jul 2015 19:58:38 +0200
Subject: [PATCH] gnu: Add emacs-pdf-tools.

* gnu/packages/emacs.scm (emacs-pdf-tools): New variable.
---
 gnu/packages/emacs.scm | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 2502f29..b052a63 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
+;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -50,6 +51,7 @@
   #:use-module (gnu packages glib)
   #:use-module (gnu packages acl)
   #:use-module (gnu packages perl)
+  #:use-module (gnu packages pdf)
   #:use-module (gnu packages linux)               ;alsa
   #:use-module (gnu packages xiph)
   #:use-module (gnu packages mp3)
@@ -776,3 +778,62 @@ an address book for email and snail mail addresses, phone numbers and the
 like.  It can be linked with various Emacs mail clients (Message and Mail
 mode, Rmail, Gnus, MH-E, and VM).  BBDB is fully customizable.")
     (license license:gpl3+)))
+
+(define-public emacs-pdf-tools
+  (package
+    (name "emacs-pdf-tools")
+    (version "0.60")
+    (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
+                "1y8k5n2jbyaxby0j6f4m9xbm0ddpmbkrfj6rp6ll5sb97lcg3vrx"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f ; there are no tests
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'enter-dir (lambda _ (chdir "server") #t))
+         (add-before
+          'configure 'autogen
+          (lambda _
+            (zero? (system* "bash" "autogen.sh"))))
+         (add-after
+          'install 'install-lisp
+          (lambda* (#:key outputs #:allow-other-keys)
+            (let ((target (string-append (assoc-ref outputs "out")
+                                         "/share/emacs/site-lisp/")))
+              (mkdir-p target)
+              (for-each
+               (lambda (file)
+                 (copy-file file (string-append target (basename file))))
+               (find-files "../lisp" "^(pdf|tab).*\\.elc?"))
+
+              ;; Set path to epdfinfo program
+              (substitute* (string-append target "pdf-info.el")
+                (("or load-file-name")
+                 (string-append "or \""
+                                (string-append (assoc-ref outputs "out")
+                                               "/bin/")
+                                "\" load-file-name"))))
+            #t)))))
+    (native-inputs `(("autoconf" ,autoconf)
+                     ("automake" ,automake)
+                     ("pkg-config" ,pkg-config)))
+    (inputs `(("poppler" ,poppler)
+              ("cairo" ,cairo)
+              ("glib" ,glib)
+              ("libpng" ,libpng)
+              ("zlib" ,zlib)))
+    (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+)))
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Add Emacs PDF tools
  2015-07-05 17:59 [PATCH] Add Emacs PDF tools Ricardo Wurmus
@ 2015-07-06 13:40 ` Alex Kost
  2015-07-09 13:56   ` Alex Kost
  0 siblings, 1 reply; 5+ messages in thread
From: Alex Kost @ 2015-07-06 13:40 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: Guix-devel

[-- Attachment #1: Type: text/plain, Size: 3166 bytes --]

Ricardo Wurmus (2015-07-05 20:59 +0300) wrote:

Thank you very much for packaging it!

[...]
> +(define-public emacs-pdf-tools
> +  (package
> +    (name "emacs-pdf-tools")
> +    (version "0.60")
> +    (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
> +                "1y8k5n2jbyaxby0j6f4m9xbm0ddpmbkrfj6rp6ll5sb97lcg3vrx"))))
> +    (build-system gnu-build-system)
> +    (arguments
> +     `(#:tests? #f ; there are no tests

Actually there are tests, but I see the problem you faced.  There is
top-level Makefile which takes care of elisp files (compiling, testing)
and runs autogen, configure, etc. in the "server" subdir.  So you chose
to move to this subdir and do a usual build process there, and to handle
elisp files manually.

Perhaps there is a way to get a benefit from the Makefile as well to
byte-compile elisp files and to perform tests.  (It's a question for a
more experienced packager; I don't know the answer)

> +       #:phases
> +       (modify-phases %standard-phases
> +         (add-after 'unpack 'enter-dir (lambda _ (chdir "server") #t))
> +         (add-before
> +          'configure 'autogen
> +          (lambda _
> +            (zero? (system* "bash" "autogen.sh"))))
> +         (add-after
> +          'install 'install-lisp
> +          (lambda* (#:key outputs #:allow-other-keys)
> +            (let ((target (string-append (assoc-ref outputs "out")
> +                                         "/share/emacs/site-lisp/")))
> +              (mkdir-p target)
> +              (for-each
> +               (lambda (file)
> +                 (copy-file file (string-append target (basename file))))
> +               (find-files "../lisp" "^(pdf|tab).*\\.elc?"))
> +
> +              ;; Set path to epdfinfo program
> +              (substitute* (string-append target "pdf-info.el")
> +                (("or load-file-name")
> +                 (string-append "or \""
> +                                (string-append (assoc-ref outputs "out")
> +                                               "/bin/")
> +                                "\" load-file-name"))))

There is 'emacs-substitute-variables' procedure from (guix build
emacs-utils) for this.  And I think it should be moved to an earlier
phase, since this and other elisp files may be (ideally) compiled after
this change.

Also there is another change that should be done IMO – a change of the
default value of 'pdf-tools-handle-upgrades' variable to prevent auto
updating, as it makes sense only if the package is updated from MELPA
(it tries to recompile the epdfinfo program).

And another thing: it is very useful to generate an "…-autoloads.el"
file so that some "pdf-…" functions and commands become available.

Here is the modified version of this package, I've tested (without
byte-compiling and tests):


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: emacs-pdf-tools.scm --]
[-- Type: text/x-scheme, Size: 2975 bytes --]

(define-public emacs-pdf-tools
  (package
    (name "emacs-pdf-tools")
    (version "0.60")
    (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
                "1y8k5n2jbyaxby0j6f4m9xbm0ddpmbkrfj6rp6ll5sb97lcg3vrx"))))
    (build-system gnu-build-system)
    (arguments
     `(#:tests? #f ; there are no tests
       #:modules ((guix build gnu-build-system)
                  (guix build utils)
                  (guix build emacs-utils))
       #:imported-modules (,@%gnu-build-system-modules
                           (guix build emacs-utils))
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'enter-dir (lambda _ (chdir "server") #t))
         (add-before
          'configure 'autogen
          (lambda _
            (zero? (system* "bash" "autogen.sh"))))
         (add-before
          'build 'patch-variables
          (lambda* (#:key outputs #:allow-other-keys)
            (with-directory-excursion "../lisp"
              ;; 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
          'install 'install-lisp
          (lambda* (#:key outputs #:allow-other-keys)
            (let ((target (string-append (assoc-ref outputs "out")
                                         "/share/emacs/site-lisp/")))
              (mkdir-p target)
              (for-each
               (lambda (file)
                 (copy-file file (string-append target (basename file))))
               (find-files "../lisp" "^(pdf|tab).*\\.elc?"))
              (emacs-generate-autoloads "pdf-tools" target)))))))
    (native-inputs `(("autoconf" ,autoconf)
                     ("automake" ,automake)
                     ("pkg-config" ,pkg-config)
                     ("emacs" ,emacs-no-x)))
    (inputs `(("poppler" ,poppler)
              ("cairo" ,cairo)
              ("glib" ,glib)
              ("libpng" ,libpng)
              ("zlib" ,zlib)))
    (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+)))

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Add Emacs PDF tools
  2015-07-06 13:40 ` Alex Kost
@ 2015-07-09 13:56   ` Alex Kost
  2015-07-10  7:16     ` Ricardo Wurmus
  0 siblings, 1 reply; 5+ messages in thread
From: Alex Kost @ 2015-07-09 13:56 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: Guix-devel

[-- Attachment #1: Type: text/plain, Size: 466 bytes --]

Since now we have 'emacs-byte-compile-directory', the elisp files may
also be compiled.  I modified your patch to:

- move patching the variables (including 'pdf-tools-handle-upgrades')
  into a separate phase;
- compile the elisp files;
- generate autoloads.

So if there is no way to "build" elisp files using the top-level
Makefile, and then to "build" epdfinfo using "autogen.sh" and friends
from the "server" subdir, I think the attached patch will do.  WDYT?


[-- Attachment #2: 0001-gnu-Add-emacs-pdf-tools.patch --]
[-- Type: text/x-patch, Size: 4535 bytes --]

From f1ad90ddcbe7ede8124f2b4c18a3ce31857ec9e0 Mon Sep 17 00:00:00 2001
From: Ricardo Wurmus <rekado@elephly.net>
Date: Sun, 5 Jul 2015 19:59:37 +0200
Subject: [PATCH] gnu: Add emacs-pdf-tools.

* gnu/packages/emacs.scm (emacs-pdf-tools): New variable.

Co-authored-by: Alex Kost <alezost@gmail.com>
---
 gnu/packages/emacs.scm | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index f00e15c..169ab08 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -4,6 +4,7 @@
 ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
 ;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
+;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -52,6 +53,7 @@
   #:use-module (gnu packages glib)
   #:use-module (gnu packages acl)
   #:use-module (gnu packages perl)
+  #:use-module (gnu packages pdf)
   #:use-module (gnu packages linux)               ;alsa
   #:use-module (gnu packages xiph)
   #:use-module (gnu packages mp3)
@@ -826,3 +828,74 @@ or XEmacs.")
     "MMM Mode is a minor mode that allows multiple major modes to coexist in a
 single buffer.")
     (license license:gpl3+)))
+
+(define-public emacs-pdf-tools
+  (package
+    (name "emacs-pdf-tools")
+    (version "0.60")
+    (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
+                "1y8k5n2jbyaxby0j6f4m9xbm0ddpmbkrfj6rp6ll5sb97lcg3vrx"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f ; there are no tests
+       #:modules ((guix build gnu-build-system)
+                  (guix build utils)
+                  (guix build emacs-utils))
+       #:imported-modules (,@%gnu-build-system-modules
+                           (guix build emacs-utils))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'enter-dir (lambda _ (chdir "server") #t))
+         (add-before
+          'configure 'autogen
+          (lambda _
+            (zero? (system* "bash" "autogen.sh"))))
+         (add-before
+          'build 'patch-variables
+          (lambda* (#:key outputs #:allow-other-keys)
+            (with-directory-excursion "../lisp"
+              ;; 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
+          'install 'install-lisp
+          (lambda* (#:key outputs #:allow-other-keys)
+            (let ((target (string-append (assoc-ref outputs "out")
+                                         "/share/emacs/site-lisp/")))
+              (mkdir-p target)
+              (for-each
+               (lambda (file)
+                 (copy-file file (string-append target (basename file))))
+               (find-files "../lisp" "^(pdf|tab).*\\.elc?"))
+              (emacs-byte-compile-directory target)
+              (emacs-generate-autoloads "pdf-tools" target)))))))
+    (native-inputs `(("autoconf" ,autoconf)
+                     ("automake" ,automake)
+                     ("pkg-config" ,pkg-config)
+                     ("emacs" ,emacs-no-x)))
+    (inputs `(("poppler" ,poppler)
+              ("cairo" ,cairo)
+              ("glib" ,glib)
+              ("libpng" ,libpng)
+              ("zlib" ,zlib)))
+    (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+)))
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Add Emacs PDF tools
  2015-07-09 13:56   ` Alex Kost
@ 2015-07-10  7:16     ` Ricardo Wurmus
  2015-07-11 14:24       ` Alex Kost
  0 siblings, 1 reply; 5+ messages in thread
From: Ricardo Wurmus @ 2015-07-10  7:16 UTC (permalink / raw)
  To: Alex Kost; +Cc: Guix-devel


Alex Kost <alezost@gmail.com> writes:

> Since now we have 'emacs-byte-compile-directory', the elisp files may
> also be compiled.  I modified your patch to:
>
> - move patching the variables (including 'pdf-tools-handle-upgrades')
>   into a separate phase;
> - compile the elisp files;
> - generate autoloads.

Thank you!

> So if there is no way to "build" elisp files using the top-level
> Makefile, and then to "build" epdfinfo using "autogen.sh" and friends
> from the "server" subdir, I think the attached patch will do.  WDYT?

The top-level Makefile uses ‘cask’ to bytecompile and test the package
tarball.  The ‘$(PACKAGE_NAME).tar’ target contains the only line that
copies the elisp files to the target directory, but it’s amidst lines
required for building the tarball.  I don’t think there’s a good way to
reuse the top-level Makefile.

~~ Ricardo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Add Emacs PDF tools
  2015-07-10  7:16     ` Ricardo Wurmus
@ 2015-07-11 14:24       ` Alex Kost
  0 siblings, 0 replies; 5+ messages in thread
From: Alex Kost @ 2015-07-11 14:24 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: Guix-devel

Ricardo Wurmus (2015-07-10 10:16 +0300) wrote:

[...]
> The top-level Makefile uses ‘cask’ to bytecompile and test the package
> tarball.  The ‘$(PACKAGE_NAME).tar’ target contains the only line that
> copies the elisp files to the target directory, but it’s amidst lines
> required for building the tarball.  I don’t think there’s a good way to
> reuse the top-level Makefile.

Ah, I agree, so I think the current patch is OK.

-- 
Alex

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-07-11 14:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-05 17:59 [PATCH] Add Emacs PDF tools Ricardo Wurmus
2015-07-06 13:40 ` Alex Kost
2015-07-09 13:56   ` Alex Kost
2015-07-10  7:16     ` Ricardo Wurmus
2015-07-11 14:24       ` Alex Kost

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).