2

I'm working on a program mode, which has various different calls to assemblers, programmers and other external programs. My cunning plan was to handle all of these with the compile function, passing an explicit compile-command that depends on which program is being run.

This sort of seems to work and now I want to add specific error regexps for the different external programs. One option would be to alter compilation-error-regexp-alist-alist, keyed on my major mode and then add my major mode to compilation-error-regexp-alist.

What I'd prefer to do, though, is something like the following:

(let ((compilation-error-regexp-alist
       (cons <my-regexp-and-numbers> compilation-error-regexp-alist))
  (compile <my-compile-command>))

What's weird is that this binding doesn't seem to affect the way the compilation buffer gets parsed / marked up. If I manually push <my-regexp-and-numbers> onto the front of compilation-error-regexp-alist and then call (compilation-mode t) on the buffer, everything gets fontified as expected (so I haven't got the regexp wrong). However, sticking the call to (compilation-mode t) inside a let form as above doesn't affect anything.

I realise this fails miserably as an easy-to-reproduce test case. If no-one has any ideas, I'll try to hack out an example, but I'm hoping that someone will go "Ah, yes! That's because doesn't get evaluated then, but rather at " or the like...

Rupert Swarbrick
  • 2,793
  • 16
  • 26

1 Answers1

2

My guess is that the variable is set for the command but somehow is not passed to compile buffer.

Try your method and view the value of the variable (C-h v) inside the compile buffer for confirmation.

Nicolas Dudebout
  • 9,172
  • 2
  • 34
  • 43
  • Well, it doesn't change, but I wouldn't expect it to: since Emacs uses dynamic binding, the changes to the variable disappear as soon as control passes out of the let form. – Rupert Swarbrick Aug 21 '12 at 22:35
  • Ahah! But you're right: the parsing code gets called by font-lock, which happens later, so my changes have disappeared by then. I'll make the variable buffer-local and set it. Thanks for pointing me in the right direction! – Rupert Swarbrick Aug 21 '12 at 22:38