On Thu, Jan 12, 2012 at 21:15:30 -0500, Ben Boeckel wrote:
> On Fri, Dec 02, 2011 at 00:24:00 -0500, Ben Boeckel wrote:
> >     dev/add-WORD-motions-to-status
> >         Adds 'B', 'E', and 'W' motions to edit mode. Not sure of emacs
> >         equivalents.
> 
> Works here. It uses the emacs 'E' behavior. I have another branch here
> which fixes the behavior when vi behavior of 'e' and 'E' where
> applicable.

And let's actually attach the patch...

--Ben
From f9c64aa28a09fb7092d52d2001b25ab9794b5743 Mon Sep 17 00:00:00 2001
From: Ben Boeckel <maths...@gmail.com>
Date: Thu, 12 Jan 2012 20:50:51 -0500
Subject: [PATCH] Add WORD motions to status line editing

---
 trunk/mode-key.c |    6 ++++++
 trunk/status.c   |   20 ++++++++++++++++----
 trunk/tmux.h     |    3 +++
 3 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/trunk/mode-key.c b/trunk/mode-key.c
index bfa8b4a..c8581d7 100644
--- a/trunk/mode-key.c
+++ b/trunk/mode-key.c
@@ -54,9 +54,12 @@ const struct mode_key_cmdstr mode_key_cmdstr_edit[] = {
        { MODEKEYEDIT_ENTER, "enter" },
        { MODEKEYEDIT_HISTORYDOWN, "history-down" },
        { MODEKEYEDIT_HISTORYUP, "history-up" },
+       { MODEKEYEDIT_NEXTSPACE, "next-space" },
+       { MODEKEYEDIT_NEXTSPACEEND, "next-space-end" },
        { MODEKEYEDIT_NEXTWORD, "next-word" },
        { MODEKEYEDIT_NEXTWORDEND, "next-word-end" },
        { MODEKEYEDIT_PASTE, "paste" },
+       { MODEKEYEDIT_PREVIOUSSPACE, "previous-space" },
        { MODEKEYEDIT_PREVIOUSWORD, "previous-word" },
        { MODEKEYEDIT_STARTOFLINE, "start-of-line" },
        { MODEKEYEDIT_SWITCHMODE, "switch-mode" },
@@ -148,7 +151,10 @@ const struct mode_key_entry mode_key_vi_edit[] = {
 
        { '$',                  1, MODEKEYEDIT_ENDOFLINE },
        { '0',                  1, MODEKEYEDIT_STARTOFLINE },
+       { 'B',                  1, MODEKEYEDIT_PREVIOUSSPACE },
        { 'D',                  1, MODEKEYEDIT_DELETETOENDOFLINE },
+       { 'E',                  1, MODEKEYEDIT_NEXTSPACEEND },
+       { 'W',                  1, MODEKEYEDIT_NEXTSPACE },
        { 'X',                  1, MODEKEYEDIT_BACKSPACE },
        { '\003' /* C-c */,     1, MODEKEYEDIT_CANCEL },
        { '\010' /* C-h */,     1, MODEKEYEDIT_BACKSPACE },
diff --git a/trunk/status.c b/trunk/status.c
index 49836a2..154bd6c 100644
--- a/trunk/status.c
+++ b/trunk/status.c
@@ -978,7 +978,7 @@ status_prompt_key(struct client *c, int key)
        struct paste_buffer     *pb;
        char                    *s, *first, *last, word[64], swapc;
        const char              *histstr;
-       const char              *wsep;
+       const char              *wsep = NULL;
        u_char                   ch;
        size_t                   size, n, off, idx;
 
@@ -1124,8 +1124,12 @@ status_prompt_key(struct client *c, int key)
                c->prompt_index = idx;
                c->flags |= CLIENT_STATUS;
                break;
+       case MODEKEYEDIT_NEXTSPACE:
+               wsep = " ";
+               /* FALLTHROUGH */
        case MODEKEYEDIT_NEXTWORD:
-               wsep = options_get_string(oo, "word-separators");
+               if (wsep == NULL)
+                       wsep = options_get_string(oo, "word-separators");
 
                /* Find a separator. */
                while (c->prompt_index != size) {
@@ -1143,8 +1147,12 @@ status_prompt_key(struct client *c, int key)
 
                c->flags |= CLIENT_STATUS;
                break;
+       case MODEKEYEDIT_NEXTSPACEEND:
+               wsep = " ";
+               /* FALLTHROUGH */
        case MODEKEYEDIT_NEXTWORDEND:
-               wsep = options_get_string(oo, "word-separators");
+               if (wsep == NULL)
+                       wsep = options_get_string(oo, "word-separators");
 
                /* Find a word. */
                while (c->prompt_index != size) {
@@ -1162,8 +1170,12 @@ status_prompt_key(struct client *c, int key)
 
                c->flags |= CLIENT_STATUS;
                break;
+       case MODEKEYEDIT_PREVIOUSSPACE:
+               wsep = " ";
+               /* FALLTHROUGH */
        case MODEKEYEDIT_PREVIOUSWORD:
-               wsep = options_get_string(oo, "word-separators");
+               if (wsep == NULL)
+                       wsep = options_get_string(oo, "word-separators");
 
                /* Find a non-separator. */
                while (c->prompt_index != 0) {
diff --git a/trunk/tmux.h b/trunk/tmux.h
index 6553388..afeba8b 100644
--- a/trunk/tmux.h
+++ b/trunk/tmux.h
@@ -443,9 +443,12 @@ enum mode_key_cmd {
        MODEKEYEDIT_ENTER,
        MODEKEYEDIT_HISTORYDOWN,
        MODEKEYEDIT_HISTORYUP,
+       MODEKEYEDIT_NEXTSPACE,
+       MODEKEYEDIT_NEXTSPACEEND,
        MODEKEYEDIT_NEXTWORD,
        MODEKEYEDIT_NEXTWORDEND,
        MODEKEYEDIT_PASTE,
+       MODEKEYEDIT_PREVIOUSSPACE,
        MODEKEYEDIT_PREVIOUSWORD,
        MODEKEYEDIT_STARTOFLINE,
        MODEKEYEDIT_SWITCHMODE,
-- 
1.7.6.5

Attachment: pgpPwRjWKU879.pgp
Description: PGP signature

------------------------------------------------------------------------------
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to