From: David Champion Date: Thu, 17 Nov 2016 23:57:42 +0000 (-0800) Subject: Adds binding to create "hotkeys" for messages. X-Git-Tag: mutt-1-8-rel~83 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fdeb4c487b6138c47bcb6e7f5aec07fbc55a557c;p=mutt Adds binding to create "hotkeys" for messages. foo will create a new macro "'foo" which will return to the current message by searching for that message's message id. The initial character of the macro is defined by $mark_macro_prefix, and defaults to "'" for verisimilitude vs. vi. Pushed by Kevin McCarthy with a minor fix. --- diff --git a/OPS b/OPS index 8bad616c..25506118 100644 --- a/OPS +++ b/OPS @@ -131,6 +131,7 @@ OP_MAIN_SYNC_FOLDER "save changes to mailbox" OP_MAIN_TAG_PATTERN "tag messages matching a pattern" OP_MAIN_UNDELETE_PATTERN "undelete messages matching a pattern" OP_MAIN_UNTAG_PATTERN "untag messages matching a pattern" +OP_MARK_MSG "create a hot-key macro for the current message" OP_MIDDLE_PAGE "move to the middle of the page" OP_NEXT_ENTRY "move to the next entry" OP_NEXT_LINE "scroll down one line" diff --git a/curs_main.c b/curs_main.c index 03e2f6a2..937edf26 100644 --- a/curs_main.c +++ b/curs_main.c @@ -2204,6 +2204,34 @@ int mutt_index_menu (void) } break; + + case OP_MARK_MSG: + + CHECK_MSGCOUNT; + CHECK_VISIBLE; + if (CURHDR->env->message_id) + { + char str[STRING], macro[STRING]; + char buf[128]; + + buf[0] = '\0'; + if (!mutt_get_field ("Enter macro stroke: ", buf, sizeof(buf), + MUTT_CLEAR) && buf[0]) + { + snprintf(str, sizeof(str), "%s%s", MarkMacroPrefix, buf); + snprintf(macro, sizeof(macro), + "~i \"%s\"\n", CURHDR->env->message_id); + km_bind(str, MENU_GENERIC, OP_MACRO, macro, "Message hotkey"); + + snprintf(buf, sizeof(buf), _("Message bound to %s."), str); + mutt_message(buf); + dprint (1, (debugfile, "Mark: %s => %s\n", str, macro)); + } + } + else + mutt_error _("No message ID to macro."); + break; + case OP_RECALL_MESSAGE: CHECK_ATTACH; diff --git a/doc/manual.xml.head b/doc/manual.xml.head index 75034cd0..f71792a4 100644 --- a/doc/manual.xml.head +++ b/doc/manual.xml.head @@ -5492,6 +5492,27 @@ dates shown in the main index. + +Marking Messages + + +There are times that it's useful to ask Mutt to "remember" which message +you're currently looking at, while you move elsewhere in your mailbox. +You can do this with the mark-message operator, which +is bound to the ~ key by default. Press this key to +enter an identifier for the marked message. When you want to return to +this message, press ' and the name that you previously +entered. + + + +(Message marking is really just a shortcut for defining a macro +that returns you to the current message by searching for its +Message-ID. You can choose a different prefix by setting the $mark_macro_prefix variable.) + + + Using Tags diff --git a/functions.h b/functions.h index a0a09d02..6f4b6b48 100644 --- a/functions.h +++ b/functions.h @@ -65,6 +65,7 @@ const struct binding_t OpGeneric[] = { /* map: generic */ { "previous-line", OP_PREV_LINE, "<" }, { "half-up", OP_HALF_UP, "[" }, { "half-down", OP_HALF_DOWN, "]" }, + { "mark-message", OP_MARK_MSG, "~" }, { "help", OP_HELP, "?" }, { "tag-prefix", OP_TAG_PREFIX, ";" }, { "tag-prefix-cond", OP_TAG_PREFIX_COND, NULL }, diff --git a/globals.h b/globals.h index 7be9fff8..30ad4413 100644 --- a/globals.h +++ b/globals.h @@ -78,6 +78,7 @@ WHERE char *HeaderCache; WHERE char *HeaderCachePageSize; #endif /* HAVE_GDBM || HAVE_DB4 */ #endif /* USE_HCACHE */ +WHERE char *MarkMacroPrefix; WHERE char *MhFlagged; WHERE char *MhReplied; WHERE char *MhUnseen; diff --git a/init.h b/init.h index 9a37194e..34103a46 100644 --- a/init.h +++ b/init.h @@ -1490,6 +1490,13 @@ struct option_t MuttVars[] = { ** slow down polling for new messages in large folders, since mutt has ** to scan all cur messages. */ + { "mark_macro_prefix",DT_STR, R_NONE, UL &MarkMacroPrefix, UL "'" }, + /* + ** .pp + ** Prefix for macros created using mark-message. A new macro + ** automatically generated with \fIa\fP will be composed + ** from this prefix and the letter \fIa\fP. + */ { "mark_old", DT_BOOL, R_BOTH, OPTMARKOLD, 1 }, /* ** .pp