From 0c4214ea2aec6497d0d67b436bbee9bc1d225f1e Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Thu, 22 Mar 2012 10:18:23 +0100 Subject: [PATCH] moreproc is now Pager/defaultpager; removed -moreproc flags; added env vars. The priority order is: MMHPAGER (env) > Pager (profile) > PAGER (env) > more --- config/config.c | 2 +- h/mh.h | 2 +- man/mh-chart.man1 | 2 -- man/mh-profile.man5 | 35 ++++++++++++++++++++++------------- man/mhl.man1 | 16 ++-------------- man/mhshow.man1 | 12 ++++++------ sbr/context_read.c | 10 ++++++++++ sbr/readconfig.c | 2 +- uip/mhl.c | 31 +++++++++++-------------------- uip/mhparam.c | 2 +- uip/mhshow.c | 25 +------------------------ uip/mhshowsbr.c | 14 +------------- uip/show.c | 23 +++++------------------ 13 files changed, 62 insertions(+), 114 deletions(-) diff --git a/config/config.c b/config/config.c index 946ea6b..e9b3f2b 100644 --- a/config/config.c +++ b/config/config.c @@ -146,7 +146,7 @@ char *mailproc = NMHBINDIR"/mhmail"; ** by mhshow as the default method of displaying message bodies ** or message parts of type text/plain. */ -char *moreproc = "more"; +char *defaultpager = "more"; /* ** This is the editor invoked by the various message diff --git a/h/mh.h b/h/mh.h index 39684af..026f0dc 100644 --- a/h/mh.h +++ b/h/mh.h @@ -293,6 +293,7 @@ extern char *components; extern char *context; extern char *curfolder; extern char *defaulteditor; +extern char *defaultpager; extern char *defaultfolder; extern char *digestcomps; extern char *distcomps; @@ -312,7 +313,6 @@ extern char *mhlproc; extern char *mhlreply; extern char *mimetypequery; extern char *mimetypequeryproc; -extern char *moreproc; extern char *msgprot; extern char *nmhaccessftp; extern char *nmhstorage; diff --git a/man/mh-chart.man1 b/man/mh-chart.man1 index 805bea8..150c0c1 100644 --- a/man/mh-chart.man1 +++ b/man/mh-chart.man1 @@ -256,8 +256,6 @@ is equivalent to .IR formfile ] .RB [ \-width .IR columns ] -.RB [ \-moreproc -.IR program ] .RI [ files .IR \&... ] .RB [ \-version ] diff --git a/man/mh-profile.man5 b/man/mh-profile.man5 index 5051da6..1f35701 100644 --- a/man/mh-profile.man5 +++ b/man/mh-profile.man5 @@ -145,6 +145,21 @@ and (profile, default: vi) .RE .PP +.BR Pager : +more +.RS 5 +This is the program used by +.B mhl +to page the +.B mhl +formatted message when displaying to a terminal. It is also the default +program used by +.B mhshow +to display message bodies (or message parts) of type text/plain. +This profile entry overrides the $PAGER environment variable, but gets +overridden by the $MMHPAGER environment variable. +.RE +.PP .BR Sendmail : /usr/sbin/sendmail .RS 5 @@ -459,19 +474,6 @@ is used to filter the message to which you are replying. .RE .PP -.BR moreproc : -more -.RS 5 -This is the program used by -.B mhl -to page the -.B mhl -formatted message when displaying to a terminal. It is also the default -program used by -.B mhshow -to display message bodies (or message parts) of type text/plain. -.RE -.PP .BR postproc : %bindir%/post .RS 5 @@ -681,6 +683,13 @@ This variable tells the default shell to run .RE .PP +.B $MMHPAGER +.br +.B $PAGER +.RS 5 +These variables (in descending priority) define the default pager to use. +.RE +.PP .B $TERM .RS 5 This variable tells diff --git a/man/mhl.man1 b/man/mhl.man1 index 9c57dbe..7e1f19d 100644 --- a/man/mhl.man1 +++ b/man/mhl.man1 @@ -14,8 +14,6 @@ mhl \- produce formatted listings of nmh messages .IR formfile ] .RB [ \-width .IR columns ] -.RB [ \-moreproc -.IR program ] .RI [ files .IR \&... ] .RB [ \-version ] @@ -35,19 +33,9 @@ If .B mhl is outputting to a terminal, then .B mhl -will -cause the -.I moreproc -to be placed between the terminal and +will cause a pager to be placed between the terminal and .BR mhl . .PP -To override the default -.I moreproc -and the profile entry, use the -.B \-moreproc -.I program -switch. -.PP The .B \-width .I width @@ -267,7 +255,7 @@ appropriate formatfield variable string. .nf .ta 2.4i .ta \w'ExtraBigProfileName 'u -^moreproc:~^Program to use as interactive front\-end +^Pager:~^Program to use as interactive front\-end .fi .SH "SEE ALSO" diff --git a/man/mhshow.man1 b/man/mhshow.man1 index f451ccb..5c49255 100644 --- a/man/mhshow.man1 +++ b/man/mhshow.man1 @@ -257,12 +257,12 @@ redirected from the terminal to the content. .PP If a display string is not found, .B mhshow -has several default values: +has the following default values: .PP .RS 5 .nf -mhshow-show-text/plain: %lmoreproc '%F' -mhshow-show-message/rfc822: %lshow -file '%F' +mhshow-show-text/plain: %l '%F' +mhshow-show-message/rfc822: %lshow \-file '%F' .fi .RE .PP @@ -394,9 +394,9 @@ determining whether a character is \*(lqnormal\*(rq, \*(lqcontrol\*(lq, or \*(lqbinary\*(rq. The second line tells .B less not to warn you -if it encounters a file that has non-ASCII characters. Then, simply +if it encounters a file that has non-ASCII characters. Then, set the -.I moreproc +.I Pager profile entry to .BR less , and it will get @@ -568,7 +568,7 @@ installation. ^nmh-private-cache~^Personal directory to store cached external contents ^mhshow-charset-~^Template for environment to render character sets ^mhshow-show-*~^Template for displaying contents -^moreproc:~^Default program to display text/plain content +^Pager:~^Default program to display text/plain content .fi .SH "SEE ALSO" diff --git a/sbr/context_read.c b/sbr/context_read.c index 1e795b0..d1b22ac 100644 --- a/sbr/context_read.c +++ b/sbr/context_read.c @@ -173,4 +173,14 @@ context_read(void) readconfig((struct node **) 0, ib, cp, 1); lkfclose(ib, ctxpath); } + + /* Set pager */ + if (!(cp = getenv("MMHPAGER")) || !*cp) { + if (!(cp = context_find("pager")) || !*cp) { + if (!(cp = getenv("PAGER")) || !*cp) { + cp = defaultpager; + } + } + } + defaultpager = cp; } diff --git a/sbr/readconfig.c b/sbr/readconfig.c index b78eb06..09cc4bd 100644 --- a/sbr/readconfig.c +++ b/sbr/readconfig.c @@ -28,7 +28,7 @@ static struct procstr procs[] = { { "lproc", &lproc }, { "mailproc", &mailproc }, { "mhlproc", &mhlproc }, - { "moreproc", &moreproc }, + { "pager", &defaultpager }, { "postproc", &postproc }, { "rmmproc", &rmmproc }, { "sendmail", &sendmail }, diff --git a/uip/mhl.c b/uip/mhl.c index 3d8ad8d..38926b6 100644 --- a/uip/mhl.c +++ b/uip/mhl.c @@ -45,27 +45,25 @@ static struct swit mhlswitches[] = { { "folder +folder", 0 }, #define FORMSW 1 { "form formfile", 0 }, -#define PROGSW 2 - { "moreproc program", 0 }, -#define WIDTHSW 3 +#define WIDTHSW 2 { "width columns", 0 }, -#define SLEEPSW 4 +#define SLEEPSW 3 { "sleep seconds", 0 }, -#define VERSIONSW 5 +#define VERSIONSW 4 { "version", 0 }, -#define HELPSW 6 +#define HELPSW 5 { "help", 0 }, -#define FORW1SW 7 +#define FORW1SW 6 { "forward", -7 }, -#define FORW2SW 8 +#define FORW2SW 7 { "forwall", -7 }, -#define DGSTSW 9 +#define DGSTSW 8 { "digest list", -6 }, -#define VOLUMSW 10 +#define VOLUMSW 9 { "volume number", -6 }, -#define ISSUESW 11 +#define ISSUESW 10 { "issue number", -5 }, -#define NBODYSW 12 +#define NBODYSW 11 { "nobody", -6 }, { NULL, 0 } }; @@ -252,7 +250,6 @@ main(int argc, char **argv) char *cp, *folder = NULL, *form = NULL; char buf[BUFSIZ], *files[MAXARGS]; char **argp, **arguments; - char *progsw = NULL; #ifdef LOCALE setlocale(LC_ALL, ""); @@ -304,12 +301,6 @@ main(int argc, char **argv) sleepsw = atoi(cp); /* ZERO ok! */ continue; - case PROGSW: - if (!(progsw = *argp++) || *progsw == '-') - adios(NULL, "missing argument to %s", - argp[-2]); - continue; - case WIDTHSW: if (!(cp = *argp++) || *cp == '-') adios(NULL, "missing argument to %s", @@ -365,7 +356,7 @@ main(int argc, char **argv) SIGNAL2(SIGQUIT, quitser); } SIGNAL2(SIGPIPE, pipeser); - m_popen(progsw ? progsw : moreproc); + m_popen(defaultpager); ontty = PITTY; } else { ontty = NOTTY; diff --git a/uip/mhparam.c b/uip/mhparam.c index db8e85a..0f9c487 100644 --- a/uip/mhparam.c +++ b/uip/mhparam.c @@ -45,8 +45,8 @@ static struct proc procs [] = { { "mailproc", &mailproc }, { "mhlproc", &mhlproc }, { "mimetypequeryproc", &mimetypequeryproc }, - { "moreproc", &moreproc }, { "msgprot", &msgprot }, + { "pager", &defaultpager }, { "postproc", &postproc }, { "rmmproc", &rmmproc }, { "sendmail", &sendmail }, diff --git a/uip/mhshow.c b/uip/mhshow.c index a1fff55..bbd99ea 100644 --- a/uip/mhshow.c +++ b/uip/mhshow.c @@ -52,16 +52,9 @@ static struct swit switches[] = { #define HELPSW 13 { "help", 0 }, /* -** switches for moreproc/mhlproc -*/ -#define PROGSW 14 - { "moreproc program", -4 }, -#define WIDTHSW 15 - { "width columns", -4 }, -/* ** switches for debugging */ -#define DEBUGSW 16 +#define DEBUGSW 14 { "debug", -5 }, { NULL, 0 } }; @@ -78,7 +71,6 @@ extern char *cache_private; /* mhshowsbr.c */ extern int serialsw; -extern char *progsw; extern int nolist; extern char *formsw; @@ -230,21 +222,6 @@ do_cache: formsw = getcpy(etcpath(cp)); continue; - /* - ** Switches for moreproc/mhlproc - */ - case PROGSW: - if (!(progsw = *argp++) || *progsw == '-') - adios(NULL, "missing argument to %s", - argp[-2]); - continue; - - case WIDTHSW: - if (!(cp = *argp++) || *cp == '-') - adios(NULL, "missing argument to %s", - argp[-2]); - continue; - case VERBSW: verbosw = 1; continue; diff --git a/uip/mhshowsbr.c b/uip/mhshowsbr.c index fe9a626..6dae3e8 100644 --- a/uip/mhshowsbr.c +++ b/uip/mhshowsbr.c @@ -36,12 +36,7 @@ extern int debugsw; int serialsw = 0; int nolist = 0; - -char *progsw = NULL; - -/* flags for moreproc/header display */ char *formsw = NULL; - pid_t xpid = 0; @@ -195,12 +190,6 @@ DisplayMsgHeader(CT ct, char *form) vec[vecp++] = form; vec[vecp++] = "-nobody"; vec[vecp++] = ct->c_file; - - /* If we've specified -moreproc, then just pass that along. */ - if (progsw) { - vec[vecp++] = "-moreproc"; - vec[vecp++] = progsw; - } vec[vecp] = NULL; fflush(stdout); @@ -615,8 +604,7 @@ show_text(CT ct, int serial, int alternate) ** if it is not a text part of a multipart/alternative */ if (!alternate || ct->c_subtype == TEXT_PLAIN) { - snprintf(buffer, sizeof(buffer), "%%p%s '%%F'", - progsw ? progsw : moreproc); + snprintf(buffer, sizeof(buffer), "%%p%s '%%F'", defaultpager); cp = (ct->c_showproc = getcpy(buffer)); return show_content_aux(ct, serial, alternate, cp, NULL); } diff --git a/uip/show.c b/uip/show.c index 2f5d9b4..70df693 100644 --- a/uip/show.c +++ b/uip/show.c @@ -21,19 +21,15 @@ static struct swit switches[] = { { "noheader", 0 }, #define FORMSW 4 { "form formfile", 0 }, -#define PROGSW 5 - { "moreproc program", 0 }, -#define WIDTHSW 6 - { "width columns", 0 }, -#define SHOWSW 7 +#define SHOWSW 5 { "showproc program", 0 }, -#define SHOWMIMESW 8 +#define SHOWMIMESW 6 { "showmimeproc program", 0 }, -#define FILESW 9 +#define FILESW 7 { "file file", -4 }, /* interface from lproc (whatnow) */ -#define VERSIONSW 10 +#define VERSIONSW 8 { "version", 0 }, -#define HELPSW 11 +#define HELPSW 9 { "help", 0 }, { NULL, 0 } }; @@ -120,15 +116,6 @@ usage: vec[vecp++] = getcpy(etcpath(cp)); continue; - case PROGSW: - case WIDTHSW: - vec[vecp++] = --cp; - if (!(cp = *argp++) || *cp == '-') - adios(NULL, "missing argument to %s", - argp[-2]); - vec[vecp++] = cp; - continue; - case SHOWSW: if (!(showproc = *argp++) || *showproc == '-') adios(NULL, "missing argument to %s", -- 1.7.10.4