Skip to content

Instantly share code, notes, and snippets.

@jewel12
Created October 29, 2012 19:42
Show Gist options
  • Save jewel12/3976052 to your computer and use it in GitHub Desktop.
Save jewel12/3976052 to your computer and use it in GitHub Desktop.
Create a new entry of DayOne on Emacs.
(defvar path-to-dayone "/usr/local/bin/dayone"
"Executable path to DayOne CLI")
(defun dayone-save-new-entry ()
"Save buffer as a new DayOne entry"
(interactive)
(if (executable-find path-to-dayone)
(call-process-region
1 (point-max) path-to-dayone nil nil nil "new")))
(defvar dayone-buffer "*dayone*"
"The name of the dayone buffer.")
(defvar dayone-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-c\C-c" 'dayone-save-and-kill-buffer)
(define-key map "\C-c\C-k" 'dayone-destroy-buffer)
map)
"Keymap used in DayOne mode.")
(defun dayone-create-new-entry ()
"Create *DayOne* buffer in new window."
(interactive)
(switch-to-buffer (get-buffer-create dayone-buffer))
(use-local-map dayone-mode-map)
(setq major-mode 'dayone-mode mode-name "DayOne"))
(defun dayone-save-and-kill-buffer ()
(interactive)
(dayone-save-new-entry)
(dayone-destroy-buffer))
(defun dayone-destroy-buffer ()
"Destroy the current *DayOne* buffer."
(interactive)
(if (equal dayone-buffer (buffer-name))
(kill-buffer (current-buffer))))
@jdivock
Copy link

jdivock commented Feb 8, 2015

Man, this plugin is great! You should put it in melpa as the current dayone entry there is pretty poor and doesn't leverage the CLI tool. Thanks so much for this.

@ashishbhateja
Copy link

Does this still work with dayone2 cli?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment