emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Daryl Manning <dwm+orgmode@wakatara.com>
Cc: Org-mode <emacs-orgmode@gnu.org>
Subject: Re: Inserting org-mode heading links the org-refile way
Date: Tue, 05 May 2020 22:32:49 +0800	[thread overview]
Message-ID: <87sggemoz2.fsf@localhost> (raw)
In-Reply-To: <CAL9aZkvSGCrv+EpCYHXfiB216XUeyqet-BPqdOtchSkJcZG3yw@mail.gmail.com>


> This looks impressive, and is *similar* to the effect I am going for, but
> what I am looking at is intercepting the `org-insert-link` functionality
> (or replacing it) with the ability to insert a link from the global
> filter-and-select interface via ivy for `org-refile`. So, in other words,
> global access to the (say 3 levels down) headings and files available
> through the ivy interface (which further allows me to filter that down).

I feel that I am missing something. Probably, because I am not using
ivy. For helm (which I am using), org-refile-get-location provides
filter-and-select interface automatically. So, I can get on-the-fly
filtering for id: link automatically. I just type `C-c C-l id: RET` and 
filter the candidates just like in org-refile. Do you need to call some
special function to use ivy with org-refile? If so, just replace
org-refile-get-location in my code with your ivy version. If you want to
go straight into inserting the link without a need to type `C-c C-l id:
RET`, you may just bind (insert "[[" (org-id-link-complete) "]]") to key
binding of your choice.

Best,
Ihor



Daryl Manning <dwm+orgmode@wakatara.com> writes:

> This looks impressive, and is *similar* to the effect I am going for, but
> what I am looking at is intercepting the `org-insert-link` functionality
> (or replacing it) with the ability to insert a link from the global
> filter-and-select interface via ivy for `org-refile`. So, in other words,
> global access to the (say 3 levels down) headings and files available
> through the ivy interface (which further allows me to filter that down).
>
> This would give me the ability to arbitrarily add links across all files
> (and particularly handy with org-contact for adding in links in cal entries
> for meetings).  Since the viy interface seems to work fine for refiling
> tasks (except for initial load of refile targets), it seems it'd be
> sufficiently performant.
>
> Daryl.
>
>
> On Mon, May 4, 2020 at 1:14 PM Ihor Radchenko <yantar92@gmail.com> wrote:
>
>> If I understand you correctly, the following code should achieve what
>> you want. The code reuses org-refile interface to complete id: links.
>>
>> (defun org-id-prompt-id ()
>>   "Prompt for the id during completion of id: link."
>>   (let ((org-refile-history nil)
>>         (org-refile-cache nil)
>>         (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)))
>>
>> (defun org-id-link-desk (link desk)
>>   "Description function for id: link."
>>   (or desk
>>       (let ((id (cadr (split-string link ":"))))
>>         (org-with-point-at (org-id-find id 'marker)
>>           (org-get-heading 'strip 'all 'the 'extra)))))
>>
>> (org-link-set-parameters "id"
>>                          :complete #'org-id-link-complete
>>                          :desk #'org-id-link-desk)
>>
>>
>>
>> Daryl Manning <dwm+orgmode@wakatara.com> writes:
>>
>> > I use ivy and org-refile to process my inbox.org file hyper-efficiently
>> and
>> > get things into my GTD system.
>> >
>> > In a recent discussion on org-roam (which nicely links to files in a nice
>> > wiki-like manner) it occurred to me if I had a similar interface to
>> search
>> > for headlines in the manner of org-refile and then insert them
>> effortlessly
>> > without having to switch to a doc and copy/store them and then switching
>> > back to my doc and inserting them, I'd be a happy camper.
>> >
>> > Is there a package/functions that does/do that in some fashion (say
>> > configurable to avoid link sprawl so say, like 3 heading levels down and
>> to
>> > files in specific directories like deft). Googling did not give joy,
>> though
>> > I noticed someone had used a similar approach for addressing link
>> *within*
>> > a document, but not quite there (swiper and worf combo and an ivy-org-ref
>> > package looked interesting).
>> >
>> > (I always worry when I post these questions that someone is going to just
>> > say "but did you not know about M-x org-insert-link-like-ivy-with-refile"
>> > so go gentle on me if I've missed something obvious. It seems I often do.
>> > This weekend in particular I've added on a whole bunch of small but in
>> the
>> > aggregate, large productivity improvements to my emacs setup which I
>> > approached solving the wrong way until I asked and someone mentioned
>> > another way to do things, so.... ).
>> >
>> > thanks,
>> > Daryl.
>>
>> --
>> Ihor Radchenko,
>> PhD,
>> Center for Advancing Materials Performance from the Nanoscale (CAMP-nano)
>> State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong
>> University, Xi'an, China
>> Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg
>>

-- 
Ihor Radchenko,
PhD,
Center for Advancing Materials Performance from the Nanoscale (CAMP-nano)
State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong University, Xi'an, China
Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg


  reply	other threads:[~2020-05-05 15:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-03 20:04 Inserting org-mode heading links the org-refile way Daryl Manning
2020-05-04  5:09 ` Ihor Radchenko
2020-05-04  6:28   ` Joseph Vidal-Rosset
2020-05-04  7:11     ` Ihor Radchenko
2020-05-04 17:41       ` Joseph Vidal-Rosset
2020-05-05 14:19   ` Daryl Manning
2020-05-05 14:32     ` Ihor Radchenko [this message]
2020-05-07  2:13     ` Josh Moller-Mara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sggemoz2.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=dwm+orgmode@wakatara.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).