Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Derived major mode and shared filename extension

16 views
Skip to first unread message

Johan Vromans

unread,
Jan 6, 2021, 5:21:37 AM1/6/21
to
Hi,

I have a major mode 'joplin-mode' that is derived from 'markdown-mode'. A
Joplin data file is basically a Markdown document with some twists, and
shares the extension '.md'. Whether a document is joplin can be determined
from its content.

What is the proper way to devise this?

One alternative is to add joplin-mode to auto-mode-alist as the handler for
'.md'. When joplin-mode detects that it is not a joplin file it changes the
mode-name back to "Markdown" and the buffer will be handled by the parent
markdown-mode.

Another alternative is to add markdown-mode to auto-mode-alist and add a
hook to markdown-mode-hooks to inspect the contents, and if it is joplin
data then invoke joplin-mode. (Which will invoke markdown-mode so I must
prevent unwanted recursion. That can be solved.)

Is either approach preferred? Or is there an even better way to do it?

Thanks,
Johan

0 new messages