[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C-g while exiting the minibuffer
From: |
martin rudalics |
Subject: |
Re: C-g while exiting the minibuffer |
Date: |
Thu, 28 Nov 2013 18:02:29 +0100 |
> Now I wonder what should be the best way to fix this. I can just switch
> the above two code blocks, which will fix the immediate problem (a C-g
> will not prevent canceling the frame-focus redirected), but I think this
> points to a larger problem of hitting C-g while processing unwind forms.
> Of course binding inhibit-quit during processing of unwind forms could
> be a source of problem in itself (if those forms fail to terminate).
I still have hare/tortoise implementations of Fset_window_prev_buffers
and Fset_window_next_buffers (for pure curiosity I attach the
corresponding part of a larger patch here). Chong didn't want to
install them then because he considered it overengineering. Installing
them means select_window could safely modify these lists with quitting
inhibited.
Calling `buffer-list-update-hook' would have to be deferred until the
end of `set-window-configuration' - no great deal IMHO.
Do you see any more problems?
martin
=== modified file 'src/window.c'
--- src/window.c 2012-02-23 17:40:33 +0000
+++ src/window.c 2012-02-27 07:43:06 +0000
@@ -51,7 +51,7 @@
#endif
Lisp_Object Qwindowp, Qwindow_live_p;
-static Lisp_Object Qwindow_configuration_p, Qrecord_window_buffer;
+static Lisp_Object Qwindow_configuration_p;
static Lisp_Object Qwindow_deletable_p, Qdelete_window, Qdisplay_buffer;
static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window;
static Lisp_Object Qwindow_resize_root_window,
Qwindow_resize_root_window_vertically;
@@ -1647,15 +1647,41 @@
DEFUN ("set-window-prev-buffers", Fset_window_prev_buffers,
Sset_window_prev_buffers, 2, 2, 0,
- doc: /* Set WINDOW's previous buffers to PREV-BUFFERS.
+ doc: /* Set WINDOW's previous buffers to PREV-BUFFERS.
WINDOW must be a live window and defaults to the selected one.
PREV-BUFFERS should be a list of elements (BUFFER WINDOW-START POS),
where BUFFER is a buffer, WINDOW-START is the start position of the
window for that buffer, and POS is a window-specific point value. */)
- (Lisp_Object window, Lisp_Object prev_buffers)
+ (Lisp_Object window, Lisp_Object prev_buffers)
{
- return decode_window (window)->prev_buffers = prev_buffers;
+ register struct window *w = decode_window (window);
+
+ if (NILP (prev_buffers))
+ return w->prev_buffers = Qnil;
+ else if (!CONSP (prev_buffers))
+ return w->prev_buffers;
+ else
+ {
+ /* Run cycle detection on prev_buffers. */
+ Lisp_Object tortoise, hare;
+
+ hare = tortoise = prev_buffers;
+ while (CONSP (hare))
+ {
+ hare = XCDR (hare);
+ if (!CONSP (hare))
+ break;
+
+ hare = XCDR (hare);
+ tortoise = XCDR (tortoise);
+
+ if (EQ (hare, tortoise))
+ return w->prev_buffers;
+ }
+
+ return w->prev_buffers = prev_buffers;
+ }
}
DEFUN ("window-next-buffers", Fwindow_next_buffers, Swindow_next_buffers,
@@ -1674,7 +1700,33 @@
NEXT-BUFFERS should be a list of buffers. */)
(Lisp_Object window, Lisp_Object next_buffers)
{
- return decode_window (window)->next_buffers = next_buffers;
+ register struct window *w = decode_window (window);
+
+ if (NILP (next_buffers))
+ return w->next_buffers = Qnil;
+ else if (!CONSP (next_buffers))
+ return w->next_buffers;
+ else
+ {
+ /* Run cycle detection on next_buffers. */
+ Lisp_Object tortoise, hare;
+
+ hare = tortoise = next_buffers;
+ while (CONSP (hare))
+ {
+ hare = XCDR (hare);
+ if (!CONSP (hare))
+ break;
+
+ hare = XCDR (hare);
+ tortoise = XCDR (tortoise);
+
+ if (EQ (hare, tortoise))
+ return w->next_buffers;
+ }
+
+ return w->next_buffers = next_buffers;
+ }
}