Day One是OSX上很是精美的一款日記軟件, 我已使用好久了. 它同時還有iOS的客戶端, 包括iPhone和iPad.app
今天發現One Day還有Command Line工具,翻了一下文檔,發現這個CLI功能很是全面.既然有功能全面的CLI工具,那麼必須就能夠在Emacs裏使用了!工具
$ ./dayone new Waits for input from stdin then creates a new entry in the default journal $ echo "an entry from yesterday" | ./dayone -d="yesterday" new Creates a new entry using yesterday’s date with the specified text $ ./dayone -d="25/03/2011 5:30PM" -s=true new < ~/Desktop/note.txt Creates a starred entry using the contents of note.txt $ echo "an entry in my other journal" | ./dayone -j=~/Documents/WorkJournal.dayone new Creates an entry in a journal other than the default
下面是在Emacs裏經過One Day CLI來操做One Day.spa
;; dayone.el ;; venmos .emacs.d/elisp/ ;; http://blog.venmos.com ;; me[at]venmos.com ;; 基於 One Day 命令行工具建立的 Elisp 包, 能夠在 Emacs 裏建立 One Day 日記. ;; dayone-cli https://dayone.zendesk.com/hc/en-us/articles/200258954-Day-One-Tools (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)))) ;;; init-dayone.el ends here