joostkremers / pandoc-mode

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

Unable to load default setting, for pandoc-load-default-settings is missing #119

Closed AnabasisXu closed 3 months ago

AnabasisXu commented 3 months ago

Window 10, Emacs 29.2, pandoc-mode: Version: 2.32

I want to set the output format org to common markdown and set the wrap to be preserved, so I save the global file.

The file can be found at D:\HOME\.emacs.d\etc\pandoc-mode\commonmark.pandoc.

The content is also right, read as org, output as common markdown, wrap preserve.

But I could not load it, for M-x there is no pandoc-load-default-settings function.

I also manually eval-buffer the pandoc-mode.el. It did not work.

My setting:

(use-package pandoc-mode
    :straight (pandoc-mode
                         :type git
                         :host github
                         :repo "joostkremers/pandoc-mode")
    :init
    (add-hook 'org-mode-hook 'pandoc-mode)
    (add-hook 'pandoc-mode-hook 'pandoc-load-default-settings)
    )
joostkremers commented 3 months ago

Hi, pandoc-load-default-settings is not an interactive function, so it won't show up with M-x. If you really want to run it by hand, you can do so with M-: (pandoc-load-default-settings) RET, but this should not be necessary.

Two things to keep in mind, though:

AnabasisXu commented 3 months ago

Hi @joostkremers thank you for your prompt reply!

I just want two things to be default:

Is there any quick setting up I can do? I also tried (setq pandoc-set-wrap "preserve"), which did not work.

Thank you again in advance!

joostkremers commented 3 months ago

The tl;dr of it is that you probably just need to rename the file commonmark.pandoc in ~/.emacs.d/etc/pandoc-mode/ to default.pandoc. For some more background:

  • On Window, Setting Files--Setting Global Setting Files will save the global file to ~/.emacs.d/etc/pandoc-mode/. If so, why saving the global file to a place inaccessible for pandoc-mode anyway?

I don't know... I don't use Windows, so I can't test, but it looks like pandoc-data-dir is set to ~/.emacs.d/etc/pandoc-mode/ in your case, because pandoc-save-global-settings-file (the function that's run when you select that menu option), saves the file to pandoc-data-dir.

If that is the case, there's no need to worry about it, pandoc-mode will be able to find the settings file.

  • I could not find the file default.pandoc anywhere in my Windows system.

That file is not created automatically, you'd need to create it yourself.

What's perhaps a bit confusing is the fact that a global settings file and a default settings file are not the same thing. A global settings file is a settings file in pandoc-data-dir. Like local and project settings files, global settings files are dependent on the output format, and hence have the output format in their name. They are only loaded when you explicitly set the output format in a pandoc-mode buffer.

A default settings file is settings file that is loaded by pandoc-load-default-settings, which can be done from pandoc-mode-hook. It has default in its name instead of the output format. The point is that there can be a local default settings file (which applies to one single file), a project one (which applies to any file in a given directory), and a global one (which applies to any file).

Is there any quick setting up I can do? I also tried (setq pandoc-set-wrap "preserve"), which did not work.

pandoc-set-wrap is a function, not a variable, so setting its value as a variable won't have any effect.

What you'd need to do to get the effect you want is to open an Org file, set the output format to commonmark and set any options that you want (that is, set wrap to preserve), select "Save Global Settings File" from the menu, and then rename the resulting global settings file to default.pandoc. From what I understand, the only thing that is missing in your case is the final step.

AnabasisXu commented 3 months ago

@joostkremers Thank you for such detailed explanation! Rename to default.pandoc works after a restart of Emacs.