aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--conkeror/markam.js54
-rw-r--r--src/markam.scm22
2 files changed, 71 insertions, 5 deletions
diff --git a/conkeror/markam.js b/conkeror/markam.js
index 2151b17..8c7c2f1 100644
--- a/conkeror/markam.js
+++ b/conkeror/markam.js
@@ -1,5 +1,5 @@
/* markam -- Store/retrieve/manage bookmarks
- Copyright (C) 2012 Tom Willemsen <tom at ryuslash dot org>
+ Copyright (C) 2012,2013 Tom Willemsen <tom at ryuslash dot org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -25,6 +25,17 @@
define_variable("markam_program", "markam",
"The location of the markam executable.");
+define_browser_object_class(
+ "markam-bookmark", null,
+ function (I, prompt) {
+ check_buffer(I.buffer, content_buffer);
+ var result = yield I.buffer.window.minibuffer.read(
+ $prompt = prompt, $completer = markam_complete
+ );
+ yield co_return(result);
+ }
+);
+
function markam_add_url(I, url, title)
{ // Add URL to markam, ask for a title (provide TITLE as a
// default), description and any number of tags.
@@ -74,4 +85,45 @@ interactive("markam-add-link",
"Select and bookmark a link in markam",
markam_add_link);
+function markam_complete(input, pos, conservative)
+{
+ if (pos == 0 && conservative)
+ yield co_return(undefined);
+
+ let str = input.substring(0, pos);
+
+ var data = "", error = "", ret = [];
+ var result = yield shell_command(
+ markam_program + " --script",
+ $fds = [{ output: async_binary_string_writer("") },
+ { input: async_binary_reader(function (s) data += s || "") },
+ { input: async_binary_reader(function (s) error += s || "") }]);
+
+ if (result != 0 || error != "")
+ throw new interactive_exception("result: " + result +
+ ", error: " + error);
+ else if (data != "") {
+ data.split('').forEach(function (row) {
+ ret.push(row.split(''));
+ });
+
+ let c = { count: ret.length,
+ get_string: function (i) ret[i][0],
+ get_description: function (i) ret[i][1],
+ // get_value: function (i) ret[i][2],
+ get_input_state: function (i) [ret[i][2]] };
+ yield co_return(c);
+ }
+}
+
+interactive("markam-find-url",
+ "Find a page from markam in the current buffer",
+ "find-url",
+ $browser_object = browser_object_markam_bookmark);
+interactive("markam-find-url-new-buffer",
+ "Find a page from markam in a new buffer",
+ "find-url-new-buffer",
+ $browser_object = browser_object_markam_bookmark);
+
+
provide("markam");
diff --git a/src/markam.scm b/src/markam.scm
index 5d6581f..8069701 100644
--- a/src/markam.scm
+++ b/src/markam.scm
@@ -1,5 +1,5 @@
;;; markam -- Store/retrieve/manage bookmarks
-;; Copyright (C) 2012 Tom Willemsen <tom at ryuslash dot org>
+;; Copyright (C) 2012,2013 Tom Willemsen <tom at ryuslash dot org>
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@@ -42,9 +42,13 @@
;; stream.
(: print-row (string fixnum string string -> void))
(define (print-row url seconds name description)
- (format #t "~a~% ~a~% ~a~% ~a~%~%" (string-no-null name)
- (string-no-null description) (string-no-null url)
- (seconds->string seconds)))
+ (if script?
+ (format #t "~a~a~a"
+ (string-no-null name) (string-no-null description)
+ (string-no-null url))
+ (format #t "~a~% ~a~% ~a~% ~a~%~%" (string-no-null name)
+ (string-no-null description) (string-no-null url)
+ (seconds->string seconds))))
;; Add NAME to the `tag' table in DB.
(define (add-tag db name)
@@ -120,9 +124,19 @@ END
(format #t "Unrecognized option: ~a~%" (car args))))
(set! args (cdr args))))
+(define (check-script args)
+ (if (member "--script" args)
+ (begin
+ (set! script? #t)
+ (delete "--script" args))
+ args))
+
+(define script? #f)
+
;; Open a database connection, list bookmarks, create a bookmark or
;; pass arguments on to `handle-regular-args'.
(define (main args)
+ (set! args (check-script args))
(let ((db (open-database (data-file "markam.db"))))
(cond
((null? args)