joostkremers / pandoc-mode

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

No bibliography selected: not picking up settings #96

Closed atanasj closed 4 years ago

atanasj commented 4 years ago

When using the pandoc-jump-to-reference I get the error No bibliography selected. My config is below:

(use-package pandoc-mode
    :hook
    (markdown-mode . pandoc-mode)
    :bind
    ("C-s-j" . pandoc-jump-to-reference)
    :config
    (setq pandoc-citation-jump-function 'pandoc-open-in-ebib
          pandoc-data-dir "/Users/atanas/.emacs.d/site-lisp/pandoc-mode/")
    )

The contents of my default.pandoc file are (sorry for the length):

;; -*- mode: emacs-lisp -*-

;; pandoc-mode global settings file
;; saved on 2020.01.15 13:49

((latexmathml)
 (mathml)
 (jsmath)
 (mathjax)
 (gladtex)
 (mimetex)
 (webtex)
 (katex)
 (katex-stylesheet)
 (bibliography "/Users/atanas/.pandoc/MyLib.bib")
 (csl "/Users/atanas/.pandoc/csl/apa-old-doi-prefix.csl")
 (citation-abbreviations)
 (natbib)
 (biblatex)
 (epub-stylesheet)
 (epub-cover-image)
 (epub-metadata)
 (epub-embed-font)
 (epub-chapter-level)
 (epub-subdirectory)
 (chapters)
 (no-tex-ligatures)
 (listings)
 (latex-engine)
 (latex-engine-opt)
 (self-contained)
 (html-q-tags)
 (ascii)
 (number-offset)
 (section-divs)
 (email-obfuscation)
 (id-prefix)
 (title-prefix)
 (css)
 (top-level-division)
 (reference-location)
 (reference-links)
 (atx-headers)
 (number-sections)
 (incremental)
 (slide-level)
 (reference-odt)
 (reference-docx)
 (reference-doc)
 (pdf-engine)
 (pdf-engine-opt)
 (standalone)
 (template)
 (variable)
 (dpi)
 (eol)
 (wrap)
 (no-wrap)
 (columns)
 (table-of-contents)
 (toc-depth)
 (no-highlight)
 (highlight-style)
 (syntax-definition)
 (include-in-header)
 (include-before-body)
 (include-after-body)
 (request-header)
 (resource-path)
 (verbose)
 (strip-comments)
 (parse-raw)
 (smart)
 (old-dashes)
 (base-header-level)
 (indented-code-classes)
 (default-image-extension)
 (lua-filter)
 (filter)
 (metadata)
 (metadata-file)
 (normalize)
 (preserve-tabs)
 (tab-stop)
 (track-changes)
 (strip-empty-paragraphs)
 (abbreviations)
 (read . "markdown")
 (read-lhs)
 (read-extensions
  ("abbreviations")
  ("all_symbols_escapable")
  ("amuse")
  ("angle_brackets_escapable")
  ("ascii_identifiers")
  ("auto_identifiers")
  ("autolink_bare_uris")
  ("backtick_code_blocks")
  ("blank_before_blockquote")
  ("blank_before_header")
  ("bracketed_spans")
  ("citations")
  ("compact_definition_lists")
  ("definition_lists")
  ("east_asian_line_breaks")
  ("emoji")
  ("empty_paragraphs")
  ("epub_html_exts")
  ("escaped_line_breaks")
  ("example_lists")
  ("fancy_lists")
  ("fenced_code_attributes")
  ("fenced_code_blocks")
  ("fenced_divs")
  ("footnotes")
  ("four_space_rule")
  ("gfm_auto_identifiers")
  ("grid_tables")
  ("hard_line_breaks")
  ("header_attributes")
  ("ignore_line_breaks")
  ("implicit_figures")
  ("implicit_header_references")
  ("inline_code_attributes")
  ("inline_notes")
  ("intraword_underscores")
  ("latex_macros")
  ("line_blocks")
  ("link_attributes")
  ("lists_without_preceding_blankline")
  ("literate_haskell")
  ("markdown_attribute")
  ("markdown_in_html_blocks")
  ("mmd_header_identifiers")
  ("mmd_link_attributes")
  ("mmd_title_block")
  ("multiline_tables")
  ("native_divs")
  ("native_spans")
  ("ntb")
  ("old_dashes")
  ("pandoc_title_block")
  ("pipe_tables")
  ("raw_attribute")
  ("raw_html")
  ("raw_tex")
  ("shortcut_reference_links")
  ("simple_tables")
  ("smart")
  ("space_in_atx_header")
  ("spaced_reference_links")
  ("startnum")
  ("strikeout")
  ("styles")
  ("subscript")
  ("superscript")
  ("table_captions")
  ("task_lists")
  ("tex_math_dollars")
  ("tex_math_double_backslash")
  ("tex_math_single_backslash")
  ("yaml_metadata_block"))
 (write . "native")
 (write-lhs)
 (write-extensions
  ("abbreviations")
  ("all_symbols_escapable")
  ("amuse")
  ("angle_brackets_escapable")
  ("ascii_identifiers")
  ("auto_identifiers")
  ("autolink_bare_uris")
  ("backtick_code_blocks")
  ("blank_before_blockquote")
  ("blank_before_header")
  ("bracketed_spans")
  ("citations")
  ("compact_definition_lists")
  ("definition_lists")
  ("east_asian_line_breaks")
  ("emoji")
  ("empty_paragraphs")
  ("epub_html_exts")
  ("escaped_line_breaks")
  ("example_lists")
  ("fancy_lists")
  ("fenced_code_attributes")
  ("fenced_code_blocks")
  ("fenced_divs")
  ("footnotes")
  ("four_space_rule")
  ("gfm_auto_identifiers")
  ("grid_tables")
  ("hard_line_breaks")
  ("header_attributes")
  ("ignore_line_breaks")
  ("implicit_figures")
  ("implicit_header_references")
  ("inline_code_attributes")
  ("inline_notes")
  ("intraword_underscores")
  ("latex_macros")
  ("line_blocks")
  ("link_attributes")
  ("lists_without_preceding_blankline")
  ("literate_haskell")
  ("markdown_attribute")
  ("markdown_in_html_blocks")
  ("mmd_header_identifiers")
  ("mmd_link_attributes")
  ("mmd_title_block")
  ("multiline_tables")
  ("native_divs")
  ("native_spans")
  ("ntb")
  ("old_dashes")
  ("pandoc_title_block")
  ("pipe_tables")
  ("raw_attribute")
  ("raw_html")
  ("raw_tex")
  ("shortcut_reference_links")
  ("simple_tables")
  ("smart")
  ("space_in_atx_header")
  ("spaced_reference_links")
  ("startnum")
  ("strikeout")
  ("styles")
  ("subscript")
  ("superscript")
  ("table_captions")
  ("task_lists")
  ("tex_math_dollars")
  ("tex_math_double_backslash")
  ("tex_math_single_backslash")
  ("yaml_metadata_block"))
 (output)
 (data-dir)
 (extract-media)
 (file-scope)
 (output-dir)
 (master-file))

I copied this settings file from my old emacs config, and updated where the default directory was. I also tried having the same content in a .pandoc file, but this doesn't get picked up either. What am I doing wrong?

joostkremers commented 4 years ago

Can you confirm that the settings (esp. the bibliography file) are really loaded? Just go to the pandoc-mode hydra and check the value of the bibliography setting (C-c / o c should get you there).

atanasj commented 4 years ago

Doesn't look like it:

image

What have I done wrong?

joostkremers commented 4 years ago

It looks like you need to add the function pandoc-load-default-settings to pandoc-mode-hook. Without it, pandoc-mode does not load any settings.

Note, though, that your default settings file specifies "native" as the output format (the option write). That means that as soon as you change your output format, the bibliography file (and all other settings) will be unset (or set to the value in any settings file for the output format you specify).

It's important to note (and perhaps I'm not making this clear enough in the documentation) that all settings are dependent on the output format. There is (currently) no way to specify settings that apply to all output formats. (Though perhaps there should be.)

atanasj commented 4 years ago

Thanks, how do I do that exactly?

joostkremers commented 4 years ago

It's described in the installation section of the manual: http://joostkremers.github.io/pandoc-mode/.

atanasj commented 4 years ago

Okay, so this is what I have in my config:

(use-package pandoc-mode
    :hook
    (markdown-mode . pandoc-mode)
    :bind
    ("C-s-j" . pandoc-jump-to-reference)
    :config
    (setq pandoc-data-dir "/Users/atanas/.emacs.d/site-lisp/pandoc-mode/"
          pandoc-citation-jump-function 'pandoc-open-in-ebib)
    (add-hook 'pandoc-load-default-settings 'pandoc-mode-hook)
    )

And this is what my site-lisp folder contains:

| ~/.emacs.d/site-lisp @ uroboros (atanas)
.
└── pandoc-mode
    ├── default.pandoc
    ├── markdown.pandoc
    ├── md.pandoc
    └── native.pandoc

But I'm still getting the No bibliography selected error... Any other suggestions?

joostkremers commented 4 years ago

Your add-hook is wrong. The hook comes first, the function second:

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

It should probably also go in the :init section of your use-package declaration.

atanasj commented 4 years ago

Brilliant, that's sorted. Thanks!