1

I'm currently trying to streamline my email/org workflow. I have a function which adds links to an org-buffer if a mail message contains DCO style signoff tags:

(defvar my-dco-tag-re
  (rx (: bol (zero-or-more (in blank))                        ;; fresh line
         (any "RSTA") (one-or-more (in alpha "-")) "-by: "    ;; tag
         (one-or-more (in alpha blank "<>@."))                ;; person
         eol))
  "Regexp to match DCO style tag.")

(defun my-capture-review-tags ()
  "Return a list of tags for current buffer"
  (let ((tags))
    (save-excursion
      (goto-char (point-min))
      (while (re-search-forward my-dco-tag-re (point-max) t)
        (add-to-list 'tags (match-string-no-properties 0))))
    tags))

(defun my-org-maybe-capture-review-tag ()
  "Check buffer for DCO tags and if found queue a review comment."
  (interactive)
  (when (my-capture-review-tags)
    (org-capture nil "g")))

This works well enough. However I now want to programatically go through my org links and grab the tags from the messages on demand. Is there a way to visit an org-link without messing with the window configuration? I've tried the following so far to no avail:

(defun my-org-visit-link-and-snarf-tags ()
  "Visit org-link-at-point and return a set of tags."
  (save-excursion
    (save-window-excursion
      (org-open-at-point t)
      (my-capture-review-tags))))

Any suggestions?

  • You can look at the text properties of the links you commonly use by placing the cursor on a link and evaluating (text-properties-at (point)) Once you know the name of the text property, you can get the value with something like this: (car (cdr (get-text-property (point) 'htmlize-link))) You can use something like (with-temp-buffer (insert-file-contents [the result of the above-mentioned snippet]) . . .) and the temporary buffer can be used behind the scenes without said buffer ever acquiring visual focus . . . . See also with-current-buffer and find-file-noselect. – lawlist Jul 8 '16 at 22:07
  • So the links in question are mu4e links (using org-mu4e) however I think the problem here is less with org than with mu4e. As it requires an asynchronous server and org-link helpers are free to open links as they want there isn't an easy way to get straight to the buffer. I think I'll need support in mu4e to do things this way around. – stsquad Jul 9 '16 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.