lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Point an Click & emacs


From: Immanuel Litzroth
Subject: Point an Click & emacs
Date: Sat, 21 May 2022 20:56:58 +0200

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

-- 
-- A man must either resolve to point out nothing new or to become a
slave to defend it. -- Sir Isaac Newton



reply via email to

[Prev in Thread] Current Thread [Next in Thread]