all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Emacs hanging after M-w and C-k
@ 2005-11-01 15:56 Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2005-11-01 15:56 UTC (permalink / raw)



Every once in a while Emacs gets into a strange mood where any text killing
(C-k, C-w, M-w, mouse selection, ...) causes it to hang (breakable with
C-g, thank god).

It turns out that it's due to some other app being stuck (probably while
holding the X selection, tho my understanding of the X protocol is too
flakey to be sure).  So maybe it's not strictly speaking an Emacs bug, but
I wish Emacs could grab the X selection asynchronously, so it wouldn't
get stuck.

Does anybody know how feasible this is?


        Stefan

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

* Re: Emacs hanging after M-w and C-k
       [not found] <4368A3F5.8030305@operax.com>
@ 2005-11-04  7:30 ` Jan D.
  2005-11-07 21:28   ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Jan D. @ 2005-11-04  7:30 UTC (permalink / raw)


>
>
>Every once in a while Emacs gets into a strange mood where any text killing
>(C-k, C-w, M-w, mouse selection, ...) causes it to hang (breakable with
>C-g, thank god).
>
>It turns out that it's due to some other app being stuck (probably while
>holding the X selection, tho my understanding of the X protocol is too
>flakey to be sure).  So maybe it's not strictly speaking an Emacs bug, but
>I wish Emacs could grab the X selection asynchronously, so it wouldn't
>get stuck.
>
>Does anybody know how feasible this is?
>  
>

If it get stuck in XSetSelectionOwner it is not feasible, as this is a 
synchronous call in X.  Can you verify that it is there it is stuck?

    Jan D.

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

* Re: Emacs hanging after M-w and C-k
  2005-11-04  7:30 ` Emacs hanging after M-w and C-k Jan D.
@ 2005-11-07 21:28   ` Stefan Monnier
  2005-11-08  7:05     ` Jan D.
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2005-11-07 21:28 UTC (permalink / raw)
  Cc: Emacs-Devel

>> Every once in a while Emacs gets into a strange mood where any text killing
>> (C-k, C-w, M-w, mouse selection, ...) causes it to hang (breakable with
>> C-g, thank god).
>> 
>> It turns out that it's due to some other app being stuck (probably while
>> holding the X selection, tho my understanding of the X protocol is too
>> flakey to be sure).  So maybe it's not strictly speaking an Emacs bug, but
>> I wish Emacs could grab the X selection asynchronously, so it wouldn't
>> get stuck.
>> 
>> Does anybody know how feasible this is?

> If it get stuck in XSetSelectionOwner it is not feasible, as this is
> a synchronous call in X.  Can you verify that it is there it is stuck?

Hmm.... OK it turns out that it's a problem due to my own local hacks (see
the patch below).  So in a vanilla Emacs, the way to reproduce a similar
problem is to do C-y when another app has the selection and is frozen.
But unless we add a timeout, there is little we can do about it in the case
of C-y.  In the case of the patch below, I'd want to run
interprogram-paste-function asynchronously, but it's not clear how to do.
That's too bad: I was planning to submit the patch below for inclusion.


        Stefan


--- orig/lisp/simple.el
+++ mod/lisp/simple.el
@@ -2382,6 +2428,21 @@
 argument is not used by `insert-for-yank'.  However, since Lisp code
 may access and use elements from the kill ring directly, the STRING
 argument should still be a \"useful\" string for such uses."
+  ;; To better pretend that X-selection = head-of-kill-ring, we copy other
+  ;; application's X-selection to the kill-ring.  This comes in handy when
+  ;; you do something like:
+  ;; - copy a piece of text in your web-browser.
+  ;; - have to do some editing (including killing) before you can yank
+  ;;   that text.
+  ;; Note: this piece of code inspired from current-kill.
+  (let ((paste (and interprogram-paste-function
+                    (funcall interprogram-paste-function))))
+    (when paste
+      (let ((interprogram-cut-function nil)
+            (interprogram-paste-function nil))
+        (kill-new paste))))
+  ;; The actual kill-new functionality.
+  (when (equal string (car kill-ring)) (setq replace t))
   (if (> (length string) 0)
       (if yank-handler
 	  (put-text-property 0 (length string)

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

* Re: Emacs hanging after M-w and C-k
  2005-11-07 21:28   ` Stefan Monnier
@ 2005-11-08  7:05     ` Jan D.
  0 siblings, 0 replies; 4+ messages in thread
From: Jan D. @ 2005-11-08  7:05 UTC (permalink / raw)
  Cc: Emacs-Devel

Stefan Monnier wrote:

>>If it get stuck in XSetSelectionOwner it is not feasible, as this is
>>a synchronous call in X.  Can you verify that it is there it is stuck?
>>    
>>
>
>Hmm.... OK it turns out that it's a problem due to my own local hacks (see
>the patch below).  So in a vanilla Emacs, the way to reproduce a similar
>problem is to do C-y when another app has the selection and is frozen.
>But unless we add a timeout, there is little we can do about it in the case
>of C-y.  In the case of the patch below, I'd want to run
>interprogram-paste-function asynchronously, but it's not clear how to do.
>That's too bad: I was planning to submit the patch below for inclusion.
>  
>

For C-y there is x-selection-timeout (default seems to be 20000, 20 
seconds).  Does that not work for you?  Actually, it seems to timeout 
somewhat later than the actual value, i.e. if I set it to 1000 (1 
second) the timeout occurs at about 2 seconds.

    Jan D.

>
>  
>

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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <4368A3F5.8030305@operax.com>
2005-11-04  7:30 ` Emacs hanging after M-w and C-k Jan D.
2005-11-07 21:28   ` Stefan Monnier
2005-11-08  7:05     ` Jan D.
2005-11-01 15:56 Stefan Monnier

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.