emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shift selection using interactive spec


From: Stefan Monnier
Subject: Re: Shift selection using interactive spec
Date: Mon, 17 Mar 2008 09:26:16 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

>> 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]