emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-file-apps regex matching against path not link
@ 2018-04-12 19:22 Frankie Y. Liu
  2018-04-12 19:38 ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Frankie Y. Liu @ 2018-04-12 19:22 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1330 bytes --]

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)))))

[-- Attachment #2: Type: text/html, Size: 2041 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: org-file-apps regex matching against path not link
  2018-04-12 19:22 org-file-apps regex matching against path not link Frankie Y. Liu
@ 2018-04-12 19:38 ` Nicolas Goaziou
  2018-04-12 22:41   ` Frankie Y. Liu
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2018-04-12 19:38 UTC (permalink / raw)
  To: Frankie Y. Liu; +Cc: emacs-orgmode

Hello,

"Frankie Y. Liu" <frankie.y.liu@gmail.com> writes:

> 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"))

What is "\d+"? You may want to try [0-9]+ insteal.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: org-file-apps regex matching against path not link
  2018-04-12 19:38 ` Nicolas Goaziou
@ 2018-04-12 22:41   ` Frankie Y. Liu
  2018-04-14  7:42     ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Frankie Y. Liu @ 2018-04-12 22:41 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 714 bytes --]

Hi Nicolas,

For:

\\.pdf:\\([0-9]+\\)\\'

[0-9]+ vs \d+ same issue, since the path not the link is being matched.

Example:
file:foo.pdf::1 will be matching on file:foo.pdf and the ::1 is dropped.

Therefore it doesn't matter what you put after :: it is not being used.





On Thu, Apr 12, 2018 at 12:38 PM, Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> Hello,
>
> "Frankie Y. Liu" <frankie.y.liu@gmail.com> writes:
>
> > 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"))
>
> What is "\d+"? You may want to try [0-9]+ insteal.
>
> Regards,
>
> --
> Nicolas Goaziou
>

[-- Attachment #2: Type: text/html, Size: 1455 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: org-file-apps regex matching against path not link
  2018-04-12 22:41   ` Frankie Y. Liu
@ 2018-04-14  7:42     ` Nicolas Goaziou
  2018-04-14 14:05       ` Frankie Y. Liu
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2018-04-14  7:42 UTC (permalink / raw)
  To: Frankie Y. Liu; +Cc: emacs-orgmode

Hello,

"Frankie Y. Liu" <frankie.y.liu@gmail.com> writes:

> For:
>
> \\.pdf:\\([0-9]+\\)\\'

You forgot a colon.

> [0-9]+ vs \d+ same issue, since the path not the link is being
> matched.
>
> Example:
> file:foo.pdf::1 will be matching on file:foo.pdf and the ::1 is
> dropped.


I cannot reproduce it here. The function
`org-file-apps-entry-match-against-dlink-p' is responsible for deciding
if a link needs to be matched in full, or not.

Regards,

-- 
Nicolas Goaziou                                                0x80A93738

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: org-file-apps regex matching against path not link
  2018-04-14  7:42     ` Nicolas Goaziou
@ 2018-04-14 14:05       ` Frankie Y. Liu
  2018-04-14 14:29         ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Frankie Y. Liu @ 2018-04-14 14:05 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 924 bytes --]

Hi Nicolas,

Sorry I mistyped in the message, I did have two colons when trying it out.
I will look into the
function you pointed out.

When you said you cannot reproduce it, does that mean it works/matches for
you?

I am using Emacs 25.3.5 and org-20180226

-f

On Sat, Apr 14, 2018 at 12:42 AM, Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> Hello,
>
> "Frankie Y. Liu" <frankie.y.liu@gmail.com> writes:
>
> > For:
> >
> > \\.pdf:\\([0-9]+\\)\\'
>
> You forgot a colon.
>
> > [0-9]+ vs \d+ same issue, since the path not the link is being
> > matched.
> >
> > Example:
> > file:foo.pdf::1 will be matching on file:foo.pdf and the ::1 is
> > dropped.
>
>
> I cannot reproduce it here. The function
> `org-file-apps-entry-match-against-dlink-p' is responsible for deciding
> if a link needs to be matched in full, or not.
>
> Regards,
>
> --
> Nicolas Goaziou                                                0x80A93738
>

[-- Attachment #2: Type: text/html, Size: 1662 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: org-file-apps regex matching against path not link
  2018-04-14 14:05       ` Frankie Y. Liu
@ 2018-04-14 14:29         ` Nicolas Goaziou
  0 siblings, 0 replies; 6+ messages in thread
From: Nicolas Goaziou @ 2018-04-14 14:29 UTC (permalink / raw)
  To: Frankie Y. Liu; +Cc: emacs-orgmode

"Frankie Y. Liu" <frankie.y.liu@gmail.com> writes:

> When you said you cannot reproduce it, does that mean it works/matches for
> you?

It does, indeed.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-04-14 14:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-12 19:22 org-file-apps regex matching against path not link Frankie Y. Liu
2018-04-12 19:38 ` Nicolas Goaziou
2018-04-12 22:41   ` Frankie Y. Liu
2018-04-14  7:42     ` Nicolas Goaziou
2018-04-14 14:05       ` Frankie Y. Liu
2018-04-14 14:29         ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

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