Emacsのメモツール(org-capture)の設定
参考:
org-capture ~Emacs + org-modeで素早くメモをとる新しい方法~ – (rubikitch loves (Emacs Ruby CUI Books))
色々 Org Capture する | Amrta
org-capture ~Emacs + org-modeで素早くメモをとる新しい方法~ – (rubikitch loves (Emacs Ruby CUI Books))
色々 Org Capture する | Amrta
いろいろとややこしく設定の量も多かったので、次のようなEmacs-Lispのファイルを作成し、load-fileでEmacsの起動時に読み込むようにしました。Emacsのメモツールとしてはhowmの方が使いやすいという印象ですが、org-modeに慣れるためにいろいろやってみました。インストールや設定は他にもいろいろあると思いますが、参考ページ及びそちらのリンクを参考にさせてもらいました。
実用性は余り感じなかったのですが、いろいろ勉強になりました。
(define-key global-map "\C-cc" 'org-capture) (require 'org-capture) (defun org-capture-demo () (interactive) (let ((file "/tmp/org-capture.org") org-capture-templates) (find-file-other-window file) (unless (save-excursion (goto-char 1) (search-forward "* test\n" nil t)) (insert "* test\n** entry\n")) (other-window 1) (setq org-capture-templates `(("a" "ふつうのエントリー後に追加" entry (file+headline ,file "entry") "* %?\n%U\n%a\n") ("b" "ふつうのエントリー前に追加" entry (file+headline ,file "entry") "* %?\n%U\n%a\n" :prepend t) ("c" "即座に書き込み" entry (file+headline ,file "entry") "* immediate-finish\n" :immediate-finish t) ("d" "ナローイングしない" entry (file+headline ,file "entry") "* 全体を見る\n\n" :unnarrowed t) ("e" "クロック中のエントリに追加" entry (clock) "* clocking" :unnarrowed t) ("f" "リスト" item (file+headline ,file "list") "- リスト") ;; うまく動かない ("g" "チェックリスト" checkitem (file+headline ,file "list") "チェックリスト") ("h" "表の行" table-line (file+headline ,file "table") "|表|") ("i" "そのまま" plain (file+headline ,file "plain") "あいうえお") ("j" "ノードをフルパス指定して挿入" entry (file+olp ,file "test" "entry") "* %?\n%U\n%a\n") ;; これもうまく動かない ("k" "ノードを正規表現指定して挿入" entry (file+regexp ,file "list") "* %?\n%U\n%a\n") ;; 年月日エントリは追記される ("l" "年/月/日のエントリを作成する1" entry (file+datetree ,file)) ("m" "年/月/日のエントリを作成する2" item (file+datetree ,file)) ("o" "年/月/日のエントリを作成する prepend" entry (file+datetree ,file) "* a" :prepend t))) (org-capture))) (global-set-key "\C-x\C-z" 'org-capture-demo) (require 'moz) (defun jk/moz-get (attr) (comint-send-string (inferior-moz-process) attr) ;; try to give the repl a chance to respond (sleep-for 0 100)) (defun jk/moz-get-current-url () (interactive) (jk/moz-get "repl._workContext.content.location.href")) (defun jk/moz-get-current-title () (interactive) (jk/moz-get "repl._workContext.content.document.title")) (defun jk/moz-get-current (moz-fun) (funcall moz-fun) ;; doesn't work if repl takes too long to output string (save-excursion (set-buffer (process-buffer (inferior-moz-process))) (goto-char (point-max)) (previous-line) (setq jk/moz-current (buffer-substring-no-properties (+ (point-at-bol) (length moz-repl-name) 3) (- (point-at-eol) 1)))) (message "%s" jk/moz-current) jk/moz-current ) (defun jk/moz-url () (interactive) (jk/moz-get-current 'jk/moz-get-current-url) ) (defun jk/moz-title () (interactive) (jk/moz-get-current 'jk/moz-get-current-title) ) ;(setq org-capture-templates ;'(("t" "Todo" entry (file+headline "~/org/all.org" "Tasks") ;"* TODO %?\n %i\n %a") ;("n" "Notes" entry (file+datetree "~/org/notes.org") ;"* %?\nEntered on %U\n %i\n %a") ;("b" "Bookmark" entry (file+datetree "~/org/notes.org") ;"* %(concat \"[[\" (jk/moz-url) \"][\" (jk/moz-title) \"]]\")\n Entered on %U\n") ;)) (setq org-capture-templates '(("f" "Firefox" entry (file+datetree "~/Dropbox/org/firefox.org" "Bookmarks") "* %?\n %(concat (jk/moz-url))\n Entered on %U\n") ; 日本語は文字化けするので URL だけ取得する。 ("w" "Weblog" entry (file+headline "~/Dropbox/org/blog.org" "Drafts") "* %? \n%[~/Dropbox/org/blogtmpl.txt]") )) (defun jk/moz-url-w3m () "Open current page of Firefox on emacs-w3m." (interactive) (w3m-browse-url (jk/moz-url))) ;; (global-set-key (kbd "\C-cW") 'jk/moz-url-w3m)
投稿した記事を見るとソースコード中にニコニコマークが出ていました。本来は;でEmacs-Lisp式をコメントアウトした部分です。htmlで表示すると特殊記号の処理の過程で、最終的な表示がおかしくなる場合が多々あります。コピペでコードを使用する場合は、ご注意の上自己責任でお願いします。
コメントを残す