all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* reading compile.el, modifying settings
@ 2011-05-03 14:03 Paul Graham
  2011-05-05 10:44 ` Tassilo Horn
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Paul Graham @ 2011-05-03 14:03 UTC (permalink / raw)
  To: help-gnu-emacs

Dear emacs experts,

I use compile mode, but I have my own set of compiler 
message regexps.  I try to set them up as follows:

.emacs:

    (load "compile")
    (load-file "~/emacs/compile-settings.el")

compile-settings.el:

    (setq compilation-error-regexp-alist ... )

However, when I compile in emacs, I end up with the
default compiler message regexps.  I then have to
manually eval the load of compile-settings.el to 
get my settings.

I think that when emacs starts up, it picks up my 
setting for compilation-error-regexp-alist, but does 
not immediately load compile.elc.  Then when I do my 
first compile, it loads compile.elc, and overwrites
my settings.

I thought that I could change my .emacs to explicitly 
load compile.elc, but this is not so easy.  The 'load'
function doesn't require an exact path, which makes it 
convenient to use -- it keeps working even when I switch
to a newer version of emacs.  If I use load-file instead,
then I have to give the full path to compile.el or
compile.elc, that is, I would have to duplicate all the
friendly logic in 'load'.

Any suggestions?

Paul



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: reading compile.el, modifying settings
  2011-05-03 14:03 reading compile.el, modifying settings Paul Graham
@ 2011-05-05 10:44 ` Tassilo Horn
  2011-05-12 12:49   ` Oleksandr Gavenko
  2011-05-05 16:31 ` Sam Steingold
  2011-05-05 19:48 ` Tassilo Horn
  2 siblings, 1 reply; 10+ messages in thread
From: Tassilo Horn @ 2011-05-05 10:44 UTC (permalink / raw)
  To: help-gnu-emacs

Paul Graham <pgraham@oasys-ds.com> writes:

Hi Paul,

> I use compile mode, but I have my own set of compiler 
> message regexps.  I try to set them up as follows:
>
> .emacs:
>
>     (load "compile")
>     (load-file "~/emacs/compile-settings.el")
>
> compile-settings.el:
>
>     (setq compilation-error-regexp-alist ... )

That looks good, except one would normally do (require 'compile), but
that shouldn't be any different here.

> However, when I compile in emacs, I end up with the
> default compiler message regexps.  I then have to
> manually eval the load of compile-settings.el to 
> get my settings.
>
> I think that when emacs starts up, it picks up my 
> setting for compilation-error-regexp-alist, but does 
> not immediately load compile.elc.  Then when I do my 
> first compile, it loads compile.elc, and overwrites
> my settings.

No, `load' shouldn't defer loading.  And even if it did, it should do no
harm, because `compilation-error-regexp-alist' is a defcustom and like
for defvars, the default value is only set if the variable is not
already bound.

Hm, maybe you should check if there is some other compile.el on your
load-path which gets loaded instead of the "real emacs" compile.el.
(M-x list-load-path-shadows RET).

Bye,
Tassilo




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: reading compile.el, modifying settings
  2011-05-03 14:03 reading compile.el, modifying settings Paul Graham
  2011-05-05 10:44 ` Tassilo Horn
@ 2011-05-05 16:31 ` Sam Steingold
  2011-05-05 18:15   ` Tassilo Horn
  2011-05-05 19:48 ` Tassilo Horn
  2 siblings, 1 reply; 10+ messages in thread
From: Sam Steingold @ 2011-05-05 16:31 UTC (permalink / raw)
  To: help-gnu-emacs

> * Paul Graham <ctenunz@bnflf-qf.pbz> [2011-05-03 07:03:43 -0700]:
>
>     (setq compilation-error-regexp-alist ... )

compilation-error-regexp-alist is defined with defcustom, so it should
be modified with custom-set-variables, not with setq.  Don't ask.

-- 
Sam Steingold (http://sds.podval.org/) on CentOS release 5.6 (Final) X 11.0.60900031
http://truepeace.org http://iris.org.il http://www.memritv.org
http://pmw.org.il http://jihadwatch.org http://openvotingconsortium.org
There are many reasons not to use Lisp - but no good ones.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: reading compile.el, modifying settings
  2011-05-05 16:31 ` Sam Steingold
@ 2011-05-05 18:15   ` Tassilo Horn
  2011-05-05 18:34     ` Sam Steingold
  0 siblings, 1 reply; 10+ messages in thread
From: Tassilo Horn @ 2011-05-05 18:15 UTC (permalink / raw)
  To: help-gnu-emacs

Sam Steingold <sds@gnu.org> writes:

Hi Sam,

>>     (setq compilation-error-regexp-alist ... )
>
> compilation-error-regexp-alist is defined with defcustom, so it should
> be modified with custom-set-variables, not with setq.  Don't ask.

No, that's not true.  You can setq any defcustom as if it was a defvar.
The former is only some macro that eventually expands to a defvar, but
contains some more metadata for the customize interface.

Bye,
Tassilo




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: reading compile.el, modifying settings
  2011-05-05 18:15   ` Tassilo Horn
@ 2011-05-05 18:34     ` Sam Steingold
  2011-05-05 19:09       ` Tassilo Horn
  0 siblings, 1 reply; 10+ messages in thread
From: Sam Steingold @ 2011-05-05 18:34 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Tassilo,

> * Tassilo Horn <gnffvyb@zrzore.sfs.bet> [2011-05-05 20:15:29 +0200]:
> Sam Steingold <sds@gnu.org> writes:
>>
>> compilation-error-regexp-alist is defined with defcustom, so it should
>> be modified with custom-set-variables, not with setq.  Don't ask.
>
> No, that's not true.  You can setq any defcustom as if it was a defvar.

Sure.  You can setq any symbol.
However, the _effect_ of setq on a variable defined with defcustom is
different - it is not respected by emacs on the same level as
custom-set-variables.
At least it was not a few years ago, when I had the same problem - my
setting being ignored - as Paul is having now.

1. some packages use symbol properties in addition to the symbol value,
   these are modified by custom-set-variables automatically

2. some custom variables have fancy setters which are called by
   custom-set-variables but not by setq (like symbol macros in CL)

In short, the rule of thumb is: do not use setq on custom variables, use
custom-set-variables instead.

-- 
Sam Steingold (http://sds.podval.org/) on CentOS release 5.6 (Final) X 11.0.60900031
http://honestreporting.com http://camera.org http://palestinefacts.org
http://ffii.org http://www.PetitionOnline.com/tap12009/ http://truepeace.org
"Syntactic sugar causes cancer of the semicolon."	-Alan Perlis




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: reading compile.el, modifying settings
  2011-05-05 18:34     ` Sam Steingold
@ 2011-05-05 19:09       ` Tassilo Horn
  2011-05-05 21:08         ` Sam Steingold
  0 siblings, 1 reply; 10+ messages in thread
From: Tassilo Horn @ 2011-05-05 19:09 UTC (permalink / raw)
  To: help-gnu-emacs

Sam Steingold <sds@gnu.org> writes:

Hi Sam,

>>> compilation-error-regexp-alist is defined with defcustom, so it should
>>> be modified with custom-set-variables, not with setq.  Don't ask.
>>
>> No, that's not true.  You can setq any defcustom as if it was a defvar.
>
> Sure.  You can setq any symbol.
> However, the _effect_ of setq on a variable defined with defcustom is
> different - it is not respected by emacs on the same level as
> custom-set-variables.
> At least it was not a few years ago, when I had the same problem - my
> setting being ignored - as Paul is having now.

If that really happens, I'd consider it a bug.

> 1. some packages use symbol properties in addition to the symbol value,
>    these are modified by custom-set-variables automatically

,----
| ;; foo is not defined before
| (setq foo 17)
| ;; now load its defcustom
| (defcustom foo 111
|   "Bla bla")
| ;; still has my value plus the props of the defcustom
| (cons foo (symbol-plist 'foo))
| ==> (17 standard-value (111) custom-requests nil variable-documentation "Bla bla")
`----

> 2. some custom variables have fancy setters which are called by
>    custom-set-variables but not by setq (like symbol macros in CL)

Yeah, but that has to be stated in the docs:

,----[ (info "(elisp)Variable Definitions") ]
|      If you specify the `:set' keyword, to make the variable take other
|      special actions when set through the customization buffer, the
|      variable's documentation string should tell the user specifically
|      how to do the same job in hand-written Lisp code.
`----

Good examples here are all those minor mode *variables*, which can be
customized to enable a mode globally, but to enable them from lisp, you
have to use the mode *function*:

  ;; Works
  (custom-set-variables
    '(hl-line-mode t))

  ;; Does not work (i.e., doesn't enable that mode)
  (setq hl-line-mode t)
  ;; so you need to use the mode function from lisp
  (hl-line-mode 1)

> In short, the rule of thumb is: do not use setq on custom variables,
> use custom-set-variables instead.

I really don't buy that.  My emacs is highly customized in plain lisp
only, so that I can comment what I do and structure it according to my
likings.

Bye,
Tassilo




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: reading compile.el, modifying settings
  2011-05-03 14:03 reading compile.el, modifying settings Paul Graham
  2011-05-05 10:44 ` Tassilo Horn
  2011-05-05 16:31 ` Sam Steingold
@ 2011-05-05 19:48 ` Tassilo Horn
  2 siblings, 0 replies; 10+ messages in thread
From: Tassilo Horn @ 2011-05-05 19:48 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Paul,

I've just tested what you are doing with a current emacs 24 bzr
checkout.

,----[ ~/test.el ]
| (require 'compile)  ; works
| ;; (load "compile") ;; works, too
| 
| (load "~/test2.el")
`----

,----[ ~/test2.el ]
| (setq compilation-error-regexp-alist "test")
`----

Now I start emacs using

  $ emacs -Q -l ~/test.el

and in there I have:

,----[ C-h v compilation-error-regexp-alist ]
| compilation-error-regexp-alist is a variable defined in `compile.el'.
| Its value is "test"
| Original value was 
| (absoft ... perl--Test2 perl--Test::Harness weblint)
`----

So I cannot reproduce the issue.

Bye,
Tassilo




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: reading compile.el, modifying settings
  2011-05-05 19:09       ` Tassilo Horn
@ 2011-05-05 21:08         ` Sam Steingold
  2011-05-06  7:13           ` Tassilo Horn
  0 siblings, 1 reply; 10+ messages in thread
From: Sam Steingold @ 2011-05-05 21:08 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Tassilo,

> * Tassilo Horn <gnffvyb@zrzore.sfs.bet> [2011-05-05 21:09:54 +0200]:
> Sam Steingold <sds@gnu.org> writes:
>> However, the _effect_ of setq on a variable defined with defcustom is
>> different - it is not respected by emacs on the same level as
>> custom-set-variables.
>> At least it was not a few years ago, when I had the same problem - my
>> setting being ignored - as Paul is having now.
>
> If that really happens, I'd consider it a bug.

Agreed.
However, these bugs are hard to reproduce, as you have just discovered
yourself.
It is much easier to work around them.

>> 1. some packages use symbol properties in addition to the symbol value,
>>    these are modified by custom-set-variables automatically
>
> ,----
> | ;; foo is not defined before
> | (setq foo 17)
> | ;; now load its defcustom
> | (defcustom foo 111
> |   "Bla bla")
> | ;; still has my value plus the props of the defcustom
> | (cons foo (symbol-plist 'foo))
> | ==> (17 standard-value (111) custom-requests nil variable-documentation "Bla bla")
> `----

that's my point - a custom variable is much more than just a symbol-value.

>> In short, the rule of thumb is: do not use setq on custom variables,
>> use custom-set-variables instead.
>
> I really don't buy that.

That's just as well because I am not selling anything.
I wonder, however, if my solution solves Paul's problem.

> My emacs is highly customized in plain lisp only, so that I can
> comment what I do and structure it according to my likings.

Mine too - and I use custom-set-variables for all custom vars in ~/.emacs.
And, of course, both setq and custom-set-variables are "plain lisp".



-- 
Sam Steingold (http://sds.podval.org/) on CentOS release 5.6 (Final) X 11.0.60900031
http://www.memritv.org http://camera.org http://mideasttruth.com
http://www.PetitionOnline.com/tap12009/ http://iris.org.il http://ffii.org
There are 3 kinds of people: those who can count and those who cannot.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: reading compile.el, modifying settings
  2011-05-05 21:08         ` Sam Steingold
@ 2011-05-06  7:13           ` Tassilo Horn
  0 siblings, 0 replies; 10+ messages in thread
From: Tassilo Horn @ 2011-05-06  7:13 UTC (permalink / raw)
  To: help-gnu-emacs

Sam Steingold <sds@gnu.org> writes:

Hi Sam,

>> ,----
>> | ;; foo is not defined before
>> | (setq foo 17)
>> | ;; now load its defcustom
>> | (defcustom foo 111
>> |   "Bla bla")
>> | ;; still has my value plus the props of the defcustom
>> | (cons foo (symbol-plist 'foo))
>> | ==> (17 standard-value (111) custom-requests nil variable-documentation
>> | "Bla bla")
>> `----
>
> that's my point - a custom variable is much more than just a
> symbol-value.

Yes, and my point is that setq does no harm either.

> I wonder, however, if my solution solves Paul's problem.

Ditto.

>> My emacs is highly customized in plain lisp only, so that I can
>> comment what I do and structure it according to my likings.
>
> Mine too - and I use custom-set-variables for all custom vars in
> ~/.emacs.  And, of course, both setq and custom-set-variables are
> "plain lisp".

Sure, with plain list I've meant any lisp not beginning with
custom-*. ;-)

But assuming you are right, why don't the docs state anything about that
users should use `custom-set-variables'?  And why is there no `setc'
macro for users preferring customization in lisp for setting variables,
which expands to a `custom-set-variables' form for defcustoms?

(info "(emacs)Init Examples") setqs custom variables quite happily...

Bye,
Tassilo




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: reading compile.el, modifying settings
  2011-05-05 10:44 ` Tassilo Horn
@ 2011-05-12 12:49   ` Oleksandr Gavenko
  0 siblings, 0 replies; 10+ messages in thread
From: Oleksandr Gavenko @ 2011-05-12 12:49 UTC (permalink / raw)
  To: help-gnu-emacs

On 05.05.2011 13:44, Tassilo Horn wrote:
> Paul Graham<pgraham@oasys-ds.com>  writes:
>
> Hi Paul,
>
>> I use compile mode, but I have my own set of compiler
>> message regexps.  I try to set them up as follows:
>>
>> .emacs:
>>
>>      (load "compile")
>>      (load-file "~/emacs/compile-settings.el")
>>
>> compile-settings.el:
>>
>>      (setq compilation-error-regexp-alist ... )
>
> That looks good, except one would normally do (require 'compile), but
> that shouldn't be any different here.
>
I use such code (as example):

(eval-after-load 'compile
   '(progn
      ;; My funny error messages.
      (add-to-list 'compilation-error-regexp-alist '("^\\( +\\[csc\\] 
\\|\\)\\(.*\\)(\\([0-9]*\\),\\([0-9]*\\)):" 2 3 4))
      (add-to-list 'compilation-error-regexp-alist '("^ 
*\\(.*\\)(\\([0-9]*\\)) +:" 1 2))
      (add-to-list 'compilation-error-regexp-alist 
'("^\"?\\([^\"]*\\)\"?,\\([0-9]*\\) .*\\[.*\\]: " 1 2)) ; KEIL compiler
      (when (boundp 'compilation-mode-font-lock-keywords)
        (add-to-list 'compilation-mode-font-lock-keywords 
'("\\(/[Oo][Uu][Tt]:[^[:blank:]]+\\)" . 1))
        (add-to-list 'compilation-mode-font-lock-keywords 
'("[[:blank:]]\\(/F[oe][^[:blank:]]+\\)" . 1))
        )
      ))




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-05-12 12:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-03 14:03 reading compile.el, modifying settings Paul Graham
2011-05-05 10:44 ` Tassilo Horn
2011-05-12 12:49   ` Oleksandr Gavenko
2011-05-05 16:31 ` Sam Steingold
2011-05-05 18:15   ` Tassilo Horn
2011-05-05 18:34     ` Sam Steingold
2011-05-05 19:09       ` Tassilo Horn
2011-05-05 21:08         ` Sam Steingold
2011-05-06  7:13           ` Tassilo Horn
2011-05-05 19:48 ` Tassilo Horn

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.