emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to occasionally store link as file.org+headline


From: Matthew Lundin
Subject: Re: How to occasionally store link as file.org+headline
Date: Tue, 18 Feb 2020 18:28:38 -0600

Mirko Vukovic <address@hidden> writes:

> For most of my links, I want to use the ID generated by orgmode
> i.e., (setq org-id-link-to-org-use-id t)
>
> But occasionally, for targets that are not part of my agenda files, I want
> to store a link of the type file:path.org::*headline
>
> I wrote the following function to accomplish that:
>
> (defun org-store-file+headline ()
>   "Store link as file + headline"
>   (interactive)
>   (let ((org-id-link-to-org-use-id nil))
>     (org-store-link nil t)))
>
> This function works (lightly tested).
>
> But is there a built-in way, such as using prefixes or arguments to
> org-store-link? I browsed the code for it, but that function is several
> hundred lines long, and I gave up.

I think the function is the best option, as the logic of whether to
store ids (based on the value of org-id-link-to-org-use-id) is
hard-coded into org-store-link and can't be changed through arguments.
You could always create a custom function and bind it to 'C-c l' in
org-mode:

(defun my-org-store-org-link (arg)
  "Store a link org mode.
When there is a prefix arg, use file+headline format"
  (interactive "P")
  (let ((org-id-link-to-org-use-id (not arg)))
    (org-store-link nil t)))

Best,
Matt



reply via email to

[Prev in Thread] Current Thread [Next in Thread]