sphinxで個人的なメモを取る際のemacsの設定
(昨日はwindowsなのに今回はunixの話です)
sphinxをemacs上で使う際にしておいた方が良さそうだと感じた設定のめも
だいたい以下のような内容が含まれてます。
- 全角空白がウザい
- "make html"を手軽に
- 出来上がったhtmlを手軽に閲覧
- 指定した箇所に空白3つ前置したい("foo" -> " foo")
.emacs
C-c C-@で"make html"をします。また、全角空白は自動的に半角空白になります。(全角空白を入力したい場合にはC-qを前置してください)
sphinx-browseで生成された_build/index.htmlをみにいきます。
;; 手抜き (defmacro ilambda (&rest body) `(lambda () (interactive) ,@body)) (defun rst-indent-for-tab-command (&optional arg) (interactive "p") (if (region-active-p) (indent-rigidly (region-beginning) (region-end) 3) (indent-for-tab-command arg))) (defun sphinx-browse () (interactive) (let ((html (shell-command-to-string "find . -name 'index.html'"))) (cond ((string= "" html) (message "%s is not found" "index.html")) (t (browse-url (file-truename html)))))) (add-hook 'rst-mode-hook (ilambda (define-key rst-mode-map "\C-c\C-@" (ilambda (compile "make html"))) (define-key rst-mode-map "\C-i" 'rst-indent-for-tab-command) (define-key rst-mode-map " " (ilambda (insert " ")))))