emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* link error when file missing
@ 2022-04-15 14:49 Alan Wehmann
  2022-04-16 12:25 ` Ihor Radchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Wehmann @ 2022-04-15 14:49 UTC (permalink / raw)
  To: emacs-orgmode

Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

      https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.
------------------------------------------------------------------------

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)
  org-link-open((link (:type "docview" :path "~/Documents/Wheaton_condo/landscaping/from Mark/20..." :format bracket :raw-link "docview:~/Documents/Wheaton_condo/landscaping/from..." :application nil :search-option nil :begin 1000 :end 1115 :contents-begin 1104 :contents-end 1113 :post-blank 0 :parent (paragraph (:begin 989 :end 1234 :contents-begin 989 :contents-end 1234 :post-blank 0 :post-affiliated 989 :parent (item (:bullet "5. " :begin 986 :end 1235 :contents-begin 989 :contents-end 1234 :checkbox nil :counter nil :structure (... ... ... ... ... ... ... ...) :pre-blank 0 :post-blank 1 :post-affiliated 986 :tag nil :parent (plain-list ...))))))) nil)
  (cond ((not type) (user-error "No link found")) ((memq type '(comment comment-block node-property keyword)) (call-interactively #'org-open-at-point-global)) ((memq type '(headline inlinetask)) (org-match-line org-complex-heading-regexp) (let ((tags-beg (match-beginning 5)) (tags-end (match-end 5))) (if (and tags-beg (>= (point) tags-beg) (< (point) tags-end)) (org-tags-view arg (save-excursion (let* (... ...) (buffer-substring ... ...)))) (let* ((val (org-offer-links-in-entry ... ... arg))) (if (consp val) (let* (...) (if ... ... ...)) nil))))) ((or (eq type 'footnote-reference) (and (eq type 'footnote-definition) (save-excursion (skip-chars-forward " \11") (let ((begin ...)) (if begin (< ... begin) (= ... ...)))))) (org-footnote-action)) ((and (eq type 'planning) (org-in-regexp org-ts-regexp-both nil t)) (org-follow-timestamp-link)) ((and (eq type 'clock) value (>= (point) (org-element-property :begin value)) (<= (point) (org-element-property :end value))) (org-follow-timestamp-link)) ((eq type 'src-block) (org-babel-open-src-block-result)) ((>= (point) (save-excursion (goto-char (org-element-property :end context)) (skip-chars-backward " \11") (point))) (user-error "No link found")) ((eq type 'inline-src-block) (org-babel-open-src-block-result)) ((eq type 'timestamp) (org-follow-timestamp-link)) ((eq type 'link) (org-link-open context arg)) ((memq type '(citation citation-reference)) (org-cite-follow context arg)) (t (user-error "No link found")))
  (let* ((context (org-element-lineage (org-element-context) '(citation citation-reference clock comment comment-block footnote-definition footnote-reference headline inline-src-block inlinetask keyword link node-property planning src-block timestamp) t)) (type (org-element-type context)) (value (org-element-property :value context))) (cond ((not type) (user-error "No link found")) ((memq type '(comment comment-block node-property keyword)) (call-interactively #'org-open-at-point-global)) ((memq type '(headline inlinetask)) (org-match-line org-complex-heading-regexp) (let ((tags-beg (match-beginning 5)) (tags-end (match-end 5))) (if (and tags-beg (>= (point) tags-beg) (< (point) tags-end)) (org-tags-view arg (save-excursion (let* ... ...))) (let* ((val ...)) (if (consp val) (let* ... ...) nil))))) ((or (eq type 'footnote-reference) (and (eq type 'footnote-definition) (save-excursion (skip-chars-forward " \11") (let (...) (if begin ... ...))))) (org-footnote-action)) ((and (eq type 'planning) (org-in-regexp org-ts-regexp-both nil t)) (org-follow-timestamp-link)) ((and (eq type 'clock) value (>= (point) (org-element-property :begin value)) (<= (point) (org-element-property :end value))) (org-follow-timestamp-link)) ((eq type 'src-block) (org-babel-open-src-block-result)) ((>= (point) (save-excursion (goto-char (org-element-property :end context)) (skip-chars-backward " \11") (point))) (user-error "No link found")) ((eq type 'inline-src-block) (org-babel-open-src-block-result)) ((eq type 'timestamp) (org-follow-timestamp-link)) ((eq type 'link) (org-link-open context arg)) ((memq type '(citation citation-reference)) (org-cite-follow context arg)) (t (user-error "No link found"))))
  (if (run-hook-with-args-until-success 'org-open-at-point-functions) nil (let* ((context (org-element-lineage (org-element-context) '(citation citation-reference clock comment comment-block footnote-definition footnote-reference headline inline-src-block inlinetask keyword link node-property planning src-block timestamp) t)) (type (org-element-type context)) (value (org-element-property :value context))) (cond ((not type) (user-error "No link found")) ((memq type '(comment comment-block node-property keyword)) (call-interactively #'org-open-at-point-global)) ((memq type '(headline inlinetask)) (org-match-line org-complex-heading-regexp) (let ((tags-beg (match-beginning 5)) (tags-end (match-end 5))) (if (and tags-beg (>= ... tags-beg) (< ... tags-end)) (org-tags-view arg (save-excursion ...)) (let* (...) (if ... ... nil))))) ((or (eq type 'footnote-reference) (and (eq type 'footnote-definition) (save-excursion (skip-chars-forward " \11") (let ... ...)))) (org-footnote-action)) ((and (eq type 'planning) (org-in-regexp org-ts-regexp-both nil t)) (org-follow-timestamp-link)) ((and (eq type 'clock) value (>= (point) (org-element-property :begin value)) (<= (point) (org-element-property :end value))) (org-follow-timestamp-link)) ((eq type 'src-block) (org-babel-open-src-block-result)) ((>= (point) (save-excursion (goto-char (org-element-property :end context)) (skip-chars-backward " \11") (point))) (user-error "No link found")) ((eq type 'inline-src-block) (org-babel-open-src-block-result)) ((eq type 'timestamp) (org-follow-timestamp-link)) ((eq type 'link) (org-link-open context arg)) ((memq type '(citation citation-reference)) (org-cite-follow context arg)) (t (user-error "No link found")))))
  org-open-at-point(nil)
  funcall-interactively(org-open-at-point nil)
  call-interactively(org-open-at-point nil nil)
  command-execute(org-open-at-point)

I note that in the "org-open-file" function in "org.el" there are the lines:

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

& in the case that I've shown, the check on existence of the file is not done.  If I change things so that existence of the tile is checked, then the error can be avoided and the warning message is exhibited.

Function "org-docview-open" calls "org-open-file", but the backtrace doesn't seem to show that.

I had the initial link error occur because I changed the location of the file so that the files were in sub-directories labelled by year.

Emacs  : GNU Emacs 27.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95))
 of 2020-08-12
Package: Org mode version 9.5.2 (9.5.2-gfbff08 @ /Users/alanwehmann/.emacs.d/elpa/org-9.5.2/)

current state:
==============
(setq
 org-src-mode-hook '(org-src-babel-configure-edit-buffer
		     org-src-mode-configure-edit-buffer)
 org-link-shell-confirm-function 'yes-or-no-p
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-modules '(ol-bbdb ol-bibtex ol-docview ol-eww ol-gnus ol-info ol-irc ol-mhe
	       ol-rmail ol-w3m ol-vm)
 org-mode-hook '(#[0 "\300\301\302\303\304$\207"
		   [add-hook change-major-mode-hook org-show-all append local] 5]
		 #[0 "\300\301\302\303\304$\207"
		   [add-hook change-major-mode-hook org-babel-show-result-all
		    append local]
		   5]
		 org-babel-result-hide-spec org-babel-hide-all-hashes)
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-bibtex-headline-format-function #[257 "\300\x01\236A\207" [:title] 3 "\n\n(fn ENTRY)"]
 org-babel-pre-tangle-hook '(save-buffer)
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe
		      org-babel-header-arg-expand)
 org-agenda-loop-over-headlines-in-active-region nil
 org-src-lang-modes '(("redis" . redis) ("php" . php) ("arduino" . arduino)
		      ("C" . c) ("C++" . c++) ("asymptote" . asy) ("bash" . sh)
		      ("beamer" . latex) ("calc" . fundamental) ("cpp" . c++)
		      ("ditaa" . artist) ("dot" . fundamental)
		      ("elisp" . emacs-lisp) ("ocaml" . tuareg)
		      ("screen" . shell-script) ("shell" . sh) ("sqlite" . sql))
 org-catch-invisible-edits 'show-and-error
 org-occur-hook '(org-first-headline-recenter)
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers
		  org-cycle-show-empty-lines
		  org-optimize-window-after-visibility-change)
 org-speed-command-hook '(org-speed-command-activate
			  org-babel-speed-command-activate)
 org-export-before-parsing-hook '(org-attach-expand-links)
 org-confirm-shell-link-function 'yes-or-no-p
 org-link-parameters '(("attachment" :follow org-attach-follow :complete
			org-attach-complete-link)
		       ("id" :follow org-id-open)
		       ("vm-imap" :follow org-vm-imap-open)
		       ("vm" :follow org-vm-open :store org-vm-store-link)
		       ("w3m" :store org-w3m-store-link)
		       ("rmail" :follow org-rmail-open :store org-rmail-store-link)
		       ("mhe" :follow org-mhe-open :store org-mhe-store-link)
		       ("irc" :follow org-irc-visit :store org-irc-store-link
			:export org-irc-export)
		       ("info" :follow org-info-open :export org-info-export :store
			org-info-store-link)
		       ("gnus" :follow org-gnus-open :store org-gnus-store-link)
		       ("eww" :follow org-eww-open :store org-eww-store-link)
		       ("docview" :follow org-docview-open :export
			org-docview-export :store org-docview-store-link)
		       ("bibtex" :follow org-bibtex-open :store
			org-bibtex-store-link)
		       ("bbdb" :follow org-bbdb-open :export org-bbdb-export
			:complete org-bbdb-complete-link :store org-bbdb-store-link)
		       ("bookmark-other-win" :follow bookmark-jump-other-window
			:export nil)
		       ("bookmark" :follow bookmark-jump :export nil) ("file+sys")
		       ("file+emacs") ("shell" :follow org-link--open-shell)
		       ("news" :follow
			#[514 "\301\300\302\x04Q\x02\"\207" ["news" browse-url ":"] 6
			  "\n\n(fn URL ARG)"]
			)
		       ("mailto" :follow
			#[514 "\301\300\302\x04Q\x02\"\207" ["mailto" browse-url ":"] 6
			  "\n\n(fn URL ARG)"]
			)
		       ("https" :follow
			#[514 "\301\300\302\x04Q\x02\"\207" ["https" browse-url ":"] 6
			  "\n\n(fn URL ARG)"]
			)
		       ("http" :follow
			#[514 "\301\300\302\x04Q\x02\"\207" ["http" browse-url ":"] 6
			  "\n\n(fn URL ARG)"]
			)
		       ("ftp" :follow
			#[514 "\301\300\302\x04Q\x02\"\207" ["ftp" browse-url ":"] 6
			  "\n\n(fn URL ARG)"]
			)
		       ("help" :follow org-link--open-help :store
			org-link--store-help)
		       ("file" :complete org-link-complete-file)
		       ("elisp" :follow org-link--open-elisp))
 org-link-elisp-confirm-function 'yes-or-no-p
 outline-minor-mode-prefix "\x03\x0f"
 org-table-copy-increment nil
 )
-- 
Alan Wehmann
Alan.Wehmann@gmail.com



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

end of thread, other threads:[~2022-07-11  5:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-15 14:49 link error when file missing Alan Wehmann
2022-04-16 12:25 ` Ihor Radchenko
     [not found]   ` <EC42A7CB-CEB6-4195-96DE-5C252CE1A29C@gmail.com>
     [not found]     ` <874k25iax8.fsf@localhost>
2022-07-11  5:01       ` [PATCH] " Ihor Radchenko

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