From 91d131d00041d5087c5076272f99de69781bc5bc Mon Sep 17 00:00:00 2001
From: Daniel Carl <danielcarl@gmx.de>
Date: Tue, 30 Jul 2013 22:03:24 +0200
Subject: [PATCH] Added new hinting mode to put links into queue.

Also added new default keybinding to open oldest queued item in current window
'ctrl-p'.
---
 doc/vimb.1    | 8 ++++++++
 src/command.c | 3 +++
 src/default.h | 2 ++
 src/hints.c   | 4 ++++
 src/hints.h   | 1 +
 5 files changed, 18 insertions(+)

diff --git a/doc/vimb.1 b/doc/vimb.1
index 4553632..d2d7572 100644
--- a/doc/vimb.1
+++ b/doc/vimb.1
@@ -238,6 +238,9 @@ Start hinting to open inputboxes or textareas with external editor.
 .TP
 .BI "hint-save [" QUERY "]"
 Start hinting to download hinted links into configured download directory.
+.TP
+.BI "hint-push [" QUERY "]"
+Start hinting to push hinted URI into the read it later queue.
 
 .SS Yank
 .TP
@@ -489,6 +492,8 @@ Open the last closed page.
 .TP
 .B U
 Open the last closed page into a new window.
+.TP ctrl\-p
+Open the oldest entry from read it later queue in current browser window.
 .TP
 .B ctrl\-q
 Quit the browser.
@@ -577,6 +582,9 @@ Start hinting to open editable form fileds with external editor.
 .B ;\-s
 Start hinting to download the linkes resource.
 .TP
+.B ;\-p
+Start hinting to push hinted URI into queue.
+.TP
 .B y
 Yank the URI or current page into clipboard.
 .TP
diff --git a/src/command.c b/src/command.c
index 6f33e19..82921c2 100644
--- a/src/command.c
+++ b/src/command.c
@@ -94,6 +94,7 @@ static CommandInfo cmd_list[] = {
     {"hint-image-tabopen",        NULL,    command_hints,                {HINTS_TYPE_IMAGE | HINTS_PROCESS_OPEN | HINTS_OPEN_NEW}},
     {"hint-editor",               NULL,    command_hints,                {HINTS_TYPE_EDITABLE}},
     {"hint-save",                 NULL,    command_hints,                {HINTS_TYPE_LINK | HINTS_PROCESS_SAVE}},
+    {"hint-push",                 NULL,    command_hints,                {HINTS_TYPE_LINK | HINTS_PROCESS_PUSH}},
     {"yank-uri",                  "yu",    command_yank,                 {VB_CLIPBOARD_PRIMARY | VB_CLIPBOARD_SECONDARY | COMMAND_YANK_URI}},
     {"yank-selection",            "ys",    command_yank,                 {VB_CLIPBOARD_PRIMARY | VB_CLIPBOARD_SECONDARY | COMMAND_YANK_SELECTION}},
     {"search-forward",            NULL,    command_search,               {VB_SEARCH_FORWARD}},
@@ -486,6 +487,8 @@ gboolean command_hints(const Arg *arg)
                 prefix = ";y";
             } else if (mode & HINTS_PROCESS_SAVE) {
                 prefix = ";s";
+            } else if (mode & HINTS_PROCESS_PUSH) {
+                prefix = ";p";
             }
             break;
 
diff --git a/src/default.h b/src/default.h
index a78c71a..18c6065 100644
--- a/src/default.h
+++ b/src/default.h
@@ -43,6 +43,7 @@ static char *default_config[] = {
     "nmap <ctrl-q>=quit",
     "nmap <ctrl-o>=back",
     "nmap <ctrl-i>=forward",
+    "nmap <ctrl-p>=pop",
     "nmap r=reload",
     "nmap R=reload!",
     "nmap C=stop",
@@ -67,6 +68,7 @@ static char *default_config[] = {
     "nmap ;I=hint-image-tabopen",
     "nmap ;e=hint-editor",
     "nmap ;s=hint-save",
+    "nmap ;p=hint-push",
     "nmap y=yank-uri",
     "nmap Y=yank-selection",
     "nmap p=open-clipboard",
diff --git a/src/hints.c b/src/hints.c
index 2ac4f11..a79ec62 100644
--- a/src/hints.c
+++ b/src/hints.c
@@ -169,6 +169,10 @@ static void run_script(char *js)
             a.s = v;
             a.i = COMMAND_SAVE_URI;
             command_save(&a);
+        } else if (mode & HINTS_PROCESS_PUSH) {
+            a.s = v;
+            a.i = COMMAND_QUEUE_PUSH;
+            command_queue(&a);
         } else {
             a.i = VB_CLIPBOARD_PRIMARY | VB_CLIPBOARD_SECONDARY;
             a.s = v;
diff --git a/src/hints.h b/src/hints.h
index aee0db0..6f835b9 100644
--- a/src/hints.h
+++ b/src/hints.h
@@ -34,6 +34,7 @@ enum {
     HINTS_PROCESS_SAVE  = (1 << 5),
     /* additional flag for HINTS_PROCESS_OPEN */
     HINTS_OPEN_NEW      = (1 << 6),
+    HINTS_PROCESS_PUSH  = (1 << 7),
 };
 
 void hints_init(WebKitWebFrame *frame);
-- 
2.20.1