]> granicus.if.org Git - neomutt/commitdiff
build: conditional compilation
authorRichard Russon <rich@flatcap.org>
Wed, 2 Dec 2015 03:58:44 +0000 (03:58 +0000)
committerRichard Russon <rich@flatcap.org>
Sun, 6 Mar 2016 00:44:21 +0000 (00:44 +0000)
Make sidebar compilation conditional on a configure option.

Add --enable-sidebar option to configure
Alter Makefile to honour configure
Move our OPS into OPS.sidebar
Surround all our code with #ifdef USE_SIDEBAR

By using the unifdef program, all the sidebar code can be removed.
The result is code that differs only slightly from the original mutt
code.  Run this on each source file:

    unifdef -Bm -UUSE_SIDEBAR -UHAVE_FMEMOPEN <FILE>

Then run sed using this script:

    s/ *- *SidebarWidth//g
    s/ *+ *SidebarWidth//g
    s/SidebarWidth *+ *//g
    s/SidebarWidth/0/g

Compared to the original mutt code, there are some minor changes,
such as whitespace, and minor refactoring of variables.

Note: One sidebar global variable is left-behind: SidebarWidth.
This is deeply embedded in the mutt code.  This is because mutt
hard-codes a lot of values: 0's for the left-hand side of the
screen and COLS representing the width of the screen.

26 files changed:
Makefile.am
OPS
OPS.SIDEBAR [new file with mode: 0644]
buffy.c
buffy.h
color.c
compose.c
configure.ac
curs_main.c
flags.c
functions.h
globals.h
imap/command.c
imap/imap.c
init.h
mailbox.h
main.c
mbox.c
menu.c
mh.c
mutt.h
mutt_curses.h
mutt_menu.h
mx.c
mx.h
pager.c

index 20ead5f04009eeb06d6f55be3ace8dacb78ab6c0..e7c4f3e2da9e059e21228fa65de7d00924d4a61c 100644 (file)
@@ -33,7 +33,6 @@ mutt_SOURCES = \
        rfc822.c rfc1524.c rfc2047.c rfc2231.c rfc3676.c \
        score.c send.c sendlib.c signal.c sort.c \
        status.c system.c thread.c charset.c history.c lib.c \
-       sidebar.c \
        muttlib.c editmsg.c mbyte.c \
        url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
 
@@ -78,6 +77,12 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \
 
 EXTRA_SCRIPTS = smime_keys
 
+if BUILD_SIDEBAR
+mutt_SOURCES += sidebar.c sidebar.h
+endif
+
+EXTRA_DIST += OPS.SIDEBAR
+
 mutt_dotlock_SOURCES = mutt_dotlock.c
 mutt_dotlock_LDADD = $(LIBOBJS)
 mutt_dotlock_DEPENDENCIES = $(LIBOBJS)
@@ -130,10 +135,10 @@ smime_keys: $(srcdir)/smime_keys.pl
 keymap_defs.h: $(OPS) $(srcdir)/gen_defs
        $(srcdir)/gen_defs $(OPS) > keymap_defs.h
 
-keymap_alldefs.h: $(srcdir)/OPS $(srcdir)/OPS.PGP $(srcdir)/OPS.MIX $(srcdir)/OPS.CRYPT $(srcdir)/OPS.SMIME $(srcdir)/gen_defs
+keymap_alldefs.h: $(srcdir)/OPS $(srcdir)/OPS.SIDEBAR $(srcdir)/OPS.PGP $(srcdir)/OPS.MIX $(srcdir)/OPS.CRYPT $(srcdir)/OPS.SMIME $(srcdir)/gen_defs
        rm -f $@
        $(srcdir)/gen_defs $(srcdir)/OPS $(srcdir)/OPS.PGP \
-               $(srcdir)/OPS.MIX $(srcdir)/OPS.CRYPT $(srcdir)/OPS.SMIME \
+               $(srcdir)/OPS.SIDEBAR $(srcdir)/OPS.MIX $(srcdir)/OPS.CRYPT $(srcdir)/OPS.SMIME \
                        > keymap_alldefs.h
 
 reldate.h: $(srcdir)/ChangeLog
diff --git a/OPS b/OPS
index 9c8670a167e72f34d674d33d90c923ec14fa7963..8414a8b337671ddee819f83f06b26da76559ee92 100644 (file)
--- a/OPS
+++ b/OPS
@@ -179,10 +179,3 @@ OP_WHAT_KEY "display the keycode for a key press"
 OP_MAIN_SHOW_LIMIT "show currently active limit pattern"
 OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread"
 OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads"
-OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page"
-OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page"
-OP_SIDEBAR_NEXT "go down to next mailbox"
-OP_SIDEBAR_PREV "go to previous mailbox"
-OP_SIDEBAR_OPEN "open hilighted mailbox"
-OP_SIDEBAR_NEXT_NEW "go down to next mailbox with new mail"
-OP_SIDEBAR_PREV_NEW "go to previous mailbox with new mail"
diff --git a/OPS.SIDEBAR b/OPS.SIDEBAR
new file mode 100644 (file)
index 0000000..3f261c8
--- /dev/null
@@ -0,0 +1,7 @@
+OP_SIDEBAR_NEXT "Move the highlight to next mailbox"
+OP_SIDEBAR_NEXT_NEW "Move the highlight to next mailbox with new mail"
+OP_SIDEBAR_OPEN "Open highlighted mailbox"
+OP_SIDEBAR_PREV "Move the highlight to previous mailbox"
+OP_SIDEBAR_PREV_NEW "Move the highlight to previous mailbox with new mail"
+OP_SIDEBAR_SCROLL_DOWN "Scroll the Sidebar down 1 page"
+OP_SIDEBAR_SCROLL_UP "Scroll the Sidebar up 1 page"
diff --git a/buffy.c b/buffy.c
index 2409a71a1b10551260278c52685a98f2f67881f8..21c136b20ccf2976aafa21bbd12e10a0f5be6814 100644 (file)
--- a/buffy.c
+++ b/buffy.c
 #include "mx.h"
 
 #include "mutt_curses.h"
+
+#ifdef USE_SIDEBAR
 #include "sidebar.h"
+#endif
 
 #ifdef USE_IMAP
 #include "imap.h"
@@ -162,6 +165,7 @@ void mutt_buffy_cleanup (const char *buf, struct stat *st)
   }
 }
 
+#ifdef USE_SIDEBAR
 /**
  * buffy_compare_name - qsort callback to sort BUFFYs
  * @a: First  BUFFY to compare
@@ -232,6 +236,7 @@ buffy_sort (BUFFY *b)
        free (ary);
        return tmp;
 }
+#endif
 
 BUFFY *mutt_find_mailbox (const char *path)
 {
@@ -268,13 +273,17 @@ void mutt_update_mailbox (BUFFY * b)
 static BUFFY *buffy_new (const char *path)
 {
   BUFFY* buffy;
+#ifdef USE_SIDEBAR
   char rp[PATH_MAX] = "";
   char *r = NULL;
+#endif
 
   buffy = (BUFFY *) safe_calloc (1, sizeof (BUFFY));
   strfcpy (buffy->path, path, sizeof (buffy->path));
+#ifdef USE_SIDEBAR
   r = realpath (path, rp);
   strfcpy (buffy->realpath, r ? rp : path, sizeof (buffy->realpath));
+#endif
   buffy->next = NULL;
   buffy->magic = 0;
 
@@ -292,7 +301,9 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *e
   char buf[_POSIX_PATH_MAX];
   struct stat sb;
   char f1[PATH_MAX];
+#ifndef USE_SIDEBAR
   char f2[PATH_MAX];
+#endif
   char *p, *q;
 
   while (MoreArgs (s))
@@ -320,8 +331,13 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *e
     p = realpath (buf, f1);
     for (tmp = &Incoming; *tmp; tmp = &((*tmp)->next))
     {
+#ifdef USE_SIDEBAR
       q = (*tmp)->realpath;
       if (mutt_strcmp (p ? p : buf, q) == 0)
+#else
+      q = realpath ((*tmp)->path, f2);
+      if (mutt_strcmp (p ? p : buf, q ? q : (*tmp)->path) == 0)
+#endif
       {
        dprint(3,(debugfile,"mailbox '%s' already registered as '%s'\n", buf, (*tmp)->path));
        break;
@@ -359,7 +375,9 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *e
     else
       (*tmp)->size = 0;
   }
+#ifdef USE_SIDEBAR
   Incoming = buffy_sort (Incoming);
+#endif
   return 0;
 }
 
@@ -384,10 +402,12 @@ static int buffy_maildir_dir_hasnew(BUFFY* mailbox, const char *dir_name)
       return 0;
   }
 
+#ifdef USE_SIDEBAR
   if (option (OPTSIDEBAR) && mailbox->msg_unread > 0) {
     mailbox->new = 1;
     return 1;
   }
+#endif
 
   if ((dirp = opendir (path)) == NULL)
   {
@@ -441,6 +461,7 @@ static int buffy_maildir_hasnew (BUFFY* mailbox)
   return 0;
 }
 
+#ifdef USE_SIDEBAR
 /**
  * buffy_maildir_update - Update messages counts for a maildir mailbox
  * @mailbox: BUFFY representing a maildir mailbox
@@ -511,6 +532,7 @@ buffy_maildir_update (BUFFY *mailbox)
        mailbox->sb_last_checked = time (NULL);
        closedir (dirp);
 }
+#endif
 
 /* returns 1 if mailbox has new mail */ 
 static int buffy_mbox_hasnew (BUFFY* mailbox, struct stat *sb)
@@ -523,7 +545,11 @@ static int buffy_mbox_hasnew (BUFFY* mailbox, struct stat *sb)
   else
     statcheck = sb->st_mtime > sb->st_atime
       || (mailbox->newly_created && sb->st_ctime == sb->st_mtime && sb->st_ctime == sb->st_atime);
+#ifdef USE_SIDEBAR
   if ((!option (OPTSIDEBAR) && statcheck) || (option (OPTSIDEBAR) && mailbox->msg_unread > 0))
+#else
+  if (statcheck)
+#endif
   {
     if (!option(OPTMAILCHECKRECENT) || sb->st_mtime > mailbox->last_visited)
     {
@@ -543,6 +569,7 @@ static int buffy_mbox_hasnew (BUFFY* mailbox, struct stat *sb)
   return rc;
 }
 
+#ifdef USE_SIDEBAR
 /**
  * buffy_mbox_update - Update messages counts for an mbox mailbox
  * @mailbox: BUFFY representing an mbox mailbox
@@ -571,6 +598,7 @@ buffy_mbox_update (BUFFY *mailbox, struct stat *sb)
                mx_close_mailbox (ctx, 0);
        }
 }
+#endif
 
 int mutt_buffy_check (int force)
 {
@@ -645,28 +673,34 @@ int mutt_buffy_check (int force)
       {
       case M_MBOX:
       case M_MMDF:
+#ifdef USE_SIDEBAR
        if (sb_should_refresh()) {
          buffy_mbox_update (tmp, &sb);
          sb_set_update_time();
        }
+#endif
        if (buffy_mbox_hasnew (tmp, &sb) > 0)
          BuffyCount++;
        break;
 
       case M_MAILDIR:
+#ifdef USE_SIDEBAR
        if (sb_should_refresh()) {
          buffy_maildir_update (tmp);
          sb_set_update_time();
        }
+#endif
        if (buffy_maildir_hasnew (tmp) > 0)
          BuffyCount++;
        break;
 
       case M_MH:
+#ifdef USE_SIDEBAR
        if (sb_should_refresh()) {
          mh_buffy_update (tmp->path, &tmp->msgcount, &tmp->msg_unread, &tmp->msg_flagged, &tmp->sb_last_checked);
          sb_set_update_time();
        }
+#endif
        mh_buffy(tmp);
        if (tmp->new)
          BuffyCount++;
diff --git a/buffy.h b/buffy.h
index cf51f02fa2569955a572a029577c87d555f23288..1eaa92edaafed253227cf33c420ea721fe1df106 100644 (file)
--- a/buffy.h
+++ b/buffy.h
 typedef struct buffy_t
 {
   char path[_POSIX_PATH_MAX];
+#ifdef USE_SIDEBAR
   char realpath[_POSIX_PATH_MAX];
+#endif
   off_t size;
   struct buffy_t *next;
+#ifdef USE_SIDEBAR
   struct buffy_t *prev;
+#endif
   short new;                   /* mailbox has new mail */
+#ifdef USE_SIDEBAR
   int msgcount;                        /* total number of messages */
   int msg_unread;              /* number of unread messages */
   int msg_flagged;             /* number of flagged messages */
+#endif
   short notified;              /* user has been notified */
   short magic;                 /* mailbox type */
   short newly_created;         /* mbox or mmdf just popped into existence */
   time_t last_visited;         /* time of last exit from this mailbox */
+#ifdef USE_SIDEBAR
   time_t sb_last_checked;      /* time of last buffy check from sidebar */
+#endif
 }
 BUFFY;
 
diff --git a/color.c b/color.c
index ea48453a69f41c5b504fa11125d94bd4d41a55d3..582fa91acefa242969a31f7354b5530e64fd9767 100644 (file)
--- a/color.c
+++ b/color.c
@@ -94,8 +94,10 @@ static const struct mapping_t Fields[] =
   { "underline",       MT_COLOR_UNDERLINE },
   { "index",           MT_COLOR_INDEX },
   { "prompt",          MT_COLOR_PROMPT },
+#ifdef USE_SIDEBAR
   { "sidebar_flagged", MT_COLOR_FLAGGED },
   { "sidebar_new",     MT_COLOR_NEW },
+#endif
   { NULL,              0 }
 };
 
index dcc7423ba21f25eb4742180dd34f7422499e68a9..5ec9f3ff4f525552e46e7062932bc1fd90878305 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -32,7 +32,9 @@
 #include "mailbox.h"
 #include "sort.h"
 #include "charset.h"
+#ifdef USE_SIDEBAR
 #include "sidebar.h"
+#endif
 
 #ifdef MIXMASTER
 #include "remailer.h"
@@ -249,7 +251,9 @@ static void draw_envelope_addr (int line, ADDRESS *addr)
 
 static void draw_envelope (HEADER *msg, char *fcc)
 {
+#ifdef USE_SIDEBAR
   sb_draw();
+#endif
   draw_envelope_addr (HDR_FROM, msg->env->from);
   draw_envelope_addr (HDR_TO, msg->env->to);
   draw_envelope_addr (HDR_CC, msg->env->cc);
index 1a76cd751448b12638a6efc2ff38851b0c28482f..2343e050d1a3792d130a3d4bfeddc4ab83a78894 100644 (file)
@@ -175,6 +175,15 @@ if test x$have_smime != xno ; then
        SMIMEAUX_TARGET="smime_keys"
 fi
 
+AC_ARG_ENABLE(sidebar, AC_HELP_STRING([--enable-sidebar], [Enable Sidebar support]),
+[       if test x$enableval = xyes ; then
+               AC_DEFINE(USE_SIDEBAR,1,[ Define if you want support for the sidebar. ])
+               OPS="$OPS \$(srcdir)/OPS.SIDEBAR"
+               need_sidebar="yes"
+        fi
+])
+AM_CONDITIONAL(BUILD_SIDEBAR, test x$need_sidebar = xyes)
+
 AC_ARG_WITH(mixmaster, AS_HELP_STRING([--with-mixmaster@<:@=PATH@:>@],[Include Mixmaster support]),
   [if test "$withval" != no
    then
index d52a5d06f5d1e4c463b06eeef1fc5f4bab0e0032..325abec90d91bb51dc7679a55512016cc9dab646 100644 (file)
 #include "sort.h"
 #include "buffy.h"
 #include "mx.h"
+
+#ifdef USE_SIDEBAR
 #include "sidebar.h"
+#endif
 
 #ifdef USE_POP
 #include "pop.h"
@@ -609,8 +612,10 @@ int mutt_index_menu (void)
        do_buffy_notify = 1;
     }
 
+#ifdef USE_SIDEBAR
     if (option (OPTSIDEBAR))
         menu->redraw |= REDRAW_SIDEBAR;
+#endif
 
     if (op != -1)
       mutt_curs_set (0);
@@ -618,12 +623,17 @@ int mutt_index_menu (void)
     if (menu->redraw & REDRAW_FULL)
     {
       menu_redraw_full (menu);
+#ifdef USE_SIDEBAR
       sb_draw();
+#endif
       mutt_show_error ();
-    } else if (menu->redraw & REDRAW_SIDEBAR) {
+    }
+#ifdef USE_SIDEBAR
+    else if (menu->redraw & REDRAW_SIDEBAR) {
       sb_draw();
       menu->redraw &= ~REDRAW_SIDEBAR;
     }
+#endif
 
     if (menu->menu == MENU_MAIN)
     {
@@ -644,14 +654,20 @@ int mutt_index_menu (void)
 
       if (menu->redraw & REDRAW_STATUS)
       {
+#ifdef USE_SIDEBAR
         /* Temporarily lie about the sidebar width */
        short sw = SidebarWidth;
        SidebarWidth = 0;
+#endif
        menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
+#ifdef USE_SIDEBAR
         SidebarWidth = sw; /* Restore the sidebar width */
+#endif
        move (option (OPTSTATUSONTOP) ? 0 : LINES-2, 0);
        SETCOLOR (MT_COLOR_STATUS);
+#ifdef USE_SIDEBAR
        sb_set_buffystats (Context);
+#endif
        mutt_paddstr (COLS, buf);
        NORMAL_COLOR;
        menu->redraw &= ~REDRAW_STATUS;
@@ -1113,7 +1129,9 @@ int mutt_index_menu (void)
          break;
 
        CHECK_MSGCOUNT;
+#ifdef USE_SIDEBAR
        CHECK_VISIBLE;
+#endif
        CHECK_READONLY;
        {
          int oldvcount = Context->vcount;
@@ -1173,7 +1191,9 @@ int mutt_index_menu (void)
          menu->redraw = REDRAW_FULL;
        break;
 
+#ifdef USE_SIDEBAR
       case OP_SIDEBAR_OPEN:
+#endif
       case OP_MAIN_CHANGE_FOLDER:
       case OP_MAIN_NEXT_UNREAD_MAILBOX:
 
@@ -1205,11 +1225,13 @@ int mutt_index_menu (void)
        {
          mutt_buffy (buf, sizeof (buf));
 
+#ifdef USE_SIDEBAR
          if (op == OP_SIDEBAR_OPEN) {
            if (!CurBuffy)
              break;
            strncpy (buf, CurBuffy->path, sizeof (buf));
          } else
+#endif
          if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
          {
            if (menu->menu == MENU_PAGER)
@@ -1228,7 +1250,9 @@ int mutt_index_menu (void)
        }
 
        mutt_expand_path (buf, sizeof (buf));
+#ifdef USE_SIDEBAR
        sb_set_open_buffy (buf);
+#endif
        if (mx_get_magic (buf) <= 0)
        {
          mutt_error (_("%s is not a mailbox."), buf);
@@ -2319,6 +2343,7 @@ int mutt_index_menu (void)
        mutt_what_key();
        break;
 
+#ifdef USE_SIDEBAR
       case OP_SIDEBAR_SCROLL_UP:
       case OP_SIDEBAR_SCROLL_DOWN:
       case OP_SIDEBAR_NEXT:
@@ -2327,6 +2352,7 @@ int mutt_index_menu (void)
       case OP_SIDEBAR_PREV_NEW:
         sb_change_mailbox (op);
         break;
+#endif
       default:
        if (menu->menu == MENU_MAIN)
          km_error_key (MENU_MAIN);
diff --git a/flags.c b/flags.c
index cd5fe4fa535fd8e516cceaff7c3c45365d51baae..f58aa38cd7eb378b9ede90fd1dec271d2ddc0d67 100644 (file)
--- a/flags.c
+++ b/flags.c
 #include "mutt_curses.h"
 #include "sort.h"
 #include "mx.h"
+
+#ifdef USE_SIDEBAR
 #include "sidebar.h"
+#endif
 
 void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
 {
@@ -264,7 +267,9 @@ void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
    */
   if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged))
     h->searched = 0;
+#ifdef USE_SIDEBAR
   sb_draw();
+#endif
 }
 
 void mutt_tag_set_flag (int flag, int bf)
index 41f9fb8962064417269a934ed3859c806c19a672..805d8b4fba644798809e273e5688c3cacb2ff076 100644 (file)
@@ -168,6 +168,7 @@ const struct binding_t OpMain[] = { /* map: index */
   { "decrypt-copy",            OP_DECRYPT_COPY,                NULL },
   { "decrypt-save",            OP_DECRYPT_SAVE,                NULL },
 
+#ifdef USE_SIDEBAR
   { "sidebar-next",            OP_SIDEBAR_NEXT,                NULL },
   { "sidebar-next-new",                OP_SIDEBAR_NEXT_NEW,            NULL },
   { "sidebar-open",            OP_SIDEBAR_OPEN,                NULL },
@@ -175,6 +176,7 @@ const struct binding_t OpMain[] = { /* map: index */
   { "sidebar-prev-new",                OP_SIDEBAR_PREV_NEW,            NULL },
   { "sidebar-scroll-down",     OP_SIDEBAR_SCROLL_DOWN,         NULL },
   { "sidebar-scroll-up",       OP_SIDEBAR_SCROLL_UP,           NULL },
+#endif
 
   { NULL,                      0,                              NULL }
 };
@@ -279,6 +281,7 @@ const struct binding_t OpPager[] = { /* map: pager */
 
   { "what-key",                OP_WHAT_KEY,            NULL },
 
+#ifdef USE_SIDEBAR
   { "sidebar-next",            OP_SIDEBAR_NEXT,                NULL },
   { "sidebar-next-new",                OP_SIDEBAR_NEXT_NEW,            NULL },
   { "sidebar-open",            OP_SIDEBAR_OPEN,                NULL },
@@ -286,6 +289,7 @@ const struct binding_t OpPager[] = { /* map: pager */
   { "sidebar-prev-new",                OP_SIDEBAR_PREV_NEW,            NULL },
   { "sidebar-scroll-down",     OP_SIDEBAR_SCROLL_DOWN,         NULL },
   { "sidebar-scroll-up",       OP_SIDEBAR_SCROLL_UP,           NULL },
+#endif
 
   { NULL,              0,                              NULL }
 };
index 6339a99ced36e47b70460cee06e6077fc25f26e0..9d50a514297013cc9eb224c7bafad99d0b67f855 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -118,10 +118,12 @@ WHERE short SearchContext;
 WHERE char *SendCharset;
 WHERE char *Sendmail;
 WHERE char *Shell;
+#ifdef USE_SIDEBAR
 WHERE char *SidebarDelim;
 WHERE char *SidebarDelimChars;
 WHERE char *SidebarFormat;
 WHERE char *SidebarIndentStr;
+#endif
 WHERE char *Signature;
 WHERE char *SimpleSearch;
 #if USE_SMTP
@@ -217,11 +219,15 @@ WHERE short ScoreThresholdDelete;
 WHERE short ScoreThresholdRead;
 WHERE short ScoreThresholdFlag;
 
+/* This isn't excluded from the build because it's too entwined in the code.
+ * For now. */
+WHERE short SidebarWidth;
+#ifdef USE_SIDEBAR
 WHERE struct buffy_t *CurBuffy INITVAL(0);
 WHERE short SidebarLastRefresh;
 WHERE short SidebarRefresh;
 WHERE LIST *SidebarWhitelist INITVAL(0);
-WHERE short SidebarWidth;
+#endif
 
 #ifdef USE_IMAP
 WHERE short ImapKeepalive;
index 296820400909b5a6ed5f50d51b97bd2574c4920e..eeda540c3fe375a5412a219ff9a8441dc8cf560a 100644 (file)
@@ -1012,11 +1012,13 @@ static void cmd_parse_status (IMAP_DATA* idata, char* s)
             opened */
          status->uidnext = oldun;
 
-       /* Added to make the sidebar show the correct numbers */
+#ifdef USE_SIDEBAR
+       /* Make the sidebar show the correct numbers */
        if (status->messages) {
          inc->msgcount   = status->messages;
          inc->msg_unread = status->unseen;
        }
+#endif
 
         FREE (&value);
         return;
index 6f4af883f152fb0776a905b0c5e3a3d402f475cb..4c1f943a8947cf6eefe087fdb2b3230b936f8117 100644 (file)
@@ -1523,7 +1523,11 @@ int imap_buffy_check (int force)
 
     imap_munge_mbox_name (munged, sizeof (munged), name);
     snprintf (command, sizeof (command),
+#ifdef USE_SIDEBAR
              "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged);
+#else
+             "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged);
+#endif
 
     if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
     {
diff --git a/init.h b/init.h
index 3da371b1fd133d3170688c996553a98420ae7ff9..cc9d3743b647b26ce48321b98117e3813252b9df 100644 (file)
--- a/init.h
+++ b/init.h
@@ -2595,6 +2595,7 @@ struct option_t MuttVars[] = {
   ** Command to use when spawning a subshell.  By default, the user's login
   ** shell from \fC/etc/passwd\fP is used.
   */
+#ifdef USE_SIDEBAR
   { "sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, UL "|" },
   /*
   ** .pp
@@ -2713,6 +2714,7 @@ struct option_t MuttVars[] = {
   ** For example: sidebar_width=20 could display 20 ASCII characters, or 10
   ** Chinese characters.
   */
+#endif
   { "sig_dashes",      DT_BOOL, R_NONE, OPTSIGDASHES, 1 },
   /*
   ** .pp
@@ -3788,7 +3790,9 @@ const struct command_t Commands[] = {
   { "send-hook",       mutt_parse_hook,        M_SENDHOOK },
   { "send2-hook",      mutt_parse_hook,        M_SEND2HOOK },
   { "set",             parse_set,              0 },
+#ifdef USE_SIDEBAR
   { "sidebar_whitelist",parse_list,            UL &SidebarWhitelist },
+#endif
   { "source",          parse_source,           0 },
   { "spam",            parse_spam_list,        M_SPAM },
   { "nospam",          parse_spam_list,        M_NOSPAM },
index 000503d7fef217b9761202a07a686c5b53cb4fc1..22496613695fe111505c2b619fb8c64478d75ade 100644 (file)
--- a/mailbox.h
+++ b/mailbox.h
@@ -27,7 +27,9 @@
 #define M_NEWFOLDER    (1<<4) /* create a new folder - same as M_APPEND, but uses
                                * safe_fopen() for mbox-style folders.
                                */
+#ifdef USE_SIDEBAR
 #define M_PEEK         (1<<5) /* revert atime back after taking a look (if applicable) */
+#endif
 
 /* mx_open_new_message() */
 #define M_ADD_FROM     (1<<0)  /* add a From_ line */
diff --git a/main.c b/main.c
index 41136129a099b2ac3b3b0883b70d9c1358f65a95..7f5895af77f09d4ca02fcb040a686a70d0c8826a 100644 (file)
--- a/main.c
+++ b/main.c
@@ -31,7 +31,9 @@
 #include "url.h"
 #include "mutt_crypt.h"
 #include "mutt_idna.h"
+#ifdef USE_SIDEBAR
 #include "sidebar.h"
+#endif
 
 #ifdef USE_SASL
 #include "mutt_sasl.h"
@@ -484,6 +486,12 @@ static void show_version (void)
        "-USE_HCACHE  "
 #endif
 
+#ifdef USE_SIDEBAR
+       "+USE_SIDEBAR  "
+#else
+       "-USE_SIDEBAR  "
+#endif
+
        );
 
 #ifdef ISPELL
@@ -556,7 +564,11 @@ init_extended_keys();
 
 int main (int argc, char **argv)
 {
+#ifdef USE_SIDEBAR
   char folder[PATH_MAX] = "";
+#else
+  char folder[_POSIX_PATH_MAX] = "";
+#endif
   char *subject = NULL;
   char *includeFile = NULL;
   char *draftFile = NULL;
@@ -1037,12 +1049,14 @@ int main (int argc, char **argv)
       strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
     mutt_expand_path (folder, sizeof (folder));
 
+#ifdef USE_SIDEBAR
     {
       char tmpfolder[PATH_MAX] = "";
       strfcpy (tmpfolder, folder, sizeof (tmpfolder));
       if (!realpath (tmpfolder, folder))
         strfcpy (folder, tmpfolder, sizeof (tmpfolder));
     }
+#endif
 
     mutt_str_replace (&CurrentFolder, folder);
     mutt_str_replace (&LastFolder, folder);
@@ -1066,7 +1080,9 @@ int main (int argc, char **argv)
     if((Context = mx_open_mailbox (folder, ((flags & M_RO) || option (OPTREADONLY)) ? M_READONLY : 0, NULL))
        || !explicit_folder)
     {
+#ifdef USE_SIDEBAR
       sb_set_open_buffy (folder);
+#endif
       mutt_index_menu ();
       if (Context)
        FREE (&Context);
diff --git a/mbox.c b/mbox.c
index cd51e641edf950e0c78c5f0f73031b10df4a76ed..1be1f34aeef69846be39a726eaee6d57bc1fbd5e 100644 (file)
--- a/mbox.c
+++ b/mbox.c
@@ -100,7 +100,9 @@ int mmdf_parse_mailbox (CONTEXT *ctx)
     mutt_perror (ctx->path);
     return (-1);
   }
+#ifdef USE_SIDEBAR
   ctx->atime = sb.st_atime;
+#endif
   ctx->mtime = sb.st_mtime;
   ctx->size = sb.st_size;
 
@@ -252,7 +254,9 @@ int mbox_parse_mailbox (CONTEXT *ctx)
 
   ctx->size = sb.st_size;
   ctx->mtime = sb.st_mtime;
+#ifdef USE_SIDEBAR
   ctx->atime = sb.st_atime;
+#endif
 
 #ifdef NFS_ATTRIBUTE_HACK
   if (sb.st_mtime > sb.st_atime)
diff --git a/menu.c b/menu.c
index b44d44b3d277f277aeae3a79736c8ea192b9cead..72a870d03f6311883bc73b85ae1c788ca57cb126 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -24,7 +24,9 @@
 #include "mutt_curses.h"
 #include "mutt_menu.h"
 #include "mbyte.h"
+#ifdef USE_SIDEBAR
 #include "sidebar.h"
+#endif
 
 extern size_t UngetCount;
 
@@ -240,7 +242,9 @@ void menu_redraw_index (MUTTMENU *menu)
   int do_color;
   int attr;
 
+#ifdef USE_SIDEBAR
   sb_draw();
+#endif
   for (i = menu->top; i < menu->top + menu->pagelen; i++)
   {
     if (i < menu->max)
@@ -274,7 +278,11 @@ void menu_redraw_index (MUTTMENU *menu)
     else
     {
       NORMAL_COLOR;
+#ifdef USE_SIDEBAR
       CLEARLINE_WIN(i - menu->top + menu->offset);
+#else
+      CLEARLINE(i - menu->top + menu->offset);
+#endif
     }
   }
   NORMAL_COLOR;
diff --git a/mh.c b/mh.c
index 51d490ff4bee27f4541131dc5ec90ded142fabc7..a1b4f4c691887007c51c35e3e2af540ceb853b21 100644 (file)
--- a/mh.c
+++ b/mh.c
@@ -295,6 +295,7 @@ void mh_buffy(BUFFY *b)
   mhs_free_sequences (&mhs);
 }
 
+#ifdef USE_SIDEBAR
 /**
  * mh_buffy_update - Update messages counts for an mh mailbox
  * @path:            Pathname of the mailbox
@@ -335,6 +336,7 @@ mh_buffy_update (const char *path, int *msgcount, int *msg_unread, int *msg_flag
        mhs_free_sequences (&mhs);
        *sb_last_checked = time (NULL);
 }
+#endif
 
 static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt)
 {
diff --git a/mutt.h b/mutt.h
index 67b614a2d58c39e768b838f43fccce215f89fbcc..411a7a60baf76477828bc9ba5e816e9cdfa1f1cc 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -423,12 +423,14 @@ enum
   OPTSAVEEMPTY,
   OPTSAVENAME,
   OPTSCORE,
+#ifdef USE_SIDEBAR
   OPTSIDEBAR,
   OPTSIDEBARFOLDERINDENT,
   OPTSIDEBARNEWMAILONLY,
   OPTSIDEBARNEXTNEWWRAP,
   OPTSIDEBARSHORTPATH,
   OPTSIDEBARSORT,
+#endif
   OPTSIGDASHES,
   OPTSIGONTOP,
   OPTSORTRE,
@@ -872,7 +874,9 @@ typedef struct _context
 {
   char *path;
   FILE *fp;
+#ifdef USE_SIDEBAR
   time_t atime;
+#endif
   time_t mtime;
   off_t size;
   off_t vsize;
@@ -907,7 +911,9 @@ typedef struct _context
   unsigned int quiet : 1;      /* inhibit status messages? */
   unsigned int collapsed : 1;   /* are all threads collapsed? */
   unsigned int closing : 1;    /* mailbox is being closed */
+#ifdef USE_SIDEBAR
   unsigned int peekonly : 1;   /* just taking a glance, revert atime */
+#endif
 
   /* driver hooks */
   void *data;                  /* driver specific data */
index a160960881624d0eaf2badefa3a82f2a745af30b..268aa3e1b78113429f82dd98bdce2a9230b3552c 100644 (file)
@@ -64,7 +64,9 @@
 #undef lines
 #endif /* lines */
 
+#ifdef USE_SIDEBAR
 #define CLEARLINE_WIN(x) move (x,SidebarWidth), clrtoeol()
+#endif
 #define CLEARLINE(x) move(x,0), clrtoeol()
 #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
 #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
@@ -122,8 +124,10 @@ enum
   MT_COLOR_UNDERLINE,
   MT_COLOR_INDEX,
   MT_COLOR_PROMPT,
+#ifdef USE_SIDEBAR
   MT_COLOR_FLAGGED,
   MT_COLOR_NEW,
+#endif
   MT_COLOR_MAX
 };
 
index aea89f14df0e11ddda4350753de35934d07ec336..8cb49dbccecc9c21a89a5e3e30e5299b87805ac1 100644 (file)
@@ -34,7 +34,9 @@
 #define REDRAW_FULL            (1<<5)
 #define REDRAW_BODY            (1<<6)
 #define REDRAW_SIGWINCH                (1<<7)
+#ifdef USE_SIDEBAR
 #define REDRAW_SIDEBAR         (1<<8)
+#endif
 
 #define M_MODEFMT "-- Mutt: %s"
 
diff --git a/mx.c b/mx.c
index bd46cd39ee8785ce9234ca5c038163b872bcce92..a6eab0a783c7cff98dfeb7d7f973751a4a299902 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -29,7 +29,9 @@
 #include "copy.h"
 #include "keymap.h"
 #include "url.h"
+#ifdef USE_SIDEBAR
 #include "sidebar.h"
+#endif
 
 #ifdef USE_IMAP
 #include "imap.h"
@@ -604,8 +606,10 @@ CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
     ctx->quiet = 1;
   if (flags & M_READONLY)
     ctx->readonly = 1;
+#ifdef USE_SIDEBAR
   if (flags & M_PEEK)
     ctx->peekonly = 1;
+#endif
 
   if (flags & (M_APPEND|M_NEWFOLDER))
   {
@@ -709,6 +713,7 @@ void mx_fastclose_mailbox (CONTEXT *ctx)
   if(!ctx) 
     return;
 
+#ifdef USE_SIDEBAR
   /* fix up the times so buffy won't get confused */
   struct utimbuf ut;
   if (ctx->peekonly && ctx->path && (ctx->mtime > ctx->atime)) {
@@ -716,10 +721,13 @@ void mx_fastclose_mailbox (CONTEXT *ctx)
     ut.modtime = ctx->mtime;
     utime (ctx->path, &ut);
   }
+#endif
 
   /* never announce that a mailbox we've just left has new mail. #3290
    * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */
+#ifdef USE_SIDEBAR
   if (!ctx->peekonly)
+#endif
   mutt_buffy_setnotified(ctx->path);
 
   if (ctx->mx_close)
@@ -732,8 +740,10 @@ void mx_fastclose_mailbox (CONTEXT *ctx)
   mutt_clear_threads (ctx);
   for (i = 0; i < ctx->msgcount; i++)
     mutt_free_header (&ctx->hdrs[i]);
+#ifdef USE_SIDEBAR
   ctx->msgcount -= ctx->deleted;
   sb_set_buffystats (ctx);
+#endif
   FREE (&ctx->hdrs);
   FREE (&ctx->v2r);
   FREE (&ctx->path);
@@ -827,10 +837,12 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint)
     if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->read 
         && !(ctx->hdrs[i]->flagged && option (OPTKEEPFLAGGED)))
       read_msgs++;
+#ifdef USE_SIDEBAR
     if (ctx->hdrs[i]->deleted && !ctx->hdrs[i]->read)
       ctx->unread--;
     if (ctx->hdrs[i]->deleted && ctx->hdrs[i]->flagged)
       ctx->flagged--;
+#endif
   }
 
   if (read_msgs && quadoption (OPT_MOVE) != M_NO)
diff --git a/mx.h b/mx.h
index 516508dfec795690956a47360b100f5a83efdea1..495667a3c3c33a82b30f29e59aa0eecc850ebc44 100644 (file)
--- a/mx.h
+++ b/mx.h
@@ -57,7 +57,9 @@ void mbox_reset_atime (CONTEXT *, struct stat *);
 int mh_read_dir (CONTEXT *, const char *);
 int mh_sync_mailbox (CONTEXT *, int *);
 int mh_check_mailbox (CONTEXT *, int *);
+#ifdef USE_SIDEBAR
 void mh_buffy_update (const char *, int *, int *, int *, time_t *);
+#endif
 int mh_check_empty (const char *);
 
 int maildir_read_dir (CONTEXT *);
diff --git a/pager.c b/pager.c
index c7ccdddaf00d9c5e1688b8e3ec7018f4c8dfe049..c3177d076168487a0073db72940ae7341213303f 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -29,7 +29,9 @@
 #include "pager.h"
 #include "attach.h"
 #include "mbyte.h"
+#ifdef USE_SIDEBAR
 #include "sidebar.h"
+#endif
 
 #include "mutt_crypt.h"
 
@@ -1096,7 +1098,9 @@ static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
   wchar_t wc;
   mbstate_t mbstate;
   int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap);
+#ifdef USE_SIDEBAR
   wrap_cols -= SidebarWidth;
+#endif
 
   if (check_attachment_marker ((char *)buf) == 0)
     wrap_cols = COLS;
@@ -1762,7 +1766,9 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra)
                            &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
            lines++;
          curline++;
+#ifdef USE_SIDEBAR
          move (lines + bodyoffset, SidebarWidth);
+#endif
        }
        last_offset = lineInfo[curline].offset;
       } while (force_redraw);
@@ -1775,7 +1781,9 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra)
          addch ('~');
        addch ('\n');
        lines++;
+#ifdef USE_SIDEBAR
        move (lines + bodyoffset, SidebarWidth);
+#endif
       }
       NORMAL_COLOR;
 
@@ -1793,9 +1801,11 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra)
       hfi.ctx = Context;
       hfi.pager_progress = pager_progress_str;
 
+#ifdef USE_SIDEBAR
       statuswidth = COLS;
       if (option (OPTSTATUSONTOP) && (PagerIndexLines > 0))
         statuswidth -= SidebarWidth;
+#endif
 
       if (last_pos < sb.st_size - 1)
        snprintf(pager_progress_str, sizeof(pager_progress_str), OFF_T_FMT "%%", (100 * last_offset / sb.st_size));
@@ -1805,6 +1815,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra)
       /* print out the pager status bar */
       move (statusoffset, SidebarWidth);
       SETCOLOR (MT_COLOR_STATUS);
+#ifdef USE_SIDEBAR
       short sw = SidebarWidth;
       if (option (OPTSTATUSONTOP) && PagerIndexLines > 0) {
         CLEARLINE_WIN (statusoffset);
@@ -1813,6 +1824,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra)
         /* Temporarily lie about the sidebar width */
         SidebarWidth = 0;
       }
+#endif
 
       if (IsHeader (extra) || IsMsgAttach (extra))
       {
@@ -1828,9 +1840,10 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra)
        snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
        mutt_paddstr (statuswidth, bn);
       }
+#ifdef USE_SIDEBAR
       if (!option (OPTSTATUSONTOP) || PagerIndexLines == 0)
         SidebarWidth = sw; /* Restore the sidebar width */
-
+#endif
       NORMAL_COLOR;
       if (option(OPTTSENABLED) && TSSupported)
       {
@@ -1846,7 +1859,9 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra)
       /* redraw the pager_index indicator, because the
        * flags for this message might have changed. */
       menu_redraw_current (index);
+#ifdef USE_SIDEBAR
       sb_draw();
+#endif
 
       /* print out the index status bar */
       menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
@@ -1858,9 +1873,11 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra)
       NORMAL_COLOR;
     }
 
+#ifdef USE_SIDEBAR
     /* if we're not using the index, update every time */
     if (index == 0)
       sb_draw();
+#endif
 
     redraw = 0;
 
@@ -2796,6 +2813,7 @@ search_next:
        mutt_what_key ();
        break;
 
+#ifdef USE_SIDEBAR
       case OP_SIDEBAR_NEXT:
       case OP_SIDEBAR_NEXT_NEW:
       case OP_SIDEBAR_PREV:
@@ -2804,6 +2822,7 @@ search_next:
       case OP_SIDEBAR_SCROLL_UP:
        sb_change_mailbox (ch);
        break;
+#endif
 
       default:
        ch = -1;