Created
October 29, 2012 19:42
-
-
Save jewel12/3976052 to your computer and use it in GitHub Desktop.
Create a new entry of DayOne on Emacs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does this still work with dayone2 cli?