emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nathan Neff <nathan.neff@gmail.com>
To: Gustavo Barros <gusbrs.2016@gmail.com>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: org-refile-target-verify-function - use inherited tag & todo
Date: Sun, 28 Feb 2021 17:00:01 -0600	[thread overview]
Message-ID: <CAC=HedD-G72Ne+qPKPSKVMj8dU4xna51nNi_gTfPsMRz4h+uQg@mail.gmail.com> (raw)
In-Reply-To: <874kzma0ly.fsf@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2937 bytes --]

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 <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.  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.
>

[-- Attachment #2: Type: text/html, Size: 4010 bytes --]

      reply	other threads:[~2021-02-28 23:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-27 20:03 Nathan Neff
2019-10-27 22:58 ` Gustavo Barros
2019-11-02  0:47   ` Nathan Neff
2019-11-02 13:06     ` Gustavo Barros
2021-02-28 23:00       ` Nathan Neff [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAC=HedD-G72Ne+qPKPSKVMj8dU4xna51nNi_gTfPsMRz4h+uQg@mail.gmail.com' \
    --to=nathan.neff@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=gusbrs.2016@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).