summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard R. Link <brlink@debian.org>2008-06-15 15:02:03 +0200
committerShawn <sabetts@juicebox.(none)>2008-10-22 14:24:40 -0700
commit1e4c576b14025d4e16e09110c31b1dec5dac85b9 (patch)
treebcda968ad241db10c30605ce75d7130f69102966
parent4ca186ff04eb611db6b11aa0c06adda7f428d4f3 (diff)
downloadratpoison-1e4c576b14025d4e16e09110c31b1dec5dac85b9.zip
make history expansion an option (switched off by default)
-rw-r--r--src/actions.c16
-rw-r--r--src/data.h2
-rw-r--r--src/editor.c6
-rw-r--r--src/main.c1
4 files changed, 25 insertions, 0 deletions
diff --git a/src/actions.c b/src/actions.c
index 702c419..120d106 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -74,6 +74,7 @@ static cmdret * set_infofmt (struct cmdarg **args);
static cmdret * set_topkmap (struct cmdarg **args);
static cmdret * set_historysize (struct cmdarg **args);
static cmdret * set_historycompaction (struct cmdarg **args);
+static cmdret * set_historyexpansion (struct cmdarg **args);
LIST_HEAD(set_vars);
@@ -142,6 +143,7 @@ init_set_vars(void)
add_set_var ("topkmap", set_topkmap, 1, "", arg_STRING);
add_set_var ("historysize", set_historysize, 1, "", arg_NUMBER);
add_set_var ("historycompaction", set_historycompaction, 1, "", arg_NUMBER);
+ add_set_var ("historyexpansion", set_historyexpansion, 1, "", arg_NUMBER);
}
/* rp_keymaps is ratpoison's list of keymaps. */
@@ -3605,6 +3607,20 @@ set_historycompaction (struct cmdarg **args)
}
static cmdret *
+set_historyexpansion (struct cmdarg **args)
+{
+ if (args[0] == NULL)
+ return cmdret_new (RET_SUCCESS, "%d", defaults.history_expansion);
+#ifndef HAVE_HISTORY
+ if (ARG(0, number)) {
+ return cmdret_new (RET_FAILURE, "Not compiled with libhistory");
+ }
+#endif
+ defaults.history_expansion = ARG(0, number);
+ return cmdret_new (RET_SUCCESS, NULL);
+}
+
+static cmdret *
set_font (struct cmdarg **args)
{
#ifdef USE_XFT_FONT
diff --git a/src/data.h b/src/data.h
index 318e61c..a7785de 100644
--- a/src/data.h
+++ b/src/data.h
@@ -261,6 +261,8 @@ struct rp_defaults
int history_size;
/* remove older history when adding the same again */
int history_compaction;
+ /* expand ! when compiled with libhistory */
+ int history_expansion;
char *frame_selectors;
diff --git a/src/editor.c b/src/editor.c
index 0623186..23b6e35 100644
--- a/src/editor.c
+++ b/src/editor.c
@@ -457,6 +457,12 @@ editor_enter (rp_input_line *line)
char *expansion;
line->buffer[line->length] = '\0';
+
+ if (!defaults.history_expansion) {
+ history_add (line->history_id, line->buffer);
+ return EDIT_DONE;
+ }
+
result = history_expand_line (line->history_id, line->buffer, &expansion);
PRINT_DEBUG (("History Expansion - result: %d\n", result));
diff --git a/src/main.c b/src/main.c
index bb9fb7f..540bb6a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -564,6 +564,7 @@ init_defaults (void)
defaults.history_size = 20;
defaults.history_compaction = True;
+ defaults.history_expansion = False;
defaults.frame_selectors = xstrdup ("");
defaults.maxundos = 20;
}