+(define-public xapers
+ (package
+ (name "xapers")
+ (version "0.8.2")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (string-append
+ "https://finestructure.net/xapers/releases/xapers-"
+ version ".tar.gz"))
+ (sha256
+ (base32
+ "0ykz6hn3qj46w3c99d6q0pi5ncq2894simcl7vapv047zm3cylmd"))))
+ (build-system python-build-system)
+ (propagated-inputs
+ `(("poppler" ,poppler)
+ ("python-urwid" ,python-urwid)
+ ("xclip" ,xclip)
+ ("xdg-utils" ,xdg-utils)))
+ (inputs
+ `(("python-latexcodec" ,python-latexcodec)
+ ("python-pybtex" ,python-pybtex)
+ ("python-pycurl" ,python-pycurl)
+ ("python-pyyaml" ,python-pyyaml)
+ ("python-six" ,python-six)
+ ("python-xapian-bindings" ,python-xapian-bindings)))
+ (arguments
+ `(#:modules ((ice-9 rdelim)
+ (guix build python-build-system)
+ (guix build utils))
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'install 'install-doc
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (define (purge-term-support input output)
+ (let loop ((line (read-line input)))
+ (if (string-prefix? "if [[ \"$term\"" line)
+ (begin (display "eval \"$cmd\"\n" output)
+ #t)
+ (begin (display (string-append line "\n") output)
+ (loop (read-line input))))))
+ (let* ((out (assoc-ref outputs "out"))
+ (bin (string-append out "/bin"))
+ (adder-out (string-append bin "/xapers-adder"))
+ (man1 (string-append out "/share/man/man1")))
+ (install-file "man/man1/xapers.1" man1)
+ (install-file "man/man1/xapers-adder.1" man1)
+ ;; below is equivalent to setting --no-term option
+ ;; permanently on; this is desirable to avoid imposing
+ ;; an x-terminal installation on the user but breaks
+ ;; some potential xapers-adder uses like auto browser
+ ;; pdf handler, but user could instead still use
+ ;; e.g. "xterm -e xapers-adder %F" for same use.
+ ;; alternatively we could propagate xterm as an input
+ ;; and replace 'x-terminal-emulator' with 'xterm'
+ (call-with-input-file "bin/xapers-adder"
+ (lambda (input)
+ (call-with-output-file adder-out
+ (lambda (output)
+ (purge-term-support input output)))))
+ (chmod adder-out #o555)))))))
+ (home-page "https://finestructure.net/xapers/")
+ (synopsis "Personal document indexing system")
+ (description
+ "Xapers is a personal document indexing system,
+geared towards academic journal articles build on the Xapian search engine.
+Think of it as your own personal document search engine, or a local cache of
+online libraries. It provides fast search of document text and
+bibliographic data and simple document and bibtex retrieval.")
+ (license gpl3+)))
+