From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id yDKSO1CJsV46JgAA0tVLHw (envelope-from ) for ; Tue, 05 May 2020 15:42:08 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id GMGfIlyJsV5tfAAAbx9fmQ (envelope-from ) for ; Tue, 05 May 2020 15:42:20 +0000 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:470:142::17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id C09029426C8 for ; Tue, 5 May 2020 14:20:22 +0000 (UTC) Received: from localhost ([::1]:52302 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVyQp-0003OL-4n for larch@yhetil.org; Tue, 05 May 2020 10:20:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58166) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVyQG-0003MR-8a for emacs-orgmode@gnu.org; Tue, 05 May 2020 10:19:48 -0400 Received: from mail-vs1-xe2b.google.com ([2607:f8b0:4864:20::e2b]:39280) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jVyQE-0007md-Jo for emacs-orgmode@gnu.org; Tue, 05 May 2020 10:19:47 -0400 Received: by mail-vs1-xe2b.google.com with SMTP id l25so1334423vso.6 for ; Tue, 05 May 2020 07:19:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wakatara.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IMeWHVNap7saTbsTuVnp+FvG088rGoBhaaFV2IE7vH4=; b=cgqMuPdAbT2DQZG25XtGqnRCJczYTdbC8k0h0lf495yqG7S5DRp9/Pt+tLcQMquhXJ v0I89isMRTv7fZZcczHrMxgrwjXpFqWs/bc/558ohP1FHOSE7jvLsDX7U9FinaZYYt6a Irys55umtYfEzUTi0TR6vaA0tDt7uUi/hdcxwL+q0M/XRhodc+mOb7IDYtKmhDTj2zsV 45M4d5UTBkO6e45viTZCqLPTm1P1L4W8NhbmnTIs8f3o+/hCdaiggNuHi85iLbutsuSJ dhkJ1nlHSLBekCOIW6HoV+8yjxZxZQZuoHAkR2DWmlbHwwBiXOYc/7fCrMxWaSIgKItV 8c7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IMeWHVNap7saTbsTuVnp+FvG088rGoBhaaFV2IE7vH4=; b=OLY7fsrpsAsOF09ERk+akkEYUJtqi60jvFe4trOfobl2juDNf8DIPAEJwF22SBxqX8 XrXPibGJ7J2Q3gva8jVywjgbescguEBKCzGQL/IfPKj1TeD0xtY6oKJYEixN35L39LaK cI6xa7yE5VMvHPu9wekwKJ7EOWDaEcAEw5G1+Il0AnLBESj8nLIGoFArVkfB7Pdk0squ rDKilliFKZTOUFs/FI4jcxz3CPlusbHjhY7bbVg2iNH8Ncki/EnXhlk8L9M/Z+cSGzp0 WwBcPoM6gNoAtc6DT2xhUSIxEhA8Bh2srf7b8qbckal6J+7+vRVkoXpgyQdKK4d07aCe wvrg== X-Gm-Message-State: AGi0PuZnZw3TMzBGLD7C/ZpPDxVgaw4+6hsM0Wk+QTbhgk1QnYXzcNp/ bC3I3bmgQqu2ezZjPkqtJZrvYHjqVmYa+WycgKwbAw== X-Google-Smtp-Source: APiQypIv9rjVAgRc3U4cjby4pQlisT+MyO0mgqKy+Cs5KW/+jIe+hObkG/ZPMdmCDfbixorcQTNG7GQlemtPBvwG6iI= X-Received: by 2002:a67:fd99:: with SMTP id k25mr2792927vsq.161.1588688385054; Tue, 05 May 2020 07:19:45 -0700 (PDT) MIME-Version: 1.0 References: <871ro0nv4u.fsf@localhost> In-Reply-To: <871ro0nv4u.fsf@localhost> From: Daryl Manning Date: Tue, 5 May 2020 22:19:08 +0800 Message-ID: Subject: Re: Inserting org-mode heading links the org-refile way To: Ihor Radchenko Content-Type: multipart/alternative; boundary="000000000000d9b09505a4e75682" Received-SPF: pass client-ip=2607:f8b0:4864:20::e2b; envelope-from=daryl@wakatara.com; helo=mail-vs1-xe2b.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Org-mode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 X-Spam-Score: -1.21 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=wakatara.com header.s=google header.b=cgqMuPdA; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 2001:470:142::17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Scan-Result: default: False [-1.21 / 13.00]; GENERIC_REPUTATION(0.00)[-0.49546033755507]; DWL_DNSWL_FAIL(0.00)[wakatara.com:server fail,2001:470:142::17:server fail]; R_SPF_ALLOW(-0.20)[+ip6:2001:470:142::/48:c]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.12), country: US(-0.00), ip: 2001:470:142::17(-0.50)]; TO_DN_ALL(0.00)[]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; RCPT_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[wakatara.com:+]; MAILLIST(-0.20)[mailman]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_IN_DNSWL_FAIL(0.00)[2001:470:142::17:server fail]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:22989, ipnet:2001:470:142::/48, country:US]; TAGGED_FROM(0.00)[larch=yhetil.org,orgmode]; FROM_NEQ_ENVFROM(0.00)[dwm@wakatara.com,emacs-orgmode-bounces@gnu.org]; ARC_NA(0.00)[]; RCVD_COUNT_FIVE(0.00)[5]; R_DKIM_ALLOW(-0.20)[wakatara.com:s=google]; FROM_HAS_DN(0.00)[]; URIBL_BLOCKED(0.00)[inbox.org:url,sutd.edu.sg:email,wakatara.com:dkim]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[emacs-orgmode@gnu.org]; DMARC_NA(0.00)[wakatara.com]; HAS_LIST_UNSUB(-0.01)[]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: yWyYd0eJklHa --000000000000d9b09505a4e75682 Content-Type: text/plain; charset="UTF-8" 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 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 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 > --000000000000d9b09505a4e75682 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
This looks impressive, and is *similar* to the effect= I am going for, but what I am looking at is intercepting the `org-insert-l= ink` 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 ot= her words, global access to the (say 3 levels down) headings and files avai= lable through the ivy interface (which further allows me to filter that dow= n).

This would give me the ability to arbitra= rily add links across all files (and particularly handy with org-contact fo= r adding in links in cal entries for meetings).=C2=A0 Since the viy interfa= ce 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&= gt; wrote:
If I = understand you correctly, the following code should achieve what
you want. The code reuses org-refile interface to complete id: links.=C2=A0=

(defun org-id-prompt-id ()
=C2=A0 "Prompt for the id during completion of id: link."
=C2=A0 (let ((org-refile-history nil)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (org-refile-cache nil)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (org-refile-target-verify-function nil))
=C2=A0 =C2=A0 (let ((prompt-ans (org-refile-get-location "Select org e= ntry")))
=C2=A0 =C2=A0 =C2=A0 (prog1
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (or (org-id-get (seq-find #'markerp<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 prompt-ans)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 'create)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (user-error "Cannot f= ind ID of the entry: %s" prompt-ans))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq org-id-history org-refile-history)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq org-id-cache org-refile-cache)))))


(defun org-id-link-complete (&optional arg)
=C2=A0 "Completion function for id: link."
=C2=A0 (let* ((id (org-id-prompt-id)))
=C2=A0 =C2=A0 (format "id:%s" id)))

(defun org-id-link-desk (link desk)
=C2=A0 "Description function for id: link."
=C2=A0 (or desk
=C2=A0 =C2=A0 =C2=A0 (let ((id (cadr (split-string link ":")))) =C2=A0 =C2=A0 =C2=A0 =C2=A0 (org-with-point-at (org-id-find id 'marker)=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (org-get-heading 'strip 'all = 9;the 'extra)))))

(org-link-set-parameters "id"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0:complete #'org-id-link-complete
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0: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 n= ice
> wiki-like manner) it occurred to me if I had a similar interface to se= arch
> for headlines in the manner of org-refile and then insert them effortl= essly
> without having to switch to a doc and copy/store them and then switchi= ng
> 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 a= nd to
> files in specific directories like deft). Googling did not give joy, t= hough
> I noticed someone had used a similar approach for addressing link *wit= hin*
> 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 j= ust
> 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 of= ten do.
> This weekend in particular I've added on a whole bunch of small bu= t 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 Jiaoto= ng University, Xi'an, China
Email: yantar92@gma= il.com, ihor_radchenko@alumni.sutd.edu.sg
--000000000000d9b09505a4e75682--