From: Richard Russon Date: Mon, 7 Mar 2016 04:43:54 +0000 (+0000) Subject: merge: cond-date - use rules to choose date format X-Git-Tag: neomutt-20160307~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=13b4e6ed9fbcd360f531f84ab7728db056435a74;p=neomutt merge: cond-date - use rules to choose date format * feature: conditional dates * change date comparisons * tidy code * add docs * add ident to PATCHES --- 13b4e6ed9fbcd360f531f84ab7728db056435a74 diff --cc PATCHES index 7f5aa585a,d86010759..61a54fb78 --- a/PATCHES +++ b/PATCHES @@@ -1,5 -1,1 +1,6 @@@ +patch-quasi-delete-neo-UNKNOWN +patch-progress-neo-UNKNOWN +patch-status-color-neo-UNKNOWN +patch-index-color-neo-UNKNOWN +patch-nested-if-neo-UNKNOWN + patch-cond-date-neo-UNKNOWN diff --cc doc/manual.xml.head index d8fbd46e6,43e5190fc..4d90b743b --- a/doc/manual.xml.head +++ b/doc/manual.xml.head @@@ -8034,888 -8016,413 +8055,1295 @@@ please have a look at the mixmaster doc + + Quasi-Delete Patch + Mark emails that should be hidden, but not deleted + + + Patch + + + To check if Mutt supports Quasi-Delete, look for + patch-quasi-delete in the mutt version. + See: . + + + + Dependencies: + mutt-1.5.24 + + + This patch is part of the NeoMutt Project. + + + + Introduction + + + The quasi-delete function marks an email that should be + hidden from the index, but NOT deleted. + + + + On its own, this patch isn't very useful. It forms a useful part of + the notmuch plugin. + + + + + + + Functions + + Quasi-Delete Functions + + + + Menus + Default Key + Function + Description + + + + + index,pager + (none) + <quasi-delete> + delete from mutt, don't touch on disk + + + +
+
+ + + + + Muttrc + +# Example Mutt config file for the 'quasi-delete' feature. + +# The 'quasi-delete' function marks an email that should be hidden +# from the index, but NOT deleted. +bind index,pager Q quasi-delete + +# vim: syntax=muttrc + + + + + See Also + + + NeoMutt Project + notmuch patch + + + + + Known Bugs + None + + + + Credits + + Karel Zak kzak@redhat.com + Richard Russon rich@flatcap.org + + +
+ + + Progress Bar Patch + Show a visual progress bar on slow operations + + + Patch + + + To check if Mutt supports Progress Bar, look for + patch-progress in the mutt version. + See: . + + + + Dependencies: + mutt-1.5.24 + + + This patch is part of the NeoMutt Project. + + + + Introduction + + + The progress patch shows a visual progress bar on slow + tasks, such as indexing a large folder over the net. + + + + + + + Colors + + Progress Colors + + + + Name + Default Color + Description + + + + + progress + default + Visual progress bar + + + +
+
+ + + + + Muttrc + +# Example Mutt config file for the 'progress' patch. + +# The 'progress' patch provides clear visual feedback for +# slow tasks, such as indexing a large folder over the net. + +# Set the color of the progress bar +# White text on a red background +color progress white red + +# vim: syntax=muttrc + + + + + See Also + + + NeoMutt Project + Color command + + + + + Known Bugs + None + + + + Credits + + Stefan Kuhn wuodan@hispeed.ch + Karel Zak kzak@redhat.com + Richard Russon rich@flatcap.org + + +
+ + + Status Color Patch + Custom rules for theming the status bar + + + Patch + + + To check if Mutt supports Status Color, look for + patch-status-color in the mutt version. + See: . + + + + Dependencies: + mutt-1.5.24 + + + This patch is part of the NeoMutt Project. + + + + Introduction + + + The status-color patch allows you to theme different + parts of the status bar (also when it's used by the index). + + + + Unlike normal color commands, color status can now + take up to 2 extra parameters (regex, num). + + + + + + + Commands + + color + + + + + foreground + + + background + + + + regex + + + + num + + + + + + + With zero parameters, Mutt will set the default color for the entire + status bar. + + + + With one parameter, Mutt will only color the parts matching the + regex. + + + + With two parameters, Mutt will only color the num'th sub-match of + the regex. + + + + + Colors + + + Status Colors + + + + Name + Default Color + Description + + + + + status + reverse + Status bar + + + +
+
+ + + + + Muttrc + +# Example Mutt config file for the 'status-color' patch. + +# The 'status-color' patch allows you to theme different parts of +# the status bar (also when it's used by the index). + +# For the examples below, set some defaults +set status_format='-%r-Mutt: %f [Msgs:%?M?%M/?%m%?n? New:%n?%?o? Old:%o?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b? Inc:%b?%?l? %l?]---(%s/%S)-%>-(%P)---' +set index_format='%4C %Z %{%b %d} %-15.15L (%?l?%4l&%4c?) %s' +set sort=threads +set sort_aux=last-date-received + +# 'status color' can take up to 2 extra parameters + +# color status foreground background [ regex [ num ]] + +# 0 extra parameters +# Set the default color for the entire status line +color status blue white + +# 1 extra parameter +# Set the color for a matching pattern +# color status foreground background regexp + +# Highlight New, Deleted, or Flagged emails +color status brightred white '(New|Del|Flag):[0-9]+' + +# Highlight mailbox ordering if it's different from the default +# First, highlight anything (*/*) +color status brightred default '\([^)]+/[^)]+\)' + +# Then override the color for one specfic case +color status default default '\(threads/last-date-received\)' + +# 2 extra parameters +# Set the color for the nth submatch of a pattern +# color status foreground background regexp num + +# Highlight the contents of the []s but not the [] themselves +color status red default '\[([^]]+)\]' 1 + +# The '1' refers to the first regex submatch, which is the inner +# part in ()s + +# Highlight the mailbox +color status brightwhite default 'Mutt: ([^ ]+)' 1 + +# Search for 'Mutt: ' but only highlight what comes after it + +# vim: syntax=muttrc + + + + + See Also + + + NeoMutt Project + Compile-Time Features + Regular Expressions + Patterns + index-color patch + Color command + + + + + Known Bugs + None + + + + Credits + + David Sterba dsterba@suse.cz + Thomas Glanzmann thomas@glanzmann.de + Kirill A. Shutemov kirill@shutemov.name + Richard Russon rich@flatcap.org + + +
+ + + Index Color Patch + Custom rules for theming the email index + + + Patch + + + To check if Mutt supports Index Color, look for + patch-index-color in the mutt version. + See: . + + + + Dependencies: + mutt-1.5.24 + status-color patch + + + This patch is part of the NeoMutt Project. + + + + Introduction + + + The index-color patch allows you to specify colors for + individual parts of the email index. e.g. Subject, Author, Flags. + + + + First choose which part of the index you'd like to color. + Then, if needed, pick a pattern to match. + + + + Note: The pattern does not have to refer to the object you wish to + color. e.g. + + + +color index_author red default "~smutt" + + + + The author appears red when the subject (~s) contains mutt. + + + + + + + Colors + + + All the colors default to default, i.e. unset. + + + + The index objects can be themed using the color command. + Some objects require a pattern. + + + +color index-object foreground background +color index-object foreground background pattern + + + + Index Colors + + + + Object + Pattern + Highlights + + + + + index + yes + Entire index line + + + index_author + yes + Author name, %A %a %F %L %n + + + index_collapsed + no + Number of messages in a collapsed thread, %M + + + index_date + no + Date field + + + index_flags + yes + Message flags, %S %Z + + + index_label + no + Message label, %y %Y + + + index_number + no + Message number, %C + + + index_size + no + Message size, %c %l + + + index_subject + yes + Subject, %s + + + +
+
+ + + + + Muttrc + +# Example Mutt config file for the 'index-color' feature. + +# Entire index line +color index white black '.*' + +# Author name, %A %a %F %L %n + +# Give the author column a dark grey background +color index_author default color234 '.*' + +# Highlight a particular from (~f) +color index_author brightyellow color234 '~fRay Charles' + +# Message flags, %S %Z +# Highlight the flags for flagged (~F) emails +color index_flags default red '~F' + +# Subject, %s +# Look for a particular subject (~s) +color index_subject brightcyan default '~s\(closes #[0-9]+\)' + +# Number of messages in a collapsed thread, %M +color index_collapsed default brightblue + +# Date field +color index_date green default + +# Message label, %y %Y +color index_label default brightgreen + +# Message number, %C +color index_number red default + +# Message size, %c %l +color index_size cyan default + +# vim: syntax=muttrc + + + + + See Also + + + NeoMutt Project + Regular Expressions + Patterns + $index_format + Color command + Status-Color patch + Keywords patch + + + + + Known Bugs + None + + + + Credits + + Christian Aichinger Greek0@gmx.net + Christoph Myon Berg myon@debian.org + Elimar Riesebieter riesebie@lxtec.de + Eric Davis edavis@insanum.com + Vladimir Marek Vladimir.Marek@oracle.com + Richard Russon rich@flatcap.org + + +
+ + + Nested If Patch + Allow complex nested conditions in format strings + + + Patch + + + To check if Mutt supports Nested If, look for + patch-nested-if in the mutt version. + See: . + + + + Dependencies: + mutt-1.5.24 + + + This patch is part of the NeoMutt Project. + + + + Introduction + + + Mutt's format strings can contain embedded if-then-else conditions. + They are of the form: + + + +%?VAR?TRUE&FALSE? + + + + If the variable VAR has a value greater than zero, + print the TRUE string, otherwise print the + FALSE string. + + + + e.g. %?S?Size: %S&Empty? + + + Which can be read as: + + + if (%S > 0) { + print "Size: %S" + } else { + print "Empty" + } + + + + These conditions are useful, but in Mutt they cannot be nested + within one another. This patch uses the notation + %<VAR?TRUE&FALSE> and allows them to be nested. + + + + The %<...> notation was used to format the + current local time. but that's not really very useful since mutt + has no means of refreshing the screen periodically. + + + + A simple nested condition might be: + (Some whitespace has been introduced for clarity) + + + + %<x? %<y? XY & X > & %<y? Y & NONE > > Conditions + %<y? XY & X > x>0 + XY x>0,y>0 + X x>0,y=0 + + + + %<x? %<y? XY & X > & %<y? Y & NONE > > Conditions + %<y? Y & NONE > x=0 + Y x=0,y>0 + NONE x=0,y=0 + + + Equivalent to: + + + if (x > 0) { + if (y > 0) { + print 'XY' + } else { + print 'X' + } + } else { + if (y > 0) { + print 'Y' + } else { + print 'NONE' + } + } + + + Examples: + + +set index_format='%4C %Z %{%b %d} %-25.25n %s%> %<M?%M Msgs &%<l?%l Lines&%c Bytes>>' + + + + if a thread is folded + display the number of messages (%M) + else if we know how many lines in the message + display lines in message (%l) + else + display the size of the message in bytes (%c) + + + +set index_format='%4C %Z %{%b %d} %-25.25n %<M?[%M] %s&%s%* %<l?%l&%c>>' + + + + if a thread is folded + display the number of messages (%M) + display the subject (%s) + else if we know how many lines in the message + display lines in message (%l) + else + display the size of the message in bytes (%c) + + + + + + Variables + The nested-if patch doesn't have any config of its own. + It modifies the behavior of the format strings. + + + + + + Muttrc + +# Example Mutt config file for the 'nested-if' feature. + +# This patch uses the format: '%<VAR?TRUE&FALSE>' for conditional +# format strings that can be nested. + +# Example 1 +# if a thread is folded +# display the number of messages (%M) +# else if we know how many lines in the message +# display lines in message (%l) +# else display the size of the message in bytes (%c) +set index_format='%4C %Z %{%b %d} %-25.25n %s%> %<M?%M Msgs &%<l?%l Lines&%c Bytes>>' + +# Example 2 +# if a thread is folded +# display the number of messages (%M) +# display the subject (%s) +# else if we know how many lines in the message +# display lines in message (%l) +# else +# display the size of the message in bytes (%c) +set index_format='%4C %Z %{%b %d} %-25.25n %<M?[%M] %s&%s%* %<l?%l&%c>>' + +# vim: syntax=muttrc + + + + + See Also + + + NeoMutt Project + cond-date patch + $index_format + $status_format + + + + + Known Bugs + Patch overwrites $<fmt> handler in $index_format + + + + Credits + + David Champion dgc@uchicago.edu + Richard Russon rich@flatcap.org + + + + + + Conditional Dates Patch + Use rules to choose date format + + + Patch + + + To check if Mutt supports Conditional Dates, look for + patch-cond-date in the mutt version. + See: . + + + + Dependencies: + mutt-1.5.24 + nested-if patch + + + + This patch is part of the NeoMutt Project. + + + + + Introduction + + + The cond-date patch allows you to construct + $index_format expressions based on the age of the email. + + + + Mutt's default $index_format displays email dates in the + form: abbreviated-month day-of-month — Jan 14. + + + + The format is configurable but only per-mailbox. This patch allows you + to configure the display depending on the age of the email. + + + + Potential Formatting Scheme + + + + Email Sent + Format + Example + + + + + Today + %H:%M + 13:23 + + + This Month + %a %d + Thu 17 + + + This Year + %b %d + Dec 10 + + + Older than 1 Year + %m/%y + 06/14 + + + +
+ + + For an explanation of the date formatting strings, see + strftime(3). + + + + By carefully picking your formats, the dates can remain + unambiguous and compact. + + + + Mutt's conditional format strings have the form: + (whitespace introduced for clarity) + + + %? TEST ? TRUE & FALSE ? + + + The examples below use the test %[ — the date + of the message in the local timezone. They will also work with + %( — the local time that the message arrived. + + + + The date tests are of the form: + + + %[nX? TRUE & FALSE ? + + + n is an optional count (defaults to 1 if missing) + X is the time period + + + + Date Formatting Codes + + + + Letter + Time Period + + + + + y + Years + + + m + Months + + + w + Weeks + + + d + Days + + + H + Hours + + + M + Minutes + + + +
+ + + Example Date Tests + + + + Test + Meaning + + + + + %[y + This year + + + %[1y + This year + + + %[6m + In the last 6 months + + + %[w + This week + + + %[d + Today + + + %[4H + In the last 4 hours + + + +
+ + + Example 1 + + We start with a one-condition test. + + + Example 1 + + + + Test + Date Range + Format String + Example + + + + + %[1m + This month + %[%b %d] + Dec 10 + + + + Older + %[%Y-%m-%d] + 2015-04-23 + + + +
+ + The $index_format string would contain: + + %?[1m?%[%b %d]&%[%Y-%m-%d]? + + + + Reparsed a little, for clarity, you can see the + test condition and the two format strings. + + + + %?[1m? & ? + %[%b %d] %[%Y-%m-%d] + + +
+ + + Example 2 + + + This example contains three test conditions and four date formats. + + + + Example 2 + + + + Test + Date Range + Format String + Example + + + + + %[d + Today + %[%H:%M ] + 12:34 + + + %[m + This month + %[%a %d] + Thu 12 + + + %[y + This year + %[%b %d] + Dec 10 + + + + Older + %[%m/%y ] + 06/15 + + + +
+ + The $index_format string would contain: + + + %<[y?%<[m?%<[d?%[%H:%M ]&%[%a %d]>&%[%b %d]>&%[%m/%y ]> + + + + Reparsed a little, for clarity, you can see the + test conditions and the four format strings. + + + + %<[y? &%[%m/%y ]> Older + %<[m? &%[%b %d]> This year + %<[d? &%[%a %d]> This month + %[%H:%M ] Today + + + + This a another view of the same example, with some whitespace + for clarity. + + + + %<[y? %<[m? %<[d? AAA & BBB > & CCC > & DDD > + + + + AAA = %[%H:%M ] + BBB = %[%a %d] + CCC = %[%b %d] + DDD = %[%m/%y ] + +
+
+ + + Variables + + + The cond-date patch doesn't have any config of its own. + It modifies the behavior of the format strings. + + + + + + + Muttrc + + # Example Mutt config file for the 'index-color' feature. + # + # The default index_format is: + # '%4C %Z %{%b %d} %-15.15L (%?l?%4l&%4c?) %s' + # + # We replace the date field '%{%b %d}', giving: + set index_format='%4C %Z %<[y?%<[m?%<[d?%[%H:%M ]&%[%a %d]>&%[%b %d]>&%[%m/%y ]> %-15.15L (%?l?%4l&%4c?) %s' + + # Test Date Range Format String Example + # -------------------------------------------- + # %[d Today %[%H:%M ] 12:34 + # %[m This month %[%a %d] Thu 12 + # %[y This year %[%b %d] Dec 10 + # - Older %[%m/%y ] 06/15 + + # vim: syntax=muttrc + + + + + See Also + + + NeoMutt Project + $index_format + nested-if patch + strftime(3) + + + + + Known Bugs + + + Date parsing doesn't quite do what you expect. + 1w doesn't mean the in the last 7 days, but + this week. This doesn't match + the normal Mutt behaviour: for example ~d>1w + means emails dated in the last 7 days. + + + + + + Credits + + Aaron Schrab aaron@schrab.com + Eric Davis edavis@insanum.com + Richard Russon rich@flatcap.org + + +
+ diff --cc muttlib.c index 8799bcd94,cab74ba91..eda7a9fe0 --- a/muttlib.c +++ b/muttlib.c @@@ -1274,27 -1206,17 +1274,35 @@@ void mutt_FormatString (char *dest, / } if (*src == '?') + { + /* change original %? to new %< notation */ + /* %?x?y&z? to % where y and z are nestable */ + char *p = (char *) src; + *p = '<'; + for ( ; *p && *p != '?'; p++); + /* nothing */ + if (*p == '?') { + p++; + } + for ( ; *p && *p != '?'; p++); + /* nothing */ + if (*p == '?') { + *p = '>'; + } + } + + if (*src == '<') { flags |= M_FORMAT_OPTIONAL; + ch = *(++src); /* save the character to switch on */ src++; + cp = prefix; + count = 0; + while ((count < sizeof (prefix)) && (*src != '?')) { + *cp++ = *src++; + count++; + } + *cp = 0; } else {