2 Commits

Author SHA1 Message Date
  Daniel 0946628681
Ignore local project cache 1 month ago
  Daniel fde876a972
Restrict listing of link targets to current buffer by default 1 month ago
2 changed files with 24 additions and 14 deletions
  1. 1
    0
      .gitignore
  2. 23
    14
      site-lisp/db-org.el

+ 1
- 0
.gitignore View File

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

+ 23
- 14
site-lisp/db-org.el View File

@@ -661,17 +661,20 @@ not."
661 661
                 (t (user-error "Neither ID nor CUSTOM_ID given")))))
662 662
     (org-search-view nil query)))
663 663
 
664
-(defun db/org--get-location ()
664
+(defun db/org--get-location (&optional arg)
665 665
   "Interactively query for location and return mark.
666
-Searches through `org-agenda-files',
667
-`org-agenda-text-search-extra-files', and the current buffer, up
668
-to level 9.  If location does not have an associated mark, error
669
-out."
670
-  (let* ((org-refile-targets `((org-agenda-files :maxlevel . 9)
671
-                               (,(cl-remove-if-not
672
-                                  #'stringp org-agenda-text-search-extra-files)
673
-                                :maxlevel . 9)
674
-                               (nil :maxlevel . 9)))
666
+Searches through the current file, and through all of
667
+`org-agenda-files', `org-agenda-text-search-extra-files', and the
668
+current buffer, if ARG is non-nil.  Search is always conducted up
669
+to level 9.  If the selected location does not have an associated
670
+mark, error out."
671
+  (let* ((org-refile-targets (if arg
672
+                                 `((org-agenda-files :maxlevel . 9)
673
+                                   (,(cl-remove-if-not
674
+                                      #'stringp org-agenda-text-search-extra-files)
675
+                                    :maxlevel . 9)
676
+                                   (nil :maxlevel . 9))
677
+                                 '((nil :maxlevel . 9))))
675 678
          (mrk (nth 3 (org-refile-get-location
676 679
                       nil
677 680
                       ;; if the current buffer is associated with a file, search
@@ -695,14 +698,20 @@ prompt for an item."
695 698
            (org-with-point-at (db/org--get-location)
696 699
              (list (org-id-get) (org-entry-get nil "CUSTOM_ID"))))))
697 700
 
698
-(defun db/org-add-link-to-other-item ()
701
+(defun db/org-add-link-to-other-item (arg)
699 702
   "Interactively query for item and add link to it at point.
703
+
704
+Search through all items of the current buffer, or
705
+`db/org-default-org-file' if the current buffer is not associated
706
+with a file.  If ARG is non-nil, include all files in
707
+`org-agenda-files' and `org-agenda-text-search-extra-files' in
708
+this search.
709
+
700 710
 Use `org-store-link' to save link to `org-stored-links'."
701
-  (interactive)
711
+  (interactive "P")
702 712
   (unless (derived-mode-p 'org-mode)
703 713
     (user-error "Not in Org Mode"))
704
-  (let ((pom (db/org--get-location))
705
-        id item)
714
+  (let ((pom (db/org--get-location arg)))
706 715
     (save-mark-and-excursion
707 716
       (org-with-point-at pom
708 717
         (org-store-link nil t))

Loading…
Cancel
Save