emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Problem with docview
@ 2013-05-10 17:25 Marvin Doyley
  2013-05-10 18:58 ` Nick Dokos
  0 siblings, 1 reply; 10+ messages in thread
From: Marvin Doyley @ 2013-05-10 17:25 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

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

I am trying to link to a specific page in a pdf file using org-docview.
 For example, I have a org file with the following header

** [[docview:~/Desktop/2013_test.pdf::3][Digital modulation notes]]

However, when I double click on the link I get the following error

Invalid image file name `nil'


Does anybody know to fix this problem ?

Thanks
M

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

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

* Re: Problem with docview
  2013-05-10 17:25 Marvin Doyley
@ 2013-05-10 18:58 ` Nick Dokos
  0 siblings, 0 replies; 10+ messages in thread
From: Nick Dokos @ 2013-05-10 18:58 UTC (permalink / raw)
  To: emacs-orgmode

Marvin Doyley <marvinpas@gmail.com> writes:

> I am trying to link to a specific page in a pdf file using
> org-docview.  For example, I have a org file with the following header
>
> ** [[docview:~/Desktop/2013_test.pdf::3][Digital modulation notes]]
>
> However, when I double click on the link I get the following error
>
> Invalid image file name `nil'
>
> Does anybody know to fix this problem ?
>

Seems to work here[fn:1]. One thing that seems slightly broken is that
if the file is huge and docview takes a while to convert it, then the
goto-page part does not seem to be effective:

,----
| (defun org-docview-open (link)
|   (when (string-match "\\(.*\\)::\\([0-9]+\\)$"  link)
|     (let* ((path (match-string 1 link))
| 	   (page (string-to-number (match-string 2 link))))
|       (org-open-file path 1) ;; let org-mode open the file (in-emacs = 1)
|       ;; to ensure org-link-frame-setup is respected
|       (doc-view-goto-page page)
|       )))
`----

It stays on p.1 in that case. It works OK for small files.

Can you turn on debug-on-error and post the backtrace?

Footnotes:

[fn:1] Org-mode version 8.0.2 (release_8.0.2-72-gccfe83 @ /home/nick/elisp/org-mode/lisp/)

-- 
Nick

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

* Re: Problem with docview
@ 2013-05-11 11:12 Marvin Doyley
  2013-05-11 14:05 ` Nick Dokos
  0 siblings, 1 reply; 10+ messages in thread
From: Marvin Doyley @ 2013-05-11 11:12 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

Hi Nick,

I tried this, but no luck. I am using emacs 24.3.1 on the mac. Doc-view is included included in this version of emacs, will this conflict with org-docview ?

cheers
M

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

* Re: Problem with docview
  2013-05-11 11:12 Problem with docview Marvin Doyley
@ 2013-05-11 14:05 ` Nick Dokos
  0 siblings, 0 replies; 10+ messages in thread
From: Nick Dokos @ 2013-05-11 14:05 UTC (permalink / raw)
  To: emacs-orgmode

Marvin Doyley <m.doyley@rochester.edu> writes:


> I tried this, but no luck. I am using emacs 24.3.1 on the
> mac. Doc-view is included included in this version of emacs, will this
> conflict with org-docview ?
>

Not sure what "this" is: What exactly did you try?

In any case, org-docview is the implementation of links on top of doc-view, so
there is no conflict (iow, org-docview *requires* doc-view).

-- 
Nick

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

* Re: Problem with docview
@ 2013-05-11 18:56 Marvin Doyley
  2013-05-11 19:23 ` Nick Dokos
  0 siblings, 1 reply; 10+ messages in thread
From: Marvin Doyley @ 2013-05-11 18:56 UTC (permalink / raw)
  To: ndokos; +Cc: emacs-orgmode@gnu.org

Hi Nick,

I tried what you suggested, but the problem still persists.
Here the backtrace

Debugger entered--Lisp error: (error "Invalid image file name `nil'")
  signal(error ("Invalid image file name `nil'"))
  error("Invalid image file name `%s'" nil)
  image-type(nil png nil)
  create-image(nil png nil :pointer arrow)
  apply(create-image nil png nil (:pointer arrow))
  (let ((image (apply (quote create-image) file (quote png) nil args))) (setq doc-view-current-image image) (insert-image image (concat "[" file "]") nil doc-view-current-slice))
  doc-view-insert-image(nil :pointer arrow)
  (let ((beg (point))) (doc-view-insert-image (nth (1- page) doc-view-current-files) :pointer (quote arrow)) (put-text-property beg (point) (quote help-echo) doc-view-current-info))
  (let ((len (length doc-view-current-files))) (if (< page 1) (setq page 1) (if (> page len) (progn (setq page len)))) (setq doc-view-current-page page doc-view-current-info (concat (propertize (format "Page %d of %d." doc-view-current-page len) (quote face) (quote bold)) (if doc-view-current-converter-process " (still converting...)\n" "\n") (if (and doc-view-current-search-matches (assq doc-view-current-page doc-view-current-search-matches)) (progn (concat (propertize "Search matches:\n" (quote face) (quote bold)) (let (...) (progn ...) contexts)))))) (setq inhibit-read-only t) (erase-buffer) (let ((beg (point))) (doc-view-insert-image (nth (1- page) doc-view-current-files) :pointer (quote arrow)) (put-text-property beg (point) (quote help-echo) doc-view-current-info)) (insert "\n" doc-view-current-info) (goto-char (point-min)) (forward-char) (setq inhibit-read-only nil))
  doc-view-goto-page(1)
  org-docview-open(#("540.full.pdf::1" 0 15 (org-attr nil)))
  org-open-at-point()
  org-open-at-mouse((mouse-2 (#<window 3 on *Backtrace*> 33 (58 . 15) 250980086 nil 33 (5 . 0) nil (3 . 15) (11 . 23))))
  call-interactively(org-open-at-mouse nil nil)

cheers
M

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

* Re: Problem with docview
  2013-05-11 18:56 Marvin Doyley
@ 2013-05-11 19:23 ` Nick Dokos
  0 siblings, 0 replies; 10+ messages in thread
From: Nick Dokos @ 2013-05-11 19:23 UTC (permalink / raw)
  To: emacs-orgmode

Marvin Doyley <m.doyley@rochester.edu> writes:


> Debugger entered--Lisp error: (error "Invalid image file name `nil'")
>   signal(error ("Invalid image file name `nil'"))
>   error("Invalid image file name `%s'" nil)
>   image-type(nil png nil)
>   create-image(nil png nil :pointer arrow)
>   apply(create-image nil png nil (:pointer arrow))
>   (let ((image (apply (quote create-image) file (quote png) nil args))) (setq doc-view-current-image image) (insert-image image (concat "[" file "]") nil doc-view-current-slice))
>   doc-view-insert-image(nil :pointer arrow)
>   (let ((beg (point))) (doc-view-insert-image (nth (1- page) doc-view-current-files) :pointer (quote arrow)) (put-text-property beg (point) (quote help-echo) doc-view-current-info))
>   (let ((len (length doc-view-current-files))) (if (< page 1) (setq
> page 1) (if (> page len) (progn (setq page len)))) (setq
> doc-view-current-page page doc-view-current-info (concat (propertize
> (format "Page %d of %d." doc-view-current-page len) (quote face)
> (quote bold)) (if doc-view-current-converter-process " (still
> converting...)\n" "\n") (if (and doc-view-current-search-matches (assq
> doc-view-current-page doc-view-current-search-matches)) (progn (concat
> (propertize "Search matches:\n" (quote face) (quote bold)) (let (...)
> (progn ...) contexts)))))) (setq inhibit-read-only t) (erase-buffer)
> (let ((beg (point))) (doc-view-insert-image (nth (1- page)
> doc-view-current-files) :pointer (quote arrow)) (put-text-property beg
> (point) (quote help-echo) doc-view-current-info)) (insert "\n"
> doc-view-current-info) (goto-char (point-min)) (forward-char) (setq
> inhibit-read-only nil))
>   doc-view-goto-page(1)

You seem to have a buggy version of doc-view.el: doc-view-current-files is
not used by doc-view-goto-page in the version that I have, which is the
version bundled with

   GNU Emacs 24.3.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.10)
   of 2013-04-09

In my version of doc-view-goto-page, there is a comment that says:

,----
|     ;; Update the buffer
|     ;; We used to find the file name from doc-view-current-files but
|     ;; that's not right if the pages are not generated sequentially
|     ;; or if the page isn't in doc-view-current-files yet.
`----

which leads me to believe that you will need to upgrade your version
of doc-view (or perhaps your emacs).

-- 
Nick

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

* Re: Problem with docview
@ 2013-05-11 20:25 Marvin Doyley
  2013-05-11 22:25 ` Nick Dokos
  0 siblings, 1 reply; 10+ messages in thread
From: Marvin Doyley @ 2013-05-11 20:25 UTC (permalink / raw)
  To: ndokos; +Cc: emacs-orgmode@gnu.org

Hi Nick,

I just updated to a newer version of emacs, which now solved the problem.
The only remaining issue is that I have to manually switch to doc-view-mode to view the pdf. Is there away to do this automatically ?

Thanks
M 

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

* Re: Problem with docview
  2013-05-11 20:25 Marvin Doyley
@ 2013-05-11 22:25 ` Nick Dokos
  2013-05-11 22:32   ` Nick Dokos
  0 siblings, 1 reply; 10+ messages in thread
From: Nick Dokos @ 2013-05-11 22:25 UTC (permalink / raw)
  To: emacs-orgmode

Marvin Doyley <m.doyley@rochester.edu> writes:

> I just updated to a newer version of emacs, which now solved the
> problem.  The only remaining issue is that I have to manually switch
> to doc-view-mode to view the pdf. Is there away to do this
> automatically ?
>

AFAIK, this happens automagically (but I don't know what magic is used:
it does not seem to be hooks however, which was my first guess). Do you
get the raw PDF in Fundamental mode? Does C-c C-c do anything?

-- 
Nick

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

* Re: Problem with docview
  2013-05-11 22:25 ` Nick Dokos
@ 2013-05-11 22:32   ` Nick Dokos
  0 siblings, 0 replies; 10+ messages in thread
From: Nick Dokos @ 2013-05-11 22:32 UTC (permalink / raw)
  To: emacs-orgmode

Nick Dokos <ndokos@gmail.com> writes:

> Marvin Doyley <m.doyley@rochester.edu> writes:
>
>> I just updated to a newer version of emacs, which now solved the
>> problem.  The only remaining issue is that I have to manually switch
>> to doc-view-mode to view the pdf. Is there away to do this
>> automatically ?
>>
>
> AFAIK, this happens automagically (but I don't know what magic is used:
> it does not seem to be hooks however, which was my first guess). Do you
> get the raw PDF in Fundamental mode? Does C-c C-c do anything?

Check your auto-mode-alist: for PDF, the associated function should be
doc-view-mode-maybe.
-- 
Nick

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

* Re: Problem with docview
@ 2013-05-11 23:15 Marvin Doyley
  0 siblings, 0 replies; 10+ messages in thread
From: Marvin Doyley @ 2013-05-11 23:15 UTC (permalink / raw)
  To: ndokos; +Cc: emacs-orgmode@gnu.org

Your suggestion worked. Adding doc-view-mode-maybe to the auto-mode-alist rendered  my pdf automatically.
I really appreciate your help.

Cheers
M

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

end of thread, other threads:[~2013-05-11 23:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-11 11:12 Problem with docview Marvin Doyley
2013-05-11 14:05 ` Nick Dokos
  -- strict thread matches above, loose matches on Subject: below --
2013-05-11 23:15 Marvin Doyley
2013-05-11 20:25 Marvin Doyley
2013-05-11 22:25 ` Nick Dokos
2013-05-11 22:32   ` Nick Dokos
2013-05-11 18:56 Marvin Doyley
2013-05-11 19:23 ` Nick Dokos
2013-05-10 17:25 Marvin Doyley
2013-05-10 18:58 ` Nick Dokos

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