From: markus schnalke Date: Thu, 22 Mar 2012 09:52:49 +0000 (+0100) Subject: Rework of Editor/defaulteditor, similar to Pager/defaultpager; new env vars. X-Git-Tag: mmh-thesis-end~258 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=f85f4b7ae62e3d05a945dcd46ead51f0a2a89a9b;p=mmh Rework of Editor/defaulteditor, similar to Pager/defaultpager; new env vars. The priority order is: MMHEDITOR (env) > Editor (profile) > VISUAL (env) EDITOR (env) > vi --- diff --git a/man/mh-profile.man5 b/man/mh-profile.man5 index 1f35701..dc37bb9 100644 --- a/man/mh-profile.man5 +++ b/man/mh-profile.man5 @@ -134,7 +134,7 @@ man page for details about private sequences. .RE .PP .BR Editor : -/usr/bin/vi +vi .RS 5 Defines the editor to be used by the commands .BR comp , @@ -142,6 +142,8 @@ Defines the editor to be used by the commands .BR forw , and .BR repl . +This profile entry overrides the $VISUAL and $EDITOR environment variables, +but gets overridden by the $MMHEDITOR environment variabel. (profile, default: vi) .RE .PP @@ -158,6 +160,7 @@ program used by 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. +(profile, default: more) .RE .PP .BR Sendmail : @@ -683,6 +686,15 @@ This variable tells the default shell to run .RE .PP +.B $MMHEDITOR +.br +.B $VISUAL +.br +.B $EDITOR +.RS 5 +These variables (in descending priority) define the default editor to use. +.RE +.PP .B $MMHPAGER .br .B $PAGER diff --git a/sbr/context_read.c b/sbr/context_read.c index d1b22ac..5733d3f 100644 --- a/sbr/context_read.c +++ b/sbr/context_read.c @@ -174,6 +174,18 @@ context_read(void) lkfclose(ib, ctxpath); } + /* Set editor */ + if (!(cp = getenv("MMHEDITOR")) || !*cp) { + if (!(cp = context_find("editor")) || !*cp) { + if (!(cp = getenv("VISUAL")) || !*cp) { + if (!(cp = getenv("EDITOR")) || !*cp) { + cp = defaulteditor; + } + } + } + } + defaulteditor = cp; + /* Set pager */ if (!(cp = getenv("MMHPAGER")) || !*cp) { if (!(cp = context_find("pager")) || !*cp) { diff --git a/uip/whatnow.c b/uip/whatnow.c index b809ebe..bd1a3d5 100644 --- a/uip/whatnow.c +++ b/uip/whatnow.c @@ -622,10 +622,9 @@ editfile(char **ed, char **arg, char *file, int use, struct msgs *mp, if ((cp = context_find(cp)) != NULL) *ed = cp; } - } else { + } else if (!*ed) { /* set initial editor */ - if (*ed == NULL && (*ed = context_find("editor")) == NULL) - *ed = defaulteditor; + *ed = defaulteditor; } if (altmsg) { diff --git a/uip/whatnowproc.c b/uip/whatnowproc.c index 1b16e5d..fbea941 100644 --- a/uip/whatnowproc.c +++ b/uip/whatnowproc.c @@ -51,8 +51,7 @@ what_now(char *ed, int nedit, int use, char *file, char *altmsg, int dist, if (nedit) { unputenv("mheditor"); } else { - m_putenv("mheditor", ed ? ed : (ed = context_find("editor")) ? - ed : defaulteditor); + m_putenv("mheditor", ed ? ed : defaulteditor); } snprintf(buffer, sizeof(buffer), "%d", use); m_putenv("mhuse", buffer);