From 2d24bcb6f607551dbf346b0c2218956dfdbf712a Mon Sep 17 00:00:00 2001 From: "Steffen (Daode) Nurpmeso" Date: Mon, 10 Oct 2016 23:16:34 +0200 Subject: [PATCH] Add ARG_G: cmd supposed to generate "gabby" history entries --- cmd_tab.h | 30 ++++++++++++++++-------------- lex.c | 7 ++++--- nail.h | 21 +++++++++++---------- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/cmd_tab.h b/cmd_tab.h index a2235a41..a5a0271e 100644 --- a/cmd_tab.h +++ b/cmd_tab.h @@ -43,6 +43,7 @@ #define ARG_ARGMASK ARG_ARGMASK #define A ARG_A #define F ARG_F +#define G ARG_G #define H ARG_H #define I ARG_I #define M ARG_M @@ -88,9 +89,9 @@ DS(N_("Delete the current message, then print the next")) }, { "undelete", &c_undelete, (A | P | MSGLIST), MDELETED,MMNDEL DS(N_("Un\"delete\" ")) }, - { "unset", &c_unset, (M | RAWLIST), 1, 1000 + { "unset", &c_unset, (G | M | RAWLIST), 1, 1000 DS(N_("Unset ")) }, - { "unsetenv", &c_unsetenv, (M | RAWLIST), 1, 1000 + { "unsetenv", &c_unsetenv, (G | M | RAWLIST), 1, 1000 DS(N_("Unset , also in the program environment")) }, { "mail", &c_sendmail, (R | M | I | STRLIST), 0, 0 DS(N_("Compose mail; recipients may be given as arguments")) }, @@ -132,9 +133,9 @@ DS(N_("Read commands from ")) }, { "source_if", &c_source_if, (M | R | RAWLIST), 1, 1 DS(N_("If can be opened successfully, read commands from it")) }, - { "set", &c_set, (M | RAWLIST), 0, 1000 + { "set", &c_set, (G | M | RAWLIST), 0, 1000 DS(N_("Print all variables, or set (a) (s)")) }, - { "setenv", &c_setenv, (M | RAWLIST), 1, 1000 + { "setenv", &c_setenv, (G | M | RAWLIST), 1, 1000 DS(N_("Set (a) (s) and export into the program environment")) }, { "shell", &c_dosh, (I | NOLIST), 0, 0 DS(N_("Invoke an interactive shell")) }, @@ -202,9 +203,9 @@ DS(N_("Forward to
")) }, { "fwd", &c_forward, (A | R | STRLIST), 0, MMNDEL DS(N_("Forward to
")) }, - { "edit", &c_editor, (A | I | MSGLIST), 0, MMNORM + { "edit", &c_editor, (G | A | I | MSGLIST), 0, MMNORM DS(N_("Edit ")) }, - { "echo", &c_echo, (H | M | ECHOLIST), 0, 1000 + { "echo", &c_echo, (G | M | ECHOLIST), 0, 1000 DS(N_("Echo given arguments")) }, { "quit", &_c_quit, NOLIST, 0, 0 DS(N_("Terminate session, saving messages as necessary")) }, @@ -224,13 +225,13 @@ DS(N_("Show size in characters for ")) }, { "hold", &c_preserve, (A | W | MSGLIST), 0, MMNDEL DS(N_("Save in system mailbox instead of *MBOX*")) }, - { "if", &c_if, (F | M | RAWLIST), 1, 1000 + { "if", &c_if, (G | F | M | RAWLIST), 1, 1000 DS(N_("Part of the if..elif..else..endif statement")) }, - { "else", &c_else, (F | M | RAWLIST), 0, 0 + { "else", &c_else, (G | F | M | RAWLIST), 0, 0 DS(N_("Part of the if..elif..else..endif statement")) }, - { "elif", &c_elif, (F | M | RAWLIST), 1, 1000 + { "elif", &c_elif, (G | F | M | RAWLIST), 1, 1000 DS(N_("Part of the if..elif..else..endif statement")) }, - { "endif", &c_endif, (F | M | RAWLIST), 0, 0 + { "endif", &c_endif, (G | F | M | RAWLIST), 0, 0 DS(N_("Part of the if..elif..else..endif statement")) }, { "alternates", &c_alternates, (M | RAWLIST), 0, 1000 DS(N_("Show or define an alternate list for the invoking user")) }, @@ -372,13 +373,13 @@ DS(N_("Print current working directory (CWD)")) }, { "pwd", &c_cwd, (M | NOLIST), 0, 0 DS(N_("Print current working directory (CWD)")) }, - { "varshow", &c_varshow, (M | RAWLIST), 1, 1000 + { "varshow", &c_varshow, (G | M | RAWLIST), 1, 1000 DS(N_("Show some informations about the given ")) }, - { "varedit", &c_varedit, (H | I | M | RAWLIST), 1, 1000 + { "varedit", &c_varedit, (G | I | M | RAWLIST), 1, 1000 DS(N_("Edit the value(s) of (an) variable(s), or create them")) }, - { "urlencode", &c_urlencode, (H| M | RAWLIST), 1, 1000 + { "urlencode", &c_urlencode, (G | M | RAWLIST), 1, 1000 DS(N_("Encode for usage in an URL")) }, - { "urldecode", &c_urldecode, (H | M | RAWLIST), 1, 1000 + { "urldecode", &c_urldecode, (G | M | RAWLIST), 1, 1000 DS(N_("Decode the URL-encoded into strings")) }, { "File", &c_File, (T | M | RAWLIST), 0, 1 DS(N_("Open a new mailbox readonly or show the current mailbox")) }, @@ -427,6 +428,7 @@ #undef ARG_ARGMASK #undef A #undef F +#undef G #undef H #undef I #undef M diff --git a/lex.c b/lex.c index 8a639237..9c408ebd 100644 --- a/lex.c +++ b/lex.c @@ -863,7 +863,7 @@ jreadline: goto jreadline; /* That *can* happen since evaluate() unstack()s on error! */ if (temporary_orig_line != NULL) - tty_addhist(temporary_orig_line, !ev.ev_add_history); + tty_addhist(temporary_orig_line, (ev.ev_add_history != TRU1)); } } @@ -1113,8 +1113,9 @@ je96: evp->ev_new_content = cp; goto jleave0; } - if (!(com->argtype & ARG_H) && !(pstate & PS_MSGLIST_SAW_NO)) - evp->ev_add_history = TRU1; + if (!(com->argtype & ARG_H)) + evp->ev_add_history = (((com->argtype & ARG_G) || + (pstate & PS_MSGLIST_SAW_NO)) ? TRUM1 : TRU1); jleave: /* Exit the current source file on error TODO what a mess! */ diff --git a/nail.h b/nail.h index 381257ba..5e97f03d 100644 --- a/nail.h +++ b/nail.h @@ -1481,7 +1481,7 @@ struct eval_ctx { ui32_t ev_line_size; /* May be used to store line memory size */ bool_t ev_is_recursive; /* Evaluation in evaluation? (collect ~:) */ ui8_t __dummy[3]; - bool_t ev_add_history; /* Enter (final) command in history? */ + bool_t ev_add_history; /* Add command to history (TRUM1=gabby)? */ char const *ev_new_content; /* History: reenter line, start with this */ }; @@ -1687,15 +1687,16 @@ enum argtype { ARG_A = 1u<< 4, /* Needs an active mailbox */ ARG_F = 1u<< 5, /* Is a conditional command */ - ARG_H = 1u<< 6, /* Never place in history */ - ARG_I = 1u<< 7, /* Interactive command bit */ - ARG_M = 1u<< 8, /* Legal from send mode bit */ - ARG_P = 1u<< 9, /* Autoprint dot after command */ - ARG_R = 1u<<10, /* Cannot be called from collect / recursion */ - ARG_T = 1u<<11, /* Is a transparent command */ - ARG_V = 1u<<12, /* Places data in temporary_arg_v_store */ - ARG_W = 1u<<13, /* Invalid when read only bit */ - ARG_O = 1u<<14 /* OBSOLETE()d command */ + ARG_G = 1u<< 6, /* Is supposed to produce "gabby" history */ + ARG_H = 1u<< 7, /* Never place in history */ + ARG_I = 1u<< 8, /* Interactive command bit */ + ARG_M = 1u<< 9, /* Legal from send mode bit */ + ARG_P = 1u<<10, /* Autoprint dot after command */ + ARG_R = 1u<<11, /* Cannot be called from collect / recursion */ + ARG_T = 1u<<12, /* Is a transparent command */ + ARG_V = 1u<<13, /* Places data in temporary_arg_v_store */ + ARG_W = 1u<<14, /* Invalid when read only bit */ + ARG_O = 1u<<15 /* OBSOLETE()d command */ }; enum gfield { -- 2.11.4.GIT