Hi,

As a side effect of the new and much improved jumplist, the bisect functionality
(bound to ^j ^k) broke. I attach a patch for the bisect.

During a bisection, jump history is slightly rewritten, as explained in the
commit message. The rest of the new jumplist behaviour (besides bisects with ^j
and ^k) is not modified.

Abdó Roig-Maranges

>From dac4e9de439673ca5513c575c212c616160049d7 Mon Sep 17 00:00:00 2001
From: Abdo Roig-Maranges <abdo.r...@gmail.com>
Date: Mon, 1 Jul 2013 23:53:53 +0200
Subject: [PATCH] Adapts bisect functionality to changes in the jumplist

This recovers the old bisect behaviour (bound to ^j ^k). Consider the
case in which the last 3 items in the jumplist are page-ordered as
follows:

   -1 ...... 0 ...... -2

where 0 is the current jump. A bisection step to the right overwrites
the jump -1 and 0 so that afterwards we have

   * .......-1 ...0...-2

This looses history (the jump on the left), but I think it is the right
behaviour for doing bisects. The improved jumplist behaviour is not
modified by this commit.
---
 shortcuts.c |  8 ++++----
 zathura.c   |  3 +--
 zathura.h   | 10 +++++++++-
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/shortcuts.c b/shortcuts.c
index bfb4cf3..d42c44b 100644
--- a/shortcuts.c
+++ b/shortcuts.c
@@ -860,11 +860,11 @@ sc_bisect(girara_session_t* session, girara_argument_t* argument,
         /* save current position at previous jump point */
         if (cur_page < prev2_page) {
           zathura_jumplist_backward(zathura);
-          zathura_jumplist_add(zathura);
+          zathura_jumplist_save(zathura);
           zathura_jumplist_forward(zathura);
 
           page_set(zathura, (cur_page + prev2_page)/2);
-          zathura_jumplist_add(zathura);
+          zathura_jumplist_save(zathura);
         }
       } else {
         /* none of prev_page or prev2_page comes after cur_page */
@@ -887,11 +887,11 @@ sc_bisect(girara_session_t* session, girara_argument_t* argument,
         /* save current position at previous jump point */
         if (prev2_page < cur_page) {
           zathura_jumplist_backward(zathura);
-          zathura_jumplist_add(zathura);
+          zathura_jumplist_save(zathura);
           zathura_jumplist_forward(zathura);
 
           page_set(zathura, (cur_page + prev2_page)/2);
-          zathura_jumplist_add(zathura);
+          zathura_jumplist_save(zathura);
         }
 
       } else {
diff --git a/zathura.c b/zathura.c
index 0165e40..de874a3 100644
--- a/zathura.c
+++ b/zathura.c
@@ -60,7 +60,6 @@ static void zathura_page_cache_invalidate_all(zathura_t* zathura);
 static bool zathura_page_cache_is_full(zathura_t* zathura, bool* result);
 static void zathura_jumplist_reset_current(zathura_t* zathura);
 static void zathura_jumplist_append_jump(zathura_t* zathura);
-static void zathura_jumplist_save(zathura_t* zathura);
 
 /* function implementation */
 zathura_t*
@@ -1328,7 +1327,7 @@ zathura_jumplist_load(zathura_t* zathura, const char* file)
   return true;
 }
 
-static void
+void
 zathura_jumplist_save(zathura_t* zathura)
 {
   g_return_if_fail(zathura != NULL);
diff --git a/zathura.h b/zathura.h
index ac22636..8a34af5 100644
--- a/zathura.h
+++ b/zathura.h
@@ -381,7 +381,7 @@ void zathura_jumplist_forward(zathura_t* zathura);
 void zathura_jumplist_backward(zathura_t* zathura);
 
 /**
- * Add current page as a new item to the jumplist after current position
+ * Add current page as a new jump at the end of the jumplist
  *
  * @param zathura The zathura session
  */
@@ -395,6 +395,14 @@ void zathura_jumplist_add(zathura_t* zathura);
 void zathura_jumplist_trim(zathura_t* zathura);
 
 /**
+ * Save current page at the current jump in the jumplist
+ *
+ * @param zathura The zathura session
+ *
+ */
+void zathura_jumplist_save(zathura_t* zathura);
+
+/**
  * Load the jumplist of the specified file
  *
  * @param zathura The zathura session
-- 
1.8.3.2

_______________________________________________
zathura mailing list
zathura@lists.pwmt.org
http://lists.pwmt.org/mailman/listinfo/zathura

Reply via email to