; ; hive.el ; ; Simple m-x braindump module. Will grow later to include a task-browser. ; ; TODO: pick a default keybinding ; m-x hive-braindump ; prompts for a tag, with completion off of your known ones ; repeats until you give a blank response ; --- actually, crm.el is in emacs21 and gives completing-read-multiple ; accumulates the tags in the prompt ; then prompts for the message itself ; hands the whole thing off to hive-braindump.py. ; Some ideas taken from db-acronym.el, which I wrote 10 years ago ;; TODO: expand-file-name here? (defvar hiveminder-tag-file "~/.hiveminder_tags.el") ; file sets hiveminder-tags (if (null (load hiveminder-tag-file t t t)) (setq hiveminder-tags (list "work" "social"))) (defvar braindump-command "braindump") ; could be a path to hive-braindump.py (require 'crm) (defun make-alist (raw-list) """why isn't this already in emacs somewhere?""" (mapcar (lambda (tag) (list tag)) raw-list)) ; (make-alist (list "work" "social" "foo")) ; => (("work") ("social") ("foo")) (setq hiveminder-tag-history '()) (setq hiveminder-dump-history '()) (defun prefix-args-with (option args) "returns (OPTION ARG1 OPTION ARG2 ...)" (mapcon (lambda (arg) (list option (car arg))) args)) ; (prefix-args-with "--tag" (list "foo" "bar" "baz")) ; => ("--tag" "foo" "--tag" "bar" "--tag" "baz") (defun hive-braindump (tags body) "Post a hiveminder braindump message (just one) with completion on your current tags, comma separated" (interactive (list ; tags: (let ( ; (crm-separator " ") ; crm isn't smart enough for that (hm-complete-table (make-alist hiveminder-tags)) ) ; TODO: auto-add new tags to hiveminder-tag-file (completing-read-multiple "tag,tag,tag: " hm-complete-table nil ; pred nil ; require-match nil ; initial-input 'hiveminder-tag-history ; hist nil ; def nil ; inherit-input-method )) ; body: (read-string "Body: " nil ; initial-input 'hiveminder-dump-history ; history ) )) ; TODO: implement this call (let ( (outbuf (get-buffer-create " *hive-bd-out*")) (taglist (prefix-args-with "--tag" tags)) ) ; (message "call braindump --tags %s body %s" tags body) (apply 'call-process (nconc (list braindump-command nil ; infile outbuf ; buffer nil) ; display taglist (list body))) (message "Done: %s" (save-excursion (set-buffer outbuf) (buffer-string))) (kill-buffer outbuf) ))