www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Emacs d-mode cannot handle backquoted backslashe

reply =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
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?
Jul 31 2014
next sibling parent reply Russel Winder via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
On Thu, 2014-07-31 at 08:40 +0000, "Nordl=C3=B6w" via Digitalmars-d-learn
wrote:
 Currently Emacs d-mode cannot correctly highlight
=20
 `\`
=20
 because it doesn't understand that single backslashes are=20
 self-contained in back-quoted strings.
=20
 I believe this extract from d-mode.el
=20
 (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=20
 d))))
 	   ;; Make it recognize D `backquote strings`
 	   (modify-syntax-entry ?` "\"" table)
=20
 	   ;; Make it recognize D's nested /+ +/ comments
 	   (modify-syntax-entry ?+  ". 23n"   table)
 	   table)))
=20
 is highly related to this problem but I don't understand the=20
 comment
=20
 	   ;; Make it recognize D `backquote strings`
I think it is trying to convert ` to " internally since "=E2=80=A6" is the string form for font-lock. Just at first sight I don't fully understand what is going on=E2=80=A6 :-(=20
 Ideas on how to fix this anyone?
Not just at the moment I'm afraid. I'll try and take a look at it tomorrow. --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Jul 31 2014
parent reply =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
On Thursday, 31 July 2014 at 09:20:28 UTC, Russel Winder via 
Digitalmars-d-learn wrote:
 Not just at the moment I'm afraid. I'll try and take a look at 
 it
 tomorrow.
Great!
Jul 31 2014
parent reply =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
On Thursday, 31 July 2014 at 10:04:57 UTC, Nordlöw wrote:
 Great!
See also: https://stackoverflow.com/questions/25089090/emacs-d-mode-cannot-handle-backquoted-backslashes
Aug 01 2014
parent reply =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
On Friday, 1 August 2014 at 21:42:02 UTC, Nordlöw wrote:

I just posted a d-mode.el fix to Russel Winder.

See the recent posts at

https://stackoverflow.com/questions/25089090/emacs-d-mode-cannot-handle-backquoted-backslashes

If you can't wait ;)
Aug 12 2014
parent =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
On Tuesday, 12 August 2014 at 17:28:25 UTC, Nordlöw wrote:
And a PR:

https://github.com/Emacs-D-Mode-Maintainers/Emacs-D-Mode/pull/22
Aug 12 2014
prev sibling parent reply "Atila Neves" <atila.neves gmail.com> writes:
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?
Aug 04 2014
next sibling parent Russel Winder via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
On Mon, 2014-08-04 at 12:25 +0000, Atila Neves via Digitalmars-d-learn
wrote:
 I took a look and I don't really know if it's possible without=20
 using the Emacs > 24 only suggestion in the Stack Overflow=20
 comment to your question.
=20
 As far as I can see, before that Emacs syntax tables have a=20
 notion of what a string is and what an escape character is. The=20
 d-mode code adds the backtick as an alternative to double and=20
 single quotes but can't do anything about the backslash. Unless=20
 it disables backslash as an escape character everywhere.
=20
 I tried setting backtick to a function that returns "\"" instead=20
 of the value to see if I could then tailor the function to depend=20
 on whether not the point was in a backtick string but that didn't=20
 work since `modify-syntax-entry` checks to see if the argument is=20
 a string.
=20
 BTW, python-mode has the same problem, I checked with r"\".
Per Nordl=C3=B6w has offered a putative fix via a pull request. I'll check out the claim and if it seems to be true (and I fully expect it to be so) I'll accept the pull request. People using MELPA should see the new package quite quickly. --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Aug 12 2014
prev sibling parent Russel Winder via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
On Tue, 2014-08-12 at 23:53 +0100, Russel Winder wrote:
[=E2=80=A6]
 Per Nordl=C3=B6w has offered a putative fix via a pull request. I'll chec=
k
 out the claim and if it seems to be true (and I fully expect it to be
 so) I'll accept the pull request. People using MELPA should see the new
 package quite quickly.
Fix committed to the mainline repository. Not sure how long it will take to get into MELPA. Should we release 2.0.7? --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Aug 13 2014