[ESS] Syntax highlighting not working for keywords with uppercase letters in ESS[SAS]

Martin Maechler maechler at stat.math.ethz.ch
Thu Jan 8 11:29:33 CET 2009


>>>>> "RoSp" == Rodney Sparapani <rsparapa at mcw.edu>
>>>>>     on Wed, 07 Jan 2009 10:09:28 -0600 writes:

    RoSp> Christian Keller wrote:

    >> Dear all
    >> 
    >> I recently came across a problem with syntactic
    >> highlighting in ESS[SAS]. As SAS programming language is
    >> not case-sensitive, keywords should be highlighted
    >> regardless of being written in lowercase or uppercase
    >> letters. However, this is not the case for GNU Emacs
    >> 22.3.1 (i386-mingw-nt5.1.2600) with ESS 5.3.10.

    >> 
    >> Example: In ESS[SAS] the keyword %let is highlighted
    >> correctly, whereas %Let or %LET are not highlighted
    >> (where they should in my opinion).
    >> 
    >> Interestingly, highlighting works correctly in ESS[SAS]
    >> for the older emacs version GNU Emacs 22.1.1
    >> (i386-mingw-nt5.1.2600) with ESS 5.3.10.


    >> As far as I understood the concept of font lock, the
    >> variable font-lock-keywords-case-fold-search controls
    >> whether keywords are highlighted regardless of their
    >> case: Documentation: *Non-nil means the patterns in
    >> `font-lock-keywords' are case-insensitive.
    >> 
    >> For GNU Emacs 22.3.1 (i386-mingw-nt5.1.2600) with ESS
    >> 5.3.10 in ESS[SAS] C-h v
    >> font-lock-keywords-case-fold-search gives:
    >> font-lock-keywords-case-fold-search is a variable defined
    >> in `font-lock.el'.  Its value is nil Automatically
    >> becomes buffer-local when set in any fashion.
    >> 
    >> But for older emacs version GNU Emacs 22.1.1
    >> (i386-mingw-nt5.1.2600) with ESS 5.3.10:
    >> font-lock-keywords-case-fold-search is a variable defined
    >> in `font-lock.el'.  Its value is t Local in buffer
    >> test.sas; global value is nil Automatically becomes
    >> buffer-local when set in any fashion.

Thank you, Christian.  Very well-diagnosed so far.
I can confirm the behavior:

In both  GNU emacs 22.2.* and 22.3.*  the highlighting fails,
and the reason is that  
font-lock-keywords-case-fold-search  is nil instead of t (or
any-other non-nil value).


    >> Has anyone a solution to this problem in GNU Emacs 22.3
    >> with ESS 5.3.10?
    >> 
    >> Please note that I used Emacs with the '--no-site-file'
    >> startup option for all my tests and my .emacs contains
    >> only the line (require 'ess-site)
    >> 
    >> 
    >> Best regards Christian

    RoSp> Hi Christian:

    RoSp> I can confirm this is a bug in 22.3.1.  The solution
    RoSp> is to edit essd-sas.el (it is read-only so you have to
    RoSp> make it writable first; if you also have an
    RoSp> essd-sas.elc, then remove that as well).

    RoSp> On line 201, insert (setq-default
    RoSp> font-lock-keywords-case-fold-search t)

    RoSp> If this sounds good to everybody, I can commit this.
    RoSp> But, 22.3.1 seems pretty buggy to me.  When I launch
    RoSp> it, the window is too big for the screen and when you
    RoSp> try to grab it to make it smaller, you often hit the X
    RoSp> button killing it.  XEmacs does not have this annoying
    RoSp> problem!

    RoSp> FWIW, I used the Windows installation instructions
    RoSp> from the README thread for both GNU Emacs and XEmacs
    RoSp> and they work perfectly.  So, both that and the fix
    RoSp> should appear in 5.3.11 RSN.

(unfortunately not yet;  as Rodney has followed up too ...)

Emacs documentation clearly says that one should not set
font-lock-keywords-case-fold-search directly but rather should
do it via  font-lock-defaults .. Rodney mentioned that
too somewhere.

And I now *have* searched our ESS lisp code and other lisp packages for
examples, and I'm pretty sure that the following was correct syntax

  (set (make-local-variable 'font-lock-defaults)
       '(SAS-mode-font-lock-keywords nil t))
  ;;                                     ^^ this *should* set
  ;; font-lock-keywords-case-fold-search, but it fails for Emacs 22.[23]

however, it does not work in Emacs 22.2 and 22.3
Setting the *case-fold-search explicitly, works though and I
have committed a fix with that.

I think one should report a bug with the emacs developers,
but I'll wait a bit (for S.E. hint hint ..) before eventually 
doing it myself.

Martin




More information about the ESS-help mailing list