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