]> granicus.if.org Git - neomutt/commitdiff
reorg notmuch functions
authorRichard Russon <rich@flatcap.org>
Tue, 11 Sep 2018 15:42:16 +0000 (16:42 +0100)
committerRichard Russon <rich@flatcap.org>
Thu, 13 Sep 2018 01:02:35 +0000 (02:02 +0100)
notmuch/mutt_notmuch.c
notmuch/mutt_notmuch.h

index d01d36e9011af3fcad60a0ee26ed8f11bd0b1653..b16e18535ce1bb5c1adfb3bbc6dc6ea8047e0ca0 100644 (file)
@@ -131,7 +131,7 @@ struct NmMboxData
 
   struct Url db_url;   /**< Parsed view url of the Notmuch database */
   char *db_url_holder; /**< The storage string used by db_url, we keep it
-                                *   to be able to free db_url */
+                        *   to be able to free db_url */
   char *db_query;      /**< Previous query */
   int db_limit;        /**< Maximum number of results to return */
   enum NmQueryType query_type; /**< Messages or Threads */
@@ -2020,54 +2020,6 @@ void nm_query_window_backward(void)
   mutt_debug(2, "(%d)\n", NmQueryWindowCurrentPosition);
 }
 
-/**
- * nm_tags_edit - Implements MxOps::tags_edit()
- */
-static int nm_tags_edit(struct Context *ctx, const char *tags, char *buf, size_t buflen)
-{
-  *buf = '\0';
-  if (mutt_get_field("Add/remove labels: ", buf, buflen, MUTT_NM_TAG) != 0)
-    return -1;
-  return 1;
-}
-
-/**
- * nm_tags_commit - Implements MxOps::tags_commit()
- */
-static int nm_tags_commit(struct Context *ctx, struct Header *hdr, char *buf)
-{
-  struct NmMboxData *data = get_mboxdata(ctx->mailbox);
-  if (!buf || !*buf || !data)
-    return -1;
-
-  notmuch_database_t *db = NULL;
-  notmuch_message_t *msg = NULL;
-  int rc = -1;
-
-  if (!(db = get_db(data, true)) || !(msg = get_nm_message(db, hdr)))
-    goto done;
-
-  mutt_debug(1, "nm: tags modify: '%s'\n", buf);
-
-  update_tags(msg, buf);
-  update_header_flags(ctx, hdr, buf);
-  update_header_tags(hdr, msg);
-  mutt_set_header_color(ctx, hdr);
-
-  rc = 0;
-  hdr->changed = true;
-done:
-  if (!is_longrun(data))
-    release_db(data);
-  if (hdr->changed)
-  {
-    ctx->mailbox->mtime.tv_sec = time(NULL);
-    ctx->mailbox->mtime.tv_nsec = 0;
-  }
-  mutt_debug(1, "nm: tags modify done [rc=%d]\n", rc);
-  return rc;
-}
-
 /**
  * nm_message_is_still_queried - Is a message still visible in the query?
  * @param mailbox Mailbox
@@ -2466,16 +2418,6 @@ static int nm_mbox_open(struct Context *ctx)
   return rc;
 }
 
-/**
- * nm_mbox_close - Implements MxOps::mbox_close()
- *
- * Nothing to do.
- */
-static int nm_mbox_close(struct Context *ctx)
-{
-  return 0;
-}
-
 /**
  * nm_mbox_check - Implements MxOps::mbox_check()
  * @param ctx         Mailbox
@@ -2693,6 +2635,16 @@ static int nm_mbox_sync(struct Context *ctx, int *index_hint)
   return rc;
 }
 
+/**
+ * nm_mbox_close - Implements MxOps::mbox_close()
+ *
+ * Nothing to do.
+ */
+static int nm_mbox_close(struct Context *ctx)
+{
+  return 0;
+}
+
 /**
  * nm_msg_open - Implements MxOps::msg_open()
  */
@@ -2717,6 +2669,16 @@ static int nm_msg_open(struct Context *ctx, struct Message *msg, int msgno)
   return !msg->fp;
 }
 
+/**
+ * nm_msg_commit - Implements MxOps::msg_commit()
+ * @retval -1 Always
+ */
+static int nm_msg_commit(struct Context *ctx, struct Message *msg)
+{
+  mutt_error(_("Can't write to virtual folder"));
+  return -1;
+}
+
 /**
  * nm_msg_close - Implements MxOps::msg_close()
  */
@@ -2729,13 +2691,51 @@ static int nm_msg_close(struct Context *ctx, struct Message *msg)
 }
 
 /**
- * nm_msg_commit - Implements MxOps::msg_commit()
- * @retval -1 Always
+ * nm_tags_edit - Implements MxOps::tags_edit()
  */
-static int nm_msg_commit(struct Context *ctx, struct Message *msg)
+static int nm_tags_edit(struct Context *ctx, const char *tags, char *buf, size_t buflen)
 {
-  mutt_error(_("Can't write to virtual folder"));
-  return -1;
+  *buf = '\0';
+  if (mutt_get_field("Add/remove labels: ", buf, buflen, MUTT_NM_TAG) != 0)
+    return -1;
+  return 1;
+}
+
+/**
+ * nm_tags_commit - Implements MxOps::tags_commit()
+ */
+static int nm_tags_commit(struct Context *ctx, struct Header *hdr, char *buf)
+{
+  struct NmMboxData *data = get_mboxdata(ctx->mailbox);
+  if (!buf || !*buf || !data)
+    return -1;
+
+  notmuch_database_t *db = NULL;
+  notmuch_message_t *msg = NULL;
+  int rc = -1;
+
+  if (!(db = get_db(data, true)) || !(msg = get_nm_message(db, hdr)))
+    goto done;
+
+  mutt_debug(1, "nm: tags modify: '%s'\n", buf);
+
+  update_tags(msg, buf);
+  update_header_flags(ctx, hdr, buf);
+  update_header_tags(hdr, msg);
+  mutt_set_header_color(ctx, hdr);
+
+  rc = 0;
+  hdr->changed = true;
+done:
+  if (!is_longrun(data))
+    release_db(data);
+  if (hdr->changed)
+  {
+    ctx->mailbox->mtime.tv_sec = time(NULL);
+    ctx->mailbox->mtime.tv_nsec = 0;
+  }
+  mutt_debug(1, "nm: tags modify done [rc=%d]\n", rc);
+  return rc;
 }
 
 /**
index 8c64edcdaa67cd1f27593fcae5b14b944cd9beac..7f2e786782070adc01795f49e7f76b8cd713bcf9 100644 (file)
@@ -51,34 +51,24 @@ extern char *NmQueryWindowTimebase;
 extern char *NmRecordTags;
 extern char *NmUnreadTag;
 
-int nm_read_entire_thread(struct Context *ctx, struct Header *h);
-
-char *nm_header_get_folder(struct Header *h);
-int nm_update_filename(struct Mailbox *mailbox, const char *old, const char *new, struct Header *h);
-bool nm_normalize_uri(const char *uri, char *buf, size_t buflen);
-char *nm_uri_from_query(struct Mailbox *mailbox, char *buf, size_t buflen);
-bool nm_message_is_still_queried(struct Mailbox *mailbox, struct Header *hdr);
-
-void nm_query_window_backward(void);
-void nm_query_window_forward(void);
-
-void nm_longrun_init(struct Mailbox *mailbox, bool writable);
-void nm_longrun_done(struct Mailbox *mailbox);
-
-char *nm_get_description(struct Mailbox *mailbox);
-int nm_description_to_path(const char *desc, char *buf, size_t buflen);
-
-int nm_record_message(struct Mailbox *mailbox, char *path, struct Header *h);
-
-void nm_debug_check(struct Mailbox *mailbox);
-int nm_get_all_tags(struct Mailbox *mailbox, char **tag_list, int *tag_count);
-
-/*
- * functions usable outside of notmuch
- */
-int nm_nonctx_get_count(char *path, int *all, int *new);
-int nm_path_probe(const char *path, const struct stat *st);
-
 extern struct MxOps mx_notmuch_ops;
 
+void  nm_debug_check             (struct Mailbox *mailbox);
+int   nm_description_to_path     (const char *desc, char *buf, size_t buflen);
+int   nm_get_all_tags            (struct Mailbox *mailbox, char **tag_list, int *tag_count);
+char *nm_get_description         (struct Mailbox *mailbox);
+char *nm_header_get_folder       (struct Header *h);
+void  nm_longrun_done            (struct Mailbox *mailbox);
+void  nm_longrun_init            (struct Mailbox *mailbox, bool writable);
+bool  nm_message_is_still_queried(struct Mailbox *mailbox, struct Header *hdr);
+int   nm_nonctx_get_count        (char *path, int *all, int *new);
+bool  nm_normalize_uri           (const char *uri, char *buf, size_t buflen);
+int   nm_path_probe              (const char *path, const struct stat *st);
+void  nm_query_window_backward   (void);
+void  nm_query_window_forward    (void);
+int   nm_read_entire_thread      (struct Context *ctx, struct Header *h);
+int   nm_record_message          (struct Mailbox *mailbox, char *path, struct Header *h);
+int   nm_update_filename         (struct Mailbox *mailbox, const char *old, const char *new, struct Header *h);
+char *nm_uri_from_query          (struct Mailbox *mailbox, char *buf, size_t buflen);
+
 #endif /* MUTT_NOTMUCH_MUTT_NOTMUCH_H */