[ESS] font-lock-keywords-case-fold-search in BUGS mode

Rodney Sparapani rsparapa at mcw.edu
Mon Mar 9 19:17:06 CET 2009


S. McKay Curtis wrote:
> 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
> 

Hi McKay:

Quite frankly, none of this makes any sense.  I do agree that it is
reminiscent of an Emacs 22.3 bug.  However, to get the behavior
that you describe, Emacs 22.3 would have to be so horribly broken
as to be nearly unusable.  For example, you mention that "i"
is fontified as if it was the censoring function I(.,.).  However,
that would require a left parentheses to follow the "i" and none
does.  So, here's two things to try:

1) upgrade ESS to 5.3.11.  A good idea anyways, but not likely
to help I'm guessing.
2) get rid of Emacs 22.3.  If it is as bad as it sounds, then
I'm guessing this will fix it.

-- 
Rodney Sparapani      Center for Patient Care & Outcomes Research (PCOR)
Sr. Biostatistician              http://www.mcw.edu/pcor
4 wheels good, 2 wheels better!  Medical College of Wisconsin (MCW)
WWLD?:  What Would Lombardi Do?  Milwaukee, WI, USA




More information about the ESS-help mailing list