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 QNibI+xus14PAwAA0tVLHw (envelope-from ) for ; Thu, 07 May 2020 02:14:04 +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 KJuRI/hus15lDAAAbx9fmQ (envelope-from ) for ; Thu, 07 May 2020 02:14:16 +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 64F66940292 for ; Thu, 7 May 2020 02:14:14 +0000 (UTC) Received: from localhost ([::1]:46244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jWW3B-0005sI-0W for larch@yhetil.org; Wed, 06 May 2020 22:14:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53762) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jWW2k-0005qj-3R for emacs-orgmode@gnu.org; Wed, 06 May 2020 22:13:46 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]:46605) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jWW2j-0001s7-7A for emacs-orgmode@gnu.org; Wed, 06 May 2020 22:13:45 -0400 Received: by mail-pf1-x433.google.com with SMTP id 145so2152977pfw.13 for ; Wed, 06 May 2020 19:13:44 -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=dLbYNosg++ecenzrPN8UITryTO+QlPPQYyg3nmD7LVE=; b=fNbRwqTLpCPVp4uvdtmC2JKGjBHfwuoHmKQEn+tntHKVK90WBRhcGEuHM6wseWvRJz tGWftndbVdYTS35gl89P1cQJXM2or3CY5I9NS6EnQvyXrVxVecgCrLmFjOlNIxT/P48F WHTy0atV4ztjT4kF0T5rg6Uaqnln2LaIUorF8tB20d8N9Ojw0MKmC559q1QTJZZnmkdt JDQCvUYcKeux9J2D5pxXRDJb7tZ+F5eNXO5rqFDIaLHqrENHWPjd4RU9u4BzE57AcmRE vPPH96jonbngTIzC7UUjwi7hoL/3H4f9FLXZBZ8I2B3yg1cbF4GULnxMtmRikuIpGHfk TeXA== 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=dLbYNosg++ecenzrPN8UITryTO+QlPPQYyg3nmD7LVE=; b=jaiIpgTcJ/yRqJtvkFiRoqFu25Nyys0qt1RX2Zb4JZHO+i603yaUdED/M5aBOn/OF5 lo4oGUQ9cifK4J2ip75+Xl3RGhFlOTwdGWL7GegMKbx0UP7r9Hsv0FbccXKv9RVWANvR G1piIuPY877XaGu2iMtB4Ayk3xG2Bm3nsnKZjPzTZ90OTkOoauZvbp8lzYhTDdM9xvpU orTc7fmRTfhCSh6ALIfIHfCyz/bzBqJCvVGQeHVutfQKdHD/Vqd1u67KVj3WHLVviSyD 5tmChaGkETQCzN3WKjZIKagIJBNNjRl/iS1/Eo4TrEZekDcnQkna3kz08d072l0rXi2l v3DA== X-Gm-Message-State: AGi0PuaRGzspDTILJxRElaOGOlu8J/J2InH+XO30YjxgVT65/u+uhEnA /S80OhZc3Pn4dvU7d/6fPUIl8rjy X-Google-Smtp-Source: APiQypJf2G/SDdv3Ebg8h0dafF2C6Iau1uPC6Cs9BqNIa6NhQnRgZJKvs7h36Cy3C8tYj7wK4poreA== X-Received: by 2002:a62:5292:: with SMTP id g140mr55115pfb.107.1588817623293; Wed, 06 May 2020 19:13:43 -0700 (PDT) Received: from localhost ([2600:1702:1d00:f1d0:80d9:fe28:676f:8b14]) by smtp.gmail.com with ESMTPSA id i13sm6119711pja.40.2020.05.06.19.13.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 19:13:42 -0700 (PDT) From: Josh Moller-Mara To: Daryl Manning , Org-mode Subject: Re: Inserting org-mode heading links the org-refile way In-Reply-To: References: <871ro0nv4u.fsf@localhost> Date: Wed, 06 May 2020 19:13:40 -0700 Message-ID: <87k11olcff.fsf@cns.nyu.edu> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=j.mollermara@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: -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, 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.71 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=fNbRwqTL; 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.71 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.49724292796039]; 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.11), 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)[jmollermara@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]; TAGGED_RCPT(0.00)[orgmode]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[emacs-orgmode@gnu.org]; HAS_LIST_UNSUB(-0.01)[]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: aUna3Lzv03b+ Hi, Here's an example of how to create an ivy prompt that inserts links. It isn't exactly what you're looking for, as it doesn't hijack `org-insert-link` functionality, nor does it specifically use `org-refile-target-verify-function` to do filtering. Instead, this uses org-ql to select TODO headers with a level of at least 3. org-ql will cache queries in a manner similar to the initial collecting of org-refile targets. You can add other filter criteria using org-ql's sexp query syntax. You can also replace the `(org-agenda-files)` to be some expression that returns the specific list of files you're interested in. (defun jmm/org-ql-ivy-prompt-for-link () "Select a todo header with ivy and insert its link" (interactive) (ivy-read "Link:" (->> (org-ql-select (org-agenda-files) '(and (todo) (level >= 3) (not (tags "ARCHIVE"))) :action 'element-with-markers) (-map #'org-ql-view--format-element)) :action (lambda (x) (let ((org-id-link-to-org-use-id t)) ; Add an ID if it doesn't exist (insert (org-with-point-at (get-text-property 0 'org-hd-marker x) (org-store-link nil))))))) Note: This also uses dash.el functions/macros. You can replace that as needed. Best, Josh 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.