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.