* Really noninteractive
@ 2020-02-20 14:39 Lars Ingebrigtsen
2020-02-20 15:23 ` Andreas Schwab
2020-02-20 15:32 ` Ihor Radchenko
0 siblings, 2 replies; 14+ messages in thread
From: Lars Ingebrigtsen @ 2020-02-20 14:39 UTC (permalink / raw)
To: emacs-devel
I somehow expected
(let ((noninteractive t)) (read-string "foo: "))
to error out, since the documentation of the variable is:
---
Non-nil means Emacs is running without interactive terminal.
---
I'm trying to use Emacs from a server context, and would prefer that
Emacs signal an error whenever you tell it to do something interactive
rather than hang forever.
Is there a way to do this that I've missed?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Really noninteractive
2020-02-20 14:39 Really noninteractive Lars Ingebrigtsen
@ 2020-02-20 15:23 ` Andreas Schwab
2020-02-20 17:42 ` Lars Ingebrigtsen
2020-02-20 19:05 ` Clément Pit-Claudel
2020-02-20 15:32 ` Ihor Radchenko
1 sibling, 2 replies; 14+ messages in thread
From: Andreas Schwab @ 2020-02-20 15:23 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: emacs-devel
On Feb 20 2020, Lars Ingebrigtsen wrote:
> I'm trying to use Emacs from a server context, and would prefer that
> Emacs signal an error whenever you tell it to do something interactive
> rather than hang forever.
Run emacs in batch mode.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Really noninteractive
2020-02-20 14:39 Really noninteractive Lars Ingebrigtsen
2020-02-20 15:23 ` Andreas Schwab
@ 2020-02-20 15:32 ` Ihor Radchenko
2020-02-20 17:42 ` Lars Ingebrigtsen
1 sibling, 1 reply; 14+ messages in thread
From: Ihor Radchenko @ 2020-02-20 15:32 UTC (permalink / raw)
To: Lars Ingebrigtsen, emacs-devel
> Is there a way to do this that I've missed?
The Elisp manual says:
-- Variable: noninteractive
This variable is non-‘nil’ when Emacs is running in batch mode.
So, in your case, emacs does not really hang, but awaits input from
terminal. You can test it by running emacs in batch mode (as suggested
by Andreas):
emacs -Q --batch --eval "(let ((noninteractive t)) (read-string \"foo: \"))"
Probably, docstring needs to be clarified to conform with the manual.
Best,
Ihor
Lars Ingebrigtsen <larsi@gnus.org> writes:
> I somehow expected
>
> (let ((noninteractive t)) (read-string "foo: "))
>
> to error out, since the documentation of the variable is:
>
> ---
> Non-nil means Emacs is running without interactive terminal.
> ---
>
> I'm trying to use Emacs from a server context, and would prefer that
> Emacs signal an error whenever you tell it to do something interactive
> rather than hang forever.
>
> Is there a way to do this that I've missed?
>
> --
> (domestic pets only, the antidote for overdose, milk.)
> bloggy blog: http://lars.ingebrigtsen.no
>
>
--
Ihor Radchenko,
PhD,
Center for Advancing Materials Performance from the Nanoscale (CAMP-nano)
State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong University, Xi'an, China
Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Really noninteractive
2020-02-20 15:23 ` Andreas Schwab
@ 2020-02-20 17:42 ` Lars Ingebrigtsen
2020-02-24 9:16 ` Andreas Schwab
2020-02-20 19:05 ` Clément Pit-Claudel
1 sibling, 1 reply; 14+ messages in thread
From: Lars Ingebrigtsen @ 2020-02-20 17:42 UTC (permalink / raw)
To: Andreas Schwab; +Cc: emacs-devel
Andreas Schwab <schwab@suse.de> writes:
>> I'm trying to use Emacs from a server context, and would prefer that
>> Emacs signal an error whenever you tell it to do something interactive
>> rather than hang forever.
>
> Run emacs in batch mode.
I don't want to do that -- I just want to ensure that certain code paths
aren't interactive.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Really noninteractive
2020-02-20 15:32 ` Ihor Radchenko
@ 2020-02-20 17:42 ` Lars Ingebrigtsen
2020-02-20 17:56 ` Noam Postavsky
0 siblings, 1 reply; 14+ messages in thread
From: Lars Ingebrigtsen @ 2020-02-20 17:42 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: emacs-devel
Ihor Radchenko <yantar92@gmail.com> writes:
> The Elisp manual says:
>
> -- Variable: noninteractive
> This variable is non-‘nil’ when Emacs is running in batch mode.
>
> So, in your case, emacs does not really hang, but awaits input from
> terminal.
I think that's what I said? And I wondered whether there was any way to
make that error out instead of prompting.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Really noninteractive
2020-02-20 17:42 ` Lars Ingebrigtsen
@ 2020-02-20 17:56 ` Noam Postavsky
2020-02-20 18:36 ` Lars Ingebrigtsen
0 siblings, 1 reply; 14+ messages in thread
From: Noam Postavsky @ 2020-02-20 17:56 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: Ihor Radchenko, emacs-devel
On Thu, 20 Feb 2020 at 12:43, Lars Ingebrigtsen <larsi@gnus.org> wrote:
> > -- Variable: noninteractive
> > This variable is non-‘nil’ when Emacs is running in batch mode.
> >
> > So, in your case, emacs does not really hang, but awaits input from
> > terminal.
>
> I think that's what I said? And I wondered whether there was any way to
> make that error out instead of prompting.
I think if you redirect stdin from /dev/null any
noninteractive/batch-mode reading will fail immediately.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Really noninteractive
2020-02-20 17:56 ` Noam Postavsky
@ 2020-02-20 18:36 ` Lars Ingebrigtsen
2020-02-20 19:11 ` dick.r.chiang
0 siblings, 1 reply; 14+ messages in thread
From: Lars Ingebrigtsen @ 2020-02-20 18:36 UTC (permalink / raw)
To: Noam Postavsky; +Cc: Ihor Radchenko, emacs-devel
Noam Postavsky <npostavs@gmail.com> writes:
> I think if you redirect stdin from /dev/null any
> noninteractive/batch-mode reading will fail immediately.
Yes, but that's not what I want. :-) I want to say "this function
call, in this otherwise totally normal Emacs, should not prompt".
I.e., what my original example said:
(let ((noninteractive t)) (read-string "foo"))
=> error
But it's starting to sound like nobody's implemented this?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Really noninteractive
2020-02-20 15:23 ` Andreas Schwab
2020-02-20 17:42 ` Lars Ingebrigtsen
@ 2020-02-20 19:05 ` Clément Pit-Claudel
1 sibling, 0 replies; 14+ messages in thread
From: Clément Pit-Claudel @ 2020-02-20 19:05 UTC (permalink / raw)
To: emacs-devel
On 2020-02-20 10:23, Andreas Schwab wrote:
> On Feb 20 2020, Lars Ingebrigtsen wrote:
>
>> I'm trying to use Emacs from a server context, and would prefer that
>> Emacs signal an error whenever you tell it to do something interactive
>> rather than hang forever.
>
> Run emacs in batch mode.
How does that help? It still prompts and waits for an answer, AFAICT.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Really noninteractive
2020-02-20 18:36 ` Lars Ingebrigtsen
@ 2020-02-20 19:11 ` dick.r.chiang
2020-02-21 13:20 ` Noam Postavsky
0 siblings, 1 reply; 14+ messages in thread
From: dick.r.chiang @ 2020-02-20 19:11 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: emacs-devel, Noam Postavsky, Ihor Radchenko
LI> Yes, but that's not what I want. :-) I want to say "this function call,
LI> in this otherwise totally normal Emacs, should not prompt".
Okay, so you've established that `noninteractive` only diverts "normal emacs"
to call `read_minibuf_noninteractive()` which in turn attempts to get input
from stdin, which as we all know by now, *you do not want*.
It's not clear what else you expect from us apart from some hackey function
advising to signal instead of calling `read_minibuf_noninteractive()`.
I am inclined to go with GP's shunting of stdin to /dev/null to avoid having
to change the C code. Most well behaved server daemons will do that... shunt
stdin to /dev/null I mean.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Really noninteractive
2020-02-20 19:11 ` dick.r.chiang
@ 2020-02-21 13:20 ` Noam Postavsky
2020-02-21 14:11 ` Eli Zaretskii
0 siblings, 1 reply; 14+ messages in thread
From: Noam Postavsky @ 2020-02-21 13:20 UTC (permalink / raw)
To: dick.r.chiang; +Cc: Lars Ingebrigtsen, Ihor Radchenko, emacs-devel
On Thu, 20 Feb 2020 at 14:11, <dick.r.chiang@gmail.com> wrote:
>
> LI> Yes, but that's not what I want. :-) I want to say "this function call,
> LI> in this otherwise totally normal Emacs, should not prompt".
>
> Okay, so you've established that `noninteractive` only diverts "normal emacs"
> to call `read_minibuf_noninteractive()` which in turn attempts to get input
> from stdin
See, I assumed this as well after reading the prior messages of this
thread. But I just tried it out now, and it actually does not do any
diversion. I'm actually not entirely sure why, I guess changes to the
`noninteractive' variable from lisp don't reach the C level?
So the redirection of stdin only helps in the --batch case.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Really noninteractive
2020-02-21 13:20 ` Noam Postavsky
@ 2020-02-21 14:11 ` Eli Zaretskii
0 siblings, 0 replies; 14+ messages in thread
From: Eli Zaretskii @ 2020-02-21 14:11 UTC (permalink / raw)
To: Noam Postavsky; +Cc: larsi, emacs-devel, dick.r.chiang, yantar92
> From: Noam Postavsky <npostavs@gmail.com>
> Date: Fri, 21 Feb 2020 08:20:48 -0500
> Cc: Lars Ingebrigtsen <larsi@gnus.org>, Ihor Radchenko <yantar92@gmail.com>,
> emacs-devel <emacs-devel@gnu.org>
>
> I guess changes to the `noninteractive' variable from lisp don't
> reach the C level?
I don't think this variable was supposed to be set from Lisp at all.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Really noninteractive
2020-02-20 17:42 ` Lars Ingebrigtsen
@ 2020-02-24 9:16 ` Andreas Schwab
2020-02-24 12:55 ` Noam Postavsky
0 siblings, 1 reply; 14+ messages in thread
From: Andreas Schwab @ 2020-02-24 9:16 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: emacs-devel
On Feb 20 2020, Lars Ingebrigtsen wrote:
> Andreas Schwab <schwab@suse.de> writes:
>
>>> I'm trying to use Emacs from a server context, and would prefer that
>>> Emacs signal an error whenever you tell it to do something interactive
>>> rather than hang forever.
>>
>> Run emacs in batch mode.
>
> I don't want to do that -- I just want to ensure that certain code paths
> aren't interactive.
Set standard-input to a function that throws.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Really noninteractive
2020-02-24 9:16 ` Andreas Schwab
@ 2020-02-24 12:55 ` Noam Postavsky
2020-02-24 13:03 ` Lars Ingebrigtsen
0 siblings, 1 reply; 14+ messages in thread
From: Noam Postavsky @ 2020-02-24 12:55 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Lars Ingebrigtsen, emacs-devel
On Mon, 24 Feb 2020 at 04:17, Andreas Schwab <schwab@suse.de> wrote:
> > I don't want to do that -- I just want to ensure that certain code paths
> > aren't interactive.
>
> Set standard-input to a function that throws.
`read-string' doesn't use `standard-input'. I think only `read' does.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Really noninteractive
2020-02-24 12:55 ` Noam Postavsky
@ 2020-02-24 13:03 ` Lars Ingebrigtsen
0 siblings, 0 replies; 14+ messages in thread
From: Lars Ingebrigtsen @ 2020-02-24 13:03 UTC (permalink / raw)
To: Noam Postavsky; +Cc: Andreas Schwab, emacs-devel
Noam Postavsky <npostavs@gmail.com> writes:
> `read-string' doesn't use `standard-input'. I think only `read' does.
Indeed.
By the way, the doc string for read is oddly phrased:
STREAM or the value of ‘standard-input’ may be:
a buffer (read from point and advance it)
a marker (read from where it points and advance it)
a function (call it with no arguments for each character,
call it with a char as argument to push a char back)
a string (takes text from string, starting at the beginning)
t (read text line using minibuffer and use it, or read from
standard input in batch mode).
All of these are odd, but the "call it with no arguments" etc is
particularly befuddling. I think what happens is that the function is
called with no arguments, and should return a character (and so on)?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2020-02-24 13:03 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-20 14:39 Really noninteractive Lars Ingebrigtsen
2020-02-20 15:23 ` Andreas Schwab
2020-02-20 17:42 ` Lars Ingebrigtsen
2020-02-24 9:16 ` Andreas Schwab
2020-02-24 12:55 ` Noam Postavsky
2020-02-24 13:03 ` Lars Ingebrigtsen
2020-02-20 19:05 ` Clément Pit-Claudel
2020-02-20 15:32 ` Ihor Radchenko
2020-02-20 17:42 ` Lars Ingebrigtsen
2020-02-20 17:56 ` Noam Postavsky
2020-02-20 18:36 ` Lars Ingebrigtsen
2020-02-20 19:11 ` dick.r.chiang
2020-02-21 13:20 ` Noam Postavsky
2020-02-21 14:11 ` Eli Zaretskii
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).