kaushalmodi / ox-hugo

A carefully crafted Org exporter back-end for Hugo
https://ox-hugo.scripter.co
GNU General Public License v3.0
882 stars 132 forks source link

org-element--cache warning upon exporting #468

Closed erganemic closed 2 years ago

erganemic commented 3 years ago

I posted this bug to the orgmode mailing list first; the response can be found here, which details the cause and solution to this issue much better than I can.

Actual Behavior

ox-hugo produces Warning (emacs): org-element--cache: Unregistered buffer modifications detected. when exporting to a file, breaking org-element-cache.

Expected Behavior

Graceful handling of caching behavior.

How to Reproduce the Issue

$ emacs -Q -l ~/.emacs.d/straight/repos/straight.el/bootstrap.el

Then M-x eval buffer on the following buffer:

(straight-use-package 'org)
(straight-use-package 'ox-hugo)
(with-eval-after-load 'ox
  (require 'backtrace) ;;org-hugo-export-wim-to-md calls org-element--cache-sync, which uses backtrace-get-frames, which isn't autoloaded
  (require 'ox-hugo))

I then navigate to the following org-mode buffer, do C-u M-x org-reload, and do C-c C-e H A to try and export it using ox-hugo.

Example Org File

+hugo_base_dir: ~

Generated Markdown File or Error

The file is generated successfully, although it produces a warning; since I reloaded org without the compiled files, the resulting backtrace is very long, but can be found at the link above.

Ox-Hugo Debug Informat

Debug Info # Debug information for `ox-hugo` ## Emacs Version GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.27, cairo version 1.17.4) of 2021-03-26 ## Org Version Org mode version 9.5 (9.5-g859984 @ /home/john/.emacs.d/straight/build/org/) ## Hugo Version hugo v0.88.1+extended linux/amd64 BuildDate=unknown ### Org `load-path` shadows **Warning**: Possible mixed installation of Org /home/john/.emacs.d/straight/build/org/ox-html hides /usr/share/emacs/27.2/lisp/org/ox-html /home/john/.emacs.d/straight/build/org/org-duration hides /usr/share/emacs/27.2/lisp/org/org-duration /home/john/.emacs.d/straight/build/org/ob-fortran hides /usr/share/emacs/27.2/lisp/org/ob-fortran /home/john/.emacs.d/straight/build/org/ol-eshell hides /usr/share/emacs/27.2/lisp/org/ol-eshell /home/john/.emacs.d/straight/build/org-contrib/ob-abc hides /usr/share/emacs/27.2/lisp/org/ob-abc /home/john/.emacs.d/straight/build/org/ol-gnus hides /usr/share/emacs/27.2/lisp/org/ol-gnus /home/john/.emacs.d/straight/build/org/ox-texinfo hides /usr/share/emacs/27.2/lisp/org/ox-texinfo /home/john/.emacs.d/straight/build/org/ol-bbdb hides /usr/share/emacs/27.2/lisp/org/ol-bbdb /home/john/.emacs.d/straight/build/org/org-id hides /usr/share/emacs/27.2/lisp/org/org-id /home/john/.emacs.d/straight/build/org/org-ctags hides /usr/share/emacs/27.2/lisp/org/org-ctags /home/john/.emacs.d/straight/build/org/ob-plantuml hides /usr/share/emacs/27.2/lisp/org/ob-plantuml /home/john/.emacs.d/straight/build/org/ol-bibtex hides /usr/share/emacs/27.2/lisp/org/ol-bibtex /home/john/.emacs.d/straight/build/org/org-macro hides /usr/share/emacs/27.2/lisp/org/org-macro /home/john/.emacs.d/straight/build/org/ob-dot hides /usr/share/emacs/27.2/lisp/org/ob-dot /home/john/.emacs.d/straight/build/org/org-feed hides /usr/share/emacs/27.2/lisp/org/org-feed /home/john/.emacs.d/straight/build/org/org-lint hides /usr/share/emacs/27.2/lisp/org/org-lint /home/john/.emacs.d/straight/build/org/org-protocol hides /usr/share/emacs/27.2/lisp/org/org-protocol /home/john/.emacs.d/straight/build/org/ol-w3m hides /usr/share/emacs/27.2/lisp/org/ol-w3m /home/john/.emacs.d/straight/build/org/ob-ruby hides /usr/share/emacs/27.2/lisp/org/ob-ruby /home/john/.emacs.d/straight/build/org/org-indent hides /usr/share/emacs/27.2/lisp/org/org-indent /home/john/.emacs.d/straight/build/org/org-datetree hides /usr/share/emacs/27.2/lisp/org/org-datetree /home/john/.emacs.d/straight/build/org/ob-R hides /usr/share/emacs/27.2/lisp/org/ob-R /home/john/.emacs.d/straight/build/org/ob-tangle hides /usr/share/emacs/27.2/lisp/org/ob-tangle /home/john/.emacs.d/straight/build/org/org-mouse hides /usr/share/emacs/27.2/lisp/org/org-mouse /home/john/.emacs.d/straight/build/org-contrib/ob-ledger hides /usr/share/emacs/27.2/lisp/org/ob-ledger /home/john/.emacs.d/straight/build/org/ox-man hides /usr/share/emacs/27.2/lisp/org/ox-man /home/john/.emacs.d/straight/build/org-contrib/ob-stan hides /usr/share/emacs/27.2/lisp/org/ob-stan /home/john/.emacs.d/straight/build/org/org-pcomplete hides /usr/share/emacs/27.2/lisp/org/org-pcomplete /home/john/.emacs.d/straight/build/org/ob-maxima hides /usr/share/emacs/27.2/lisp/org/ob-maxima /home/john/.emacs.d/straight/build/org/ob-awk hides /usr/share/emacs/27.2/lisp/org/ob-awk /home/john/.emacs.d/straight/build/org/ox-odt hides /usr/share/emacs/27.2/lisp/org/ox-odt /home/john/.emacs.d/straight/build/org/ox-org hides /usr/share/emacs/27.2/lisp/org/ox-org /home/john/.emacs.d/straight/build/org/ol hides /usr/share/emacs/27.2/lisp/org/ol /home/john/.emacs.d/straight/build/org/ob-org hides /usr/share/emacs/27.2/lisp/org/ob-org /home/john/.emacs.d/straight/build/org/org-archive hides /usr/share/emacs/27.2/lisp/org/org-archive /home/john/.emacs.d/straight/build/org/ob-comint hides /usr/share/emacs/27.2/lisp/org/ob-comint /home/john/.emacs.d/straight/build/org/ob-lob hides /usr/share/emacs/27.2/lisp/org/ob-lob /home/john/.emacs.d/straight/build/org/ob-python hides /usr/share/emacs/27.2/lisp/org/ob-python /home/john/.emacs.d/straight/build/org/org-attach hides /usr/share/emacs/27.2/lisp/org/org-attach /home/john/.emacs.d/straight/build/org/ob-lisp hides /usr/share/emacs/27.2/lisp/org/ob-lisp /home/john/.emacs.d/straight/build/org/ob-perl hides /usr/share/emacs/27.2/lisp/org/ob-perl /home/john/.emacs.d/straight/build/org/ob-haskell hides /usr/share/emacs/27.2/lisp/org/ob-haskell /home/john/.emacs.d/straight/build/org/ox-ascii hides /usr/share/emacs/27.2/lisp/org/ox-ascii /home/john/.emacs.d/straight/build/org/ob-js hides /usr/share/emacs/27.2/lisp/org/ob-js /home/john/.emacs.d/straight/build/org-contrib/ob-shen hides /usr/share/emacs/27.2/lisp/org/ob-shen /home/john/.emacs.d/straight/build/org/org-element hides /usr/share/emacs/27.2/lisp/org/org-element /home/john/.emacs.d/straight/build/org/ob-sqlite hides /usr/share/emacs/27.2/lisp/org/ob-sqlite /home/john/.emacs.d/straight/build/org-contrib/ob-J hides /usr/share/emacs/27.2/lisp/org/ob-J /home/john/.emacs.d/straight/build/org/ol-mhe hides /usr/share/emacs/27.2/lisp/org/ol-mhe /home/john/.emacs.d/straight/build/org-contrib/ob-mscgen hides /usr/share/emacs/27.2/lisp/org/ob-mscgen /home/john/.emacs.d/straight/build/org/org-mobile hides /usr/share/emacs/27.2/lisp/org/org-mobile /home/john/.emacs.d/straight/build/org/ox-publish hides /usr/share/emacs/27.2/lisp/org/ox-publish /home/john/.emacs.d/straight/build/org/org-entities hides /usr/share/emacs/27.2/lisp/org/org-entities /home/john/.emacs.d/straight/build/org/org-faces hides /usr/share/emacs/27.2/lisp/org/org-faces /home/john/.emacs.d/straight/build/org/org-clock hides /usr/share/emacs/27.2/lisp/org/org-clock /home/john/.emacs.d/straight/build/org/org-macs hides /usr/share/emacs/27.2/lisp/org/org-macs /home/john/.emacs.d/straight/build/org/org-plot hides /usr/share/emacs/27.2/lisp/org/org-plot /home/john/.emacs.d/straight/build/org/org-version hides /usr/share/emacs/27.2/lisp/org/org-version /home/john/.emacs.d/straight/build/org/ox-icalendar hides /usr/share/emacs/27.2/lisp/org/ox-icalendar /home/john/.emacs.d/straight/build/org/ob-octave hides /usr/share/emacs/27.2/lisp/org/ob-octave /home/john/.emacs.d/straight/build/org/org-habit hides /usr/share/emacs/27.2/lisp/org/org-habit /home/john/.emacs.d/straight/build/org/org-refile hides /usr/share/emacs/27.2/lisp/org/org-refile /home/john/.emacs.d/straight/build/org/org-capture hides /usr/share/emacs/27.2/lisp/org/org-capture /home/john/.emacs.d/straight/build/org-contrib/ob-io hides /usr/share/emacs/27.2/lisp/org/ob-io /home/john/.emacs.d/straight/build/org-contrib/ob-asymptote hides /usr/share/emacs/27.2/lisp/org/ob-asymptote /home/john/.emacs.d/straight/build/org/ol-eww hides /usr/share/emacs/27.2/lisp/org/ol-eww /home/john/.emacs.d/straight/build/org/ob-calc hides /usr/share/emacs/27.2/lisp/org/ob-calc /home/john/.emacs.d/straight/build/org/ob-css hides /usr/share/emacs/27.2/lisp/org/ob-css /home/john/.emacs.d/straight/build/org/org-keys hides /usr/share/emacs/27.2/lisp/org/org-keys /home/john/.emacs.d/straight/build/org/ox hides /usr/share/emacs/27.2/lisp/org/ox /home/john/.emacs.d/straight/build/org/org-timer hides /usr/share/emacs/27.2/lisp/org/org-timer /home/john/.emacs.d/straight/build/org/ob-ocaml hides /usr/share/emacs/27.2/lisp/org/ob-ocaml /home/john/.emacs.d/straight/build/org/ob-screen hides /usr/share/emacs/27.2/lisp/org/ob-screen /home/john/.emacs.d/straight/build/org/ob-clojure hides /usr/share/emacs/27.2/lisp/org/ob-clojure /home/john/.emacs.d/straight/build/org/ob-lilypond hides /usr/share/emacs/27.2/lisp/org/ob-lilypond /home/john/.emacs.d/straight/build/org/ob-lua hides /usr/share/emacs/27.2/lisp/org/ob-lua /home/john/.emacs.d/straight/build/org/ob-latex hides /usr/share/emacs/27.2/lisp/org/ob-latex /home/john/.emacs.d/straight/build/org/ol-irc hides /usr/share/emacs/27.2/lisp/org/ol-irc /home/john/.emacs.d/straight/build/org/ox-beamer hides /usr/share/emacs/27.2/lisp/org/ox-beamer /home/john/.emacs.d/straight/build/org/org-compat hides /usr/share/emacs/27.2/lisp/org/org-compat /home/john/.emacs.d/straight/build/org/ob-sed hides /usr/share/emacs/27.2/lisp/org/ob-sed /home/john/.emacs.d/straight/build/org/ox-latex hides /usr/share/emacs/27.2/lisp/org/ox-latex /home/john/.emacs.d/straight/build/org-contrib/ob-vala hides /usr/share/emacs/27.2/lisp/org/ob-vala /home/john/.emacs.d/straight/build/org/org hides /usr/share/emacs/27.2/lisp/org/org /home/john/.emacs.d/straight/build/org/org-footnote hides /usr/share/emacs/27.2/lisp/org/org-footnote /home/john/.emacs.d/straight/build/org/ob-groovy hides /usr/share/emacs/27.2/lisp/org/ob-groovy /home/john/.emacs.d/straight/build/org/ob-java hides /usr/share/emacs/27.2/lisp/org/ob-java /home/john/.emacs.d/straight/build/org/ob-scheme hides /usr/share/emacs/27.2/lisp/org/ob-scheme /home/john/.emacs.d/straight/build/org-contrib/ob-ebnf hides /usr/share/emacs/27.2/lisp/org/ob-ebnf /home/john/.emacs.d/straight/build/org/org-goto hides /usr/share/emacs/27.2/lisp/org/org-goto /home/john/.emacs.d/straight/build/org/org-num hides /usr/share/emacs/27.2/lisp/org/org-num /home/john/.emacs.d/straight/build/org-contrib/ob-picolisp hides /usr/share/emacs/27.2/lisp/org/ob-picolisp /home/john/.emacs.d/straight/build/org/org-src hides /usr/share/emacs/27.2/lisp/org/org-src /home/john/.emacs.d/straight/build/org/ob-shell hides /usr/share/emacs/27.2/lisp/org/ob-shell /home/john/.emacs.d/straight/build/org/ob-processing hides /usr/share/emacs/27.2/lisp/org/ob-processing /home/john/.emacs.d/straight/build/org/ob-core hides /usr/share/emacs/27.2/lisp/org/ob-core /home/john/.emacs.d/straight/build/org/org-tempo hides /usr/share/emacs/27.2/lisp/org/org-tempo /home/john/.emacs.d/straight/build/org/ob-table hides /usr/share/emacs/27.2/lisp/org/ob-table /home/john/.emacs.d/straight/build/org/ox-md hides /usr/share/emacs/27.2/lisp/org/ox-md /home/john/.emacs.d/straight/build/org-contrib/ob-hledger hides /usr/share/emacs/27.2/lisp/org/ob-hledger /home/john/.emacs.d/straight/build/org/ob-exp hides /usr/share/emacs/27.2/lisp/org/ob-exp /home/john/.emacs.d/straight/build/org/ob-ref hides /usr/share/emacs/27.2/lisp/org/ob-ref /home/john/.emacs.d/straight/build/org/ob-eshell hides /usr/share/emacs/27.2/lisp/org/ob-eshell /home/john/.emacs.d/straight/build/org/ol-docview hides /usr/share/emacs/27.2/lisp/org/ol-docview /home/john/.emacs.d/straight/build/org/org-attach-git hides /usr/share/emacs/27.2/lisp/org/org-attach-git /home/john/.emacs.d/straight/build/org/org-install hides /usr/share/emacs/27.2/lisp/org/org-install /home/john/.emacs.d/straight/build/org/org-inlinetask hides /usr/share/emacs/27.2/lisp/org/org-inlinetask /home/john/.emacs.d/straight/build/org/org-list hides /usr/share/emacs/27.2/lisp/org/org-list /home/john/.emacs.d/straight/build/org/ob-makefile hides /usr/share/emacs/27.2/lisp/org/ob-makefile /home/john/.emacs.d/straight/build/org/ob-sql hides /usr/share/emacs/27.2/lisp/org/ob-sql /home/john/.emacs.d/straight/build/org/ob-matlab hides /usr/share/emacs/27.2/lisp/org/ob-matlab /home/john/.emacs.d/straight/build/org/ol-info hides /usr/share/emacs/27.2/lisp/org/ol-info /home/john/.emacs.d/straight/build/org/ob-C hides /usr/share/emacs/27.2/lisp/org/ob-C /home/john/.emacs.d/straight/build/org/ol-rmail hides /usr/share/emacs/27.2/lisp/org/ol-rmail /home/john/.emacs.d/straight/build/org/ob hides /usr/share/emacs/27.2/lisp/org/ob /home/john/.emacs.d/straight/build/org/org-agenda hides /usr/share/emacs/27.2/lisp/org/org-agenda /home/john/.emacs.d/straight/build/org/org-colview hides /usr/share/emacs/27.2/lisp/org/org-colview /home/john/.emacs.d/straight/build/org/ob-gnuplot hides /usr/share/emacs/27.2/lisp/org/ob-gnuplot /home/john/.emacs.d/straight/build/org/org-table hides /usr/share/emacs/27.2/lisp/org/org-table /home/john/.emacs.d/straight/build/org/ob-forth hides /usr/share/emacs/27.2/lisp/org/ob-forth /home/john/.emacs.d/straight/build/org/ob-eval hides /usr/share/emacs/27.2/lisp/org/ob-eval /home/john/.emacs.d/straight/build/org/ob-ditaa hides /usr/share/emacs/27.2/lisp/org/ob-ditaa /home/john/.emacs.d/straight/build/org-contrib/ob-coq hides /usr/share/emacs/27.2/lisp/org/ob-coq /home/john/.emacs.d/straight/build/org/org-loaddefs hides /usr/share/emacs/27.2/lisp/org/org-loaddefs /home/john/.emacs.d/straight/build/org/ob-emacs-lisp hides /usr/share/emacs/27.2/lisp/org/ob-emacs-lisp /home/john/.emacs.d/straight/build/org/ob-sass hides /usr/share/emacs/27.2/lisp/org/ob-sass /home/john/.emacs.d/straight/build/org/org-crypt hides /usr/share/emacs/27.2/lisp/org/org-crypt Study the output of `M-x list-load-path-shadows`. ## `ox-hugo` defcustoms
org-hugo-section "posts"
org-hugo-use-code-for-kbd nil
org-hugo-preserve-filling t
org-hugo-delete-trailing-ws t
org-hugo-prefer-hyphen-in-tags t
org-hugo-allow-spaces-in-tags t
org-hugo-tag-processing-functions (org-hugo–tag-processing-fn-replace-with-spaces-maybe org-hugo–tag-processing-fn-replace-with-hyphens-maybe)
org-hugo-auto-set-lastmod nil
org-hugo-export-with-toc nil
org-hugo-export-with-section-numbers nil
org-hugo-front-matter-format "toml"
org-hugo-default-static-subdirectory-for-externals "ox-hugo"
org-hugo-external-file-extensions-allowed-for-copying ("jpg" "jpeg" "tiff" "png" "svg" "gif" "mp4" "pdf" "odt" "doc" "ppt" "xls" "docx" "pptx" "xlsx")
org-hugo-date-format "%Y-%m-%dT%T%z"
org-hugo-paired-shortcodes ""
org-hugo-langs-no-descr-in-code-fences nil
org-hugo-suppress-lastmod-period 0.0
org-hugo-front-matter-format "toml"
kaushalmodi commented 3 years ago

Thanks for reporting this! I will look into this suggested fix in the mailing list:

The fix on ox-hugo side can be made similarly to the new implementation of org-export--generate-copy-script - ox-hugo needs to manually reset the cache after silent changes in temporary Org buffer.

kaushalmodi commented 2 years ago

Thanks to Ihor Radchenko, this is now fixed in Org main branch: https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=4426d8009f14bcb48e91ce5517af3af4f762ab22

Ref: https://lists.gnu.org/r/emacs-orgmode/2021-12/msg00436.html