diff options
author | Kyle Meyer <kyle@kyleam.com> | 2015-03-06 02:02:42 -0500 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2015-03-06 02:02:42 -0500 |
commit | a9928fc5a23f05ac7eeada1dd9ed3e2d7a2514db (patch) | |
tree | a32da17881584980ac38bd9fea92e0fa1c9a617a | |
parent | 67d91718f7d174f7f708b1e963da99f849f21345 (diff) | |
download | bog-a9928fc5a23f05ac7eeada1dd9ed3e2d7a2514db.tar.gz |
Reorganize citekey methods
-rw-r--r-- | bog.el | 88 |
1 files changed, 47 insertions, 41 deletions
@@ -248,43 +248,7 @@ treated as word characters.") ;;; Citekey methods -(defmacro bog-selection-method (name context-method collection-method) - "Create citekey selection function. -Create a function named bog-citekey-from-NAME with the following -behavior: -- Takes one argument (NO-CONTEXT). -- If NO-CONTEXT is nil, calls CONTEXT-METHOD with no arguments. -- If CONTEXT-METHOD returns nil or if NO-CONTEXT is non-nil, - prompts with the citekeys gathered by COLLECTION-METHOD." - `(defun ,(intern (concat "bog-citekey-from-" name)) (no-context) - ,(format "Select citekey with `%s'. -Fall back on `%s'. -If NO-CONTEXT is non-nil, immediately fall back." - (symbol-name context-method) - (symbol-name collection-method)) - (or (and no-context (bog-select-citekey (,collection-method))) - (,context-method) - (bog-select-citekey (,collection-method))))) - -(bog-selection-method "surroundings-or-files" - bog-citekey-from-surroundings - bog-all-file-citekeys) - -(bog-selection-method "surroundings-or-bibs" - bog-citekey-from-surroundings - bog-bib-citekeys) - -(bog-selection-method "surroundings-or-all" - bog-citekey-from-surroundings - bog-all-citekeys) - -(bog-selection-method "point-or-buffer-headings" - bog-citekey-at-point - bog-heading-citekeys-in-wide-buffer) - -(bog-selection-method "point-or-all-headings" - bog-citekey-at-point - bog-all-heading-citekeys) +;;;; Collection (defvar bog--citekey-cache nil "Alist of cached citekeys. @@ -333,10 +297,6 @@ Otherwise, prompt for CATEGORY." (or (and bog--no-sort values) (sort values #'string-lessp))) -(defun bog-select-citekey (citekeys) - "Prompt for citekey from CITEKEYS." - (org-icompleting-read "Select citekey: " citekeys)) - (defun bog-citekey-at-point () "Return citekey at point. The citekey must have the format specified by @@ -448,6 +408,52 @@ word constituents." (push (match-string-no-properties 0) citekeys)))) (bog--maybe-sort (delete-dups citekeys))))) +;;;; Selection + +(defmacro bog-selection-method (name context-method collection-method) + "Create citekey selection function. +Create a function named bog-citekey-from-NAME with the following +behavior: +- Takes one argument (NO-CONTEXT). +- If NO-CONTEXT is nil, calls CONTEXT-METHOD with no arguments. +- If CONTEXT-METHOD returns nil or if NO-CONTEXT is non-nil, + prompts with the citekeys gathered by COLLECTION-METHOD." + `(defun ,(intern (concat "bog-citekey-from-" name)) (no-context) + ,(format "Select citekey with `%s'. +Fall back on `%s'. +If NO-CONTEXT is non-nil, immediately fall back." + (symbol-name context-method) + (symbol-name collection-method)) + (or (and no-context (bog-select-citekey (,collection-method))) + (,context-method) + (bog-select-citekey (,collection-method))))) + +(bog-selection-method "surroundings-or-files" + bog-citekey-from-surroundings + bog-all-file-citekeys) + +(bog-selection-method "surroundings-or-bibs" + bog-citekey-from-surroundings + bog-bib-citekeys) + +(bog-selection-method "surroundings-or-all" + bog-citekey-from-surroundings + bog-all-citekeys) + +(bog-selection-method "point-or-buffer-headings" + bog-citekey-at-point + bog-heading-citekeys-in-wide-buffer) + +(bog-selection-method "point-or-all-headings" + bog-citekey-at-point + bog-all-heading-citekeys) + +(defun bog-select-citekey (citekeys) + "Prompt for citekey from CITEKEYS." + (org-icompleting-read "Select citekey: " citekeys)) + +;;;; Other + (defun bog-list-orphan-citekeys (&optional file) "List citekeys that appear in notes but don't have a heading. With prefix argument FILE, include only orphan citekeys from that |