unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* in batch or during test
@ 2015-04-21 11:13 Phillip Lord
  0 siblings, 0 replies; 4+ messages in thread
From: Phillip Lord @ 2015-04-21 11:13 UTC (permalink / raw)
  To: help-gnu-emacs



Is there a way to discover if Emacs is being run in batch and/or running
a test?

I have a package that uses "after-change-functions" and several other
"self-niling" hooks. If I have a bug in my package, the hook function
automatically gets removed, leaving the package in an inconsistent state
(because one hook may have gone but the others remain). So instead I use
"condition-case" to catch any errors and disable the entire package
(i.e. all of the hook functions) if an error occurs.

This works well, but unfortunately effectively swallows the backtrace.
Particularly annoying when I am running automated tests. So, I want to
write a macro like `condition-case-unless-debug' but which is "unless
running in batch or running ert". But I don't know how to find out if I
am in batch or running ert!

Phil



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

* Re: in batch or during test
       [not found] <mailman.1261.1429614787.904.help-gnu-emacs@gnu.org>
@ 2015-04-21 12:08 ` Rusi
  2015-04-21 14:39   ` Phillip Lord
  2015-04-21 19:21 ` Ted Zlatanov
  1 sibling, 1 reply; 4+ messages in thread
From: Rusi @ 2015-04-21 12:08 UTC (permalink / raw)
  To: help-gnu-emacs

On Tuesday, April 21, 2015 at 4:43:09 PM UTC+5:30, Phil Lord wrote:
> Is there a way to discover if Emacs is being run in batch and/or running
> a test?
> 
> I have a package that uses "after-change-functions" and several other
> "self-niling" hooks. If I have a bug in my package, the hook function
> automatically gets removed, leaving the package in an inconsistent state
> (because one hook may have gone but the others remain). So instead I use
> "condition-case" to catch any errors and disable the entire package
> (i.e. all of the hook functions) if an error occurs.
> 
> This works well, but unfortunately effectively swallows the backtrace.
> Particularly annoying when I am running automated tests. So, I want to
> write a macro like `condition-case-unless-debug' but which is "unless
> running in batch or running ert". But I don't know how to find out if I
> am in batch or running ert!
> 
> Phil

Maybe you want the variable 'noninteractive'?
(info "(elisp)batch mode")


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

* Re: in batch or during test
  2015-04-21 12:08 ` in batch or during test Rusi
@ 2015-04-21 14:39   ` Phillip Lord
  0 siblings, 0 replies; 4+ messages in thread
From: Phillip Lord @ 2015-04-21 14:39 UTC (permalink / raw)
  To: Rusi; +Cc: help-gnu-emacs

Rusi <rustompmody@gmail.com> writes:
>> This works well, but unfortunately effectively swallows the backtrace.
>> Particularly annoying when I am running automated tests. So, I want to
>> write a macro like `condition-case-unless-debug' but which is "unless
>> running in batch or running ert". But I don't know how to find out if I
>> am in batch or running ert!
>> 
>> Phil
>
> Maybe you want the variable 'noninteractive'?
> (info "(elisp)batch mode")


Perfect, yes! I apropos'ed for "batch", but couldn't find it.

Phil



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

* Re: in batch or during test
       [not found] <mailman.1261.1429614787.904.help-gnu-emacs@gnu.org>
  2015-04-21 12:08 ` in batch or during test Rusi
@ 2015-04-21 19:21 ` Ted Zlatanov
  1 sibling, 0 replies; 4+ messages in thread
From: Ted Zlatanov @ 2015-04-21 19:21 UTC (permalink / raw)
  To: help-gnu-emacs

On Tue, 21 Apr 2015 12:13:00 +0100 phillip.lord@newcastle.ac.uk (Phillip Lord) wrote: 

PL> Is there a way to discover if Emacs is being run in batch and/or running
PL> a test?

I thought this article was very good on the topic of scripting with
Emacs: http://www.lunaryorn.com/2014/08/12/emacs-script-pitfalls.html

Ted


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

end of thread, other threads:[~2015-04-21 19:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.1261.1429614787.904.help-gnu-emacs@gnu.org>
2015-04-21 12:08 ` in batch or during test Rusi
2015-04-21 14:39   ` Phillip Lord
2015-04-21 19:21 ` Ted Zlatanov
2015-04-21 11:13 Phillip Lord

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).