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: Fri, 1 Nov 2019 19:47:18 -0500 [thread overview]
Message-ID: <CAC=HedB438dezZSrsRWFY=2oRC7o+k929ksFpGBcc1WN6cd13w@mail.gmail.com> (raw)
In-Reply-To: <87h83tokxy.fsf@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3406 bytes --]
Thanks Gustavo, notes below:
On Sun, Oct 27, 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. 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’ve 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’s 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-targets)
> #+end_src
>
> This presumes (setq org-refile-use-outline-path 'file). If you use any
> other value, you should probably adjust the function’s 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.
>
[-- Attachment #2: Type: text/html, Size: 4720 bytes --]
next prev parent reply other threads:[~2019-11-02 0:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-27 20:03 org-refile-target-verify-function - use inherited tag & todo Nathan Neff
2019-10-27 22:58 ` Gustavo Barros
2019-11-02 0:47 ` Nathan Neff [this message]
2019-11-02 13:06 ` Gustavo Barros
2021-02-28 23:00 ` Nathan Neff
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=HedB438dezZSrsRWFY=2oRC7o+k929ksFpGBcc1WN6cd13w@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).