On Mon, Jun 14, 2021 at 07:44:24PM -0700, Kevin J. McCarthy wrote:
I still need to test more when I have time tomorrow, so please let me know if there are problems with this version.
And... right after I hit send, I noticed I forgot to include the (drretval < 0) test after the initial scan. I've copied that up and am attaching the modified patch.
-- Kevin J. McCarthy GPG Fingerprint: 8975 A9B3 3AA3 7910 385C 5308 ADEF 7684 8031 6BDA
From f06d18360b610366ce68d8ebf9d6a39a0572ec01 Mon Sep 17 00:00:00 2001 From: Rene Kita <m...@rkta.de> Date: Sun, 13 Jun 2021 15:56:58 +0200 Subject: [PATCH] Add skip_quoted_context option. Using skip-quoted the first unquoted line becomes the new top line displayed in the pager. This leaves the user with no context to know what the answer refers to. Add an option to keep some lines of context when using skip-quoted. With skip_quoted_context set to 5, skip-quoted will show at most 5 lines of the previous quote. If the previous quote is shorter than 5 lines the whole quote will be displayed. This option defaults to 0 to remain backwards compatible. --- globals.h | 1 + init.h | 9 +++++++ pager.c | 76 +++++++++++++++++++++++++++++++++++++++---------------- 3 files changed, 64 insertions(+), 22 deletions(-) diff --git a/globals.h b/globals.h index 859732e6..06ce410e 100644 --- a/globals.h +++ b/globals.h @@ -234,6 +234,7 @@ WHERE short HistSize; WHERE short MenuContext; WHERE short PagerContext; WHERE short PagerIndexLines; +WHERE short PagerSkipQuotedContext; WHERE short ReadInc; WHERE short ReflowWrap; WHERE short SaveHist; diff --git a/init.h b/init.h index acc7d8b2..26784882 100644 --- a/init.h +++ b/init.h @@ -2386,6 +2386,15 @@ struct option_t MuttVars[] = { ** is less than $$pager_index_lines, then the index will only use as ** many lines as it needs. */ + { "pager_skip_quoted_context", DT_NUM, R_NONE, {.p=&PagerSkipQuotedContext}, {.l=0} }, + /* + ** .pp + ** Determines the number of lines of context to show before the + ** unquoted text when using \fC$<skip-quoted>\fP. When set to a + ** positive number at most that many lines of the previous quote are + ** displayed. If the previous quote is shorter the whole quote is + ** displayed. + */ { "pager_stop", DT_BOOL, R_NONE, {.l=OPTPAGERSTOP}, {.l=0} }, /* ** .pp diff --git a/pager.c b/pager.c index 700af2d6..bb5d495b 100644 --- a/pager.c +++ b/pager.c @@ -2573,33 +2573,65 @@ search_next: { int dretval = 0; int new_topline = rd.topline; + int num_quoted = 0; - while ((new_topline < rd.lastLine || - (0 == (dretval = display_line (rd.fp, &rd.last_pos, &rd.lineInfo, - new_topline, &rd.lastLine, &rd.maxLine, MUTT_TYPES | (flags & MUTT_PAGER_NOWRAP), - &rd.QuoteList, &rd.q_level, &rd.force_redraw, &rd.SearchRE, rd.pager_window)))) - && rd.lineInfo[new_topline].type != MT_COLOR_QUOTED) - new_topline++; + if (PagerSkipQuotedContext < 0) + PagerSkipQuotedContext = 0; - if (dretval < 0) - { - mutt_error _("No more quoted text."); - break; - } + /* Skip past previous "context" quoted lines */ + if (PagerSkipQuotedContext > 0) + { + while ((new_topline < rd.lastLine || + (0 == (dretval = display_line (rd.fp, &rd.last_pos, &rd.lineInfo, + new_topline, &rd.lastLine, &rd.maxLine, MUTT_TYPES | (flags & MUTT_PAGER_NOWRAP), + &rd.QuoteList, &rd.q_level, &rd.force_redraw, &rd.SearchRE, rd.pager_window)))) + && rd.lineInfo[new_topline].type == MT_COLOR_QUOTED) + { + new_topline++; + num_quoted++; + } - while ((new_topline < rd.lastLine || - (0 == (dretval = display_line (rd.fp, &rd.last_pos, &rd.lineInfo, - new_topline, &rd.lastLine, &rd.maxLine, MUTT_TYPES | (flags & MUTT_PAGER_NOWRAP), - &rd.QuoteList, &rd.q_level, &rd.force_redraw, &rd.SearchRE, rd.pager_window)))) - && rd.lineInfo[new_topline].type == MT_COLOR_QUOTED) - new_topline++; + if (dretval < 0) + { + mutt_error _("No more unquoted text after quoted text."); + break; + } + } - if (dretval < 0) - { - mutt_error _("No more unquoted text after quoted text."); - break; + if (num_quoted <= PagerSkipQuotedContext) + { + num_quoted = 0; + while ((new_topline < rd.lastLine || + (0 == (dretval = display_line (rd.fp, &rd.last_pos, &rd.lineInfo, + new_topline, &rd.lastLine, &rd.maxLine, MUTT_TYPES | (flags & MUTT_PAGER_NOWRAP), + &rd.QuoteList, &rd.q_level, &rd.force_redraw, &rd.SearchRE, rd.pager_window)))) + && rd.lineInfo[new_topline].type != MT_COLOR_QUOTED) + new_topline++; + + if (dretval < 0) + { + mutt_error _("No more quoted text."); + break; + } + + while ((new_topline < rd.lastLine || + (0 == (dretval = display_line (rd.fp, &rd.last_pos, &rd.lineInfo, + new_topline, &rd.lastLine, &rd.maxLine, MUTT_TYPES | (flags & MUTT_PAGER_NOWRAP), + &rd.QuoteList, &rd.q_level, &rd.force_redraw, &rd.SearchRE, rd.pager_window)))) + && rd.lineInfo[new_topline].type == MT_COLOR_QUOTED) + { + new_topline++; + num_quoted++; + } + + if (dretval < 0) + { + mutt_error _("No more unquoted text after quoted text."); + break; + } } - rd.topline = new_topline; + + rd.topline = new_topline - MIN (PagerSkipQuotedContext, num_quoted); } break; -- 2.30.2
signature.asc
Description: PGP signature