Skip to content

Include possibility to run external program in the way how xpdf does it, to capture reference #981

@gnusupport

Description

@gnusupport

Is your feature request related to a problem? Please describe.:

It is best EPUB reader that I know. However, I can't capture references. Reason I use XPDF is that I can press single key and run external program which captures file name, page number, selection and similar.

Describe the solution you'd like:

I would like option to set up key binding so that I can run external program in similar way as xpdf.

For example I have in my ~/.xpdfrc this option:

bind ctrl-c any endSelection "run(xpdf-capture-page.sh '%f' '%p')"
or
bind ctrl-o any endSelection "run(xpdfcapture.sh '%f' '%p' '%x' '%y' '%X' '%Y' '%u')"

which makes sure that I can run external program named
"xpdf-capture-page.sh" with parameters such as file and page number,
selection paremeters. Then I can decide by external program how to
capture and store the reference to the PDF file and page number
together with it's selection.

Here is the external program:

#!/bin/sh
file=$1
page=$2
emacsclient -e "(hyperscope-capture-xpdf-page \"$file\" \"$page\")"

The external function then recognizes the file, and stores the hyperlink in the database.

(defun hyperscope-capture-xpdf-page (filename-uuid page &optional p x y X Y u)
  ;; (message "%p %x %y %X %Y %u" p x y X Y u)
  (let* ((filename-uuid (string-trim filename-uuid "'" "'"))
	 (basename (file-name-base filename-uuid))
	 (id (hyperscope-id-by-uuid basename)))
    (rcd-unless id
	(rcd-warning-message "Could not find ID for `%s'" filename-uuid)
      (raise-frame)
      (x-focus-frame nil)
      (let* ((link (hyperscope-link-value id))
	     (subtype (hyperscope-subtype id))
	     (parent (hyperscope-parent id))
	     (text (gui-selection-value))
	     (name (hyperscope-name id))
	     (name (rcd-ask-get "Name of Hyperdocument: " name name)))
	(cond (id (let ((new-id (hyperscope-add-generic name link nil 19 subtype parent page nil nil nil nil nil text)))
		    (hyperscope-isolate new-id)))
	      (t (rcd-warning-message "Could not capture Hyperdocument ID: %d, page %d" id page)))))))

It opens up and launches Emacs function, but I could launch any other function or do what I wish.

Reading books is important, but indexing specific sections of it even
more important, as that way I skip to browse through the
book.

It allows a collection of references by specification as given by Doug Engelbart in

TECHNOLOGY TEMPLATE PROJECT OHS Framework:
https://www.dougengelbart.org/content/view/110/460/

Describe alternatives you've considered:

The only alternative I have is `xpdf' which works perfect for that
purpose, but that one cannot handle EPUB documents.

Additional context

See video how it works with xpdf:

https://gnu.support/images/2023/01/2023-01-20/mpv-shot0001.jpg

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions