joostkremers / pandoc-mode

An Emacs minor mode for interacting with Pandoc.
https://joostkremers.github.io/pandoc-mode/
177 stars 14 forks source link

Default output settings not being saved #111

Closed tinkerbits closed 2 years ago

tinkerbits commented 2 years ago

Hi,

Never opened a Github issue before so apologies in advance if this is not the right way to report this issue. I'm encountering the following issue on Ubuntu 20.04 using emacs 27.1 and pandoc 2.5

I have a single org file called worknotes.org, and I regularly need to save certain sections of that file to a docx document. This works just fine when I call pandoc-main-hydra/body, configure docx as output format and then run pandoc.

However, I can't for the life of me find out how to make pandoc save this setting so that next time I launch Emacs, and emacs automatically opens worknotes.org and activates pandoc-mode, docx is already set as default output. Whatever I try, pandoc-mode's output format is reset to native when I relaunch emacs.

I've tried following the instructions written here: http://joostkremers.github.io/pandoc-mode/#settings-files

These were my steps:

1) Run pandoc-main-hydra/body to open up pandoc-mode's main menu 2) Go to Output Format > Wordprocessor Formats and then select MS Word (docx). The minibuffer tells me "Output format set to 'docx'" 3) Confirm current settings by going to Main Menu > View Current Settings. The result is:

Current settings:

((read . "org")
 (write . "docx"))

4) Save my settings, by going to Main Menu > Settings files > 'Set current format as default' + 'Save file settings'. 5) Save my worknotes.org file, quit emacs and then restart emacs to see pandoc-mode's output format set back to native.

I've saving settings as project or as global settings, but that made no difference.

In my directory I can see the .worknotes.org.docx.pandoc file (which should be the settings file) and the symlink to it:

lrwxrwxrwx 1 jon jon 26 Jan 11 12:26 .worknotes.org.default.pandoc -> .worknotes.org.docx.pandoc -rw-rw-r-- 1 jon jon 4941 Jan 11 12:26 .worknotes.org.docx.pandoc

There was a .worknotes.org.native.pandoc file which I removed (hoping that would stop pandoc-mode from resetting output format back to native, but no luck.

Not sure if this is a bug or if the mistake is on my end; keen to hear your thoughts.

Jon

joostkremers commented 2 years ago

Not sure if this is a bug or if the mistake is on my end;

Not sure... Everything certainly seems to be in order. Can you check the contents of .worknotes.org.docx.pandoc? Is it what you expect?

I use this functionality myself and I have no problems with it, so it's surprising that it doesn't work for you.

How do you start pandoc-mode in the relevant buffer? (Grasping at straws here, though...)

tinkerbits commented 2 years ago

I'm not sure what I should be looking for in that file. It contains a lot of words between brackets; probably elisp but I don't know my way around elisp unfortunately.

For brevity's sake here's the results of a grep on the terms "docx", "native" and "default" on that file:

~/D/i/deliverability-general   *…  cat .worknotes.org.docx.pandoc | grep docx (reference-docx) (write . "docx")

~/D/i/deliverability-general   *…  cat .worknotes.org.docx.pandoc | grep native ("native_divs") ("native_spans") ("native_divs") ("native_spans")

~/D/i/deliverability-general   *…  cat .worknotes.org.docx.pandoc | grep default (default-image-extension) (defaults)

Let me know if you'd rather see the entire file.

Regarding how pandoc-mode is started in the buffer; I do it manually (M-x pandoc-mode). Though not really because I only do that once; I use desktop-save-mode to store my desktop in between emacs sessions.

joostkremers commented 2 years ago

I found the problem (I think 🙂 ) Note that activating pandoc-mode does not load the default settings file. For that to happen, you need to add a hook:

(add-hook 'pandoc-mode-hook 'pandoc-load-default-settings)

I had actually completely forgotten about this fact myself 😊 , but it's in the documentation, in the section on installation: https://joostkremers.github.io/pandoc-mode/#installation (which is where I just read about it... 😄 )

tinkerbits commented 2 years ago

Joost you absolute legend! I completely read over that bit so this was 100% a PICNIC issue (Problem In Chair Not In Computer). Adding that hook indeed loads the defaults when starting Emacs :)

Thank you!

Jon

joostkremers commented 2 years ago

Oh, I'm glad that was it! I was half worried that you would say you already had this hook set up and it still wasn't working... 😅