diff options
author | Leon Rische <leon.rische@me.com> | 2023-05-14 12:43:28 +0200 |
---|---|---|
committer | Leon Rische <leon.rische@me.com> | 2023-05-14 12:43:28 +0200 |
commit | 1ce66c21dc131e6059b524a422db5c85256a90f6 (patch) | |
tree | 98f02e62c7fbd5d54900a10c3e012d45da0652bc | |
parent | 073bfef99533d444103995f2dcf9c16b23506e70 (diff) |
Resolve 'buffer context immediately on selection
-rw-r--r-- | org-fc-core.el | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/org-fc-core.el b/org-fc-core.el index 5ff8be1..1b6a608 100644 --- a/org-fc-core.el +++ b/org-fc-core.el @@ -684,14 +684,26 @@ Positions are shuffled in a way that preserves the order of the org-fc-custom-contexts)) (defun org-fc-select-context () - "Select a review context." - (let ((context (completing-read + "Select a review context. +The `buffer' context is resolved to the filename of the current +buffer immediately." + (let* ((choice (completing-read "Context: " (mapcar (lambda (c) (car c)) (org-fc-contexts)) nil - :require-match))) - (unless (string= context "") - (alist-get (intern context) (org-fc-contexts))))) + :require-match)) + (context + ;; If the result is empty, the user quit the prompt + (unless (string= choice "") + (alist-get (intern choice) (org-fc-contexts))))) + ;; Resolve the `buffer' immediately so it will be valid even when + ;; using the selected context from within another buffer, + ;; e.g. when starting a review from the dashboard. + (if (eq (plist-get context :paths) 'buffer) + (list + :paths (buffer-file-name) + :filter (plist-get context :filter)) + context))) ;;; Footer |