* bug#4399: 23.1; let a file know it was run with --script
@ 2009-09-11 2:06 Tom Tromey
2009-09-11 3:58 ` Glenn Morris
0 siblings, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2009-09-11 2:06 UTC (permalink / raw)
To: bug-gnu-emacs
Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.
Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list,
and to the gnu.emacs.bug news group.
Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:
On occasion it would be convenient to have a .el file which could check
whether it was invoked with --script. (Python can do this, it is quite
handy there.)
I don't think there is a way to do this currently.
If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
`bt full' and `xbacktrace'.
If you would like to further debug the crash, please read the file
/usr/share/emacs/23.1/etc/DEBUG for instructions.
In GNU Emacs 23.1.1 (i386-redhat-linux-gnu, GTK+ Version 2.16.5)
of 2009-08-26 on x86-2.fedora.phx.redhat.com
Windowing system distributor `The X.Org Foundation', version 11.0.10601901
configured using `configure '--build=i386-redhat-linux-gnu' '--host=i386-redhat-linux-gnu' '--target=i586-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--with-dbus' '--with-gif' '--with-jpeg' '--with-png' '--with-rsvg' '--with-tiff' '--with-xft' '--with-xpm' '--with-x-toolkit=gtk' 'build_alias=i386-redhat-linux-gnu' 'host_alias=i386-redhat-linux-gnu' 'target_alias=i586-redhat-linux-gnu' 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-bu
ffer-size=4 -m32 -march=i586 -mtune=generic -fasynchronous-unwind-tables''
Important settings:
value of $LC_ALL: nil
value of $LC_COLLATE: nil
value of $LC_CTYPE: nil
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: en_US.UTF-8
value of $XMODIFIERS: nil
locale-coding-system: utf-8-unix
default-enable-multibyte-characters: t
Major mode: Group
Minor modes in effect:
gnus-agent-mode: t
shell-dirtrack-mode: t
erc-list-mode: t
erc-menu-mode: t
erc-autojoin-mode: t
erc-ring-mode: t
erc-pcomplete-mode: t
erc-track-mode: t
erc-track-minor-mode: t
erc-match-mode: t
erc-button-mode: t
erc-fill-mode: t
erc-stamp-mode: t
erc-netsplit-mode: t
erc-spelling-mode: t
erc-truncate-mode: t
diff-auto-refine-mode: t
gnus-undo-mode: t
erc-status-mode: t
erc-services-mode: t
erc-networks-mode: t
erc-irccontrols-mode: t
erc-noncommands-mode: t
erc-move-to-prompt-mode: t
erc-readonly-mode: t
tooltip-mode: t
mouse-wheel-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
global-auto-composition-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
Recent input:
q SPC 5 0 <return> M-> SPC Q y C-n C-n C-SPC C-u E
SPC C-u E q C-z o <f10> <f10> C-z o C-r o t h e r C-a
SPC 5 0 <return> M-> C-u C-u C-p C-u C-n p = C-u E
E E E E E S-SPC E S-SPC E S-SPC E S-SPC E C-u C-p C-n
M S-SPC M S-SPC M S-SPC q s C-u C-u C-n p p SPC 5 0
<return> M-> q SPC M-> q C-s a r c C-a C-s f r C-a
SPC 5 0 <return> M-> Q y s ESC [ > 1 ; 2 0 0 5 ; 0
c C-x b * G TAB RET 1 g n n SPC ESC > Q y C-r o t h
e r C-a SPC 5 0 RET ESC > C-u C-p C-p p C-u RET RET
RET RET RET C-u RET M SPC n M SPC SPC E E SPC SPC SPC
E = C-l C-a ESC v ESC v ESC v q s ESC [ 2 1 ~ ESC [
2 1 ~ ESC [ 2 1 ~ ESC [ 2 1 ~ ESC [ 2 1 ~ ESC [ 2 1
~ C-v C-l p p p SPC E q n n SPC ESC > C-p C-p E E q
C-l C-u C-n C-u C-n C-u C-n C-l n SPC 5 RET Q y n n
n SPC 5 0 RET ESC > Q y p SPC 5 0 RET ESC > Q y s ESC
v ESC [ 2 1 ~ ESC [ 2 1 ~ ESC [ 2 1 ~ ESC [ 2 1 ~ ESC
[ 2 1 ~ ESC x r e p o r t - e m TAB b TAB RET
Recent messages:
Retrieving newsgroup: nnml:mail.cygnus...
Fetching headers for nnml:mail.cygnus...done
Generating summary...done
Mark set
Discard changes to this group and exit? (y or n)
(No changes need to be saved)
Saving /home/tromey/.newsrc.eld...
Saving file /home/tromey/.newsrc.eld...
Wrote /home/tromey/.newsrc.eld
Saving /home/tromey/.newsrc.eld...done
Tom
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#4399: 23.1; let a file know it was run with --script
2009-09-11 2:06 bug#4399: 23.1; let a file know it was run with --script Tom Tromey
@ 2009-09-11 3:58 ` Glenn Morris
2009-09-18 17:34 ` Tom Tromey
0 siblings, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2009-09-11 3:58 UTC (permalink / raw)
To: Tom Tromey; +Cc: 4399
Tom Tromey wrote:
> On occasion it would be convenient to have a .el file which could check
> whether it was invoked with --script.
You can check for a non-nil value of `noninteractive'. Or do you need
to distinguish --batch from --script for some reason?
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#4399: 23.1; let a file know it was run with --script
2009-09-11 3:58 ` Glenn Morris
@ 2009-09-18 17:34 ` Tom Tromey
2009-09-18 18:04 ` Glenn Morris
2022-02-07 0:54 ` bug#4399: simple way to identify top-level --script file Lars Ingebrigtsen
0 siblings, 2 replies; 10+ messages in thread
From: Tom Tromey @ 2009-09-18 17:34 UTC (permalink / raw)
To: Glenn Morris; +Cc: 4399
>>>>> "GM" == Glenn Morris <rgm@gnu.org> writes:
Sorry for the delay in my reply.
>> On occasion it would be convenient to have a .el file which could check
>> whether it was invoked with --script.
GM> You can check for a non-nil value of `noninteractive'. Or do you need
GM> to distinguish --batch from --script for some reason?
I was hoping for something like the python idiom:
if __name__ == "__main__":
... this lets a file determine if it was invoked "as the main program".
My specific use was for tests: I want "emacs --script test.el" to run
the tests, but I want to be able to load the file just to get the defuns
without running the test suite.
Tom
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#4399: 23.1; let a file know it was run with --script
2009-09-18 17:34 ` Tom Tromey
@ 2009-09-18 18:04 ` Glenn Morris
2009-09-18 18:56 ` Tom Tromey
2022-02-07 0:54 ` bug#4399: simple way to identify top-level --script file Lars Ingebrigtsen
1 sibling, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2009-09-18 18:04 UTC (permalink / raw)
To: Tom Tromey; +Cc: 4399
Tom Tromey wrote:
> My specific use was for tests: I want "emacs --script test.el" to run
> the tests, but I want to be able to load the file just to get the defuns
> without running the test suite.
It sounds like noninteractive will work fine (you could perhaps check
command-line-args if you want finer control)? Or use the traditional:
emacs -batch -l ./test.el -f batch-run-tests
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#4399: 23.1; let a file know it was run with --script
2009-09-18 18:04 ` Glenn Morris
@ 2009-09-18 18:56 ` Tom Tromey
2009-09-18 19:00 ` Glenn Morris
0 siblings, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2009-09-18 18:56 UTC (permalink / raw)
To: Glenn Morris; +Cc: 4399
>>>>> "GM" == Glenn Morris <rgm@gnu.org> writes:
GM> It sounds like noninteractive will work fine (you could perhaps check
GM> command-line-args if you want finer control)? Or use the traditional:
I don't think that has the same effect if you load multiple such files.
I only want the "main" one to eval the code.
GM> emacs -batch -l ./test.el -f batch-run-tests
This won't work if you want to use #! to start a script.
I guess I can work around this by writing a new .el that just loads
things and evals something.
Tom
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#4399: 23.1; let a file know it was run with --script
2009-09-18 18:56 ` Tom Tromey
@ 2009-09-18 19:00 ` Glenn Morris
2009-09-19 1:11 ` Tom Tromey
0 siblings, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2009-09-18 19:00 UTC (permalink / raw)
To: Tom Tromey; +Cc: 4399
Tom Tromey wrote:
>>>>>> "GM" == Glenn Morris <rgm@gnu.org> writes:
>
> GM> It sounds like noninteractive will work fine (you could perhaps check
> GM> command-line-args if you want finer control)?
>
> I don't think that has the same effect if you load multiple such files.
> I only want the "main" one to eval the code.
That's what I was suggesting checking command-line-args for.
If you still need some extra functionality, we can leave reopen this
as a wishlist.
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#4399: 23.1; let a file know it was run with --script
2009-09-18 19:00 ` Glenn Morris
@ 2009-09-19 1:11 ` Tom Tromey
2009-09-19 3:19 ` Glenn Morris
0 siblings, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2009-09-19 1:11 UTC (permalink / raw)
To: Glenn Morris; +Cc: 4399
GM> That's what I was suggesting checking command-line-args for.
Ah, now I get it.
I guess this will work as long as I don't mind hard-coding in the file's
name. Unless there's a way to also get this?
thanks,
Tom
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#4399: 23.1; let a file know it was run with --script
2009-09-19 1:11 ` Tom Tromey
@ 2009-09-19 3:19 ` Glenn Morris
2009-09-19 3:25 ` Processed: " Emacs bug Tracking System
0 siblings, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2009-09-19 3:19 UTC (permalink / raw)
To: Tom Tromey; +Cc: 4399
reopen 4399
severity 4399 wishlist
retitle 4399 simple way to identify top-level --script file
stop
Tom Tromey wrote:
> I guess this will work as long as I don't mind hard-coding in the file's
> name. Unless there's a way to also get this?
On reflection, it seems a pretty poor solution, so I'll reopen this as
a wishlist.
Summary:
When using --script, it would be nice if there was a simple way for
the file so loaded to identify itself as the "main file", distinct
from any libraries it might require.
(I'd probably just use a hack like:
#!/bin/sh
exec emacs -batch -l test.el -f batch-run-test
but I suppose this is against the spirit of --script)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Processed: Re: bug#4399: 23.1; let a file know it was run with --script
2009-09-19 3:19 ` Glenn Morris
@ 2009-09-19 3:25 ` Emacs bug Tracking System
0 siblings, 0 replies; 10+ messages in thread
From: Emacs bug Tracking System @ 2009-09-19 3:25 UTC (permalink / raw)
To: Glenn Morris; +Cc: Emacs Bugs
Processing commands for control@emacsbugs.donarmstrong.com:
> reopen 4399
Bug #4399 {Done: Glenn Morris <rgm@gnu.org>} [emacs] 23.1; let a file know it was run with --script
> severity 4399 wishlist
Bug #4399 [emacs] 23.1; let a file know it was run with --script
Severity set to 'wishlist' from 'normal'
> retitle 4399 simple way to identify top-level --script file
Bug #4399 [emacs] 23.1; let a file know it was run with --script
Changed bug title to 'simple way to identify top-level --script file' from '23.1; let a file know it was run with --script '
> stop
Stopping processing here.
Please contact me if you need assistance.
Don Armstrong
(administrator, Emacs bugs database)
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#4399: simple way to identify top-level --script file
2009-09-18 17:34 ` Tom Tromey
2009-09-18 18:04 ` Glenn Morris
@ 2022-02-07 0:54 ` Lars Ingebrigtsen
1 sibling, 0 replies; 10+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-07 0:54 UTC (permalink / raw)
To: Tom Tromey; +Cc: Glenn Morris, 4399
Tom Tromey <tromey@redhat.com> writes:
> I was hoping for something like the python idiom:
>
> if __name__ == "__main__":
>
> ... this lets a file determine if it was invoked "as the main program".
>
> My specific use was for tests: I want "emacs --script test.el" to run
> the tests, but I want to be able to load the file just to get the defuns
> without running the test suite.
(I'm going through old bug reports that unfortunately weren't resolved
at the time.)
In my opinion, I think it would be too niche to add a special mechanism
for this. You can use --eval '(setq something-to-react-to t)' --script
... if you want to have different things happening in this case.
So I'm closing this bug report.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-02-07 0:54 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-11 2:06 bug#4399: 23.1; let a file know it was run with --script Tom Tromey
2009-09-11 3:58 ` Glenn Morris
2009-09-18 17:34 ` Tom Tromey
2009-09-18 18:04 ` Glenn Morris
2009-09-18 18:56 ` Tom Tromey
2009-09-18 19:00 ` Glenn Morris
2009-09-19 1:11 ` Tom Tromey
2009-09-19 3:19 ` Glenn Morris
2009-09-19 3:25 ` Processed: " Emacs bug Tracking System
2022-02-07 0:54 ` bug#4399: simple way to identify top-level --script file Lars Ingebrigtsen
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.