From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id UDPDIs8gPGAwRAAA0tVLHw (envelope-from ) for ; Sun, 28 Feb 2021 23:01:35 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id MBKVHs8gPGCZZAAA1q6Kng (envelope-from ) for ; Sun, 28 Feb 2021 23:01:35 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.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 C313D15A38 for ; Mon, 1 Mar 2021 00:01:34 +0100 (CET) Received: from localhost ([::1]:39670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lGV48-0006uc-Ey for larch@yhetil.org; Sun, 28 Feb 2021 18:01:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGV2v-0006uA-6i for emacs-orgmode@gnu.org; Sun, 28 Feb 2021 18:00:17 -0500 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]:36208) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lGV2t-0005x8-3d for emacs-orgmode@gnu.org; Sun, 28 Feb 2021 18:00:16 -0500 Received: by mail-ej1-x62c.google.com with SMTP id do6so24855443ejc.3 for ; Sun, 28 Feb 2021 15:00:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Rl3jq69953bNvbM37FBOMOq61tkZZQBLltwCqaHZJAM=; b=i734X/M/D1SCTIMrK3aIiYtDR9ADLJZ5oWXf+QnKSVTWnkpP/3XN9DJGZpyXYJwe16 0KooR3w7nhLTOxYN92uofJcYekCC6rmKn4hFYPEjGZL7h18rIhKEVyV9FSj513joIzlP SOhQKEpVVM4esb6yyc4C/RfNmIWJ55i+j+JL4Aqf3APOnv6wFpZcK+KM0xNL5BPnZjvZ bKpqtlzEmBZOtAXZq+O67doGVQ9jSncR7StCcmfhWCQfI2FXdmheF8/Hzfsh2WtBhu1R ZVKiX/yGko8yFjVYHqiLbaNlboaRKWvNCDcAy1RKwqlk5mDpA9RDI4JsSJd3wZ7sQ/k5 cXPg== 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=Rl3jq69953bNvbM37FBOMOq61tkZZQBLltwCqaHZJAM=; b=MZ9IgAj9e7c1OA7SzVmuoSrg7VtFBh9rLrViMoFeIfYrHPU1Ovk7xArLd1C6qvJq6l BdC1I2+2KHK9cMyasfEiaknAOhxzV6nuaHbErmTpnswMvXExQjt1szwIjg1J17n2yHEb A1ce2avFuNH13S+6XZj/JXgMLwhmNQl4p7QvydEyZ/1LN1CM0DYDRLmoIw3j3jBHsiYb gQMWD37u2VJPyvVP/diZORn58i7piARZfkrpOCHIqWAUg/nfL2jixutpBlhD9yIHaeWq LU9fJlLsJT7rJyBKYRS3E0SCeI14epN2ThBPGnB4MNtFFn+BtZOOVpYmETHS2dfhp1sr iUjQ== X-Gm-Message-State: AOAM531u32zhJ7rcO3mUXQGNk7ZZxMh631/tFKY0+HWE44nohoiUaP0+ J3PZS90iweXO57BwgO4AR/vEDT4c+UfPiAj9yg== X-Google-Smtp-Source: ABdhPJwEkGy5YEiV2EaG6tE8Up2fmxDnFMssda6I5xbGL/NgpcsNxD1E2sQq2+5HTDmOHpZ/pvqX02WrJrcGxAwQ3wc= X-Received: by 2002:a17:906:73c2:: with SMTP id n2mr13252332ejl.224.1614553212694; Sun, 28 Feb 2021 15:00:12 -0800 (PST) MIME-Version: 1.0 References: <87h83tokxy.fsf@gmail.com> <874kzma0ly.fsf@gmail.com> In-Reply-To: <874kzma0ly.fsf@gmail.com> From: Nathan Neff Date: Sun, 28 Feb 2021 17:00:01 -0600 Message-ID: Subject: Re: org-refile-target-verify-function - use inherited tag & todo To: Gustavo Barros Content-Type: multipart/alternative; boundary="000000000000b6b39205bc6d76b6" Received-SPF: pass client-ip=2a00:1450:4864:20::62c; envelope-from=nathan.neff@gmail.com; helo=mail-ej1-x62c.google.com 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, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: emacs-orgmode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1614553295; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=Rl3jq69953bNvbM37FBOMOq61tkZZQBLltwCqaHZJAM=; b=b12cV22RBBbt3KfeB8RaYdlilZLQ/9Gl913Q8dHOzTbIbSV1zO/Vr6fY4CGgbR5EsngY7c Rbzrd5Qx6LMb/Dklm7s43XgdK7AC7oSPC2au44a2jBs2PE3YQmcDkt2b/2wXkEEBYu3gHL VZG/yRUTyo9nzlqijUQjv6yPsFMi/h/Gj6YrCJdQzEhhH7pZJ7s0Fpyc4FBlaZPP4VoVy3 Yp8XWGOmIRopfKDMqDZVKuEw4rv8LPecaRYp3X3k65A/qnoV7Qq6R8BAYjuc328YpAHFbU BAgRICuAsaHjry2CWx82Y86oE8o2h842vWzVJ9OPFXLLEzKF8KACxKWP4ID6cQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1614553295; a=rsa-sha256; cv=none; b=r5IYgd7BawXXXYxZHf3SliiE28AxxB2Fu38VYs25jfGZpMWEDr/66qPI7X8EYqXgGE9utI l+P/pH/0N7PQYsgNMMygLf2sRki9B5bBcEwL/0rBSOGPbAFBd+828S3Jikajz4SWWBrbTQ qMVsZq4qbKQAVBoBN+R/YYavOcjtbTN0kobazSMJA17UoXXE52FFbNRgce1SmMHfpaouAv fwRZMdxJAGlTPn5vwl5TeSY1z1sieSLsQ7G2JYcAoR4gt2cUwRercXN9uTlFIAlpNyzRJ9 P9drQXE70Nh9Ycih0NvJCFmsTUptowKllMO/c+HXoD5jnkHNxyXF2r1f0qLzrA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b="i734X/M/"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -1.56 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b="i734X/M/"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: C313D15A38 X-Spam-Score: -1.56 X-Migadu-Scanner: scn0.migadu.com X-TUID: Zdz9qGfo8kTR --000000000000b6b39205bc6d76b6 Content-Type: text/plain; charset="UTF-8" Thank you Gustavo, I got this to work after revisiting! I changed my org-agenda-files to a single variable "org-agenda-files.org" , and populated the file with my agenda files. I modified the wrapper script to call the (org-agenda-files) function. This is so nice - I have a lot of org-mode files and the ability to remove files "root" heading is really nice when filtering by tag. #+begin_src emacs-lisp (defun njn-org-refile-filter-targets (orig-fun &rest args) (let ((targets (apply orig-fun args)) (agenda-files (mapcar #'file-name-nondirectory (org-agenda-files)))) (cl-remove-if (lambda (x) (member (car x) agenda-files)) targets))) #+end_src On Sat, Nov 2, 2019 at 8:06 AM Gustavo Barros wrote: > Hi Nate, > > On Fri, Nov 01 2019, Nathan Neff wrote: > > > Indeed, I do use org-refile-use-outline-path 'file. However, I have a > > simple > > directory specified for my org-agenda-files. ("~/org-mode") > > Therefore > > I'll need to > > do something a bit different. > > > > It appears that your solution creates "targets" which is the targets > > list > > of course, and > > then it creates "agenda-files" which goes through org-agenda-files and > > finds all the filenames > > in org-agenda files. > > > > It then mutates "targets", and removes any entry which is a filename > > from > > org-agenda-files. > > > > Since my org-agenda-files is simply ("~/org-mode/") none of the > > entries > > match. > > > > Hmmm, let me ask: Why not simply go through targets and remove any > > entry > > whose value is > > a simple filename? Why search org-agenda-files first? This function > > also > > assumes that the org-refile-targets > > always comes from org-agenda-files. > > > > I'll play with your function and see what I can get -- thank you for > > the > > head-start! > > > > Thanks > > --Nate > > I'm glad this might be useful to you. And you are correct in all of > observations. > > My main point is simply that, as things stand, you won't be able to trim > the file level candidates with `org-refile-target-verify-function`, as > they are hardcoded. But this simple function is the sketch of a > (hackish) way. > > `org-refile-get-targets`' main purpose is to return the list of > targets. The advice function grabs this return value, filters the list > and returns the filtered list. How it filters may depend, as you noted. > I've chosen a simple criterion which meets my use case > (`org-agenda-files`, as I specify the individual files directly there, > and use only those as refile targets). Indeed, it does make some > presumptions, as you noted. (The function does not "search > org-agenda-files" though, it just gets the list of their names, which is > contained in the variable). In your case, you will certainly have to > devise another filtering criterion. I think the one you suggest is a > good one too. > > Best regards, > Gustavo. > --000000000000b6b39205bc6d76b6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thank you Gustavo, I got this to work aft= er revisiting!

I changed my org-agenda-files to a single= variable "org-agenda-files.or= g" , and populated=C2=A0
the file with my agenda files.<= /div>

I modified the wrapper script to call the (org-age= nda-files) function.

This is so nice - I have a lo= t of org-mode files and the ability to remove=C2=A0
files "r= oot"=C2=A0heading is really nice when filtering by tag.

=
#+begin_src emacs-lisp
(defun njn-org-refile-filt= er-targets (orig-fun &rest args)
=C2=A0 (let ((targets (apply= orig-fun args))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (agenda-files (mapca= r #'file-name-nondirectory (org-agenda-files))))
=C2=A0 =C2= =A0 (cl-remove-if (lambda (x)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (member (car x) agenda-files)) targets))= )

#+end_src

=
On Sat= , Nov 2, 2019 at 8:06 AM Gustavo Barros <gusbrs.2016@gmail.com> wrote:
= Hi Nate,

On Fri, Nov 01 2019, Nathan Neff wrote:

> Indeed, I do use org-refile-use-outline-path 'file.=C2=A0 However,= I have a
> simple
> directory specified for my org-agenda-files.=C2=A0 ("~/org-mode&q= uot;)
> Therefore
> I'll need to
> do something a bit different.
>
> It appears that your solution creates "targets" which is the= targets
> list
> of course, and
> then it creates "agenda-files" which goes through org-agenda= -files and
> finds all the filenames
> in org-agenda files.
>
> It then mutates "targets", and removes any entry which is a = filename
> from
> org-agenda-files.
>
> Since my org-agenda-files is simply ("~/org-mode/") none of = the
> entries
> match.
>
> Hmmm, let me ask:=C2=A0 Why not simply go through targets and remove a= ny
> entry
> whose value is
> a simple filename?=C2=A0 Why search org-agenda-files first?=C2=A0 This= function
> also
> assumes that the org-refile-targets
> always comes from org-agenda-files.
>
> I'll play with your function and see what I can get -- thank you f= or
> the
> head-start!
>
> Thanks
> --Nate

I'm glad this might be useful to you.=C2=A0 And you are correct in all = of
observations.

My main point is simply that, as things stand, you won't be able to tri= m
the file level candidates with `org-refile-target-verify-function`, as
they are hardcoded.=C2=A0 But this simple function is the sketch of a
(hackish) way.

`org-refile-get-targets`' main purpose is to return the list of
targets. The advice function grabs this return value, filters the list
and returns the filtered list.=C2=A0 How it filters may depend, as you note= d.
I've chosen a simple criterion which meets my use case
(`org-agenda-files`, as I specify the individual files directly there,
and use only those as refile targets).=C2=A0 Indeed, it does make some
presumptions, as you noted.=C2=A0 (The function does not "search
org-agenda-files" though, it just gets the list of their names, which = is
contained in the variable).=C2=A0 In your case, you will certainly have to =
devise another filtering criterion.=C2=A0 I think the one you suggest is a =
good one too.

Best regards,
Gustavo.
--000000000000b6b39205bc6d76b6--