emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] HTML/images zipped?


From: Nick Dokos
Subject: Re: [O] HTML/images zipped?
Date: Fri, 26 Jun 2015 17:51:50 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

John Kitchin <address@hidden> writes:

> I did something like this for org-files:
> https://github.com/jkitchin/jmax/blob/master/ox-archive.el
>

I tried this on some arbitrary org file (not containing any references) and I 
got an error:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  file-name-directory(nil)
  (let* ((temporary-file-directory (file-name-directory (buffer-file-name))) 
(tempname (make-temp-file "extract-bib")) (contents (buffer-string)) (cb 
(current-buffer)) basename texfile bibfile results) (find-file tempname) 
(insert contents) (setq basename (file-name-sans-extension 
(file-name-nondirectory buffer-file-name)) texfile (concat tempname ".tex") 
bibfile (concat tempname ".bib")) (save-excursion (goto-char (point-min)) (if 
(re-search-forward "^bibliography:" (point-max) (quote end)) nil (insert 
(format "\nbibliography:%s" (mapconcat (quote identity) 
reftex-default-bibliography ","))))) (save-buffer) (org-latex-export-to-latex) 
(find-file texfile) (reftex-parse-all) (reftex-create-bibtex-file bibfile) 
(save-buffer) (setq results (buffer-string)) (kill-buffer (concat basename 
".bib")) (kill-buffer (concat basename ".tex")) (kill-buffer basename) 
(delete-file bibfile) (delete-file texfile) (delete-file tempname) 
(switch-to-buffer cb) (if (not (string= "" results)) (progn (save-excursion 
(goto-char (point-max)) (insert "\n\n") (org-insert-heading) (insert (format " 
Bibtex entries\n\n#+BEGIN_SRC text :tangle %s\n%s\n#+END_SRC" (concat 
(file-name-sans-extension ...) ".bib") results))))))
  org-ref-extract-bibtex-entries()
  (let* ((org-file (buffer-name)) (org-file-abs-path (buffer-file-name)) 
(base-name (file-name-sans-extension org-file)) (org-archive (if (string= 
zip-base-name "") (concat base-name "-" (format-time-string "%Y-%m-%d" 
(current-time))) zip-base-name)) (org-archive-zip (concat org-archive ".zip")) 
link-list) (if (file-exists-p org-archive-zip) (progn (delete-file 
org-archive-zip))) (if (file-exists-p org-archive) (progn (delete-directory 
org-archive t))) (make-directory org-archive t) (setq link-list (let 
((parsetree (org-element-parse-buffer)) (counter 0)) (org-element-map parsetree 
(quote link) (function (lambda (link) (let* (... ... ... ... ... ... ... ...) 
(message ...) (cond ... ... ...))))))) (message (format "\n\nlink-list: %s\n\n" 
link-list)) (let ((counter 0)) (defalias (quote ox-mrkup-filter-link) (function 
(lambda (text back-end info) (message "handing link %s: %s\n" counter text) 
(let ((link ...)) (message "  %s replacement is %s\n" counter link) (if (not 
...) (progn ... ...) (setq output ...)) (setq counter (+ counter 1)) output)))) 
(let ((org-export-filter-link-functions (quote (ox-mrkup-filter-link)))) 
(org-org-export-as-org))) (switch-to-buffer "*Org ORG Export*") (insert (format 
"# archived from %s on %s\n" org-file-abs-path (format-time-string "%Y-%m-%d" 
(current-time)))) (org-ref-extract-bibtex-entries) (write-file 
(expand-file-name org-file org-archive)) (shell-command (concat "zip -v -r " 
org-archive-zip " *")) (rename-file org-archive-zip (concat "../" org-archive 
".zip")) (switch-to-buffer org-file) (delete-directory org-archive t) 
org-archive-zip)
  ox-archive-create-zip("foo")
...

I think there is a bug in ox-archive-create-zip:

--8<---------------cut here---------------start------------->8---
    ...
    (switch-to-buffer "*Org ORG Export*")
    (insert (format "# archived from %s on %s\n"
                    org-file-abs-path
                    (format-time-string "%Y-%m-%d" (current-time))))

    ;; add bibliography references if they exist. 
    (org-ref-extract-bibtex-entries)
    ...
--8<---------------cut here---------------end--------------->8---

because the first thing that org-ref-extract-bibtex-entries does is

--8<---------------cut here---------------start------------->8---
  (let* ((temporary-file-directory (file-name-directory (buffer-file-name)))
--8<---------------cut here---------------end--------------->8---

and (buffer-file-name) returns nil on the *Org ORG Export* buffer.
But since you obviously use this code successfully, I wonder why
you don't hit this.

Thanks for any help,
Nick





reply via email to

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