org-hatena-diary.el のテスト
org-mode -> はてな記法エクスポータも Emacs からはてなダイアリーの記事を投稿・管理するのも既にあったので手を
組ませてみる。
…実装の仕方に目を瞑りさすれば、なかなかよさげ?
設定例
(setq org-hatena-diary-username "アカウント名") (setq org-hatena-diary-password "APIキー") (global-set-key (kbd "<f12>") 'org-hatena-diary-list)
ライブラリ
;;; org-hatena-diary.el --- Write diary in org-mode and post it to hatena diary -*- lexical-binding: t; -*- ;; Copyright (C) 2015 arikui ;; Author: <arikui.ruby@gmail.com> ;; Keywords: ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see http://www.gnu.org/licenses/. ;;; Commentary: ;; This elisp hacks two libraries, ;; hatena-diary.el(http://d.hatena.ne.jp/tarao/20130110/1357821338) and ;; ox-hatena.el(http://akisute3.hatenablog.com/entry/2013/08/23/150311), ;; to cooperate. ;;; Code: (require 'hatena-diary) (require 'ox-hatena) (eval-when-compile (require 'cl)) (defun org-hatena-diary::advice-hatena-d-parse-content (f &rest args) (save-window-excursion (org-hatena-export-as-hatena) (apply f args))) (advice-add 'hatena-d-parse-content :around 'org-hatena-diary::advice-hatena-d-parse-content) (defun org-hatena-diary::turn-on-org-mode () (when (string= "* Title" (buffer-string)) ; 記事の新規作成の場合 (erase-buffer) (insert "#+TITLE: #+FILETAGS: ") (goto-char (point-min)) (end-of-line)) (org-mode)) (setq hatena:d:major-mode 'org-hatena-diary::turn-on-org-mode) (defvaralias 'org-hatena-diary-username 'hatena:username) (defvaralias 'org-hatena-diary-password 'hatena:password) (defalias 'org-hatena-diary-list 'hatena:d:list) (provide 'org-hatena-diary) ;;; org-hatena-diary.el ends here