From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nathan Neff Subject: org-refile-target-verify-function - use inherited tag & todo Date: Sun, 27 Oct 2019 15:03:42 -0500 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000f26f190595e9e1dd" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:50767) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOola-0007W9-V3 for emacs-orgmode@gnu.org; Sun, 27 Oct 2019 16:04:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iOolY-00059Q-Lq for emacs-orgmode@gnu.org; Sun, 27 Oct 2019 16:03:58 -0400 Received: from mail-io1-xd2a.google.com ([2607:f8b0:4864:20::d2a]:41568) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iOolY-00058i-9G for emacs-orgmode@gnu.org; Sun, 27 Oct 2019 16:03:56 -0400 Received: by mail-io1-xd2a.google.com with SMTP id r144so8156501iod.8 for ; Sun, 27 Oct 2019 13:03:55 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode --000000000000f26f190595e9e1dd Content-Type: text/plain; charset="UTF-8" Hi all, I want to filter my refile targets to "Tasks" headings. This snippet works: https://lists.gnu.org/r/emacs-orgmode/2016-02/msg00088.html There's a few things I'd like to improve on: 1) My org-agenda-files show up in the list. For example, foo.org and bar.org show up in the refile targets, despite the function should return nil if a heading does not contain "Tasks" 2) I would like to limit the "Task" headings to those that have a parent heading with a tag :project: I have :project: tag as exclude-from-inheritance, so this might be tricky 3) I would like the parent heading with :project: tag to have a TODO state that is not "done" and is not "cancelled". Can anyone help me improve on this? I think I'm missing some really easy documentation / examples. As an aside, is there a definitive "Org Mode API" doc that shows the functions that would assist me in writing a function to perform the above filtering? Something like a Javadoc for Org-Mode? There's great articles, etc. but I think it would be cool to have a "public" API defined / documented - otherwise it seems that I'm simply going through existing blogs, documentation etc and of course the source code. When going through source code, there's many functions that are named similarly and yes there's docs but I found myself wanting some kind of Javadoc-ish API documentation :) Thanks, --Nate --000000000000f26f190595e9e1dd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi all, I want to filter my refile target= s to "Tasks" headings.=C2=A0 This snippet works:
https://lists.gnu.org/r/emacs-orgmode/2016-02/msg00088.html

There's a few things I'd like to i= mprove on:

1) My org-agenda-files show up in the l= ist.=C2=A0 For example, foo.org and bar.org show up in the refile targets, despite the = function should return nil if a heading does not contain "Tasks"<= /div>

2) I would like to limit the "Task" head= ings to those that have a parent heading with a tag :project:
I h= ave :project: tag as exclude-from-inheritance, so this might be tricky

3) I would like the parent heading with :project: tag = to have a TODO state that is not "done" and is not "cancelle= d".

Can anyone help me improve on this?=C2=A0= I think I'm missing some really easy documentation / examples.=C2=A0 A= s an aside, is there a definitive "Org Mode API" doc that shows t= he functions that would assist me in writing a function to perform the abov= e filtering?=C2=A0 Something like a Javadoc for Org-Mode?=C2=A0 There's= great articles, etc. but I think it would be cool to have a "public&q= uot; API defined / documented - otherwise it seems that I'm simply goin= g through existing blogs, documentation etc and of course the source code.= =C2=A0 When going through source code, there's many functions that are = named similarly and yes there's docs but I found myself wanting some ki= nd of Javadoc-ish API documentation :)

Thanks,
--Nate
--000000000000f26f190595e9e1dd-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gustavo Barros Subject: Re: org-refile-target-verify-function - use inherited tag & todo Date: Sun, 27 Oct 2019 19:58:01 -0300 Message-ID: <87h83tokxy.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:35565) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOrUD-0007Bk-Sk for emacs-orgmode@gnu.org; Sun, 27 Oct 2019 18:58:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iOrUC-0005lF-On for emacs-orgmode@gnu.org; Sun, 27 Oct 2019 18:58:13 -0400 Received: from mail-qt1-x831.google.com ([2607:f8b0:4864:20::831]:34459) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iOrUC-0005kw-LO for emacs-orgmode@gnu.org; Sun, 27 Oct 2019 18:58:12 -0400 Received: by mail-qt1-x831.google.com with SMTP id e14so12018118qto.1 for ; Sun, 27 Oct 2019 15:58:11 -0700 (PDT) In-Reply-To: (Nathan Neff's message of "Sun, 27 Oct 2019 15:03:42 -0500") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nathan Neff Cc: emacs-orgmode Hi Nate, On Sun, Oct 27 2019, Nathan Neff wrote: > 1) My org-agenda-files show up in the list. For example, foo.org and bar= .org show up in the refile targets, despite the > function should return nil if a heading does not contain "Tasks" Curiously, I=E2=80=99ve been scratching this itch just today. So I might as= well share. I presume you are using some of the specific values of `org-refile-use-outline-path'. If that=E2=80=99s the case, the file level a= s a refile target is hardcoded in `org-refile-get-targets', independently of what you might have in `org-refile-target-verify-function'. We have somewhere in `org-refile-get-targets': #+begin_src emacs-lisp (when (eq org-refile-use-outline-path 'file) (push (list (file-name-nondirectory f) f nil nil) tgs)) (when (eq org-refile-use-outline-path 'buffer-name) (push (list (buffer-name (buffer-base-buffer)) f nil nil) tgs)) (when (eq org-refile-use-outline-path 'full-file-path) (push (list (file-truename (buffer-file-name (buffer-base-buffer))) f nil= nil) tgs)) #+end_src (`tgs' is the local variable which is collecting candidates for return). So, you might not use `org-refile-use-outline-path'. In this case the file info will be provided in the end of the refile target in parentheses (for targets outside the current buffer). And the file level will not be offered as a target. I, however like `org-refile-use-outline-path' and set it to 'file. But I also want to not be able to refile to the file level. So I advised `org-refile-get-targets' with: #+begin_src emacs-lisp (defun my/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))) (advice-add 'org-refile-get-targets :around #'my/org-refile-filter-targets) #+end_src This presumes (setq org-refile-use-outline-path 'file). If you use any other value, you should probably adjust the function=E2=80=99s let bound variables for the case. This is also sort of hackish, so exert your own due caution in choosing whether or not to use it. HTH, Gustavo. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nathan Neff Subject: Re: org-refile-target-verify-function - use inherited tag & todo Date: Fri, 1 Nov 2019 19:47:18 -0500 Message-ID: References: <87h83tokxy.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000004e3df0596526d61" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:46621) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iQhZl-0007OW-PM for emacs-orgmode@gnu.org; Fri, 01 Nov 2019 20:47:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iQhZh-0004io-GG for emacs-orgmode@gnu.org; Fri, 01 Nov 2019 20:47:31 -0400 Received: from mail-io1-xd32.google.com ([2607:f8b0:4864:20::d32]:46608) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iQhZf-0004fi-Hq for emacs-orgmode@gnu.org; Fri, 01 Nov 2019 20:47:27 -0400 Received: by mail-io1-xd32.google.com with SMTP id c6so12680661ioo.13 for ; Fri, 01 Nov 2019 17:47:24 -0700 (PDT) In-Reply-To: <87h83tokxy.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Gustavo Barros Cc: emacs-orgmode --00000000000004e3df0596526d61 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks Gustavo, notes below: On Sun, Oct 27, 2019 at 5:58 PM Gustavo Barros wrote: > Hi Nate, > > On Sun, Oct 27 2019, Nathan Neff wrote: > > > 1) My org-agenda-files show up in the list. For example, foo.org and > bar.org show up in the refile targets, despite the > > function should return nil if a heading does not contain "Tasks" > > Curiously, I=E2=80=99ve been scratching this itch just today. So I might = as well > share. > > I presume you are using some of the specific values of > `org-refile-use-outline-path'. If that=E2=80=99s the case, the file level= as a > refile target is hardcoded in `org-refile-get-targets', independently of > what you might have in `org-refile-target-verify-function'. > > We have somewhere in `org-refile-get-targets': > > #+begin_src emacs-lisp > (when (eq org-refile-use-outline-path 'file) > (push (list (file-name-nondirectory f) f nil nil) tgs)) > (when (eq org-refile-use-outline-path 'buffer-name) > (push (list (buffer-name (buffer-base-buffer)) f nil nil) tgs)) > (when (eq org-refile-use-outline-path 'full-file-path) > (push (list (file-truename (buffer-file-name (buffer-base-buffer))) f > nil nil) tgs)) > #+end_src > > (`tgs' is the local variable which is collecting candidates for return). > > So, you might not use `org-refile-use-outline-path'. In this case the > file info will be provided in the end of the refile target in > parentheses (for targets outside the current buffer). And the file level > will not be offered as a target. > > I, however like `org-refile-use-outline-path' and set it to 'file. But I > also want to not be able to refile to the file level. So I advised > `org-refile-get-targets' with: > > #+begin_src emacs-lisp > (defun my/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))) > (advice-add 'org-refile-get-targets :around #'my/org-refile-filter-target= s) > #+end_src > > This presumes (setq org-refile-use-outline-path 'file). If you use any > other value, you should probably adjust the function=E2=80=99s let bound > variables for the case. This is also sort of hackish, so exert your own > due caution in choosing whether or not to use it. > 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 > > HTH, > Gustavo. > --00000000000004e3df0596526d61 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks Gustavo, notes below:

On Sun, Oct 2= 7, 2019 at 5:58 PM Gustavo Barros <gusbrs.2016@gmail.com> wrote:
Hi Nate,=

On Sun, Oct 27 2019, Nathan Neff wrote:

> 1) My org-agenda-files show up in the list.=C2=A0 For example, foo.org and bar.org s= how up in the refile targets, despite the
> function should return nil if a heading does not contain "Tasks&q= uot;

Curiously, I=E2=80=99ve been scratching this itch just today. So I might as= well
share.

I presume you are using some of the specific values of
`org-refile-use-outline-path'. If that=E2=80=99s the case, the file lev= el as a
refile target is hardcoded in `org-refile-get-targets', independently o= f
what you might have in `org-refile-target-verify-function'.

We have somewhere in `org-refile-get-targets':

#+begin_src emacs-lisp
(when (eq org-refile-use-outline-path 'file)
=C2=A0 (push (list (file-name-nondirectory f) f nil nil) tgs))
(when (eq org-refile-use-outline-path 'buffer-name)
=C2=A0 (push (list (buffer-name (buffer-base-buffer)) f nil nil) tgs))
(when (eq org-refile-use-outline-path 'full-file-path)
=C2=A0 (push (list (file-truename (buffer-file-name (buffer-base-buffer))) = f nil nil) tgs))
#+end_src

(`tgs' is the local variable which is collecting candidates for return)= .

So, you might not use `org-refile-use-outline-path'. In this case the file info will be provided in the end of the refile target in
parentheses (for targets outside the current buffer). And the file level will not be offered as a target.

I, however like `org-refile-use-outline-path' and set it to 'file. = But I
also want to not be able to refile to the file level. So I advised
`org-refile-get-targets' with:

#+begin_src emacs-lisp
(defun my/org-refile-filter-targets (orig-fun &rest args)
=C2=A0 (let ((targets (apply orig-fun args))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (agenda-files (mapcar #'file-name-nondirect= ory 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 (memb= er (car x) agenda-files))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 targets))) (advice-add 'org-refile-get-targets :around #'my/org-refile-filter-= targets)
#+end_src

This presumes (setq org-refile-use-outline-path 'file). If you use any<= br> other value, you should probably adjust the function=E2=80=99s let bound variables for the case. This is also sort of hackish, so exert your own
due caution in choosing whether or not to use it.

=
Indeed, I do use org-refile-use-outline-path 'file.=C2=A0 Ho= wever, I have a simple
directory specified for my org-agenda-file= s. =C2=A0("~/org-mode") =C2=A0Therefore I'll need to=C2=A0
do something a bit different. =C2=A0

It ap= pears that your solution creates "targets" which is the targets l= ist 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/&quo= t;) none of the entries match.

Hmmm, let me ask: = =C2=A0Why not simply go through targets and remove any 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 y= our function and see what I can get -- thank you for the head-start!
<= div>
Thanks
--Nate=C2=A0

HTH,
Gustavo.
--00000000000004e3df0596526d61-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gustavo Barros Subject: Re: org-refile-target-verify-function - use inherited tag & todo Date: Sat, 02 Nov 2019 10:06:49 -0300 Message-ID: <874kzma0ly.fsf@gmail.com> References: <87h83tokxy.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; format=flowed Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:35924) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iQt7O-0000hE-Gx for emacs-orgmode@gnu.org; Sat, 02 Nov 2019 09:07:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iQt7L-0003vo-Ug for emacs-orgmode@gnu.org; Sat, 02 Nov 2019 09:07:02 -0400 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]:33742) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iQt7J-0003tT-GQ for emacs-orgmode@gnu.org; Sat, 02 Nov 2019 09:06:58 -0400 Received: by mail-qt1-x834.google.com with SMTP id y39so16935249qty.0 for ; Sat, 02 Nov 2019 06:06:55 -0700 (PDT) In-reply-to: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nathan Neff Cc: emacs-orgmode 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. 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--