[ESS] Syntax Highlighting

Oliver Jones ojones at wiwi.uni-bielefeld.de
Thu Jan 31 17:57:27 CET 2013


Hi

Am 31.01.2013 15:30, schrieb Vitalie Spinu:
>    >>  Oliver Jones<ojones at wiwi.uni-bielefeld.de>
>    >>  on Thu, 31 Jan 2013 15:09:02 +0100 wrote:
>
>    >  Looking in too ess-sta-l.el I couldn't figure out where the symbols for
>    >  indicating comments are defined. Neither could I figure out where I can modify
>    >  the variable STA-syntax-table (M-x
>    >  customize-variable RET STA-syntax-table RET give NO MATCH) or where I should include
>    >  (modify-syntax-entry ?* "<" STA-syntax-table)
>
>    >  Do I have to copy that line in my ~/.emacs.d/init.el ?
>
> Yes, this is what Rodney meant. But it will not quite work because "<"
> defines a start of a block comment and not a fence comment (which I
> assume is what you need).
>
> What is exactly the use of * in STATA? Are you sure it is a comment
> symbol? How does the multiplication work then?

Comments may be added to programs in three ways:

- begin the line with *;
- begin the comment with //; or
- place the comment between /* and */ delimiters.

(From: http://www.stata.com/help.cgi?comments)

Regarding Multiplication I guess something like this is meant:
(The following is some Stata code with explanation of the comments)

drop _all
set obs 10
* comment this line
* Asterisk just works if it is at the beginning of the line
gen x = 1 // comment the rest of the line with //

/* A Block comment
can
span multipli
lines
and ends with */

* /* even though this line should be a comment out Stata still
recognizes the beginning of a block comment.
(But even Stata's own dofile editor doesn't get the syntax highlighting right
in these cases, because they are really rare in practice I guess.)
They work like parenthesis, i.e. after opening another one by /* we
have to close two of them. That's way the
next line is not evaluated even if we close one block now by */
gen y = 2
now let's close the first opening block comment.
As with opening the block comment you can close it on a line
* that is commented out by an asterisk */

gen z = 3

exit

This code produces the variables x and z, containing just ones and threes.

I think all that's needed is the functionality to comment lines out by an
asterisk, because starting a block comment on a line that is commented out
is not a useful functionality.
Or can you think of situations when you want to stuff like that?

>
> There are two comments in stata that ESS currently supports // for fence
> comment (aka one line) and /* ... */ for block comments.  And I don't
> see an easy way to implement * as a fence comment without screwing
> multiplication or standard /* ... */ comment (at least not with
> syntactic tables).
>
>      Vitalie

-- 
_______________________________________________________________________________
Universität Bielefeld
Fakultät für Wirtschaftswissenschaften
Lehrstuhl für Ökonometrie und Statistik
Raum / room:  V9-108
Tel / phone:  +49 (0)521 106 4895
http://www.wiwi.uni-bielefeld.de/oekonometrie.html



More information about the ESS-help mailing list