Le 21/05/2022 à 20:56, Immanuel Litzroth a écrit :
Today I found out it's quite easy to get point and click working
with emacs as pdf viewer when using the pdf-tools package.
1. Install pdf-tools: https://github.com/politza/pdf-tools
It's available as a package in emacs.

2. put this in your .emacs config
(defconst lilypond-filename-rx
   (rx (seq
        string-start
        (group (1+ print))
        ":"
        (group (1+ digit))
        ":"
        (group (1+ digit))
        ":"
        (group (1+ digit))
        string-end)))

(defun lilypond-pdf-links-browse-uri-function (uri)
   "Check if the link starts with texedit and just reroute to emacs.
Otherwise call pdf-links-browse-uri-default."
   (cl-check-type uri string)
   (let* ((obj (url-generic-parse-url uri))
          (match (string-match lilypond-filename-rx (url-filename obj))))
     (unless match
       (message "Could not match %s" (url-filename obj)))
     (let* ((filename (match-string 1 (url-filename obj)))
            (line (string-to-number (match-string 2 (url-filename obj))))
            (pos (string-to-number (match-string 3 (url-filename obj))))
            (buf (or (find-buffer-visiting filename)
                     (find-file-noselect filename))))
       (pop-to-buffer buf)
       (goto-char (point-min))
       (forward-line (1- line))
       (forward-char pos))))


(setq pdf-links-browse-uri-function 'lilypond-pdf-links-browse-uri-function)
3. Open a lilypond generated pdf with \PointAndClickOn and click away.

The code might need some refining but it does work here quite well.
Immanuel


Hello,

What kind of answer to this post do you await?

Best,
Jean


Reply via email to