1

I am using markdown-mode on a git-commit message. At the bottom of a git-commit I append some lines to remind me what to take care. Example:

My commit message...

# *
# 1. `Separate subject from body with a blank line`
# 2. `Limit the subject line to 50 characters`

If possible, I want to use org-mode's bullets on a markdown file.

My goal is to use # * as a org's bullet indication. The reason for this is I want to hide some comments in the markdown but keeping bullet as comment as well.

commit.md :

My commit message...     | My commit message...
                         |
# *                      | # *  // collapsed
# notes                  |
# notes                  |
6
  • So you want to have Org mode-like folding in a file with a markdown major mode, right?
    – NickD
    Nov 21, 2022 at 14:51
  • Yes sir, but I want to indicate the start point of folding using comment character, for example: # *
    – alper
    Nov 21, 2022 at 16:04
  • I think your title is misleading: you don't want to change bullet indication in org-mode, because the buffer is NOT an Org mode buffer at all. What you want is a folding mode that you can use in markdown mode.
    – NickD
    Nov 21, 2022 at 16:23
  • 2
    markdown-mode already supports code-folding, nearly identical to what org-mode does. How does what you want differ from that?
    – Tyler
    Nov 21, 2022 at 16:41
  • BTW, you realize that # is not a comment character in Markdown, right? IIUC, there is no comment character - see e.g. stackoverflow.com/questions/4823468/comments-in-markdown
    – NickD
    Nov 22, 2022 at 13:28

3 Answers 3

1

I assume you already have the markdown-mode and poly-markdown packages installed and running in your emacs configuration file.

MWE

# headline

## level 2 headline 1 ##

### level 3 headline 1 ###
some text goes here

### level 3 headline 2 ###

## level 2 headline 2 ##
another text goes here

For some weird reason, code folding was not displayed in this GIF image, but I hope you get the point.

enter image description here

put the above in your markdown file and let the pointer be on the headline and hit Tab repeatedly you will get the desired code folding. Use it for comments or anything you want.

Emacs setup inside init.el

(use-package markdown-mode
  :ensure t
  :mode ("README\\.md\\'" . gfm-mode)
  :commands (markdown-mode gfm-mode)
  :init (setq markdown-command "multimarkdown")
  )

(use-package poly-markdown
  :ensure t
  )
3
  • By default can it be opened as collapesed?
    – alper
    Nov 25, 2022 at 12:05
  • not quite sure what you mean, but if you mean like #+STARTUP: hidestars in the beginning of org files to hide bullet stars at the startup then no, to the best of my knowledge.
    – doctorate
    Nov 25, 2022 at 12:53
  • Yes sir #+STARTUP: overview is what I was looking forI . That's why first I want to keep org-mode but using # * as bullet indicator in the original question
    – alper
    Nov 26, 2022 at 19:37
1

I am not sure what you mean, but I do not have enough reputation to comment. Therefore, I will just write an answer here.

To add comments to a markdown file, wrap the comment text as follows <!-- comment text -->, (see https://www.w3schools.io/file/markdown-comments/). If you are using markdown-mode then you can quickly comment in/out lines/regions using C-x C-;.

The 'headline/org bullets' in markdown-mode are provided by outline mode. You can configure the 'bullet' via the outline-regexp variable.

0

I have used following trick, where TAB beginning of #+begin_src markdown line is able the wrap the comment messages:

My git commit...

#+begin_src markdown                                       
# 1. `Separate subject from body with a blank line`
# 2. `Limit the subject line to 50 characters`
# 3. `Capitalize the subject line`
# 4. `Do not end the subject line with a period`
# 5. `Use the imperative mood in the subject line`
# 6. `Wrap the body at 72 characters`
# 7. `Use the body to explain what and why vs. how`
#+end_src

as:

My git commit...

#+begin_src markdown ▾

in my .emacs config file, I have following lines:

(add-to-list 'auto-mode-alist '("/\\.git/MERGE_MSG\\'" . git-commit-mode))
(add-to-list 'auto-mode-alist '("/\\.git/COMMIT_EDITMSG\\'" . git-commit-mode))
(add-to-list 'auto-mode-alist '("/\\.git/commit-msg\\'" . git-commit-mode))
(setq git-commit-major-mode 'org-mode)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.