From abaf3f85f1ec69020266cda04f2365f9309d2b3c Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Sat, 1 Oct 2022 07:12:27 -0400 Subject: improve go-to-talk --- emacsconf.el | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) (limited to 'emacsconf.el') diff --git a/emacsconf.el b/emacsconf.el index 8ff487e..d95ce0d 100644 --- a/emacsconf.el +++ b/emacsconf.el @@ -156,30 +156,25 @@ (if (and search (string-match "\\(.*?\\) - " search)) (match-string 1 search) search)) -(defun emacsconf-go-to-talk (&optional search) + +(defun emacsconf-go-to-talk (search) (interactive (list (emacsconf-complete-talk))) - (when search - (setq search (emacsconf-get-slug-from-string search)) - (pop-to-buffer (find-file-noselect emacsconf-org-file)) - (let ((choices - (save-excursion - (delq nil - (org-map-entries - (lambda () - (cons - (concat (org-entry-get (point) "SLUG") " - " - (org-entry-get (point) "ITEM") " - " - (org-entry-get (point) "NAME") " - " - (org-entry-get (point) "EMAIL")) - (point))) - "SLUG={.}"))))) - (goto-char - (if search - (or (org-find-property "SLUG" search) - (cdr (seq-find (lambda (s) (string-match search (car s))) choices))) - (assoc-default (completing-read "Find: " choices) - choices))) - (org-reveal)))) + (pop-to-buffer (find-file-noselect emacsconf-org-file)) + (if (emacsconf-get-slug-from-string search) + (goto-char (org-find-property "SLUG" (emacsconf-get-slug-from-string search))) + (catch 'found + (org-map-entries + (lambda () + (when (string-match search + (cons + (concat (org-entry-get (point) "SLUG") " - " + (org-entry-get (point) "ITEM") " - " + (org-entry-get (point) "NAME") " - " + (org-entry-get (point) "EMAIL")) + (point))) + (throw 'found))) + "SLUG={.}"))) + (org-reveal)) (defmacro emacsconf-for-each-talk (&rest body) (declare (indent 0) (debug t)) -- cgit v1.2.3