From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: Re: [PATCH] Add Emacs PDF tools Date: Mon, 06 Jul 2015 16:40:39 +0300 Message-ID: <87twthflpk.fsf@gmail.com> References: <878uaujxiu.fsf@elephly.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZC6dd-0004fF-Nr for guix-devel@gnu.org; Mon, 06 Jul 2015 09:40:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZC6dZ-0003Tg-Gv for guix-devel@gnu.org; Mon, 06 Jul 2015 09:40:49 -0400 Received: from mail-la0-x22c.google.com ([2a00:1450:4010:c03::22c]:36096) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZC6dZ-0003Qp-0N for guix-devel@gnu.org; Mon, 06 Jul 2015 09:40:45 -0400 Received: by lagc2 with SMTP id c2so155159290lag.3 for ; Mon, 06 Jul 2015 06:40:43 -0700 (PDT) In-Reply-To: <878uaujxiu.fsf@elephly.net> (Ricardo Wurmus's message of "Sun, 05 Jul 2015 19:59:37 +0200") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Ricardo Wurmus Cc: Guix-devel --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 =E2=80=93 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 "=E2=80=A6-autoloads.el" file so that some "pdf-=E2=80=A6" functions and commands become available. Here is the modified version of this package, I've tested (without byte-compiling and tests): --=-=-= Content-Type: text/x-scheme Content-Disposition: inline; filename=emacs-pdf-tools.scm (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+))) --=-=-=--