bug-bash
[Top][All Lists]
Advanced

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

Here's the Emacs line movement behavior...


From: Brian J. Fox
Subject: Here's the Emacs line movement behavior...
Date: Tue, 25 Sep 2001 17:00:36 -0700

diff -cprP readline-4.2a-alpha1/bind.c readline-4.2a-alpha1-new/bind.c
*** readline-4.2a-alpha1/bind.c Wed Aug 22 06:38:40 2001
--- readline-4.2a-alpha1-new/bind.c     Tue Sep 25 16:48:24 2001
*************** static struct {
*** 1252,1257 ****
--- 1252,1258 ----
    { "match-hidden-files",     &_rl_match_hidden_files,        0 },
    { "meta-flag",              &_rl_meta_flag,                 0 },
    { "output-meta",            &_rl_output_meta_chars,         0 },
+   { "emacs-vertical-movement",        &_rl_emacs_vertical_movement,   0 },
    { "prefer-visible-bell",    &_rl_prefer_visible_bell,       V_SPECIAL },
    { "print-completions-horizontally", &_rl_print_completions_horizontally, 0 
},
    { "show-all-if-ambiguous",  &_rl_complete_show_all,         0 },
diff -cprP readline-4.2a-alpha1/readline.c readline-4.2a-alpha1-new/readline.c
*** readline-4.2a-alpha1/readline.c     Wed Aug 22 06:39:42 2001
--- readline-4.2a-alpha1-new/readline.c Tue Sep 25 16:57:49 2001
*************** int rl_readline_state = RL_STATE_NONE;
*** 139,144 ****
--- 139,152 ----
  /* The current offset in the current input line. */
  int rl_point;
  
+ /* Non-zero means that C-p and C-n try to remember where you were in the line.
+    Affects rl_get_previous_history (), rl_get_next_history (),
+    rl_newline (). */
+ int _rl_emacs_vertical_movement = 1;
+ 
+ /* The most recent offset that we know about. */
+ static int _rl_target_point = -1;
+ 
  /* Mark in the current input line. */
  int rl_mark;
  
*************** rl_newline (count, key)
*** 1435,1440 ****
--- 1443,1457 ----
       int count, key;
  {
    rl_done = 1;
+ 
+   if (_rl_emacs_vertical_movement != 0)
+     {
+       if (rl_point == rl_end)
+       _rl_target_point = -1;
+       else
+       _rl_target_point = rl_point;
+     }
+ 
    RL_SETSTATE(RL_STATE_DONE);
  
  #if defined (VI_MODE)
*************** rl_get_next_history (count, key)
*** 2003,2008 ****
--- 2020,2032 ----
    if (count == 0)
      return 0;
  
+   if (_rl_emacs_vertical_movement != 0)
+     {
+       if (_rl_target_point == -1)
+       if ((rl_point != 0) || (rl_end != 0))
+         _rl_target_point = rl_point;
+     }
+ 
    rl_maybe_replace_line ();
  
    temp = (HIST_ENTRY *)NULL;
*************** rl_get_next_history (count, key)
*** 2026,2031 ****
--- 2050,2067 ----
        strcpy (the_line, temp->line);
        rl_undo_list = (UNDO_LIST *)temp->data;
        rl_end = rl_point = strlen (the_line);
+ 
+       if (_rl_emacs_vertical_movement != 0)
+       {
+         if (_rl_target_point > -1)
+           {
+             if (_rl_target_point < rl_end)
+               rl_point = _rl_target_point;
+             else
+               rl_point = rl_end;
+           }
+       }
+ 
  #if defined (VI_MODE)
        if (rl_editing_mode == vi_mode)
        rl_point = 0;
*************** rl_get_previous_history (count, key)
*** 2049,2054 ****
--- 2085,2099 ----
    if (count == 0)
      return 0;
  
+   if (_rl_emacs_vertical_movement != 0)
+     {
+       if (_rl_target_point == -1)
+       {
+         if ((rl_point != 0) || (rl_end != 0))
+           _rl_target_point = rl_point;
+       }
+     }
+ 
    /* If we don't have a line saved, then save this one. */
    rl_maybe_save_line ();
  
*************** rl_get_previous_history (count, key)
*** 2083,2088 ****
--- 2128,2142 ----
        strcpy (the_line, temp->line);
        rl_undo_list = (UNDO_LIST *)temp->data;
        rl_end = rl_point = line_len;
+ 
+       if (_rl_emacs_vertical_movement != 0)
+       {
+         if (_rl_target_point > -1)
+           {
+             if (_rl_target_point < rl_end)
+               rl_point = _rl_target_point;
+           }
+       }
  
  #if defined (VI_MODE)
        if (rl_editing_mode == vi_mode)
diff -cprP readline-4.2a-alpha1/rlprivate.h readline-4.2a-alpha1-new/rlprivate.h
*** readline-4.2a-alpha1/rlprivate.h    Wed Aug 22 06:37:50 2001
--- readline-4.2a-alpha1-new/rlprivate.h        Tue Sep 25 16:50:33 2001
*************** extern int _rl_bell_preference;
*** 232,237 ****
--- 232,238 ----
  extern int _rl_meta_flag;
  extern int _rl_convert_meta_chars_to_ascii;
  extern int _rl_output_meta_chars;
+ extern int _rl_emacs_vertical_movement;
  extern char *_rl_comment_begin;
  extern unsigned char _rl_parsing_conditionalized_out;
  extern Keymap _rl_keymap;

Brian
-- 
== The Difference Between Cultures: ==
    Einigkeit und Recht und Freiheit
    Liberte', E'galite', Fraternite'
    Sex, drugs and rock'n'roll



reply via email to

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