}
else if (a->type == TYPETEXT) {
/* On text, default to editor */
- mutt_edit_file (NONULL (Editor), a->filename);
+ mutt_edit_file(a->filename);
} else {
rfc1524_entry_delete(&entry);
mutt_error (_("No mailcap edit entry for %s"), type);
mutt_message_hook (NULL, msg, M_SEND2HOOK);
break;
case OP_COMPOSE_EDIT_MESSAGE:
- if (Editor && !option (OPTEDITHDRS)) {
- mutt_edit_file (Editor, msg->content->filename);
+ if (!option (OPTEDITHDRS)) {
+ mutt_edit_file(msg->content->filename);
mutt_update_encoding (msg->content);
menu->redraw = REDRAW_CURRENT | REDRAW_STATUS;
mutt_message_hook (NULL, msg, M_SEND2HOOK);
char *err = NULL;
mutt_env_to_local (msg->env);
- mutt_edit_headers (NONULL (Editor), msg->content->filename, msg,
- fcc, fcclen);
+ mutt_edit_headers(msg->content->filename, msg, fcc, fcclen);
if (mutt_env_to_idna (msg->env, &tag, &err)) {
mutt_error (_("Bad IDN in \"%s\": '%s'"), tag, err);
p_delete(&err);
case OP_COMPOSE_EDIT_FILE:
CHECK_COUNT;
- mutt_edit_file (NONULL (Editor), idx[menu->current]->content->filename);
+ mutt_edit_file(idx[menu->current]->content->filename);
mutt_update_encoding (idx[menu->current]->content);
menu->redraw = REDRAW_CURRENT | REDRAW_STATUS;
mutt_message_hook (NULL, msg, M_SEND2HOOK);
goto bail;
}
- mutt_edit_file (NONULL (Editor), tmp);
+ mutt_edit_file(tmp);
if ((rc = stat (tmp, &sb)) == -1) {
mutt_error (_("Can't stat %s: %s"), tmp, strerror (errno));
WHERE char *DisplayFilter;
WHERE char *DsnNotify;
WHERE char *DsnReturn;
-WHERE char *Editor;
WHERE char *EditorHeaders;
WHERE char *FileCharset;
WHERE char *FolderFormat;
#include <lib-crypt/crypt.h>
#include "mutt_idna.h"
-void mutt_edit_headers (const char *editor,
- const char *body,
- HEADER * msg, char *fcc, ssize_t fcclen)
+void mutt_edit_headers(const char *body,
+ HEADER * msg, char *fcc, ssize_t fcclen)
{
char path[_POSIX_PATH_MAX]; /* tempfile used to edit headers + body */
char buffer[LONG_STRING];
mtime = m_decrease_mtime(path, &st);
- mutt_edit_file (editor, path);
+ mutt_edit_file(path);
stat (path, &st);
if (mtime == st.st_mtime) {
/* the file has not changed! */
Tempdir = m_strdup((p = getenv ("TMPDIR")) ? p : "/tmp");
- p = getenv ("VISUAL");
- if (!p) {
- p = getenv ("EDITOR");
- if (!p)
- p = "vi";
- }
- Editor = m_strdup(p);
-
if ((p = getenv ("REPLYTO")) != NULL) {
BUFFER buf, token;
** Note: if $$edit_headers had to be turned on by force because
** $$strict_mailto is \fIunset\fP, this option has no effect.
*/
- {"editor", DT_PATH, R_NONE, UL &Editor, "" },
- /*
- ** .pp
- ** This variable specifies which editor is used by Madmutt.
- ** It defaults to the value of the \fT$$$VISUAL\fP, or \fT$$$EDITOR\fP, environment
- ** variable, or to the string "\fTvi\fP" if neither of those are set.
- */
{"encode_from", DT_BOOL, R_NONE, OPTENCODEFROM, "no" },
/*
** .pp
############ Put tokens here ############
## dotlock
+## editor
## sendmail
## shell
## tmpdir
case LTK_SENDMAIL:
case LTK_SHELL:
_mutt_expand_path(buf, sizeof(buf), val, 0);
- mlua_regsets(tk, buf);
+ val = buf;
+ /* FALLTHROUGH */
+
+ case LTK_EDITOR:
+ mlua_regsets(tk, val);
return 0;
}
}
/* {{{ madmutt magic properties */
+static void madmutt_init_editor(char *buf, ssize_t len)
+{
+ m_strcpy(buf, len, getenv("VISUAL") ?: getenv("EDITOR") ?: "vi");
+ fprintf("%s\n", buf);
+}
+
static void madmutt_init_shell(char *buf, ssize_t len)
{
struct passwd *pw = getpwuid(getuid());
** Contains the path of the \fTmadmutt_dotlock(1)\fP binary to be used by
** Madmutt.
*/
+ {"editor", madmutt_init_editor, NULL },
+ /*
+ ** .pp
+ ** This variable specifies which editor is used by Madmutt.
+ ** It defaults to the value of the \fT$$$VISUAL\fP, or \fT$$$EDITOR\fP, environment
+ ** variable, or to the string "\fTvi\fP" if neither of those are set.
+ */
{ "sendmail", NULL, SENDMAIL " -oem -oi" },
/*
** .pp
#include <langinfo.h>
#endif
+#include <lib-lua/lib-lua.h>
#include <lib-sys/unix.h>
#include <lib-sys/mutt_signal.h>
CLEARLINE (LINES - 1);
}
-void mutt_edit_file (const char *editor, const char *data)
+void mutt_edit_file(const char *data)
{
char cmd[LONG_STRING];
mutt_endwin (NULL);
- m_quotefile_fmt(cmd, sizeof (cmd), editor, data);
+ m_quotefile_fmt(cmd, sizeof (cmd), mlua_reggets(LTK_EDITOR), data);
if (mutt_system (cmd) == -1)
mutt_error (_("Error running \"%s\"!"), cmd);
keypad (stdscr, TRUE);
void mutt_progress_bar (progress_t* progress, long pos);
void mutt_clear_error (void);
-void mutt_edit_file (const char *, const char *);
+void mutt_edit_file (const char *);
void mutt_curses_error (const char *, ...)
__attribute__((format(printf, 1, 2)));
void mutt_curses_message (const char *, ...)
void mutt_default_save (char *, ssize_t, HEADER *);
void mutt_display_address (ENVELOPE *);
void mutt_edit_content_type (HEADER *, BODY *, FILE *);
-void mutt_edit_headers (const char *, const char *, HEADER *, char *, ssize_t);
+void mutt_edit_headers(const char *, HEADER *, char *, ssize_t);
void mutt_enter_command (void);
void mutt_fix_reply_recipients (ENVELOPE * env);
void mutt_folder_hook (char *);
process_user_header (msg->env);
- if (option (OPTSIGONTOP) && (!(flags & SENDKEY) && Editor))
+ if (option (OPTSIGONTOP) && (!(flags & SENDKEY)))
append_signature (tempfp);
/* include replies/forwarded messages, unless we are given a template */
&& generate_body (tempfp, msg, flags, ctx, cur) == -1)
goto cleanup;
- if (!option (OPTSIGONTOP) && (!(flags & SENDKEY) && Editor))
+ if (!option (OPTSIGONTOP) && (!(flags & SENDKEY)))
append_signature (tempfp);
/*
goto cleanup;
} else if (option (OPTEDITHDRS)) {
mutt_env_to_local (msg->env);
- mutt_edit_headers (Editor, msg->content->filename, msg, fcc,
- sizeof (fcc));
+ mutt_edit_headers(msg->content->filename, msg, fcc, sizeof (fcc));
mutt_env_to_idna (msg->env, NULL, NULL);
}
else {
- mutt_edit_file (Editor, msg->content->filename);
+ mutt_edit_file(msg->content->filename);
if (stat (msg->content->filename, &st) == 0) {
if (mtime != st.st_mtime)