From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ihor Radchenko Subject: Re: Links in Org-mode : Clunky Date: Mon, 29 Jul 2019 08:34:00 +0800 Message-ID: <87pnlt3chz.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:44137) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hrtd8-0005kq-Cc for emacs-orgmode@gnu.org; Sun, 28 Jul 2019 20:35:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hrtd7-000371-An for emacs-orgmode@gnu.org; Sun, 28 Jul 2019 20:35:10 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:37644) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hrtd7-00036i-4P for emacs-orgmode@gnu.org; Sun, 28 Jul 2019 20:35:09 -0400 Received: by mail-pg1-x543.google.com with SMTP id i70so16560583pgd.4 for ; Sun, 28 Jul 2019 17:35:08 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nathan Neff , emacs-orgmode Dear Nathan, > Has anyone coded such a plugin or am I missing some cool Helm-fu? Not exactly the same, but see the code below. Note that the code does not support creating CUSTOM_ID. Instead, it silently creates an ID if it does not exist (see (org-id-get ... 'create)). The helm completion will work if it is enabled globally. #+begin_src emacs-lisp (defvar org-id-history nil "ID completion history for id: link type.") (defvar org-id-cache nil "ID completion cache for id: link type.") (defun org-id-prompt-id () "Prompt for the id during completion of att-id: link." (let ((org-refile-history org-id-history) (org-refile-cache org-id-cache) (org-refile-target-verify-function nil)) (let ((prompt-ans (org-refile-get-location "Select org entry"))) (prog1 (or (org-id-get (seq-find #'markerp prompt-ans) 'create) (user-error "Cannot find ID of the entry: %s" prompt-ans)) (setq org-id-history org-refile-history) (setq org-id-cache org-refile-cache))))) (defun org-id-link-complete (&optional arg) "Completion function for id: link." (let* ((id (org-id-prompt-id))) (format "id:%s" id))) (org-link-set-parameters "id" :complete #'org-id-link-complete) #+end_src Regards, Ihor Nathan Neff writes: > Hello all, > > I've always found that the links in org-mode are basically > very clunky to try to use in a quick fashion. > > To my understanding (see my other question about CUSTOM_ID > versus ID) it's a good practice to store either a CUSTOM_ID or ID > - (still can't grok the difference) and then store a hyperlink to that > CUSTOM_ID or ID. > > By storing a hyperlink to CUSTOM_ID or ID my heading can change, > but this won't matter. I can also move the heading to another file, and > links > to it will still work. > > However, I find that it's pretty clunky to store a CUSTOM_ID or ID > for a heading, and then copy the link, and then paste it where I want to > use it. Granted, it's not very difficult using org-store-link and > org-insert-link, > but it's just not as easy as I would think it would be. > > I've recently stumbled on Helm and was wondering if anyone has coded some > kind of function that would show me a list of my headings, and create a > CUSTOM_ID > or ID for the heading and then copy a link to that heading so that I could > easily paste it. > > Let's say I'm typing some stuff and want to insert a link to another > heading, I would > press some key combo and a helm search would come up. I would find the > heading that > I want to link to. If the heading has a CUSTOM_ID property, then a link to > that CUSTOM_ID > would be inserted at the text where my cursor is. If there's not a > CUSTOM_ID property perhaps a prompt for a CUSTOM_ID could pop up. Once I > enter the CUSTOM_ID, the link is created and copied to my cursor location / > clipboard. > > Has anyone coded such a plugin or am I missing some cool Helm-fu? > > Thanks, > --Nate