Hallo, Does anybody know if there are any patches to color mutt's questions and to make tag-prefix "conditional", i.e. doing nothing if there are no tagged messages?
I should have asked first, but after not finding such patches, I tried to write them. They seem to work, but I don't know if they are really usable. The first one let's you color questions, for example: "color question brightwhite default" It contains no docu, and looks strange when you don't use the same background as with "normal". It also looks strange, for example when you change mailboxes, the mailboxname changes its color when changing this name. But if there is anybody interessted, I would try to solve these and add some docu (and an entry to the patches list). The second one adds a new command "tag-prefix-cond". It should behave exactly the same as tag-prefix, with one difference. If there are no tagged messages, it will empty the "ungetch-buffer", this seems to reliably stop/abort every macro. It's a hack, but it seems to work. Any comments appreciated. The patches were created from the freebsd mutt-devel port 1.3.23.2 If you call me clueless after looking at the patches, you are right :-) WARNING: THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Nicolas
--- color.c.ori Tue Nov 13 22:19:54 2001 +++ color.c Tue Nov 13 22:20:31 2001 @@ -78,6 +78,7 @@ { "status", MT_COLOR_STATUS }, { "tree", MT_COLOR_TREE }, { "error", MT_COLOR_ERROR }, + { "question", MT_COLOR_QUESTION }, { "normal", MT_COLOR_NORMAL }, { "tilde", MT_COLOR_TILDE }, { "markers", MT_COLOR_MARKERS }, --- mutt_curses.h.ori Tue Nov 13 22:19:12 2001 +++ mutt_curses.h Tue Nov 13 22:19:44 2001 @@ -119,6 +119,7 @@ MT_COLOR_BOLD, MT_COLOR_UNDERLINE, MT_COLOR_INDEX, + MT_COLOR_QUESTION, MT_COLOR_MAX }; --- curs_lib.c.ori Thu Nov 15 21:58:00 2001 +++ curs_lib.c Thu Nov 15 22:18:18 2001 @@ -105,7 +105,9 @@ do { CLEARLINE (LINES-1); + SETCOLOR(MT_COLOR_QUESTION); addstr (field); + SETCOLOR(MT_COLOR_NORMAL); mutt_refresh (); getyx (stdscr, y, x); ret = _mutt_enter_string (buf, buflen, y, x, complete, multiple, files, numfiles, es); @@ -170,7 +172,9 @@ #endif CLEARLINE(LINES-1); + SETCOLOR(MT_COLOR_QUESTION); printw ("%s ([%s]/%s): ", msg, def ? yes : no, def ? no : yes); + SETCOLOR(MT_COLOR_NORMAL); FOREVER { mutt_refresh (); @@ -396,10 +400,12 @@ { event_t ch; + SETCOLOR(MT_COLOR_QUESTION); mvaddstr (LINES-1, 0, (char *) prompt); addstr (_(" ('?' for list): ")); if (buf[0]) addstr (buf); + SETCOLOR(MT_COLOR_NORMAL); clrtoeol (); mutt_refresh (); @@ -481,7 +487,9 @@ char *p, *nletters; nletters = _(letters); + SETCOLOR (MT_COLOR_QUESTION); mvaddstr (LINES - 1, 0, prompt); + SETCOLOR (MT_COLOR_NORMAL); clrtoeol (); FOREVER {
--- OPS.orig Fri Nov 16 00:02:23 2001 +++ OPS Fri Nov 16 00:00:47 2001 @@ -153,6 +153,7 @@ OP_SORT_REVERSE "sort messages in reverse order" OP_TAG "tag the current entry" OP_TAG_PREFIX "apply next function to tagged messages" +OP_TAG_PREFIX_COND "apply next function ONLY to tagged messages" OP_TAG_SUBTHREAD "tag the current subthread" OP_TAG_THREAD "tag the current thread" OP_TOGGLE_NEW "toggle a message's 'new' flag" --- curs_lib.c.orig Thu Nov 15 23:56:51 2001 +++ curs_lib.c Thu Nov 15 23:57:02 2001 @@ -39,7 +39,7 @@ * is impossible to unget function keys in SLang, so roll our own input * buffering routines. */ -static size_t UngetCount = 0; +size_t UngetCount = 0; static size_t UngetBufLen = 0; static event_t *KeyEvent; --- curs_main.c.orig Thu Nov 15 23:53:57 2001 +++ curs_main.c Thu Nov 15 23:58:31 2001 @@ -43,7 +43,7 @@ - +extern size_t UngetCount; @@ -620,6 +620,36 @@ } else if (option (OPTAUTOTAG) && Context && Context->tagged) tag = 1; + + if (op == OP_TAG_PREFIX_COND) + { + if (!Context) + { + mutt_error _("No mailbox is open."); + continue; + } + + if (!Context->tagged) + { + while(UngetCount>0) + mutt_getch(); + mutt_error _("No tagged messages."); + continue; + } + tag = 1; + + /* give visual indication that the next command is a tag- command */ + mvaddstr (LINES - 1, 0, "tag-"); + clrtoeol (); + + /* get the real command */ + if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX) + { + /* abort tag sequence */ + CLEARLINE (LINES-1); + continue; + } + } mutt_clear_error (); } --- functions.h.orig Tue Sep 11 12:51:39 2001 +++ functions.h Thu Nov 15 23:57:02 2001 @@ -51,6 +51,7 @@ { "half-down", OP_HALF_DOWN, "]" }, { "help", OP_HELP, "?" }, { "tag-prefix", OP_TAG_PREFIX, ";" }, + { "tag-prefix-cond", OP_TAG_PREFIX_COND, NULL }, { "shell-escape", OP_SHELL_ESCAPE, "!" }, { "select-entry", OP_GENERIC_SELECT_ENTRY,M_ENTER_S }, { "search", OP_SEARCH, "/" }, --- menu.c.orig Tue Nov 6 21:36:57 2001 +++ menu.c Thu Nov 15 23:59:37 2001 @@ -30,6 +30,8 @@ extern int Charset_is_utf8; /* FIXME: bad modularisation */ +extern size_t UngetCount; + static void print_enriched_string (int attr, unsigned char *s, int do_color) { wchar_t wc; @@ -862,6 +864,24 @@ } else { + mutt_error _("No tagged entries."); + i = -1; + } + } + if (i == OP_TAG_PREFIX_COND) + { + if (menu->tagged) + { + mvaddstr (LINES - 1, 0, "Tag-"); + clrtoeol (); + i = km_dokey (menu->menu); + menu->tagprefix = 1; + CLEARLINE (LINES - 1); + } + else + { + while(UngetCount>0) + mutt_getch(); mutt_error _("No tagged entries."); i = -1; }