unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* RE: Can't interrupt directory_files_internal run fromtimer-event-handler
@ 2005-08-05 12:01 klaus.berndl
  2005-08-05 12:53 ` Juanma Barranquero
  2005-08-09 23:29 ` Stefan Monnier
  0 siblings, 2 replies; 11+ messages in thread
From: klaus.berndl @ 2005-08-05 12:01 UTC (permalink / raw)


Klaus Zeitler wrote:
> The following problem occurs with CVS emacs + ECB under Solaris 5.8.
> 
> While ECB performs its stealth update activities, emacs sometimes
> seems to 
> hang for a long time.
> gdb shows the following function and backtrace:
> 
> directory_files_internal (directory=16076323, full=3313665,
>     match=3313665, nosort=3313713, attrs=0, id_format=3313665)
>     at /vol/freeware/cvs/emacs/head/emacs/src/dired.c:226
> 226           if (dp == NULL && errno == EAGAIN)
> (gdb) p directory
> $1 = 16076323
> (gdb) pr
> "/vol/cld_scratch"
> 
> (gdb) xbacktrace
>  "directory-files"
>  "apply"
>  "ecb-directory-files"
>  "ecb-check-emptyness-of-dir"
>  "ecb-stealthy-empty-dir-check"
>  "ecb-stealthy-updates"
>  "apply"
>  "byte-code"
>  "timer-event-handler"
> 
> I think emacs waits for readdir in dired.c:223 to complete and
> unfortunately C-g doesn't work during stealthy update.

ECB encapslates ist "stealthy" tasks in a loop like:

        (while (and (not (input-pending-p))
                ...

So IMHO C-g should work....

AFAIK there is a new macro in CVS named `while-no-input' (there
was a discussion some time ago).... Could using this macro
solve problems like that posted from the OP??

Ciao,
Klaus

> 
> The culprit BTW is a mount point to a VAX cluster that e.g. need 20
> minutes 
> to return from 'M-x eval-expression (directory-files
> "/vol/cld_scratch")'. While I can interrupt 'M-x eval-expression
> (directory-files "/vol/cld_scratch")' with C-g just fine, C-g has no
> effect when this command is run from timer-event-handler.
> 
>>  Klaus Zeitler      Lucent Technologies  |
>>  Email:             kzeitler@lucent.com  |
>  ------------------------------------------
> ---
> The only problem with being a man of leisure
> is that you can never stop and take a rest.
> 
> 
> _______________________________________________
> Emacs-devel mailing list
> Emacs-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: Can't interrupt directory_files_internal run fromtimer-event-handler
  2005-08-05 12:01 klaus.berndl
@ 2005-08-05 12:53 ` Juanma Barranquero
  2005-08-06  6:27   ` Richard M. Stallman
  2005-08-09 23:29 ` Stefan Monnier
  1 sibling, 1 reply; 11+ messages in thread
From: Juanma Barranquero @ 2005-08-05 12:53 UTC (permalink / raw)


On 8/5/05, klaus.berndl@sdm.de <klaus.berndl@sdm.de> wrote:

> AFAIK there is a new macro in CVS named `while-no-input' (there
> was a discussion some time ago)....

BTW, `while-no-input' and `throw-on-input' are not documented on the
Emacs Lisp Reference; and the docstring for `throw-on-input' is
suboptimal:

  If non-nil, any keyboard input throws to this symbol.
  The value of that variable is passed to `quit-flag' and later causes a
  peculiar kind of quitting.

-- 
                    /L/e/k/t/u

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

* Re: Can't interrupt directory_files_internal run fromtimer-event-handler
  2005-08-05 12:53 ` Juanma Barranquero
@ 2005-08-06  6:27   ` Richard M. Stallman
  2005-08-06 11:58     ` Juanma Barranquero
  2005-08-06 23:39     ` Kim F. Storm
  0 siblings, 2 replies; 11+ messages in thread
From: Richard M. Stallman @ 2005-08-06  6:27 UTC (permalink / raw)
  Cc: emacs-devel

    BTW, `while-no-input' and `throw-on-input' are not documented on the
    Emacs Lisp Reference; and the docstring for `throw-on-input' is
    suboptimal:

while-no-input is in the Lisp manual.  throw-on-input is not for users
to use; perhaps we should rename it to while-no-input-throw-internal.

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

* Re: Can't interrupt directory_files_internal run fromtimer-event-handler
  2005-08-06  6:27   ` Richard M. Stallman
@ 2005-08-06 11:58     ` Juanma Barranquero
  2005-08-06 23:39     ` Kim F. Storm
  1 sibling, 0 replies; 11+ messages in thread
From: Juanma Barranquero @ 2005-08-06 11:58 UTC (permalink / raw)
  Cc: emacs-devel

On 8/6/05, Richard M. Stallman <rms@gnu.org> wrote:

> while-no-input is in the Lisp manual.

Yes, you're right. Sorry.

> throw-on-input is not for users
> to use; perhaps we should rename it to while-no-input-throw-internal.

I agree.

-- 
                    /L/e/k/t/u

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

* Re: Can't interrupt directory_files_internal run fromtimer-event-handler
  2005-08-06  6:27   ` Richard M. Stallman
  2005-08-06 11:58     ` Juanma Barranquero
@ 2005-08-06 23:39     ` Kim F. Storm
  2005-08-08 12:09       ` Richard M. Stallman
  1 sibling, 1 reply; 11+ messages in thread
From: Kim F. Storm @ 2005-08-06 23:39 UTC (permalink / raw)
  Cc: Juanma Barranquero, emacs-devel

"Richard M. Stallman" <rms@gnu.org> writes:

>     BTW, `while-no-input' and `throw-on-input' are not documented on the
>     Emacs Lisp Reference; and the docstring for `throw-on-input' is
>     suboptimal:
>
> while-no-input is in the Lisp manual.  throw-on-input is not for users
> to use; perhaps we should rename it to while-no-input-throw-internal.

In its current form, a caller of while-no-input cannot differentiate
between BODY returning nil as a normal return value or BODY being
interrupted.

Furthermore, caller cannot know if BODY was interrupted by input or C-g.

As I need to differentiate between all three cases in ido, I had to
use throw-on-input directly.

For that reason, I think we should either document throw-on-input (and
keep its name), or [better] change while-no-input to return 'quit for
C-g, 'input-pending-p for input, and value of BODY otherwise.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: Can't interrupt directory_files_internal run fromtimer-event-handler
  2005-08-06 23:39     ` Kim F. Storm
@ 2005-08-08 12:09       ` Richard M. Stallman
  0 siblings, 0 replies; 11+ messages in thread
From: Richard M. Stallman @ 2005-08-08 12:09 UTC (permalink / raw)
  Cc: lekktu, emacs-devel

    For that reason, I think we should either document throw-on-input (and
    keep its name), or [better] change while-no-input to return `quit' for
    C-g, `input-pending-p' for input, and value of BODY otherwise.

This won't achieve the goal of making it possible to distinguish all
the possible cases.  It just makes the confusion cases less likely.

However, if you write (list ...) around the intended body form,
then you can tell for certain whether the body form finished.
As for distinguishing between C-g and other input, I think a simple
change will make `while-no-input' return t when there's input.
I will install that soon.

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

* Re: Can't interrupt directory_files_internal run fromtimer-event-handler
  2005-08-05 12:01 klaus.berndl
  2005-08-05 12:53 ` Juanma Barranquero
@ 2005-08-09 23:29 ` Stefan Monnier
  1 sibling, 0 replies; 11+ messages in thread
From: Stefan Monnier @ 2005-08-09 23:29 UTC (permalink / raw)
  Cc: kzeitler, emacs-devel

> ECB encapslates ist "stealthy" tasks in a loop like:

>         (while (and (not (input-pending-p))
>                 ...

> So IMHO C-g should work....

Only if each iteration takes a (small) finite time.  The OP's problem is
that one of the iteration doesn't terminate.

> AFAIK there is a new macro in CVS named `while-no-input' (there
> was a discussion some time ago).... Could using this macro
> solve problems like that posted from the OP??

Could be.  Another related new macro is with-local-quit (which uses no new
internal feature and can thus be backported to other Emacsen).


        Stefan

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

* AW: Can't interrupt directory_files_internal run fromtimer-event-handler
@ 2005-08-10  9:35 klaus.berndl
  2005-08-10 19:51 ` Richard M. Stallman
  2005-08-12  6:59 ` Stefan Monnier
  0 siblings, 2 replies; 11+ messages in thread
From: klaus.berndl @ 2005-08-10  9:35 UTC (permalink / raw)
  Cc: kzeitler, emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 1450 bytes --]

>> ECB encapslates ist "stealthy" tasks in a loop like:

>>         (while (and (not (input-pending-p))
>>                 ...

>> So IMHO C-g should work....

>Only if each iteration takes a (small) finite time.  The OP's problem is
>that one of the iteration doesn't terminate.

i know - therefore my question concerning while-no-input!
In fact: ECB has some tasks which should be run really(!) stealthy, like
checking if a dir is empty, getting the VC-state of all files in a dir,
checking which files in a dir are read-only... in case of a remote host
an iteration of such a task (i.e. for one file of a dir) can be potentially
long lasting...

With the current available elisp-tools (macos, functions etc.) ECB can run
these tasks only pseudo-stealthy...therefore a way to make this really stealthy
would be very important for ECB so users are not blocked...

I have no preference how to achieve this (while-no-input, with-local-quit etc..),
but i would be great if i could achieve this goal at all!

>> AFAIK there is a new macro in CVS named `while-no-input' (there
>> was a discussion some time ago).... Could using this macro
>> solve problems like that posted from the OP??

>Could be.  Another related new macro is with-local-quit (which uses no new
>internal feature and can thus be backported to other Emacsen).

see above - what would be the best way to enable real stealthiness?

Thanks a lot,
Klaus

[-- Attachment #1.2: Type: text/html, Size: 2200 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: AW: Can't interrupt directory_files_internal run fromtimer-event-handler
  2005-08-10  9:35 AW: Can't interrupt directory_files_internal run fromtimer-event-handler klaus.berndl
@ 2005-08-10 19:51 ` Richard M. Stallman
  2005-08-12  6:59 ` Stefan Monnier
  1 sibling, 0 replies; 11+ messages in thread
From: Richard M. Stallman @ 2005-08-10 19:51 UTC (permalink / raw)
  Cc: kzeitler, monnier, emacs-devel

    In fact: ECB has some tasks which should be run really(!) stealthy, like
    checking if a dir is empty, getting the VC-state of all files in a dir,
    checking which files in a dir are read-only... in case of a remote host

The best way to do this and make sure it is stealthy is by running a
subprocess.  The subprocess can run in parallel with Emacs.

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

* Re: Can't interrupt directory_files_internal run fromtimer-event-handler
  2005-08-10  9:35 AW: Can't interrupt directory_files_internal run fromtimer-event-handler klaus.berndl
  2005-08-10 19:51 ` Richard M. Stallman
@ 2005-08-12  6:59 ` Stefan Monnier
  1 sibling, 0 replies; 11+ messages in thread
From: Stefan Monnier @ 2005-08-12  6:59 UTC (permalink / raw)
  Cc: kzeitler, emacs-devel

> With the current available elisp-tools (macos, functions etc.) ECB can run
> these tasks only pseudo-stealthy...therefore a way to make this really
> stealthy would be very important for ECB so users are not blocked...

> I have no preference how to achieve this (while-no-input, with-local-quit
> etc..), but i would be great if i could achieve this goal at all!

Do you expect us to figure out what's best for you?
I'd say use while-no-input but you're in a better position to make this call.


        Stefan

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

* Re: Can't interrupt directory_files_internal run fromtimer-event-handler
  2005-08-12  8:00 AW: " klaus.berndl
@ 2005-08-12 11:59 ` Stefan Monnier
  0 siblings, 0 replies; 11+ messages in thread
From: Stefan Monnier @ 2005-08-12 11:59 UTC (permalink / raw)
  Cc: kzeitler, emacs-devel

>> I'd say use while-no-input but you're in a better position to make this call.

> the only thing i wanted is: An expert-estimation if while-no-input is
> a good way - or with-local-quit - if i remember right you said that this
> could easily being backported - maybe its not a really good idea to use
> a macro which is only available in forthcoming Emacs 22 - IMHO also users
> of Emacs 21.X should get a good solution...

while-no-input is a more general and robust way to do what your (while (not
(input-pending-p))) is trying to do.  It's basically designed specifically
for cases like yours.  But it's a new feature in Emacs-22.

with-local-quit is just a convenient macro to temporarily disable
inhibit-quit (that's typically set in timers, post-command-hooks, ...).
The macro-expanded code doesn't use any new feature.  It's not a general
solution to your problem, but it can be used to solve the specific problem
of the OP where C-g wasn't able to unfreeze Emacs.

> is there a short example how to use this with-local-quit? This would help me
> a lot - or a pointer where to find such an example..

cd ...emacs/lisp; grep with-local-quit **/*.el

Read the definition of the macro: it's fairly simple.


        Stefan

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

end of thread, other threads:[~2005-08-12 11:59 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-10  9:35 AW: Can't interrupt directory_files_internal run fromtimer-event-handler klaus.berndl
2005-08-10 19:51 ` Richard M. Stallman
2005-08-12  6:59 ` Stefan Monnier
  -- strict thread matches above, loose matches on Subject: below --
2005-08-12  8:00 AW: " klaus.berndl
2005-08-12 11:59 ` Stefan Monnier
2005-08-05 12:01 klaus.berndl
2005-08-05 12:53 ` Juanma Barranquero
2005-08-06  6:27   ` Richard M. Stallman
2005-08-06 11:58     ` Juanma Barranquero
2005-08-06 23:39     ` Kim F. Storm
2005-08-08 12:09       ` Richard M. Stallman
2005-08-09 23:29 ` Stefan Monnier

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).