Compare commits

...

2 Commits

Author SHA1 Message Date
Daniel - 0946628681
Ignore local project cache 2021-03-20 11:52:05 +01:00
Daniel - fde876a972
Restrict listing of link targets to current buffer by default
This is much faster, and usually what we want.  If references outside the
current buffer are necessary, just prefix the call with a universal argument.
2021-03-20 11:50:56 +01:00
2 changed files with 24 additions and 14 deletions

1
.gitignore vendored
View File

@ -57,3 +57,4 @@
/dired-history /dired-history
/sandbox/.emacs.d /sandbox/.emacs.d
/flycheck_init.el /flycheck_init.el
/projects

View File

@ -661,17 +661,20 @@ not."
(t (user-error "Neither ID nor CUSTOM_ID given"))))) (t (user-error "Neither ID nor CUSTOM_ID given")))))
(org-search-view nil query))) (org-search-view nil query)))
(defun db/org--get-location () (defun db/org--get-location (&optional arg)
"Interactively query for location and return mark. "Interactively query for location and return mark.
Searches through `org-agenda-files', Searches through the current file, and through all of
`org-agenda-text-search-extra-files', and the current buffer, up `org-agenda-files', `org-agenda-text-search-extra-files', and the
to level 9. If location does not have an associated mark, error current buffer, if ARG is non-nil. Search is always conducted up
out." to level 9. If the selected location does not have an associated
(let* ((org-refile-targets `((org-agenda-files :maxlevel . 9) mark, error out."
(,(cl-remove-if-not (let* ((org-refile-targets (if arg
#'stringp org-agenda-text-search-extra-files) `((org-agenda-files :maxlevel . 9)
:maxlevel . 9) (,(cl-remove-if-not
(nil :maxlevel . 9))) #'stringp org-agenda-text-search-extra-files)
:maxlevel . 9)
(nil :maxlevel . 9))
'((nil :maxlevel . 9))))
(mrk (nth 3 (org-refile-get-location (mrk (nth 3 (org-refile-get-location
nil nil
;; if the current buffer is associated with a file, search ;; if the current buffer is associated with a file, search
@ -695,14 +698,20 @@ prompt for an item."
(org-with-point-at (db/org--get-location) (org-with-point-at (db/org--get-location)
(list (org-id-get) (org-entry-get nil "CUSTOM_ID")))))) (list (org-id-get) (org-entry-get nil "CUSTOM_ID"))))))
(defun db/org-add-link-to-other-item () (defun db/org-add-link-to-other-item (arg)
"Interactively query for item and add link to it at point. "Interactively query for item and add link to it at point.
Search through all items of the current buffer, or
`db/org-default-org-file' if the current buffer is not associated
with a file. If ARG is non-nil, include all files in
`org-agenda-files' and `org-agenda-text-search-extra-files' in
this search.
Use `org-store-link' to save link to `org-stored-links'." Use `org-store-link' to save link to `org-stored-links'."
(interactive) (interactive "P")
(unless (derived-mode-p 'org-mode) (unless (derived-mode-p 'org-mode)
(user-error "Not in Org Mode")) (user-error "Not in Org Mode"))
(let ((pom (db/org--get-location)) (let ((pom (db/org--get-location arg)))
id item)
(save-mark-and-excursion (save-mark-and-excursion
(org-with-point-at pom (org-with-point-at pom
(org-store-link nil t)) (org-store-link nil t))