[ESS] font-lock-keywords-case-fold-search in BUGS mode
S. McKay Curtis
smcurtis at stat.washington.edu
Mon Mar 9 18:09:34 CET 2009
Hi Stephen,
Here is the particular file that I am working on:
model {
for (i in 1:nS){
for (j in 1:nI){ mn[i,j] <- mu[j] + lam[j]*theta[i] }
Y[i,1:4] ~ dmnorm(mn[i,1:4],Pmat1[,])
Y[i,5:8] ~ dmnorm(mn[i,5:8],Pmat2[,])
}
##==================================================
## Priors for latent variables
for (i in 1:nS){ theta[i] ~ dnorm(0,1) }
##==================================================
## Loadings and Intercepts
for (j in 1:nI){ lam[j] ~ dnorm(0,1) T(0,) }
for (j in 1:nI){ mu[j] ~ dnorm(0,1) }
##==================================================
## Priors for variance parameters
Pmat1[1:4,1:4] ~ dwish(W[,],4)
Sig1[1:4,1:4] <- inverse(Pmat1[,])
Pmat2[1:4,1:4] ~ dwish(W[,],4)
Sig2[1:4,1:4] <- inverse(Pmat2[,])
}
All keywords (like "for", "dnorm", etc.) are font locked as I would
expect them to be, *except* the subscript "i" is also font locked
(e.g. in Y[i,1:4]). This is because "I" (capital i) is defined as a
keyword (because it's used in specifying truncated distributions like
"dnorm(0,1) I(0,)"), but because "font-lock-keywords-case-fold-search"
is set to "t" so the lower case "i" when used as an index is also
highlighted. Similarly, if I were to type "FOR" (all caps) into this
buffer, it would also be highlighted.
I can get the syntax highlighting that I expect by setting the value
of font-lock-keywords-case-fold-search manually ("M-x set-variable
[RET] font-lock-keywords-case-fold-search [RET] nil"), but my attempt
to add a hook to do this automatically hasn't worked.
I am using GNU Emacs 22.3.1 and ESS 5.3.8.
Thanks again,
McKay
On Mon, Mar 9, 2009 at 9:45 AM, Stephen Eglen <S.J.Eglen at damtp.cam.ac.uk> wrote:
> S. McKay Curtis <smcurtis at stat.washington.edu> wrote:
>
>> Hi all,
>>
>> I have the following lines of code in my ".emacs" file
>>
>> (add-hook 'ess-bugs-mode-hook
>> '(lambda()
>> (setq font-lock-keywords-case-fold-search nil)
>> )
>> )
>>
>> But when I open a ".bug" file, the value of the variable
>> "font-lock-keywords-case-fold-search" is still "t", even though I have
>> added this hook to set it to "nil" (and even though its global value
>> is "nil"). I am pretty sure that emacs goes into bugs mode when
>> opening the .bug file, because the mode line reads "ESS[BUGS]". Does
>> anyone know why this variable isn't being set to "nil"?
>
> This sounds like very similar to a problem reported in SAS mode a few
> weeks ago. Please can you send an example file and state what you
> expect to be font locked, and how it appears for you. (I ask for these
> so that we can debug it!)
>
> Please also tell us what version of ESS and what version Emacs you use.
>
> Thanks, Stephen
>
More information about the ESS-help
mailing list