Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs d-mode cannot handle backquoted backslashes

Currently Emacs https://github.com/Emacs-D-Mode-Maintainers/Emacs-D-Mode cannot correctly highlight

`\`

because it doesn't understand that single backslashes are self-contained in such a raw string literal.

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. Ideas on how to fix this anyone?

See also: http://forum.dlang.org/post/[email protected]

like image 499
Nordlöw Avatar asked Aug 01 '14 21:08

Nordlöw


2 Answers

What Jon O. says: use a syntax-propertize-function. E.g.

(setq-local syntax-propertize-function
            (syntax-propertize-rules ("`\\(\\\\\\)`" (1 "."))))
like image 147
Stefan Avatar answered Oct 05 '22 00:10

Stefan


Fix has now been committed to the Git repository with required Emacs minimum of 24.3 as that has been tested on Debian Sid.

like image 36
Russel Winder Avatar answered Oct 05 '22 02:10

Russel Winder