emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How to occasionally store link as file.org+headline
@ 2020-02-14 16:48 Mirko Vukovic
  2020-02-19  0:28 ` Matthew Lundin
  0 siblings, 1 reply; 2+ messages in thread
From: Mirko Vukovic @ 2020-02-14 16:48 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 683 bytes --]

Hello,

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.

Thank you,

Mirko

[-- Attachment #2: Type: text/html, Size: 1077 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to occasionally store link as file.org+headline
  2020-02-14 16:48 How to occasionally store link as file.org+headline Mirko Vukovic
@ 2020-02-19  0:28 ` Matthew Lundin
  0 siblings, 0 replies; 2+ messages in thread
From: Matthew Lundin @ 2020-02-19  0:28 UTC (permalink / raw)
  To: Mirko Vukovic, emacs-orgmode

Mirko Vukovic <mirko.vukovic@gmail.com> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-19  0:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-14 16:48 How to occasionally store link as file.org+headline Mirko Vukovic
2020-02-19  0:28 ` Matthew Lundin

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).