 (require 'cl)
 (require 'anything)
 
-(defvar hateda-exec-path "~/bin/hateda")
+(defvar hateda-executable "~/bin/hateda")
 (defvar hateda-draft-dir "~/hateda/")
 (defvar hateda-draft-entry-regexp "Draft id: \\([1-9][0-9]*\\)  title: \\(.*\\)  date: \\([0-9]+\\)")
 (defstruct hateda-draft-entry

    (hateda-draft-rm (hateda-draft-entry-id entry))))

(defun hateda-draft-rm (id)
  (shell-command (hateda-mkString `(,hateda-exec-path "draft" "rm" ,id) " ")))

(defun anything-hateda-draft-entries-get-candidates ()
  (message "Wait a moment....")

  (interactive)
  (write-region (point-min) (point-max) hateda-draft-tmp-file nil nil)
  (message "Wait a moment.....")
  (shell-command (hateda-mkString `(,hateda-executable "draft" "add" ,hateda-draft-tmp-file) " ")))

(defun hateda-mkString (lst &optional spliter)
  (reduce (lambda (m o) (concat m (or spliter "") o)) lst))
