emacs-orgmode
[Top][All Lists]
Advanced

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

Re: link error when file missing


From: Ihor Radchenko
Subject: Re: link error when file missing
Date: Sat, 16 Apr 2022 20:25:03 +0800

Alan Wehmann <alan.wehmann@gmail.com> writes:

> I have a link in a text file that looks as follows, in fundamental mode:
>
> 5. Contracts: [[docview:~/Documents/Wheaton_condo/landscaping/from 
> Mark/2019/ALM_landscape_contract_Fall_2018.pdf::1][Landscape]], 
> [[docview:~/Documents/Wheaton_condo/landscaping/from 
> Mark/2018/ALM_snow_management_contract_Fall_2018.pdf::1][Snow]]
>
> The path is deliberately wrong in the first link--in order to demonstrate the 
> error that results.  The year "2019" there should be "2018" and then in that 
> case the link works properly (when the file is set to org-mode); the result 
> of using the proper link is that the document is shown in a docview buffer.
>
> As is, there is an error thrown & below is the backtrace for it (after 
> appropriate use of "toggle-debug-on-error")
>
> Debugger entered--Lisp error: (wrong-type-argument listp t)
>   image-mode-winprops(nil)
>   image-mode-window-put(page 0 nil)
>   doc-view-goto-page(1)
>   org-docview-open("~/Documents/Wheaton_condo/landscaping/from Mark/20..." 
> nil)

Confirmed.

This is caused by ol-docview's assumption (see org-docview-open) that
org-open-file does not open non-existing file, as it is stated in
org-open-file docstring:

>> If the file does not exist, throw an error.

However, the docstring is not quite correct. Below is code in
org-open-file that is repronsible for throwing the error:

    (when (and (not (eq cmd 'emacs)) ; Emacs has no problems with non-ex files
               (not (file-exists-p file))
               (not org-open-non-existing-files))
      (user-error "No such file: %s" file))

Clearly, throwing or not throwing error is controlled by
org-open-non-existing-files and org-open-file never throws an error with
non-nil first optional argument (IN-EMACS).

This code has been introduced years ago by Carsten.

We have several options to fix the issue:
1. Only fix the reported issue in ol-docview.el and extend org-open-file 
documention
2. In addition, make org-open-file throw an error when opening non-existing 
files in
   emacs (unless org-open-non-existing-files is non-nil)

The second option poses a risk of breaking existing configs.

WDYT?

Best,
Ihor



reply via email to

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