Skip to content

Commit

Permalink
Move compose files to lib under compose/
Browse files Browse the repository at this point in the history
No functional changes, simply moving all compose code under this
directory in preparation for building libcompose.

libsend depends on libcompose, so set it first under MUTTLIBS in
Makefile.autosetup

Move compose config to composelib
  • Loading branch information
matthewhughes934 authored and flatcap committed Aug 31, 2020
1 parent 8f7a470 commit e3c9ab8
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 46 deletions.
17 changes: 15 additions & 2 deletions Makefile.autosetup
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ default: all
# neomutt
NEOMUTT= neomutt$(EXEEXT)
NEOMUTTOBJS= browser.o commands.o command_parse.o \
complete.o compose.o conststrings.o context.o copy.o \
complete.o conststrings.o context.o copy.o \
editmsg.o enriched.o enter.o flags.o functions.o git_ver.o \
handler.o hdrline.o help.o hook.o icommands.o index.o init.o \
keymap.o mailcap.o maillist.o main.o menu.o muttlib.o mutt_account.o \
Expand Down Expand Up @@ -161,6 +161,19 @@ $(LIBCOMPMBOX): $(PWD)/compmbox $(LIBCOMPMBOXOBJS)
$(PWD)/compmbox:
$(MKDIR_P) $(PWD)/compmbox

###############################################################################
# libcompose
LIBCOMPOSE= libcompose.a
LIBCOMPOSEOBJS= compose/config.o compose/compose.o
CLEANFILES+= $(LIBCOMPOSE) $(LIBCOMPOSEOBJS)
ALLOBJS+= $(LIBCOMPOSEOBJS)

$(LIBCOMPOSE): $(PWD)/compose $(LIBCOMPOSEOBJS)
$(AR) cr $@ $(LIBCOMPOSEOBJS)
$(RANLIB) $@
$(PWD)/compose:
$(MKDIR_P) $(PWD)/compose

###############################################################################
# libcompress
@if USE_LZ4
Expand Down Expand Up @@ -593,7 +606,7 @@ MUTTLIBS+= $(LIBAUTOCRYPT) $(LIBPOP) $(LIBNNTP) $(LIBCOMPMBOX) \
$(LIBSTORE) $(LIBPATTERN) $(LIBGUI) $(LIBHELPBAR) $(LIBDEBUG) $(LIBMBOX) \
$(LIBNOTMUCH) $(LIBMAILDIR) $(LIBNCRYPT) $(LIBIMAP) $(LIBCONN) \
$(LIBHCACHE) $(LIBCOMPRESS) $(LIBSIDEBAR) $(LIBBCACHE) \
$(LIBHISTORY) $(LIBALIAS) $(LIBSEND) $(LIBCORE) $(LIBCONFIG) \
$(LIBHISTORY) $(LIBALIAS) $(LIBSEND) $(LIBCOMPOSE) $(LIBCORE) $(LIBCONFIG) \
$(LIBEMAIL) $(LIBADDRESS) $(LIBMUTT)

# neomutt
Expand Down
11 changes: 3 additions & 8 deletions compose.c → compose/compose.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

/**
* @page compose GUI editor for an email's headers
* @page compose_compose GUI editor for an email's headers
*
* GUI editor for an email's headers
*/
Expand All @@ -37,6 +37,7 @@
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "private.h"
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
Expand All @@ -46,7 +47,7 @@
#include "conn/lib.h"
#include "gui/lib.h"
#include "mutt.h"
#include "compose.h"
#include "lib.h"
#include "ncrypt/lib.h"
#include "send/lib.h"
#include "browser.h"
Expand Down Expand Up @@ -95,12 +96,6 @@
/// Maximum number of rows to use for the Headers: field
#define MAX_USER_HDR_ROWS 5

/* These Config Variables are only used in compose.c */
char *C_ComposeFormat; ///< Config: printf-like format string for the Compose panel's status bar
char *C_Ispell; ///< Config: External command to perform spell-checking
unsigned char C_Postpone; ///< Config: Save messages to the #C_Postponed folder
bool C_ComposeShowUserHeaders; ///< Config: Whether to display user-defined headers

static const char *There_are_no_attachments = N_("There are no attachments");

static void compose_status_line(char *buf, size_t buflen, size_t col, int cols,
Expand Down
75 changes: 75 additions & 0 deletions compose/config.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* @file
* Config used by libcompose
*
* @authors
* Copyright (C) 2020 Richard Russon <[email protected]>
*
* @copyright
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* @page compose_config Config used by libcompose
*
* Config used by libcompose
*/

#include <stdbool.h>
#include "private.h"
#include "config/lib.h"

#ifndef ISPELL
#define ISPELL "ispell"
#endif

// clang-format off
char * C_ComposeFormat; ///< Config: printf-like format string for the Compose panel's status bar
bool C_ComposeShowUserHeaders; ///< Config: Whether to display user-defined headers
unsigned char C_Copy; ///< Config: Save outgoing emails to $record
bool C_EditHeaders; ///< Config: Let the user edit the email headers whilst editing an email
char * C_Ispell; ///< Config: External command to perform spell-checking
unsigned char C_Postpone; ///< Config: Save messages to the `$postponed` folder
// clang-format on

static struct ConfigDef ComposeVars[] = {
// clang-format off
{ "compose_show_user_headers", DT_BOOL, &C_ComposeShowUserHeaders, true, 0, NULL,
"Controls whether or not custom headers are shown in the compose envelope"
},
{ "edit_headers", DT_BOOL, &C_EditHeaders, false, 0, NULL,
"Let the user edit the email headers whilst editing an email"
},
{ "compose_format", DT_STRING|R_MENU, &C_ComposeFormat, IP "-- NeoMutt: Compose [Approx. msg size: %l Atts: %a]%>-", 0, NULL,
"printf-like format string for the Compose panel's status bar"
},
{ "ispell", DT_STRING|DT_COMMAND, &C_Ispell, IP ISPELL, 0, NULL,
"External command to perform spell-checking"
},
{ "copy", DT_QUAD, &C_Copy, MUTT_YES, 0, NULL,
"Save outgoing emails to $record"
},
{ "postpone", DT_QUAD, &C_Postpone, MUTT_ASKYES, 0, NULL,
"Save messages to the #C_Postponed folder"
},
// clang-format on
};

/**
* config_init_compose - Register compose config variables - Implements ::module_init_config_t
*/
bool config_init_compose(struct ConfigSet *cs)
{
return cs_register_variables(cs, ComposeVars, 0);
}
27 changes: 17 additions & 10 deletions compose.h → compose/lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* GUI editor for an email's headers
*
* @authors
* Copyright (C) 2018 Richard Russon <[email protected]>
* Copyright (C) 2020 Richard Russon <[email protected]>
*
* @copyright
* This program is free software: you can redistribute it and/or modify it under
Expand All @@ -20,21 +20,28 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef MUTT_COMPOSE_H
#define MUTT_COMPOSE_H
/**
* @page compose COMPOSE: Display and edit an email's headers
*
* Display the mailboxes in a side panel
*
* | File | Description |
* | :------------------ | :------------------------- |
* | compose/compose.c | @subpage compose_compose |
* | compose/config.c | @subpage compose_config |
*/

#ifndef MUTT_COMPOSE_LIB_H
#define MUTT_COMPOSE_LIB_H

struct Buffer;
struct Email;

/* These Config Variables are only used in compose.c */
extern char *C_ComposeFormat;
extern char *C_Ispell;
extern unsigned char C_Postpone;
extern bool C_ComposeShowUserHeaders;

/* flags for mutt_compose_menu() */
#define MUTT_COMPOSE_NOFREEHEADER (1 << 0)

int mutt_compose_menu(struct Email *e, struct Buffer *fcc, struct Email *e_cur, int flags);

#endif /* MUTT_COMPOSE_H */
bool config_init_compose(struct ConfigSet *);

#endif /* MUTT_COMPOSE_LIB_H */
33 changes: 33 additions & 0 deletions compose/private.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @file
* GUI editor for an email's headers
*
* @authors
* Copyright (C) 2020 Richard Russon <[email protected]>
*
* @copyright
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef MUTT_COMPOSE_PRIVATE_H
#define MUTT_COMPOSE_PRIVATE_H

extern char * C_ComposeFormat;
extern bool C_ComposeShowUserHeaders;
extern unsigned char C_Copy;
extern bool C_EditHeaders;
extern char * C_Ispell;
extern unsigned char C_Postpone;

#endif /* MUTT_COMPOSE_PRIVATE_H */
25 changes: 2 additions & 23 deletions mutt_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
#include "alias/lib.h"
#include "gui/lib.h"
#include "bcache/lib.h"
#include "compose/lib.h"
#include "browser.h"
#include "commands.h"
#include "compose.h"
#include "handler.h"
#include "hdrline.h"
#include "hook.h"
Expand All @@ -65,10 +65,6 @@
#include "sort.h"
#include "status.h"

#ifndef ISPELL
#define ISPELL "ispell"
#endif

#define CONFIG_INIT_TYPE(CS, NAME) \
extern const struct ConfigSetType cst_##NAME; \
cs_register_type(CS, &cst_##NAME)
Expand Down Expand Up @@ -229,12 +225,6 @@ struct ConfigDef MainVars[] = {
{ "collapse_unread", DT_BOOL, &C_CollapseUnread, true, 0, NULL,
"Prevent the collapse of threads with unread emails"
},
{ "compose_format", DT_STRING|R_MENU, &C_ComposeFormat, IP "-- NeoMutt: Compose [Approx. msg size: %l Atts: %a]%>-", 0, NULL,
"printf-like format string for the Compose panel's status bar"
},
{ "compose_show_user_headers", DT_BOOL, &C_ComposeShowUserHeaders, true, 0, NULL,
"Controls whether or not user-defined headers are shown in the compose envelope"
},
{ "config_charset", DT_STRING, &C_ConfigCharset, 0, 0, charset_validator,
"Character set that the config files are in"
},
Expand All @@ -244,9 +234,6 @@ struct ConfigDef MainVars[] = {
{ "confirmcreate", DT_BOOL, &C_Confirmcreate, true, 0, NULL,
"Confirm before creating a new mailbox"
},
{ "copy", DT_QUAD, &C_Copy, MUTT_YES, 0, NULL,
"Save outgoing emails to $record"
},
{ "copy_decode_weed", DT_BOOL, &C_CopyDecodeWeed, false, 0, NULL,
"Controls whether to weed headers when copying or saving emails"
},
Expand Down Expand Up @@ -280,9 +267,6 @@ struct ConfigDef MainVars[] = {
{ "duplicate_threads", DT_BOOL|R_RESORT|R_RESORT_INIT|R_INDEX, &C_DuplicateThreads, true, 0, pager_validator,
"Highlight messages with duplicated message IDs"
},
{ "edit_headers", DT_BOOL, &C_EditHeaders, false, 0, NULL,
"Let the user edit the email headers whilst editing an email"
},
{ "editor", DT_STRING|DT_NOT_EMPTY|DT_COMMAND, &C_Editor, IP "vi", 0, NULL,
"External command to use as an email editor"
},
Expand Down Expand Up @@ -372,9 +356,6 @@ struct ConfigDef MainVars[] = {
{ "index_format", DT_STRING|DT_NOT_EMPTY|R_INDEX|R_PAGER, &C_IndexFormat, IP "%4C %Z %{%b %d} %-15.15L (%?l?%4l&%4c?) %s", 0, NULL,
"printf-like format string for the index menu (emails)"
},
{ "ispell", DT_STRING|DT_COMMAND, &C_Ispell, IP ISPELL, 0, NULL,
"External command to perform spell-checking"
},
{ "keep_flagged", DT_BOOL, &C_KeepFlagged, false, 0, NULL,
"Don't move flagged messages from #C_Spoolfile to #C_Mbox"
},
Expand Down Expand Up @@ -488,9 +469,6 @@ struct ConfigDef MainVars[] = {
{ "pipe_split", DT_BOOL, &C_PipeSplit, false, 0, NULL,
"Run the pipe command on each message separately"
},
{ "postpone", DT_QUAD, &C_Postpone, MUTT_ASKYES, 0, NULL,
"Save messages to the #C_Postponed folder"
},
{ "postponed", DT_STRING|DT_MAILBOX|R_INDEX, &C_Postponed, IP "~/postponed", 0, NULL,
"Folder to store postponed messages"
},
Expand Down Expand Up @@ -783,6 +761,7 @@ static void init_variables(struct ConfigSet *cs)
#ifdef USE_AUTOCRYPT
CONFIG_INIT_VARS(cs, autocrypt);
#endif
CONFIG_INIT_VARS(cs, compose);
CONFIG_INIT_VARS(cs, conn);
#ifdef USE_HCACHE
CONFIG_INIT_VARS(cs, hcache);
Expand Down
2 changes: 0 additions & 2 deletions mutt_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ WHERE int C_ToggleQuotedShowLevels; ///< Config: Number of quote levels

/* Quad-options */
WHERE unsigned char C_Bounce; ///< Config: Confirm before bouncing a message
WHERE unsigned char C_Copy; ///< Config: Save outgoing emails to $record
WHERE unsigned char C_Delete; ///< Config: Really delete messages, when the mailbox is closed
WHERE unsigned char C_ForwardAttachments; ///< Config: Forward attachments when forwarding a message
WHERE unsigned char C_MimeForward; ///< Config: Forward a message as a 'message/RFC822' MIME part
Expand All @@ -143,7 +142,6 @@ WHERE bool C_Confirmappend; ///< Config: Confirm before appendi
WHERE bool C_Confirmcreate; ///< Config: Confirm before creating a new mailbox
WHERE bool C_CopyDecodeWeed; ///< Config: Controls whether to weed headers when copying or saving emails
WHERE bool C_DeleteUntag; ///< Config: Untag messages when they are marked for deletion
WHERE bool C_EditHeaders; ///< Config: Let the user edit the email headers whilst editing an email
WHERE bool C_FlagSafe; ///< Config: Protect flagged messages from deletion
WHERE bool C_ForwardDecode; ///< Config: Decode the message when forwarding it
WHERE bool C_ForwardQuote; ///< Config: Automatically quote a forwarded message using #C_IndentString
Expand Down
2 changes: 1 addition & 1 deletion send/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
#include "mutt.h"
#include "send.h"
#include "lib.h"
#include "compose/lib.h"
#include "ncrypt/lib.h"
#include "pattern/lib.h"
#include "compose.h"
#include "context.h"
#include "copy.h"
#include "handler.h"
Expand Down

0 comments on commit e3c9ab8

Please sign in to comment.