for configuring a default editor with --with-editor.
sbr/folder_free.c sbr/folder_pack.c \
sbr/folder_read.c sbr/folder_realloc.c sbr/gans.c \
sbr/getans.c sbr/getanswer.c sbr/getarguments.c \
- sbr/getcpy.c sbr/getfolder.c sbr/getpass.c \
+ sbr/getcpy.c sbr/geteditor.c sbr/getfolder.c \
+ sbr/getpass.c \
sbr/fmt_addr.c sbr/fmt_compile.c sbr/fmt_new.c \
sbr/fmt_rfc2047.c sbr/fmt_scan.c sbr/lock_file.c \
sbr/m_atoi.c sbr/m_backup.c sbr/m_convert.c \
sbr_libmh_a_CPPFLAGS = -I./sbr -DNMHETCDIR='"$(sysconfdir)"' \
-DMAILSPOOL='"$(mailspool)"' \
-DSENDMAILPATH='"$(sendmailpath)"' -DNMHBINDIR='"$(bindir)"' \
- -DNMHLIBDIR='"$(libdir)"' \
- -DDEFAULT_EDITOR='"$(editorpath)"'
+ -DNMHLIBDIR='"$(libdir)"'
sbr_libdtimep_a_SOURCES = sbr/dtimep.l
sbr_libdtimep_a_CFLAGS = $(sbr_libmh_a_CPPFLAGS) \
@echo 's,%mandir%,$(mandir),g' >> $@
@echo 's,%mailspool%,$(mailspool),g' >> $@
@echo 's,%sendmailpath%,$(sendmailpath),g' >> $@
- @echo 's,%default_editor%,$(editorpath),g' >> $@
@echo 's,%manext1%,$(manext1),g' >> $@
@echo 's,%manext5%,$(manext5),g' >> $@
@echo 's,%manext7%,$(manext7),g' >> $@
char *whomproc = nmhbindir (/whom);
-/*
- * This is the editor invoked by the various message
- * composition programs. It SHOULD be a full screen
- * editor, such as vi or emacs, but any editor will work.
- */
-
-char *defaulteditor = DEFAULT_EDITOR;
-
/*
* This is the global nmh alias file. It is somewhat obsolete, since
* global aliases should be handled by the Mail Transport Agent (MTA).
AC_DEFINE([TLS_SUPPORT], [1], [Support TLS for session encryption.])dnl
tls_support=yes],[tls_support=no])
-dnl What should be the default editor?
-AC_ARG_WITH([editor],
- AS_HELP_STRING([--with-editor=EDITOR],[specify the default editor]))
-
-AS_IF([test -n "$with_editor"], [editorpath="$with_editor"])
-
dnl Set the backup prefix
AC_ARG_WITH([hash-backup],
AS_HELP_STRING([--with-hash-backup],[use # as the backup prefix (default: ,)]))
pathtmp=/usr/lib:/usr/sbin:/usr/etc:/usr/ucblib:/usr/bin:/bin
AC_PATH_PROG([sendmailpath], [sendmail], [/usr/sbin/sendmail], [$pathtmp])
-dnl Look for `vi'
-pathtmp=/usr/bin:/bin:/usr/ucb:/usr/local/bin
-AC_PATH_PROG([vipath], [vi], [/bin/vi], [$pathtmp])
-
-dnl If editor is not specified yet,
-dnl then use `vi' as the default.
-AS_IF([test -z "$editorpath"], [editorpath="$vipath"])
-AC_SUBST([editorpath])dnl
-
dnl Cygwin FAT filesystems do not support hard links. So default to
dnl cp instead, even if running on an NTFS or other filesystem.
AS_CASE(["$host_os"],
- inc(1) now supports a -port switch to specify the port used by the
POP server.
- pick(1) now decodes MIME-encoded header fields before searching.
+- The VISUAL and EDITOR environment variables are now supported as fallbacks
+ if the user does not configure an editor entry in their profile.
----------------------------
- The configure flag --with-pager has been removed; the default pager
is now hardcoded as "more". Users are still free to override the
default using the PAGER environment variable or entries in .mh_profile.
+- The configure flag --with-editor has been removed; the fallback editor
+ if none is configured is "vi".
---------
BUG FIXES
extern char *components;
extern char *context;
extern char *current;
-extern char *defaulteditor;
extern char *defaultfolder;
extern char *digestcomps;
extern char *distcomps;
*/
#define DEFAULT_PAGER "more"
+#define DEFAULT_EDITOR "vi"
#include <signal.h>
char **getarguments (char *, int, char **, int);
char *get_charset(void);
char *getcpy (char *);
+char *get_default_editor(void);
char *getfolder(int);
int lkclose(int, char*);
int lkfclose(FILE *, char *);
.RE
.PP
.BR Editor :
-/usr/bin/vi
+vi
.RS 5
Defines the editor to be used by the commands
.BR comp ,
.BR forw ,
and
.BR repl .
-(profile, default: %default_editor%)
+If not set in profile the value will be taken from the VISUAL and
+EDITOR environment variables.
+(profile, default: vi)
.RE
.PP
.BR automimeproc :
--- /dev/null
+
+/*
+ * geteditor.c -- Determine the default editor to use
+ *
+ * This code is Copyright (c) 2013, by the authors of nmh. See the
+ * COPYRIGHT file in the root directory of the nmh distribution for
+ * complete copyright information.
+ */
+
+#include <h/mh.h>
+#include <h/utils.h>
+
+static char *default_editor = NULL;
+
+char *
+get_default_editor(void)
+{
+ char *str;
+
+ if (default_editor)
+ return default_editor;
+
+ if (!(str = context_find("editor")) && !(str = getenv("VISUAL")) &&
+ !(str = getenv("EDITOR"))) {
+ str = DEFAULT_EDITOR;
+ }
+
+ return (default_editor = str);
+}
if (nedit) {
unputenv ("mheditor");
} else {
- m_putenv ("mheditor", ed ? ed : (ed = context_find ("editor"))
- ? ed : defaulteditor);
+ m_putenv ("mheditor", ed ? ed : (ed = get_default_editor()));
}
snprintf (buffer, sizeof(buffer), "%d", use);
m_putenv ("mhuse", buffer);
}
} else {
/* set initial editor */
- if (*ed == NULL && (*ed = context_find ("editor")) == NULL)
- *ed = defaulteditor;
+ if (*ed == NULL)
+ *ed = get_default_editor();
}
if (altmsg) {