From 1ce66c21dc131e6059b524a422db5c85256a90f6 Mon Sep 17 00:00:00 2001 From: Leon Rische Date: Sun, 14 May 2023 12:43:28 +0200 Subject: Resolve 'buffer context immediately on selection --- org-fc-core.el | 22 +++++++++++++++++----- 1 file 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 -- cgit v1.2.3