all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* AW: vc-state always calls heuristic function
@ 2004-11-26  9:26 klaus.berndl
  2004-11-26 11:44 ` Kim F. Storm
  0 siblings, 1 reply; 34+ messages in thread
From: klaus.berndl @ 2004-11-26  9:26 UTC (permalink / raw)
  Cc: emacs-devel


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

sorry for sending this again - but until now i got
no answer to my question about the current state of
while-no-inmput - see below - maybe you have forgotten to
answer... ;-)

Klaus


-----Ursprüngliche Nachricht-----
Von: emacs-devel-bounces+klaus.berndl=sdm.de@gnu.org im Auftrag von klaus.berndl@sdm.de
Gesendet: Mi 24.11.2004 15:44
An: monnier@iro.umontreal.ca
Cc: emacs-devel@gnu.org
Betreff: RE: vc-state always calls heuristic function
 
Stefan Monnier wrote:
>> and between each pass of the loop it is interruptable..well, but of
>> course there remains the problem - how to interrupt if one pass
>> takes long 
>> time...
> 
> Google for `while-no-input'.

Done - after reading the whole thread i can say: I agree at 100% with you and Kim.
Such a macro would be very important especially for a program like Emacs which
has still not thread-feature like Java, C++ et. al. IMHO this is one of the
most important any annoying lacks of emacs-lisp and for programmers...
And i agree with Kim that especially people working with remote-paths and
packages which makes this completely transparent (like tramp, ange-ftp and efs)
would profite a lot from such a macro like while-no-input - 

The current discussion how to enable tools like ECB to display some state-value
for files (as the VC-state-values) where the computation could be expensive
is IMHO a good example to demonstrate the need of such feature - so we have no
threads avaliable in emacs-lisp to perform such expensive tasks in the background
without blocking the user of Emacs but we could at least offer the users of
such tools a way how to easily (hitting C-g is not acceptable) interrupt also
"atomic" calls as call of call-process etc...

Well, Stefan - this thread was discussed in 2002 - what is current state of
this while-no-input???

>> Hmm, now i'm confused... ECB needs a function how to get the
>> VC-state. Well, the user can customize which function ECB should
>> use.  But if he should 
>> not use `vc-recompute-state' how he should get fresh-but-slow state??
> 
> Oh, you're right I got confused: vc-cvs-heuristic-state doesn't pay
> attention to vc-cvs-stay-local.  Hmmm....
> I guess VC could/should provide a function like vc-recompute-state or
> vc-check-for-updates.  Currently this operation is only provided as
> part of vc-next-action, but it might be nice to decouple the two.

Yes, see my discussion with Andre about this...

Klaus

> 
> 
>         Stefan



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


[-- Attachment #1.2: Type: text/html, Size: 3523 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] 34+ messages in thread
* RE: while-no-input
@ 2004-11-29 15:02 klaus.berndl
  0 siblings, 0 replies; 34+ messages in thread
From: klaus.berndl @ 2004-11-29 15:02 UTC (permalink / raw)
  Cc: rms, storm

Stefan Monnier wrote:
>>> Don't forget that the code within while-no-input is usually code
>>> that was not specifically designed for while-no-input (otherwise it
>>> would already use input-pending-p instead).
> 
>> Hmm, are you sure about that??
> 
> About what?

about "that the code within while-no-input is usually code that
was not specifically designed for while-no-input (otherwise it would
already use input-pending-p instead)"... but it seems that i have
misunderstood your latest posting....

> 
>> IMHO the code within while-no-input can also be code which would use
>> input-pending-p already, so my example with performing a
>> VC-state-check 
> 
> I never said otherwise, did I?
> 
> 
>         Stefan

^ permalink raw reply	[flat|nested] 34+ messages in thread
* RE: while-no-input
@ 2004-11-29 14:30 klaus.berndl
  2004-11-29 14:55 ` while-no-input Stefan Monnier
  0 siblings, 1 reply; 34+ messages in thread
From: klaus.berndl @ 2004-11-29 14:30 UTC (permalink / raw)
  Cc: emacs-devel, storm

Stefan Monnier wrote:
>> The only thing programs do to control quitting is to bind
>> inhibit-quit on and off.  That is not relevant to handling
>> with-no-input, so I think 
> 
> Could you substantiate that claim?
> AFAIK inhibit-quit is used to get more-or-less-atomic behavior in
> places where it matters.  while-no-input should very clearly obey
> inhibit-quit since it also causes non-local exits at places where it
> can't be predited (just like quit).
> Don't forget that the code within while-no-input is usually code that
> was not specifically designed for while-no-input (otherwise it would
> already use input-pending-p instead).

Hmm, are you sure about that??
IMHO the code within while-no-input can also be code which would use
input-pending-p already, so my example with performing a VC-state-check
for a set of files which i want to be interruptable by the user at EVERY
timepoint.... with only input-pending-p i can only interrupt directly before
the next VC-state-check, because the call `vc-state' rsp. `vc-recompute-state'
is not interruptable unless by hitting quit... 

But if i could encapsulate processing my set of files in your while-no-input
macro then it could be interrupted at EVERY timepoint, if i have understood
you right, because this would also interrupt the inner state-check-function,
wouldn't it?

So i would do

(while-no-input ....
  (unwind-protect
  ;; checvk the state for the set of files in BODYFORM
    ( ;; cleanup whatever is to clean up
     ))

Have i understodd this right?

> 
> Here is another way to say the ame thing: of all the non-local exits
> we have right now, `quit' is the only one that's asynchronous. 
> `while-no-input' introduces another form of asynchronous signalling
> and is thus much more like `quit' than like `throw'.

^ permalink raw reply	[flat|nested] 34+ messages in thread
* while-no-input
@ 2002-10-01 21:19 Stefan Monnier
  2002-10-02 19:24 ` while-no-input Richard Stallman
  0 siblings, 1 reply; 34+ messages in thread
From: Stefan Monnier @ 2002-10-01 21:19 UTC (permalink / raw)



Sometimes I'd like to be able to run something "while there's nothing
else to do".  For example, right now icomplete does not work when
completing file names because getting the list of completions can take
an exceedingly long time.  But if it could say "try to build the list
but abort as soon as the user hits a key", then we could use it
there just fine.

So I have a little patch that does just that.  What it does:

1 - add a quit-on-input variable that causes a quit signal to be sent
    as soon as some user input comes in (and the variable is non-nil).

2 - change QUIT to pass the value of `quit-flag' as part of the quit
    signal so we can tell the difference between a real `quit' and
    a `quit-on-input'.

3 - add a `while-no-input' macro that uses the above facilities to run
    its body and exit as soon as user-input is detected.


	Stefan


Index: keyboard.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/keyboard.c,v
retrieving revision 1.708
diff -u -u -b -r1.708 keyboard.c
--- keyboard.c	27 Sep 2002 17:03:46 -0000	1.708
+++ keyboard.c	1 Oct 2002 21:15:14 -0000
@@ -3374,6 +3402,9 @@
 }
 #endif
 
+
+Lisp_Object Vquit_on_input;
+
 /* Store an event obtained at interrupt level into kbd_buffer, fifo */
 
 void
@@ -3501,6 +3538,14 @@
       ASET (kbd_buffer_gcpro, idx + 1, event->arg);
       ++kbd_store_ptr;
     }
+  
+  /* If we're in a section that requested to be interrupted as soon
+     as input comes, then set quit-flag to cause an interrupt.  */
+  if (!NILP (Vquit_on_input)
+      && event->kind != FOCUS_IN_EVENT
+      && event->kind != HELP_EVENT
+      && event->kind != DEICONIFY_EVENT)
+    Vquit_flag = Vquit_on_input;
 }
 
 
@@ -11038,6 +11029,12 @@
 	       doc: /* *How long to display an echo-area message when the minibuffer is active.
 If the value is not a number, such messages don't time out.  */);
   Vminibuffer_message_timeout = make_number (2);
+
+  DEFVAR_LISP ("quit-on-input", &Vquit_on_input,
+	       doc: /* If non-nil, any input will cause a `quit' signal to be thrown.
+The value of that variable is passed to `quit-flag' and is later carried
+by the `quit' signal.  */);
+  Vquit_on_input = Qnil;
 }
 
 void
Index: lisp.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/lisp.h,v
retrieving revision 1.440
diff -u -r1.440 lisp.h
--- lisp.h	11 Sep 2002 01:59:33 -0000	1.440
+++ lisp.h	1 Oct 2002 21:17:54 -0000
@@ -1759,8 +1760,9 @@
   do {							\
     if (!NILP (Vquit_flag) && NILP (Vinhibit_quit))	\
       {							\
+	Lisp_Object flag = Vquit_flag;			\
 	Vquit_flag = Qnil;				\
-	Fsignal (Qquit, Qnil);				\
+	Fsignal (Qquit, flag);				\
       }							\
   } while (0)
 
Index: subr.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/subr.el,v
retrieving revision 1.326
diff -u -r1.326 subr.el
--- subr.el	29 Sep 2002 18:37:43 -0000	1.326
+++ subr.el	1 Oct 2002 21:18:28 -0000
@@ -1606,11 +1622,25 @@
 
 (defmacro with-local-quit (&rest body)
   "Execute BODY with `inhibit-quit' temporarily bound to nil."
+  (declare (debug t) (indent 0))
   `(condition-case nil
        (let ((inhibit-quit nil))
 	 ,@body)
      (quit (setq quit-flag t))))
 
+(defmacro while-no-input (&rest body)
+  "Execute BODY as long as there's no pending input."
+  (declare (debug t) (indent 0))
+  (let ((quit-sym (make-symbol "input")))
+    `(with-local-quit
+       (condition-case err
+	   (let ((quit-on-input ',quit-sym))
+	     (when (sit-for 0 0 t)
+	       ,@body))
+	 ;; Check it is indeed a quit-on-input.  If not, rethrow the signal.
+	 (quit (unless (eq (cdr err) ',quit-sym)
+		 (signal (car err) (cdr err))))))))
+
 (defmacro combine-after-change-calls (&rest body)
   "Execute BODY, but don't call the after-change functions till the end.
 If BODY makes changes in the buffer, they are recorded

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

end of thread, other threads:[~2004-11-30 14:56 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-26  9:26 AW: vc-state always calls heuristic function klaus.berndl
2004-11-26 11:44 ` Kim F. Storm
2004-11-27 18:51   ` while-no-input Richard Stallman
2004-11-27 23:03     ` while-no-input Kim F. Storm
2004-11-29  6:11       ` while-no-input Richard Stallman
2004-11-29 14:20         ` while-no-input Stefan Monnier
2004-11-30  7:03           ` while-no-input Richard Stallman
2004-11-30 14:56             ` while-no-input Kim F. Storm
  -- strict thread matches above, loose matches on Subject: below --
2004-11-29 15:02 while-no-input klaus.berndl
2004-11-29 14:30 while-no-input klaus.berndl
2004-11-29 14:55 ` while-no-input Stefan Monnier
2002-10-01 21:19 while-no-input Stefan Monnier
2002-10-02 19:24 ` while-no-input Richard Stallman
2002-10-02 21:43   ` while-no-input Stefan Monnier
2002-10-03 13:28     ` while-no-input Richard Stallman
2002-10-03 15:53       ` while-no-input Stefan Monnier
2002-10-03 22:44         ` while-no-input Kim F. Storm
2002-10-03 22:33           ` while-no-input Stefan Monnier
2002-10-04 15:46         ` while-no-input Richard Stallman
2002-10-04 15:59           ` while-no-input Stefan Monnier
2002-10-05 16:33             ` while-no-input Richard Stallman
2002-10-24  0:06             ` while-no-input Kim F. Storm
2002-10-24  7:20               ` while-no-input Stefan Monnier
2002-10-24 10:24                 ` while-no-input Kim F. Storm
2002-10-25  5:35                   ` while-no-input Richard Stallman
2002-10-25  9:19                     ` while-no-input Kim F. Storm
2002-10-26 20:15                       ` while-no-input Richard Stallman
2002-10-25 13:44                     ` while-no-input Stefan Monnier
2002-10-26 20:13                       ` while-no-input Richard Stallman
2002-10-29 19:45                         ` while-no-input Stefan Monnier
2002-10-31 17:25                           ` while-no-input Richard Stallman
2002-10-31 18:03                             ` while-no-input Stefan Monnier
2002-11-02  3:32                               ` while-no-input Richard Stallman
2002-10-05 22:43       ` while-no-input Kim F. Storm

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.