From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id GE80N0CJsV7ILwAA0tVLHw (envelope-from ) for ; Tue, 05 May 2020 15:41:52 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id AOcLF0uJsV6aFwAAB5/wlQ (envelope-from ) for ; Tue, 05 May 2020 15:42:03 +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 8603F943736 for ; Tue, 5 May 2020 14:37:33 +0000 (UTC) Received: from localhost ([::1]:57780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVyhQ-0001zZ-UB for larch@yhetil.org; Tue, 05 May 2020 10:37:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVyh4-0001xf-3e for emacs-orgmode@gnu.org; Tue, 05 May 2020 10:37:10 -0400 Received: from mail-qk1-x72f.google.com ([2607:f8b0:4864:20::72f]:43202) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jVyh2-0004Wt-MQ for emacs-orgmode@gnu.org; Tue, 05 May 2020 10:37:09 -0400 Received: by mail-qk1-x72f.google.com with SMTP id i14so2427926qka.10 for ; Tue, 05 May 2020 07:37:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=qwPnp4fxyaIv3mPDmhnAkMdYDZFdPR4x/trDawT4brM=; b=SMaRlN6ChAijOzXcvTDqqSOwhVzFmtHwjrkZyDkNjduBzV7Rd+VH5RH2T1tcRvuvuz ecdVcO+4N1Bn/gpNL9aq5aZruo6rnGc/QLI6zMxDFhm/Zh26IJMstFQ15JD5SIDyiocB IoK0vbMrI0UYsU0i6jixphy7rOE1JPF3uaiMkuvxhNH3zKg/KqX6KgzedL/L47uOgmvn VrtyvKR/UYp6kH1vA5MnT7Cl9ZBUyiyDQZI+G0wfwEJZjNmj7MReln9HaSTjPJDtV0cD 1xLji3acYw9MMvsvVqIfCohbFo4B2ngEnmaOuKOQMGBo7dMgAFtdkvW2qXSeh7Adi4Zs aVQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=qwPnp4fxyaIv3mPDmhnAkMdYDZFdPR4x/trDawT4brM=; b=gQqddgJOVpzv2tDGIulEALMSIsZ25G/Hp7m0xljM1OZFwOno4A7qpGmJZ4A9nqRQ/B AYN8UrjsyKePOcmxVq+SPhDzTqfh1M7cBLgNEstr2yQUqcEXkx68lLWNhjyTLzsQH76R 9Xxiv/xlxwpaJTfbK2/bx4yTXDlOgl1rhkGKDZ8eVmgYiqk4x42t6X/jwzViUT5ahYiS Q/XBIdBWYAwv+Y4bGP9/UuYRw7VLALi28DdD25vlIt8pAekUt+yMS8xH5twKenp26Xi3 icGvHZuDwg6+fdv5PGX0BCCAbgsPi0f1NujZgRscelSS0hR7odn/V3chBZhtVsMcOlcp 9hGw== X-Gm-Message-State: AGi0PuYmA+jeSrbJr5uFu2oIkRcZYL1erMWWy27PLV3GVhdmk7Q2A4jk jONFHxFEvH7m3dfHx59E7V7FTdsmZE7RYg== X-Google-Smtp-Source: APiQypIZsWcJ9gCO9zDyNyiTY9mJjlK0ck6wUwoq8aFyrhdE9PUg8TZH5d2r41dxWHbqCIEw8jwFNQ== X-Received: by 2002:a37:a310:: with SMTP id m16mr2013637qke.346.1588689427532; Tue, 05 May 2020 07:37:07 -0700 (PDT) Received: from localhost ([208.167.241.222]) by smtp.gmail.com with ESMTPSA id y140sm1892193qkb.127.2020.05.05.07.37.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2020 07:37:06 -0700 (PDT) From: Ihor Radchenko To: Daryl Manning Subject: Re: Inserting org-mode heading links the org-refile way In-Reply-To: References: <871ro0nv4u.fsf@localhost> Date: Tue, 05 May 2020 22:32:49 +0800 Message-ID: <87sggemoz2.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::72f; envelope-from=yantar92@gmail.com; helo=mail-qk1-x72f.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: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=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=gmail.com header.s=20161025 header.b=SMaRlN6C; dmarc=pass (policy=none) header.from=gmail.com; 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]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.49547327395995]; DWL_DNSWL_FAIL(0.00)[gmail.com:server fail,2001:470:142::17:server fail]; R_SPF_ALLOW(-0.20)[+ip6:2001:470:142::/48:c]; FREEMAIL_FROM(0.00)[gmail.com]; 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)[]; DKIM_TRACE(0.00)[gmail.com:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; MAILLIST(-0.20)[mailman]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_IN_DNSWL_FAIL(0.00)[2001:470:142::17:server fail]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:22989, ipnet:2001:470:142::/48, country:US]; TAGGED_FROM(0.00)[larch=yhetil.org]; FROM_NEQ_ENVFROM(0.00)[yantar92@gmail.com,emacs-orgmode-bounces@gnu.org]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; RCVD_COUNT_FIVE(0.00)[6]; FROM_HAS_DN(0.00)[]; URIBL_BLOCKED(0.00)[inbox.org:url,wakatara.com:email,sutd.edu.sg:email]; TAGGED_RCPT(0.00)[orgmode]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[emacs-orgmode@gnu.org]; HAS_LIST_UNSUB(-0.01)[]; MID_RHS_NOT_FQDN(0.50)[]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: I0LLcBZ+I8pR > 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 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 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 >> -- 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