0

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)
  (ispell-change-dictionary
   (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)))
       "polish"
     "english"))
  (flyspell-mode)
  (flyspell-buffer))


(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 ()
  (interactive)
  (flyspell-delete-all-overlays))

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

(defun english ()
  (interactive)
  (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))
                (whitespace-mode))))

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?

3
  • 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
    Commented Aug 18, 2023 at 20:54
  • Off-topic: may I ask why you use "\\.\\(cs\\)\\'" instead of "\\.cs\\'"? 🤔
    – shynur
    Commented Aug 21, 2023 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
    Commented Aug 22, 2023 at 11:21

0

Your Answer

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

Browse other questions tagged or ask your own question.