Skip to content

Checks for major-mode should include derived modes #532

@hmelman

Description

@hmelman

I'm having a problem with toggling hiding that I can't quite track down, not all list items get converted to bullets properly. In researching this I found that it worked properly in markdown-mode and gfm-mode but not in my recently created derived mode. I created this derived mode to have a special abbrev table to use for some markdown documents. Here it is:

(define-derived-mode d&d-mode gfm-mode "D&D"
  "Major mode for editing text for D&D."
  (set (make-local-variable 'require-final-newline) mode-require-final-newline)
  (abbrev-mode 1))

I found several places in the markdown-mode code that check what the major-mode is using the following:

(memq major-mode '(markdown-mode gfm-mode))
(memq major-mode '(gfm-mode gfm-view-mode))
(member major-mode '(markdown-mode markdown-view-mode gfm-mode gfm-view-mode))

Regardless of whether it solves my toggle hiding problem (which it seems to) I think these should be changed to some form of the following to allow for derived modes of markdown-mode and gfm-mode. Particularly since markdown-view-mode and gfm-view-mode are derived modes themselves and gfm-mode is derived from markdown-mode. They also have the benefit of being shorter and easier to read.

(derived-mode-p 'markdown-mode)
(derived-mode-p 'gfm-mode)
  • Markdown Mode: 2.5dev, 20200815.203
  • Emacs: 27.1
  • OS: macOS Catalina

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions