I don't know what is happening and how to debug this.

I moved my Emacs config from Fedora to Xubuntu 22.04 (that use older version of GNU Emacs) and now each time I open markdown file (only once per open file) Emacs generates HTML output of the markdown?

What may be responsible for this behavior?

THis it the only configuration for markdown files that I have in my .emacs file:

(dolist (pair '(("\\.\\(cs\\)\\'" . csharp-mode)
                ("\\.\\(css\\)\\'" . web-mode)
                ("\\.\\(ejs\\)\\'" . web-mode)
                ;; ("\\.\\(xml\\|rss\\|xsl\\|svg\\|glade\\|rng\\|kml\\|html\\|xhtml\\)\\'" . nxml-mode)
                ("\\.\\(php\\|php\\.in\\|xml\\|twig\\|rss\\|xsl\\|svg\\|glade\\|rng\\|kml\\|html\\|xhtml\\)\\'" . web-mode)
                ("\\.\\(md\\)\\'" . markdown-mode)
                ("\\.\\(prisma\\)\\'" . prisma-mode)
                ("\\.markdown$" . jekyll-markdown-mode)
                ("\\.\\(template\\|tpl\\)\\'" . mustache-mode)
                ("\\.jsx\\'" . web-mode)
                ("\\.\\(gs\\)\\'" . ruby-mode)
                ("\\.\\(js\\)\\'" . javascript-mode)))
  (add-to-list 'auto-mode-alist pair))

(require 'ispell)

(defun markdown ()
  (setq fill-column 100)
   (if (let ((name (buffer-file-name)))
         (or (string-match-p "jcubic/www/blog/repo" name)
             (string-match-p "jcubic/www/jankiewicz" name)
             (string-match-p "jcubic/astek/blog" name)
             (string-match-p "/pl/" name)))

(setq flyspell-generic-check-word-predicate 'flyspell-generic-textmode-verify)
(defun flyspell-generic-textmode-verify ()
  "Used for `flyspell-generic-check-word-predicate' in text modes."
  (eq major-mode 'markdown-mode))

(defun flyspell-clear ()

(defun lang (lang)
  (interactive "sLanguage: ")
  (ispell-change-dictionary lang)

(defun english ()
  (lang "english"))

(add-hook 'markdown-mode-hook 'markdown)

Besides this code I also have some highlighting modes enabled but they are not executed when opening the file. But I've checked that they do work, they are added to:

(add-hook 'after-change-major-mode-hook 'highlight-selected-modes)
(add-hook 'after-change-major-mode-hook
          (lambda ()
            (if (null (memql major-mode whitespace-mode-disable))

When I switch to fundamental mode and then run M-x markdown-mode it works as expected.

Do you have a clue what could be generating that HTML output?

  • 2
    Start with emacs -q i.e. without your init file and make sure that that works properly. If that is the case, then bisect your init file to find the culprit. See this question and answer for more details.
    – NickD
    Aug 18 at 20:54
  • Off-topic: may I ask why you use "\\.\\(cs\\)\\'" instead of "\\.cs\\'"? 🤔
    – shynur
    Aug 21 at 16:58
  • @shynur I have no idea, I just copy pasted this code from somewhere else long ago, and I use it like this since.
    – jcubic
    Aug 22 at 11:21


Your Answer

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

Browse other questions tagged or ask your own question.