0

I've been trying to have Markdown Mode open all markdown files in CONTENTS view, i.e. all folded up. I can of course just hit S-TAB twice whenever I open a markdown file, but, with markdown-mode.el available I shouldn't need to. I can only see one likely variable to tweak - markdown-cycle-global-status. I attempted to tweak this this in my init.el:

(use-package markdown-mode :mode ("\\.markdown\\'" "\\.md\\'") :init ; (setq markdown-cycle-global-status 3) ; doesn't trigger CONTENTS (setq markdown-command "pandoc")) ; (add-hook 'markdown-mode-hook ; (lambda () ; (setq markdown-cycle-global-status 3))) ; doesn't trigger CONTENTS 

The trailing comments "doesn't..." follow code that, when uncommented, has no effect, though I thought it might. So I tried tweaking ~/.emacs.d/straight/repos/markdown-mode/markdown-mode.el:

(defvar markdown-cycle-global-status 3) ; by default it's 1 

- still not opening md's in CONTENTS view.

So any suggestions how to do this?

1 Answer 1

1

Since it's a defvar and not a defcustom my guess is that the mode isn't designed for you to customize that variable, so I would instead copy some of the code from the markdown-cycle command :-(

(use-package markdown-mode :mode ("\\.markdown\\'" "\\.md\\'") :preface (defun my/markdown-set-global-status () (outline-hide-sublevels 1) (setq markdown-cycle-global-status 3) (markdown-outline-fix-visibility) ) :init (add-hook 'markdown-mode-hook #'my/markdown-set-global-status) (setq markdown-command "pandoc")) 
3
  • That partially works in my configuration: only the first (markdown-cycle t) is respected, getting me to OVERVIEW (then the first S-TAB has no effect). Commented Sep 12, 2022 at 19:39
  • Oh wow, that markdown-cycle code didn't work like I thought. I think at this point the simplest thing is to copy the code from markdown-cycle :-( so I will update my answer. Commented Sep 13, 2022 at 16:51
  • Just for reference, from your first version I used just one line, :preface (defun my/markdown-OVERVIEW () (markdown-cycle t)), which got me to OVERVIEW. Your edited code does get me directly into CONTENTS view, but with one disadvantage: 1st S-TAB (bound to markdown-shifttab) reports "OVERVIEW" though nothing has changed in the buffer; 2nd S-TAB reports "CONTENTS", again no change in the buffer; 3rd S-TAB successfully gets SHOW ALL, and from then cycles through those three views as expected. Any ideas how to get S-TAB immediately fully functional? Commented Sep 14, 2022 at 9:25

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.