unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Eduardo Ochs <eduardoochs@gmail.com>
Cc: Adam Porter <adam@alphapapa.net>, Emacs developers <emacs-devel@gnu.org>
Subject: Re: hyperscope
Date: Fri, 6 Nov 2020 22:18:52 +0300	[thread overview]
Message-ID: <X6WhnMN/g3R5aooT@protected.rcdrun.com> (raw)
In-Reply-To: <CADs++6igNNj7xPo7SWtBuAfNoYiJu6ihsRr5L2McxJz+Q6gbiw@mail.gmail.com>

* Eduardo Ochs <eduardoochs@gmail.com> [2020-11-06 21:19]:
> do you have examples of the syntax of these links and of what we need
> to make them work? I am especially interested in "MPV play video at
> exact time", "Launch Program", "Media", "PDF by Page Nr." and
> "Set"...

I do not have universal approach similar like URL, it is database
approach such as (hyperscope 123) where ID 123 is defined to open
specific video at specific time. Links are shown to user on screen as
such and users define them but they are not accessible without
database.

> I am asking because one of the topics of my talk at the next EmacsConf
> (in a few weeks!) is how eev implements links to all these things,
> and I want to compare eev's approach with other packages. See:
> 
>   http://angg.twu.net/eev-intros/find-pdf-like-intro.html
>   http://angg.twu.net/eev-intros/find-audiovideo-intro.html

I was researching eev before weeks and it has alignment with some
principles of collective IQ creation, so I may as well include eev
mode in my hyperscope if such exist. 

Here are some functions handling those links, you may see that mpv
opens up by using id

(defun hlink-mpv-play-video-at-exact-time (id)
  (let* ((link (hlinks-link id))
	 (arguments (hlinks-arguments id))
	 (command (format "mpv --start=%s '%s'" arguments link)))
    (async-shell-command command)
    (hlink-description-show id)))

(defun hlink-show-pdf-by-page (link argument)
  "Opens the PDF page by number"
  (funcall (intern hyperscope-pdf-function) link argument))

hyperscope-pdf-function:

(defun hyperscope-evince (file &optional page query)
  "Opens PDF with evince document viewer"
  (let* ((command "evince")
	 (command (if page (format "%s --page-index=%s" command page) command))
	 (command (if query (format "%s -l '%s'" command query) command))
	 (command (format "%s '%s'" command file)))
    (async-shell-command command)))

> I know org-player and org-pdftools, but I found them hard to set up.

It is better you make simple eev based functions to handle such links.

Maybe this function below can open PDF inside of Emacs at specific
page number for maybe specific query in PDF/DJVU/DVI or specific
match. But it could be as well not functional. I have to test it to
confirm, but you could reuse for evv to view PDF/DJVU/DVI finely
grained inside of Emacs.

(defun doc-view-open-file (file &optional page-number query match)
  "Opens PDF file in GNU Emacs at specific page number or at
specific match"
  (let* ((allowed-extensions '("pdf" "djvu" "dvi"))
	 (file-ext (file-name-extension file))
	 (match (if match match 0)))
    (when (and (file-exists-p file)
	       (seq-contains-p allowed-extensions file-ext 'equalp))
      (setq doc-view--current-search-matches nil)
      (let ((created (create-file-buffer file))
	    (buffer (get-file-buffer file)))
	(switch-to-buffer created)
	(set-visited-file-name file t)
	(insert file)
	(doc-view-mode)
	(read-only-mode)
	(when page-number
	  (doc-view-goto-page page-number))
	(when query
	  (let ((txt (expand-file-name "doc.txt"
				       (doc-view--current-cache-dir))))
	    (if (file-readable-p txt)
		(progn
		  (setq doc-view--current-search-matches
			(doc-view-search-internal query txt))
		  (doc-view-search-next-match match)))))))))




  reply	other threads:[~2020-11-06 19:18 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20201104161200.tyeo2r5jibdahukb.ref@Ergus>
2020-11-04 16:12 ` Feature branches review please Ergus
2020-11-04 23:18   ` Basil L. Contovounesios
2020-11-05  8:30   ` Gregory Heytings via Emacs development discussions.
2020-11-05 10:05     ` Jean Louis
2020-11-05 16:10       ` Gregory Heytings via Emacs development discussions.
2020-11-05 16:27         ` Manuel Uberti
2020-11-05 17:00           ` Gregory Heytings via Emacs development discussions.
2020-11-05 17:32             ` Jean Louis
2020-11-05 18:50               ` Stefan Monnier
2020-11-05 19:30                 ` Jean Louis
2020-11-05 19:52                   ` Eli Zaretskii
2020-11-05 21:55                   ` Adam Porter
2020-11-05 22:18                     ` hyperscope Jean Louis
2020-11-06 18:18                       ` hyperscope Eduardo Ochs
2020-11-06 19:18                         ` Jean Louis [this message]
2020-11-06  5:50                     ` Feature branches review please Jean Louis
2020-11-05 20:39               ` Gregory Heytings via Emacs development discussions.
2020-11-05 21:09                 ` Ergus
2020-11-05 21:19                   ` Gregory Heytings via Emacs development discussions.
2020-11-05 21:36                     ` Jean Louis
2020-11-05 21:44                     ` Stefan Monnier
2020-11-05 22:00                       ` Gregory Heytings via Emacs development discussions.
2020-11-05 22:36                         ` Ergus
2020-11-06  8:42                           ` Gregory Heytings via Emacs development discussions.
2020-11-05 21:33                 ` Jean Louis
2020-11-05 21:46                   ` Basil L. Contovounesios
2020-11-05 22:24                   ` Gregory Heytings via Emacs development discussions.
2020-11-05 22:48                     ` Jean Louis
2020-11-06  9:19                       ` Gregory Heytings via Emacs development discussions.
2020-11-06 10:51                         ` Feature branches review please (ivy hello) Jean Louis
2020-11-06 11:17                           ` Oleh Krehel
2020-11-06 11:42                             ` Jean Louis
2020-11-06 11:49                               ` Basil L. Contovounesios
2020-11-06 12:01                                 ` Jean Louis
2020-11-06 21:12                                   ` Basil L. Contovounesios
2020-11-06 11:57                               ` Could ivy minibuffer stay where it is? Jean Louis
2020-11-06 15:20                                 ` Basil L. Contovounesios
2020-11-06 15:36                                   ` Jean Louis
2020-11-06 21:17                                     ` Basil L. Contovounesios
2020-11-07 12:51                                       ` Oleh Krehel
2020-11-07 17:23                                         ` Jean Louis
2020-11-08 11:21                                           ` Oleh Krehel
2020-11-08 12:51                                             ` Jean Louis
2020-11-06 13:56                               ` Feature branches review please (ivy hello) Stefan Monnier
2020-11-06 14:10                                 ` Eli Zaretskii
2020-11-06 14:55                                   ` Stefan Monnier
2020-11-06 15:24                                 ` Jean Louis
2020-11-06 12:07                           ` Gregory Heytings via Emacs development discussions.
2020-11-06 14:02                             ` Stefan Monnier
2020-11-06 14:41                               ` Gregory Heytings via Emacs development discussions.
2020-11-06 19:23                             ` Jean Louis
2020-11-06 21:09                               ` Gregory Heytings via Emacs development discussions.
2020-11-15 20:12                       ` Feature branches review please Juri Linkov
2020-11-15 22:32                         ` Drew Adams
2020-11-06 10:31               ` Alan Mackenzie
2020-11-06 10:55                 ` Jean Louis
2020-11-05 17:22         ` Jean Louis
2020-11-05 13:25   ` Andrii Kolomoiets

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=X6WhnMN/g3R5aooT@protected.rcdrun.com \
    --to=bugs@gnu.support \
    --cc=adam@alphapapa.net \
    --cc=eduardoochs@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).