はメカニズムorg-mode
を持っています。Capture-Refile-Archive
私はよくメモやログを取るためにそれを使用します。また、自分の語彙を増やすためにも使用したいと思います。たとえば、英語のテキストを読んでいるときに新しい単語に遭遇した場合、単に入力C-c c v e
してその単語を語彙ファイルに記録したいと思いますWord-List-EN.org
。また、単語を文字に分類して、たとえばcashew
エントリに記録することもできます/C/CA
。C-c c v E
エスペラント語を.のようなファイルに記録するために入力したいと思いますvortaro.org
。org-capture-templates
これを実装するように構成するにはどうすればよいですか?org-infoを読みましたが、まだ手がかりがありません。マニュアルには、のようなものを使用できると書かれています(function function-finding-location)
。しかし、私は自分自身を定義する必要がありますfunction-finding-location
。elispマスターが私を助けてくれることを願っています!
1805 次
2 に答える
5
テンプレートの一部としてファイルの場所を選択するための機能がニーズに対して早すぎるという事実について、pmr は正しいと思います。
org capture refile ワークフローと統合する 1 つの方法は、標準の org capture テンプレート システムを使用して新しい単語をボキャブ バッファにファイルし、カスタム elisp 関数をフックとして使用することです。新しい定義を正しい場所にファイルします。
単語と定義の入力を求めるプロンプトを出し、それを組織バッファーの適切な場所に挿入するサンプルとして、次の関数を作成しました。必要に応じて、これを選択したキーにバインドするか、フック アプローチの開始点として使用できます。
;;
;; remove extra spaces between stars and the headline text
;;
(defun tidy-headlines ()
(interactive)
(save-excursion
(goto-char (point-min))
(while (re-search-forward "^\\*+\\([[:space:]][[:space:]]+\\)" (point-max) t)
(replace-match " " nil nil nil 1))))
;;
;; function for storing things in vocab files like cashew /C/CA/Cashew
;;
(defun insert-vocab-word (vocab-word definition)
"prompts for a word then opens a vocab file and puts the word in place"
(interactive "sWord: \nsDefinition: ")
(find-file "~/org/vocab.org")
(tidy-headlines)
(goto-char (point-min))
(let* ((first-char (upcase (substring vocab-word 0 1)))
(first-two-chars (upcase (substring vocab-word 0 2))))
(while (and (re-search-forward "^\\* " (point-max) t)
(string< (buffer-substring-no-properties (point) (+ 1 (point))) first-char)))
(if (string= (buffer-substring-no-properties (point) (+ 1 (point))) first-char)
(let* ((end-of-subtree (save-excursion (org-end-of-subtree) (point))))
(while (and (re-search-forward "^\\*\\* " end-of-subtree t)
(string< (buffer-substring-no-properties (point) (+ 2 (point))) first-two-chars)))
(if (string= (buffer-substring-no-properties (point) (+ 2 (point))) first-two-chars)
(let* ((end-of-subtree2 (save-excursion (org-end-of-subtree) (point))))
(while (and (re-search-forward "^\\*\\*\\* " end-of-subtree2 t)
(string< (word-at-point) vocab-word)))
(if (string< vocab-word (word-at-point))
(progn
(beginning-of-line)
(org-insert-heading t))
(org-insert-heading-after-current))
(insert vocab-word)
(org-insert-subheading t)
(insert definition))
(progn
(if (string< first-two-chars (buffer-substring-no-properties (point) (+ 2 (point))))
(progn
(beginning-of-line)
(org-insert-heading t))
(org-insert-heading-after-current))
(insert first-two-chars)
(org-insert-subheading t)
(insert vocab-word)
(org-insert-subheading t)
(insert definition))))
(progn
(org-insert-heading-after-current)
(insert first-char)
(org-insert-subheading t)
(insert first-two-chars)
(org-insert-subheading t)
(insert vocab-word)
(org-insert-subheading t)
(insert definition)))))
于 2012-12-11T07:02:43.957 に答える
1
org-capture を同様のものに取得するのに大きな問題がありましたが、org-remember はうまく機能しました。関連する .emacs ビットは次のとおりです。
(require 'org-install)
(setq org-directory "~/.orgfiles/")
(setq org-default-notes-file (expand-file-name "~/.orgfiles/notes.org"))
(setq remember-annotation-functions '(org-remember-annotation))
(setq remember-handler-functions '(org-remember-handler))
(add-hook 'remember-mode-hook 'org-remember-apply-template)
(setq org-agenda-files '("~/.orgfiles"))
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-cc" 'org-remember)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)
(setq org-remember-templates
'(("Todo" ?t "* TODO %^{Brief Description} %^g\n%? Added: %U" "~/.orgfiles/TODO.org" "Tasks")
("Idea" ?i "* %^{Brief Description} %^g\n%? Added: %U" "~/.orgfiles/Idea.org" "Ideas")
("Study" ?s "* %^{Brief Description} %^g\n%? Added: %U" "~/.orgfiles/Study.org" "Study")
("Receipt" ?r "** %^{Brief Description} %U %^g\n%?" "~/.orgfiles/Receipt.org")
)
)
于 2012-12-04T09:09:06.280 に答える