From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.bugs Subject: bug#8996: Set PRIMARY from last selection, not last selected window Date: Sat, 24 Mar 2012 19:10:53 +0800 Message-ID: <87pqc2b6f6.fsf@gnu.org> References: <4E121079.6020103@harpegolden.net> <8739illrkc.fsf@stupidchicken.com> <4E169B83.4050706@harpegolden.net> <4E1A6689.1040203@harpegolden.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1332587535 7478 80.91.229.3 (24 Mar 2012 11:12:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 24 Mar 2012 11:12:15 +0000 (UTC) Cc: 8996@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Mar 24 12:12:14 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1SBOtH-0005ru-Oh for geb-bug-gnu-emacs@m.gmane.org; Sat, 24 Mar 2012 12:12:11 +0100 Original-Received: from localhost ([::1]:53732 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SBOtG-0005o4-IF for geb-bug-gnu-emacs@m.gmane.org; Sat, 24 Mar 2012 07:12:10 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:34465) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SBOtD-0005na-3h for bug-gnu-emacs@gnu.org; Sat, 24 Mar 2012 07:12:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SBOtB-0002mY-5G for bug-gnu-emacs@gnu.org; Sat, 24 Mar 2012 07:12:06 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57739) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SBOtB-0002mM-1T for bug-gnu-emacs@gnu.org; Sat, 24 Mar 2012 07:12:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SBPN8-0003Yd-3Z for bug-gnu-emacs@gnu.org; Sat, 24 Mar 2012 07:43:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Chong Yidong Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 24 Mar 2012 11:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8996 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 8996-submit@debbugs.gnu.org id=B8996.133258936113640 (code B ref 8996); Sat, 24 Mar 2012 11:43:02 +0000 Original-Received: (at 8996) by debbugs.gnu.org; 24 Mar 2012 11:42:41 +0000 Original-Received: from localhost ([127.0.0.1]:36338 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SBPMl-0003Xw-Sr for submit@debbugs.gnu.org; Sat, 24 Mar 2012 07:42:40 -0400 Original-Received: from fencepost.gnu.org ([208.118.235.10]:44315) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SBPMA-0003XD-MQ for 8996@debbugs.gnu.org; Sat, 24 Mar 2012 07:42:36 -0400 Original-Received: from bb121-6-68-206.singnet.com.sg ([121.6.68.206]:34235 helo=ulysses) by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1SBOs9-0003ao-RO; Sat, 24 Mar 2012 07:11:03 -0400 In-Reply-To: (Stefan Monnier's message of "Tue, 13 Mar 2012 09:23:01 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.94 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:58075 Archived-At: Stefan Monnier writes: >> Hmm. bug #6872 was addressed by trunk r101176, which suppresses the >> primary update on handle_switch_frame, but, well, that only covers >> that immediate frame switch case. Kinda need to address switching >> between individual windows too (or actually instead since >> handle_switch_frame will always wind up calling select_window itself, >> I think). However, select-window itself is not a command afaiui, and >> enumerating all potential window-switching commands is probably not >> viable. I can't say I like the attached solution (modelled on the >> deactivate-mark variable) very much, though nor did I have any >> especially better ideas. > > I think this approach isn't as terrible as it sounds (tho I don't much > like the name you chose, sorry). We'd want to let-bind that new var > in things like save-selected-window, with-selected-window, ... which > is kind of ugly. > > Maybe a better approach is to record the selected window before > running a command, and only do the select-active-regions dance if the > command did not change the selected window. Why not just extend the Bug#6872 approach to handle-select-window too? === modified file 'src/keyboard.c' *** src/keyboard.c 2012-02-24 08:34:09 +0000 --- src/keyboard.c 2012-03-24 11:09:56 +0000 *************** *** 241,246 **** --- 241,247 ---- Time last_event_timestamp; static Lisp_Object Qx_set_selection, Qhandle_switch_frame; + static Lisp_Object Qhandle_select_window; Lisp_Object QPRIMARY; static Lisp_Object Qself_insert_command; *************** *** 1647,1653 **** ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly) : (!NILP (Vselect_active_regions) && !NILP (Vtransient_mark_mode))) ! && !EQ (Vthis_command, Qhandle_switch_frame)) { EMACS_INT beg = XINT (Fmarker_position (BVAR (current_buffer, mark))); --- 1648,1655 ---- ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly) : (!NILP (Vselect_active_regions) && !NILP (Vtransient_mark_mode))) ! && !EQ (Vthis_command, Qhandle_switch_frame) ! && !EQ (Vthis_command, Qhandle_select_window)) { EMACS_INT beg = XINT (Fmarker_position (BVAR (current_buffer, mark))); *************** *** 11649,11654 **** --- 11651,11657 ---- DEFSYM (Qx_set_selection, "x-set-selection"); DEFSYM (QPRIMARY, "PRIMARY"); DEFSYM (Qhandle_switch_frame, "handle-switch-frame"); + DEFSYM (Qhandle_select_window, "handle-select-window"); DEFSYM (Qinput_method_function, "input-method-function"); DEFSYM (Qinput_method_exit_on_first_char, "input-method-exit-on-first-char");