emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Alan Wehmann <alan.wehmann@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: link error when file missing
Date: Sat, 16 Apr 2022 20:25:03 +0800	[thread overview]
Message-ID: <87zgklmd0g.fsf@localhost> (raw)
In-Reply-To: <F75F924A-BD3F-4998-A2DE-E1CD1A4A538C@gmail.com>

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)


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.



  reply	other threads:[~2022-04-16 12:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-15 14:49 link error when file missing Alan Wehmann
2022-04-16 12:25 ` Ihor Radchenko [this message]
     [not found]   ` <EC42A7CB-CEB6-4195-96DE-5C252CE1A29C@gmail.com>
     [not found]     ` <874k25iax8.fsf@localhost>
2022-07-11  5:01       ` [PATCH] " Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zgklmd0g.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=alan.wehmann@gmail.com \
    --cc=emacs-orgmode@gnu.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


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