emacs-orgmode
[Top][All Lists]
Advanced

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

[O] org-file-apps regex matching against path not link


From: Frankie Y. Liu
Subject: [O] org-file-apps regex matching against path not link
Date: Thu, 12 Apr 2018 12:22:48 -0700

I wanted to open a pdf at a particular page, the instructions under org-file-apps suggested using 

(add-to-list 'org-file-apps '("\\.pdf::\\(\\d+\\)\\'" . "evince -p %1 %s"))

This doesn't work because the regular _expression_ doesn't parse the link but the path.  Therefore the ::(\d+) part is not being matched.

I had to write my own version using both file and link but maybe there is a better way -- or a more elegant solution than what I have below.  Please let me know.

(add-to-list 'org-file-apps
                       '("\\.pdf\\'" .
                         (lambda
                           (file link)
                           (let*
                               ((mylink
                                 (split-string link "::"))
                                (option
                                 (>
                                  (length mylink)
                                  1))
                                (cmd
                                 (concat "evince " file
                                         (and option
                                              (concat " -p "
                                                      (nth 1 mylink))))))
                             (message "Running %s...done" cmd)
                             (start-process-shell-command cmd nil cmd)))))


reply via email to

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