I took a look and I don't really know if it's possible without using the Emacs > 24 only suggestion in the Stack Overflow comment to your question.

As far as I can see, before that Emacs syntax tables have a notion of what a string is and what an escape character is. The d-mode code adds the backtick as an alternative to double and single quotes but can't do anything about the backslash. Unless it disables backslash as an escape character everywhere.

I tried setting backtick to a function that returns "\"" instead of the value to see if I could then tailor the function to depend on whether not the point was in a backtick string but that didn't work since `modify-syntax-entry` checks to see if the argument is a string.

BTW, python-mode has the same problem, I checked with r"\".

Atila

On Thursday, 31 July 2014 at 08:40:12 UTC, Nordlöw wrote:
Currently Emacs d-mode cannot correctly highlight

`\`

because it doesn't understand that single backslashes are self-contained in back-quoted strings.

I believe this extract from d-mode.el

(defvar d-mode-syntax-table nil
  "Syntax table used in d-mode buffers.")
(or d-mode-syntax-table
    (setq d-mode-syntax-table
(let ((table (funcall (c-lang-const c-make-mode-syntax-table d))))
           ;; Make it recognize D `backquote strings`
           (modify-syntax-entry ?` "\"" table)

           ;; Make it recognize D's nested /+ +/ comments
           (modify-syntax-entry ?+  ". 23n"   table)
           table)))

is highly related to this problem but I don't understand the comment

           ;; Make it recognize D `backquote strings`

Ideas on how to fix this anyone?

Reply via email to