2
votes

I have check-parens set to a save hook for my files, my Markdown files in particular, to alert me about unbalanced parentheses. They are almost always errors, and this has saved me from a great many errors involving Markdown links inside parenthetical asides:

 ;In Markdown files, there are few excuses for unbalanced delimiters
(add-hook 'markdown-mode-hook
          (lambda ()
            (when buffer-file-name
              (add-hook 'after-save-hook
                        'check-parens
                        nil t))))

I've noticed that I have similar issues with quoting - I will drop a trailing quote, or I will forget to convert single and doubles appropriately, etc. (This sometimes overlaps with link errors when I put paper titles into the tooltip.) There's little more reason for imbalanced "s than there are for (s or )s, and it's the same task check-parens is already doing. So naturally I'd like to have check-parens cover quotes as well.

But I can't seem to do so! The right way seems to involve hacking the Markdown syntax table, but nothing I try seems to work –

(modify-syntax-entry ?\" "(\"" markdown-mode-syntax-table)
(modify-syntax-entry ?\" ")\"" markdown-mode-syntax-table)
(modify-syntax-entry ?\" "$\"" markdown-mode-syntax-table)
(modify-syntax-entry ?\" "^\"" markdown-mode-syntax-table)
(modify-syntax-entry ?\" ".\"" markdown-mode-syntax-table)
(modify-syntax-entry ?' "\"" markdown-mode-syntax-table)

etc etc etc. They all either do nothing or cause check-parens to spit out errors early in the file where as far as I can tell everything works just fine.

I've read through a number of links on the topic and the C-h f documentation for modify-syntax-entry:

and asked on #emacs, to no avail.

(The version is Emacs 24.0.93.1 on Debian unstable.)

1

1 Answers

1
votes

Try

(modify-syntax-entry ?\" "\"" markdown-mode-syntax-table)