emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Opening of links
@ 2022-09-23 14:49 Guillaume MULLER
  2022-09-24  2:08 ` Ihor Radchenko
  2022-09-24 11:49 ` Max Nikulin
  0 siblings, 2 replies; 4+ messages in thread
From: Guillaume MULLER @ 2022-09-23 14:49 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1.1: Type: text/plain, Size: 1683 bytes --]

Hi,

Thanks for org, "the best tool in the world"! ;) (*)

I have a simple org file (Linux / Emacs 27.1 + Doom):

--------------
#+TITLE: Test pdf links

+ [[file:~/test.pdf][PDF 1]]
--------------

When I click on the link with mouse1, the document is opened in Calibre. When I use mouse3, the document is opened in Emacs. I get a similar behavior with org-attached PDF documents: using 'o' will open them in Calibre, 'O' in Emacs.

Such a behavior for mouse1/'o' raises 2 questions:

- My OS settings are configured so that PDFs are opened in Evince. I configured this with "xfce4-settings-manager > Default Applications" (which runs "xfce4-mime-settings" under the hood) and it can be verified with "xdg-open test.pdf" or by opening Thunar and clicking on "test.pdf".
   So, where in the world does org-mode/Emacs finds that it should use Calibre instead of Evince?

- Now, I would like to circumvent this global OS behavior, so that Emacs itself would be used specifically to open PDF links in files I open in Emacs. When I was using Vanilla Emacs, I was advised to use pdf-tools, and given a config that was working. I translated that into my DoomEmacs config.org as follows:
   (use-package! pdf-tools
     :magic ("%PDF" . pdf-view-mode)
     :config
       (pdf-tools-install :no-query)
     )
   But apparently it does not override org's (default) behavior of opening PDF file with external tools.
   Is there

Sorry for these (probably very) basic questions, but I could not find anything relevant on the web (or I haven't found the correct keywords...). I would be very grateful of any help!

Have a nice Week end

-- 
Guillaume MULLER


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 673 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

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

* Re: Opening of links
  2022-09-23 14:49 Opening of links Guillaume MULLER
@ 2022-09-24  2:08 ` Ihor Radchenko
  2022-09-24 11:49 ` Max Nikulin
  1 sibling, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2022-09-24  2:08 UTC (permalink / raw)
  To: Guillaume MULLER; +Cc: emacs-orgmode

Guillaume MULLER <guillaume.muller@emse.fr> writes:

> + [[file:~/test.pdf][PDF 1]]
> --------------
>
> When I click on the link with mouse1, the document is opened in Calibre. When I use mouse3, the document is opened in Emacs. I get a similar behavior with org-attached PDF documents: using 'o' will open them in Calibre, 'O' in Emacs.
>
> Such a behavior for mouse1/'o' raises 2 questions:
>
> - My OS settings are configured so that PDFs are opened in Evince. I configured this with "xfce4-settings-manager > Default Applications" (which runs "xfce4-mime-settings" under the hood) and it can be verified with "xdg-open test.pdf" or by opening Thunar and clicking on "test.pdf".
>    So, where in the world does org-mode/Emacs finds that it should use Calibre instead of Evince?
>
> - Now, I would like to circumvent this global OS behavior, so that Emacs itself would be used specifically to open PDF links in files I open in Emacs. When I was using Vanilla Emacs, I was advised to use pdf-tools, and given a config that was working. I translated that into my DoomEmacs config.org as follows:
>    (use-package! pdf-tools
>      :magic ("%PDF" . pdf-view-mode)
>      :config
>        (pdf-tools-install :no-query)
>      )
>    But apparently it does not override org's (default) behavior of opening PDF file with external tools.
>    Is there

See https://orgmode.org/manual/Handling-Links.html#Handling-Links
(search org-open-at-point). The app selection is controlled by
org-file-apps customization.

> Sorry for these (probably very) basic questions, but I could not find anything relevant on the web (or I haven't found the correct keywords...). I would be very grateful of any help!

No problem. This mailing list is open to all Org-related staff,
including basic questions. Do not hesitate to participate in the
discussion or ask anything.

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92


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

* Re: Opening of links
  2022-09-23 14:49 Opening of links Guillaume MULLER
  2022-09-24  2:08 ` Ihor Radchenko
@ 2022-09-24 11:49 ` Max Nikulin
  2022-09-25 11:06   ` Max Nikulin
  1 sibling, 1 reply; 4+ messages in thread
From: Max Nikulin @ 2022-09-24 11:49 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Guillaume MULLER

On 23/09/2022 21:49, Guillaume MULLER wrote:
> 
> - My OS settings are configured so that PDFs are opened in Evince. I 
> configured this with "xfce4-settings-manager > Default Applications" 
> (which runs "xfce4-mime-settings" under the hood) and it can be verified 
> with "xdg-open test.pdf" or by opening Thunar and clicking on "test.pdf".

I would name it desktop environment configuration since OS may have more 
settings and it is your issue.

These settings likely alters ~/.config/mimeapps.list
https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html
"Association between MIME types and applications"

Unfortunately Emacs does not support this part of XDG specs, so there 
are no ready to use functions to work with .desktop files and MIME 
associations. You may add entries calling xdg-open for file types you 
wish to the `org-file-apps' custom variable.

>    So, where in the world does org-mode/Emacs finds that it should use 
> Calibre instead of Evince?

You may have mailcap configuration where Calibre has higher priority 
than Evince, check /etc/mailcap
RFC 1524. A User Agent Configuration Mechanism For Multimedia Mail 
Format Information
https://www.rfc-editor.org/rfc/rfc1524.html

Emacs has limited support of mailcap and it is used by Org mode. 
Besides system configuration, Emacs has a set of predefined association. 
Unfortunately the latter is broken in Emacs-27, see
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=40247
#40247 - 27.0.90; mailcap-mime-data erased when parsing mime parts - GNU 
bug report logs

> - Now, I would like to circumvent this global OS behavior, so that Emacs 
> itself would be used specifically to open PDF links in files I open in 
> Emacs. When I was using Vanilla Emacs, I was advised to use pdf-tools, 
> and given a config that was working. I translated that into my DoomEmacs 
> config.org as follows:
>    (use-package! pdf-tools
>      :magic ("%PDF" . pdf-view-mode)
>      :config
>        (pdf-tools-install :no-query)
>      )
>    But apparently it does not override org's (default) behavior of 
> opening PDF file with external tools.

The code of `org-open-file' is tricky. You may instrument this function 
for debugging and step through it to realize what actually happens. 
Maybe pdf-tools vs. doc-view mode choice is controlled by `auto-mode-alist'.

Concerning external viewer configuration, you may adapt for Evince the 
following approach:
Max Nikulin. Re: Org mode links: Open a PDF file at a given page and 
highlight a given string. Sat, 3 Sep 2022 20:00:47 +0700. 
https://list.orgmode.org/tevj61$17d8$1@ciao.gmane.io


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

* Re: Opening of links
  2022-09-24 11:49 ` Max Nikulin
@ 2022-09-25 11:06   ` Max Nikulin
  0 siblings, 0 replies; 4+ messages in thread
From: Max Nikulin @ 2022-09-25 11:06 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Guillaume MULLER

On 24/09/2022 18:49, Max Nikulin wrote:
> On 23/09/2022 21:49, Guillaume MULLER wrote:
>>
>> - My OS settings are configured so that PDFs are opened in Evince. I 
>> configured this with "xfce4-settings-manager > Default Applications" 
>> (which runs "xfce4-mime-settings" under the hood) and it can be 
>> verified with "xdg-open test.pdf" or by opening Thunar and clicking on 
>> "test.pdf".
> 
> I would name it desktop environment configuration since OS may have more 
> settings and it is your issue.
> 
> These settings likely alters ~/.config/mimeapps.list
> https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html 
> 
> "Association between MIME types and applications"
> 
> Unfortunately Emacs does not support this part of XDG specs, so there 
> are no ready to use functions to work with .desktop files and MIME 
> associations. You may add entries calling xdg-open for file types you 
> wish to the `org-file-apps' custom variable.

Likely the following entry in `org-file-apps' to override maicap by 
xdg-open may allow to achieve what you expect:

     (system . (lambda (file _link) (browse-url-xdg-open file))))

However links with page numbers (supported for "docview:" type out of 
the box) will not work with such generic handler.


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

end of thread, other threads:[~2022-09-25 11:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-23 14:49 Opening of links Guillaume MULLER
2022-09-24  2:08 ` Ihor Radchenko
2022-09-24 11:49 ` Max Nikulin
2022-09-25 11:06   ` Max Nikulin

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