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 qPgTCuCkr14gHwAA0tVLHw (envelope-from ) for ; Mon, 04 May 2020 05:15:12 +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 2ESnBOqkr143BgAAB5/wlQ (envelope-from ) for ; Mon, 04 May 2020 05:15:22 +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 F2E7F9445FE for ; Mon, 4 May 2020 05:15:20 +0000 (UTC) Received: from localhost ([::1]:47694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVTRo-0007oT-Ou for larch@yhetil.org; Mon, 04 May 2020 01:15:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48364) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVTQb-00075Z-JM for emacs-orgmode@gnu.org; Mon, 04 May 2020 01:14:05 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]:43986) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jVTQZ-0008O7-UH for emacs-orgmode@gnu.org; Mon, 04 May 2020 01:14:05 -0400 Received: by mail-pf1-x433.google.com with SMTP id v63so4991852pfb.10 for ; Sun, 03 May 2020 22:14:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:in-reply-to:references:date:message-id:mime-version; bh=w9jaARvOIDWI4qeT3ew1Jjs0vNii5iaunn/hob2f/TM=; b=VoCZ/GVCwX9uljrgl5LYGqG7QIxNRSzNkwI3YB87ZPSljBZFHF50K+6zZPADJ1so7p QLHC+UDNQsdvUHbFfcnfLc9zvNwJM/P5MF8BEyVwxqWNfq5D3G6zrYQ0OOEtLEHrYbTQ cLf4dmi8NrfgRehVnTntwCfy9kN/RRTDyYRZSJMVsN7Ks+tMPRetpZR5PdAp7XNJurFw ED97kAKEeGeOp3WtOs2spqJ63a7XcvhsPsut6ZRSqBOiEstza6NaaFJhto1r5eu8zpws lEAlR5w2w8zcR4+IArNzz+OxHY3GjyJ1lmtD+kFagMaIIpzpARuLQf/LMFSM4N2M+fIl hxOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:in-reply-to:references:date :message-id:mime-version; bh=w9jaARvOIDWI4qeT3ew1Jjs0vNii5iaunn/hob2f/TM=; b=NfEM2xkgFqlraOo2l+fdeIZV9U2EtHeM/3OAEK8Pns72lpbhz2+oWk9xQGaqoblwzw nyIGN16frzQp/k2qCbFXSJZM/fwEo6cj64woFJANZFKWCvhu/cHxdoa4Ta2jiN8EmGWC DJJKz0gqLLXxydty4LkSQMdqmADkPTlxCGA8WiRP8EAI84B7ruy5Tqw8IfV/xzRA/W+t vmGhJQdWAmaChAv5dTR/atoTpmC+JGZ2bsrXdQuB0XSufsTbvOl3GrWdd4FaqG25WYOQ 8/EFFSTWO3PYRA5H36rlpkb8PBlRjbypA4DsYRt2Tb6Mxag6qb0P1Y7/Oy8edlubdirz 3qIw== X-Gm-Message-State: AGi0PubAxsNkrQ8uJFVh3XqhZIHIGVY6nH1L42qey3bucGImtjbij5rt iqiWfEXAOp8AZxHGsJLEBh4= X-Google-Smtp-Source: APiQypK7FNkWhROEW+5JEqfwNcQqEFPGMkZoKuPZrx9ayyeoYeez4m0uda9M+YrooK7oJaKv499C/Q== X-Received: by 2002:aa7:9839:: with SMTP id q25mr15564694pfl.311.1588569242350; Sun, 03 May 2020 22:14:02 -0700 (PDT) Received: from localhost ([210.3.160.218]) by smtp.gmail.com with ESMTPSA id k5sm318573pjl.32.2020.05.03.22.14.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 May 2020 22:14:01 -0700 (PDT) From: Ihor Radchenko To: Daryl Manning , emacs-orgmode@gnu.org Subject: Re: Inserting org-mode heading links the org-refile way In-Reply-To: References: Date: Mon, 04 May 2020 13:09:53 +0800 Message-ID: <871ro0nv4u.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=yantar92@gmail.com; helo=mail-pf1-x433.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: , 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=VoCZ/GVC; 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.49410232384737]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2001:470:142::/48:c]; FREEMAIL_FROM(0.00)[gmail.com]; DWL_DNSWL_FAIL(0.00)[gmail.com:server fail,2001:470:142::17:server fail]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.14), country: US(-0.00), ip: 2001:470:142::17(-0.49)]; 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)[wakatara.com:email,sutd.edu.sg:email,inbox.org:url]; 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: BwI111sEBM6O 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