From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel Subject: Re: C-g while exiting the minibuffer Date: Thu, 28 Nov 2013 18:02:29 +0100 Message-ID: <52977725.50800@gmx.at> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------080201000603010400050102" X-Trace: ger.gmane.org 1385658165 23035 80.91.229.3 (28 Nov 2013 17:02:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 28 Nov 2013 17:02:45 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 28 18:02:50 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Vm4zJ-0005Kb-L9 for ged-emacs-devel@m.gmane.org; Thu, 28 Nov 2013 18:02:49 +0100 Original-Received: from localhost ([::1]:43162 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm4zJ-0006Jg-9U for ged-emacs-devel@m.gmane.org; Thu, 28 Nov 2013 12:02:49 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm4z8-0006JW-Rh for emacs-devel@gnu.org; Thu, 28 Nov 2013 12:02:46 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vm4z1-0006oL-I9 for emacs-devel@gnu.org; Thu, 28 Nov 2013 12:02:38 -0500 Original-Received: from mout.gmx.net ([212.227.17.20]:64691) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm4z1-0006oE-8o for emacs-devel@gnu.org; Thu, 28 Nov 2013 12:02:31 -0500 Original-Received: from [62.47.33.171] ([62.47.33.171]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0LlGoc-1VBMaR4C62-00b5Qv for ; Thu, 28 Nov 2013 18:02:30 +0100 In-Reply-To: X-Provags-ID: V03:K0:cv3yIZHsYXFby4wsVIFlSg397pyxR/eGB44N1sQh1v/hjFxh2xF gdrqyEa66Gn1bQ5yEwOuSUJx7C7SOs79bEQ1f0e6vMkD7aqWmRNK2ZQG0FH1YeywfkhL3H5 C7+2A0NGlGUu9fzwqLumLG6XROeRBDyx35Z+bwXi8A5tt2AAfvlsGykN1aZFJ3NC6H3MaK9 zj1tr3S5iO9h/l/dqx+Kw== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 212.227.17.20 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:165835 Archived-At: This is a multi-part message in MIME format. --------------080201000603010400050102 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit > 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 --------------080201000603010400050102 Content-Type: text/plain; name="prev-next-buffers.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="prev-next-buffers.diff" === 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; + } } --------------080201000603010400050102--