From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Shift selection using interactive spec Date: Mon, 17 Mar 2008 09:26:16 -0400 Message-ID: References: <87k5k69p92.fsf@stupidchicken.com> <200803140408.m2E47hPU014494@sallyv1.ics.uci.edu> <87prtxpekk.fsf@kfs-lx.rd.rdm> <87abl11ilo.fsf@stupidchicken.com> <874pb9koyw.fsf@stupidchicken.com> <87od9gzqv9.fsf@stupidchicken.com> <87bq5gytbi.fsf@stupidchicken.com> <8763vndi0r.fsf@kfs-lx.rd.rdm> <87hcf6ratt.fsf@stupidchicken.com> <878x0if9ul.fsf@stupidchicken.com> <87od9e9gnx.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1205760394 31094 80.91.229.12 (17 Mar 2008 13:26:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 17 Mar 2008 13:26:34 +0000 (UTC) Cc: Dan Nicolaescu , emacs-devel@gnu.org, "Kim F. Storm" To: Chong Yidong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 17 14:27:03 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JbFMk-0002sK-37 for ged-emacs-devel@m.gmane.org; Mon, 17 Mar 2008 14:27:02 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JbFMA-00029d-BR for ged-emacs-devel@m.gmane.org; Mon, 17 Mar 2008 09:26:26 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JbFM6-00029C-EW for emacs-devel@gnu.org; Mon, 17 Mar 2008 09:26:22 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JbFM5-00028x-TY for emacs-devel@gnu.org; Mon, 17 Mar 2008 09:26:22 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JbFM5-00028u-PC for emacs-devel@gnu.org; Mon, 17 Mar 2008 09:26:21 -0400 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JbFM5-0005JH-9S for emacs-devel@gnu.org; Mon, 17 Mar 2008 09:26:21 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAL8O3kdMCrTo/2dsb2JhbACnIoEK X-IronPort-AV: E=Sophos;i="4.25,512,1199682000"; d="scan'208";a="16136253" Original-Received: from smtp.pppoe.ca ([65.39.196.238]) by ironport2-out.pppoe.ca with ESMTP; 17 Mar 2008 09:26:16 -0400 Original-Received: from pastel.home ([76.10.180.232]) by smtp.pppoe.ca (Internet Mail Server v1.0) with ESMTP id XQR53016; Mon, 17 Mar 2008 09:26:16 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 2F7A98F79; Mon, 17 Mar 2008 09:26:16 -0400 (EDT) In-Reply-To: <87od9e9gnx.fsf@stupidchicken.com> (Chong Yidong's message of "Sun, 16 Mar 2008 23:24:18 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:92824 Archived-At: >> Shouldn't we just get rid of those special cases "to speed up the cases >> that are plenty fast anyway"? > Not sure what you mean. Something like the patch below. >> It is ugly right now and this makes it worse. How 'bout just >> >> if (CONSP (Vtransient_mark_mode)) >> Vtransient_mark_mode = XCDR (Vtransient_mark_mode); >> >> and then replace `identity' with (t . nil) and `only' with (t . (t . nil)). >> Or something like that? > I'm assuming we want to preserve backward compatibility re the meaning > of `only' and `identity' for transient-mark-mode. I'm not sure if > there are external packages using these. I don't think this backward compatibility is important: these are fairly recently introduced values and they're only used in unusual corner cases. > (If we break compability, we also ought to choose more descriptive > symbol names than `identity' and `only'.) Then again, we may want to move these special value to deactivate-mark or something like that. I think we should feel free to rework this bit if the result is cleaner. >> Any reason to use `only' rather than to explicitly deactivate the mark >> in handle-shift-selection when this-command-keys-shift-translated is >> (and the region was selected with this-command-keys-shift-translated)? >> Apparently that is the approach that is used in pc-selection-mode and in >> cua-selection-mode, so it seems to work well enough. The `only' form of >> transient-mark-mode is a bit brittle for my taste (gets broken by >> switch-frame events and things like that), so I'd rather only use it if >> really necessary. > If the user runs any other command, it is supposed to deactivate the > mark/unhighlight the region. Maybe for most commands, but maybe not all. If all(most) non-shifted movement commands turn it off explicitly (as I suggested above), and given that all buffer modifications already turn it off, there isn't much left and those left may actually be better off *not* turning the selection off. I first want to try this, and only if it causes actual problems will I want to try something else. The "only" form is too fleeting and tends to disappear for the tiniest reasons. I prefer a region that occasionally stays ON when we don't want it than one where you feel like it might disappear from under you at any time. Stefan === modified file 'src/keyboard.c' --- src/keyboard.c 2008-03-16 18:24:38 +0000 +++ src/keyboard.c 2008-03-17 13:17:46 +0000 @@ -1754,143 +1754,8 @@ } else { - if (NILP (current_kboard->Vprefix_arg)) - { - /* In case we jump to directly_done. */ - Vcurrent_prefix_arg = current_kboard->Vprefix_arg; - - /* Recognize some common commands in common situations and - do them directly. */ - if (EQ (Vthis_command, Qforward_char) && PT < ZV) - { - struct Lisp_Char_Table *dp - = window_display_table (XWINDOW (selected_window)); - lose = FETCH_CHAR (PT_BYTE); - SET_PT (PT + 1); - if (! NILP (Vpost_command_hook)) - /* Put this before calling adjust_point_for_property - so it will only get called once in any case. */ - goto directly_done; - if (current_buffer == prev_buffer - && last_point_position != PT - && NILP (Vdisable_point_adjustment) - && NILP (Vglobal_disable_point_adjustment)) - adjust_point_for_property (last_point_position, 0); - already_adjusted = 1; - if (PT == last_point_position + 1 - && (dp - ? (VECTORP (DISP_CHAR_VECTOR (dp, lose)) - ? XVECTOR (DISP_CHAR_VECTOR (dp, lose))->size == 1 - : (NILP (DISP_CHAR_VECTOR (dp, lose)) - && (lose >= 0x20 && lose < 0x7f))) - : (lose >= 0x20 && lose < 0x7f)) - /* To extract the case of continuation on - wide-column characters. */ - && ASCII_BYTE_P (lose) - && (XFASTINT (XWINDOW (selected_window)->last_modified) - >= MODIFF) - && (XFASTINT (XWINDOW (selected_window)->last_overlay_modified) - >= OVERLAY_MODIFF) - && (XFASTINT (XWINDOW (selected_window)->last_point) - == PT - 1) - && !windows_or_buffers_changed - && EQ (current_buffer->selective_display, Qnil) - && !detect_input_pending () - && NILP (XWINDOW (selected_window)->column_number_displayed) - && NILP (Vexecuting_kbd_macro)) - direct_output_forward_char (1); - goto directly_done; - } - else if (EQ (Vthis_command, Qbackward_char) && PT > BEGV) - { - struct Lisp_Char_Table *dp - = window_display_table (XWINDOW (selected_window)); - SET_PT (PT - 1); - lose = FETCH_CHAR (PT_BYTE); - if (! NILP (Vpost_command_hook)) - goto directly_done; - if (current_buffer == prev_buffer - && last_point_position != PT - && NILP (Vdisable_point_adjustment) - && NILP (Vglobal_disable_point_adjustment)) - adjust_point_for_property (last_point_position, 0); - already_adjusted = 1; - if (PT == last_point_position - 1 - && (dp - ? (VECTORP (DISP_CHAR_VECTOR (dp, lose)) - ? XVECTOR (DISP_CHAR_VECTOR (dp, lose))->size == 1 - : (NILP (DISP_CHAR_VECTOR (dp, lose)) - && (lose >= 0x20 && lose < 0x7f))) - : (lose >= 0x20 && lose < 0x7f)) - && (XFASTINT (XWINDOW (selected_window)->last_modified) - >= MODIFF) - && (XFASTINT (XWINDOW (selected_window)->last_overlay_modified) - >= OVERLAY_MODIFF) - && (XFASTINT (XWINDOW (selected_window)->last_point) - == PT + 1) - && !windows_or_buffers_changed - && EQ (current_buffer->selective_display, Qnil) - && !detect_input_pending () - && NILP (XWINDOW (selected_window)->column_number_displayed) - && NILP (Vexecuting_kbd_macro)) - direct_output_forward_char (-1); - goto directly_done; - } - else if (EQ (Vthis_command, Qself_insert_command) - /* Try this optimization only on char keystrokes. */ - && NATNUMP (last_command_char) - && CHAR_VALID_P (XFASTINT (last_command_char), 0)) - { - unsigned int c - = translate_char (Vtranslation_table_for_input, - XFASTINT (last_command_char)); - int value; - if (NILP (Vexecuting_kbd_macro) - && !EQ (minibuf_window, selected_window)) - { - if (!nonundocount || nonundocount >= 20) - { - Fundo_boundary (); - nonundocount = 0; - } - nonundocount++; - } - - lose = ((XFASTINT (XWINDOW (selected_window)->last_modified) - < MODIFF) - || (XFASTINT (XWINDOW (selected_window)->last_overlay_modified) - < OVERLAY_MODIFF) - || (XFASTINT (XWINDOW (selected_window)->last_point) - != PT) - || MODIFF <= SAVE_MODIFF - || windows_or_buffers_changed - || !EQ (current_buffer->selective_display, Qnil) - || detect_input_pending () - || !NILP (XWINDOW (selected_window)->column_number_displayed) - || !NILP (Vexecuting_kbd_macro)); - - value = internal_self_insert (c, 0); - - if (value == 2) - nonundocount = 0; - - if (! NILP (Vpost_command_hook)) - /* Put this before calling adjust_point_for_property - so it will only get called once in any case. */ - goto directly_done; - - /* VALUE == 1 when AFTER-CHANGE functions are - installed which is the case most of the time - because FONT-LOCK installs one. */ - if (!lose && !value) - direct_output_for_insert (c); - goto directly_done; - } - } - /* Here for a command that isn't executed directly */ - { #ifdef HAVE_X_WINDOWS int scount = SPECPDL_INDEX (); @@ -1917,8 +1782,6 @@ unbind_to (scount, Qnil); #endif } - } - directly_done: ; current_kboard->Vlast_prefix_arg = Vcurrent_prefix_arg; /* Note that the value cell will never directly contain nil