[mutt] 03/17: patches-20160502/sensible-browser

Antonio Radici antonio at moszumanska.debian.org
Sun Aug 28 15:32:54 UTC 2016


This is an automated email from the git hooks/post-receive script.

antonio pushed a commit to branch patch-queue/master
in repository mutt.

commit e19353f6d62da4e6193c754bf3dedc3a3084be94
Author: Richard Russon <rich at flatcap.org>
Date:   Fri May 6 19:53:13 2016 +0100

    patches-20160502/sensible-browser
    
    
    Gbp-Pq: Topic neomutt-devel
    Gbp-Pq: Name sensible-browser.patch
---
 README.sensible-browser | 39 +++++++++++++++++++++
 browser.c               | 30 ++++++++++++-----
 doc/manual.xml.head     | 90 +++++++++++++++++++++++++++++++++++++++++++++++++
 menu.c                  | 11 ++++++
 mutt_menu.h             |  1 +
 5 files changed, 163 insertions(+), 8 deletions(-)

diff --git a/README.sensible-browser b/README.sensible-browser
new file mode 100644
index 0000000..adfc076
--- /dev/null
+++ b/README.sensible-browser
@@ -0,0 +1,39 @@
+Sensible-Browser Patch
+======================
+
+    Make the file browser behave
+
+Patch
+-----
+
+    To check if Mutt supports "sensible-browser", look for
+    "patch-sensible-browser" in the mutt version.
+
+    Dependencies
+    * mutt-1.5.24
+
+Introduction
+------------
+
+    When using the file/folder browser, the selection isn't always where you
+    would expect. When you navigate to '..' (parent folder), the selection
+    should show the folder you *used* to be in.
+
+See Also
+--------
+
+    * NeoMutt project
+
+Known Bugs
+----------
+
+    * Limited to IMAP folders
+    * Always on
+    * Should only select folder when folder is sorted alphabetically
+
+Credits
+-------
+
+    * Haakon Riiser <haakon.riiser at fys.uio.no>
+    * Richard Russon <rich at flatcap.org>
+
diff --git a/browser.c b/browser.c
index a83852d..2a66993 100644
--- a/browser.c
+++ b/browser.c
@@ -76,6 +76,7 @@ typedef struct folder_t
   int num;
 } FOLDER;
 
+static char OldLastDir[_POSIX_PATH_MAX] = "";
 static char LastDir[_POSIX_PATH_MAX] = "";
 static char LastDirBackup[_POSIX_PATH_MAX] = "";
 
@@ -893,17 +894,32 @@ static void init_menu (struct browser_state *state, MUTTMENU *menu, char *title,
   }
   else
 #endif
-  if (buffy)
+  if (buffy) {
+    menu->is_mailbox_list = 1;
     snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0));
-  else
+  } else
   {
+    menu->is_mailbox_list = 0;
     strfcpy (path, LastDir, sizeof (path));
     mutt_pretty_mailbox (path, sizeof (path));
 #ifdef USE_IMAP
-  if (state->imap_browse && option (OPTIMAPLSUB))
-    snprintf (title, titlelen, _("Subscribed [%s], File mask: %s"),
-	      path, NONULL (Mask.pattern));
-  else
+  if (state->imap_browse && option (OPTIMAPLSUB)) {
+    char *p = strrchr (OldLastDir, '/');
+    if (p && ((p - OldLastDir) == mutt_strlen (LastDir)) &&
+       (mutt_strncmp (LastDir, OldLastDir, p - OldLastDir) == 0)) {
+      /* If we get here, it means that LastDir is the parent directory of
+       * OldLastDir.  I.e., we're returning from a subdirectory, and we want
+       * to position the cursor on the directory we're returning from. */
+      int i;
+      for (i = 0; i < state->entrymax; i++) {
+        if (mutt_strcmp (state->entry[i].name, p + 1) == 0) {
+          menu->current = i;
+        }
+      }
+    }
+    snprintf (title, titlelen, _("Directory [%s], File mask: %s"),
+             path, NONULL(Mask.pattern));
+  } else
 #endif
     snprintf (title, titlelen, _("Directory [%s], File mask: %s"),
 	      path, NONULL(Mask.pattern));
@@ -1136,8 +1152,6 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num
 #endif
 	    )
 	  {
-	    char OldLastDir[_POSIX_PATH_MAX];
-
 	    /* save the old directory */
 	    strfcpy (OldLastDir, LastDir, sizeof (OldLastDir));
 
diff --git a/doc/manual.xml.head b/doc/manual.xml.head
index 9807cbd..bd51b69 100644
--- a/doc/manual.xml.head
+++ b/doc/manual.xml.head
@@ -13158,6 +13158,96 @@ openssl s_client -host <imap server> -port <port> -tls1 -servername
   </sect2>
 </sect1>
 
+<sect1 id="sensible-browser">
+	<title>Sensible-Browser Patch</title>
+	<subtitle>Make the file browser behave</subtitle>
+
+	<sect2 id="sensible-browser-patch">
+		<title>Patch</title>
+
+		<para>
+			To check if Mutt supports <quote>sensible-browser</quote>, look for
+			<quote>patch-sensible-browser</quote> in the mutt version.
+			See: <xref linkend="mutt-patches"/>.
+		</para>
+
+		<itemizedlist>
+			<title>Dependencies:</title>
+			<listitem><para>mutt-1.5.24</para></listitem>
+		</itemizedlist>
+
+		<para>This patch is part of the <ulink url="https://github.com/neomutt/neomutt/wiki">NeoMutt Project</ulink>.</para>
+	</sect2>
+
+	<sect2 id="sensible-browser-intro">
+		<title>Introduction</title>
+
+		<para>
+			When using the file/folder browser, the selection isn't always where you would
+			expect. When you navigate to '..' (parent folder), the selection should show the
+			folder you <emphasis>used</emphasis> to be in.
+		</para>
+
+	</sect2>
+
+<!--
+	<sect2 id="sensible-browser-variables">
+		<title>Variables</title>
+		<para>None</para>
+	</sect2>
+
+	<sect2 id="sensible-browser-functions">
+		<title>Functions</title>
+		<para>None</para>
+	</sect2>
+
+	<sect2 id="sensible-browser-commands">
+		<title>Commands</title>
+		<para>None</para>
+	</sect2>
+
+	<sect2 id="sensible-browser-colors">
+		<title>Colors</title>
+		<para>None</para>
+	</sect2>
+
+	<sect2 id="sensible-browser-sort">
+		<title>Sort</title>
+		<para>None</para>
+	</sect2>
+-->
+
+	<sect2 id="sensible-browser-muttrc">
+		<title>Muttrc</title>
+		<para>None</para>
+	</sect2>
+
+	<sect2 id="sensible-browser-see-also">
+		<title>See Also</title>
+
+		<itemizedlist>
+			<listitem><para><ulink url="https://github.com/neomutt/neomutt/wiki">NeoMutt Project</ulink></para></listitem>
+		</itemizedlist>
+	</sect2>
+
+	<sect2 id="sensible-browser-known-bugs">
+		<title>Known Bugs</title>
+		<itemizedlist>
+			<listitem><para>Limited to IMAP folders</para></listitem>
+			<listitem><para>Always on</para></listitem>
+			<listitem><para>Should only select folder when folder is sorted alphabetically</para></listitem>
+		</itemizedlist>
+	</sect2>
+
+	<sect2 id="sensible-browser-credits">
+		<title>Credits</title>
+		<itemizedlist>
+		<listitem><para>Haakon Riiser <email>haakon.riiser at fys.uio.no</email></para></listitem>
+		<listitem><para>Richard Russon <email>rich at flatcap.org</email></para></listitem>
+		</itemizedlist>
+	</sect2>
+</sect1>
+
 </chapter>
 
 <chapter id="security">
diff --git a/menu.c b/menu.c
index 252760c..627e4e6 100644
--- a/menu.c
+++ b/menu.c
@@ -938,8 +938,17 @@ int menu_redraw (MUTTMENU *menu)
 
 int mutt_menuLoop (MUTTMENU *menu)
 {
+  static int last_position = -1;
   int i = OP_NULL;
 
+  if (menu->max && menu->is_mailbox_list) {
+    if (last_position > (menu->max - 1)) {
+      last_position = -1;
+    } else if (last_position >= 0) {
+      menu->current = last_position;
+    }
+  }
+
   FOREVER
   {
     if (option (OPTMENUCALLER))
@@ -1163,6 +1172,8 @@ int mutt_menuLoop (MUTTMENU *menu)
 	break;
 
       default:
+        if (menu->is_mailbox_list)
+          last_position = menu->current;
 	return (i);
     }
   }
diff --git a/mutt_menu.h b/mutt_menu.h
index d5c97d0..be4165d 100644
--- a/mutt_menu.h
+++ b/mutt_menu.h
@@ -53,6 +53,7 @@ typedef struct menu_t
   int offset;  /* row offset within the window to start the index */
   int pagelen;	/* number of entries per screen */
   int tagprefix;
+  int is_mailbox_list;
   mutt_window_t *indexwin;
   mutt_window_t *statuswin;
   mutt_window_t *helpwin;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mutt/mutt.git



More information about the pkg-mutt-commits mailing list