summaryrefslogtreecommitdiffstats
path: root/hdrline.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2018-10-29 13:45:02 -0700
committerKevin McCarthy <kevin@8t8.us>2018-10-31 11:15:50 -0700
commit7ebb6205369a70643d79670a7305748f773faff6 (patch)
tree655eccf9842e807739f4746950fdf99d1f4831b4 /hdrline.c
parent5cfbcf522f90cbb745a5e5c8558aa47631caa7d5 (diff)
Add index-format-hook and expando.
index-format-hook is used to allow dynamic insertion/evaluation of format strings into $index_format. It can be used, for example, to implement date formatting based on the age of the message. Add a new %@name@ expando to $index_format, which evaluates the matching index-format-hooks with "name".
Diffstat (limited to 'hdrline.c')
-rw-r--r--hdrline.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/hdrline.c b/hdrline.c
index ea76e836..5e79d32d 100644
--- a/hdrline.c
+++ b/hdrline.c
@@ -753,6 +753,29 @@ hdr_format_str (char *dest,
break;
+ case '@':
+ {
+ const char *end = src;
+ static unsigned char recurse = 0;
+
+ while (*end && *end != '@')
+ end++;
+ if ((*end == '@') && (recurse < 20))
+ {
+ recurse++;
+ mutt_substrcpy (buf2, src, end, sizeof(buf2));
+ mutt_FormatString (buf2, sizeof(buf2), col, cols,
+ NONULL (mutt_idxfmt_hook (buf2, ctx, hdr)),
+ hdr_format_str, (unsigned long) hfi, flags);
+ mutt_format_s (dest, destlen, prefix, buf2);
+ recurse--;
+
+ src = end + 1;
+ break;
+ }
+ /* otherwise fall through */
+ }
+
default:
snprintf (dest, destlen, "%%%s%c", prefix, op);
break;