emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [Refile] Make agenda-files and current file targets
@ 2013-10-30 12:44 Alexander Baier
  2013-10-30 16:44 ` Alexander Baier
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Baier @ 2013-10-30 12:44 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

I am trying to configure my refiling targets in a way, that allows me to
refile to any of the files in org-agenda-files, as well as to the file
displayed by the current buffer, if it is not included in
org-agenda-files.  Additionally, I want the headings in agenda-files to
be included up to level 4, but of current file every heading should be
considered a target.

This is what I came up with so far:

----------------------------------------------------------------
(setq org-refile-targets
      (quote ((org-agenda-files :maxlevel . 4)
              (#'(lambda ()
                   (unless (member (buffer-file-name) org-agenda-files)
                     (buffer-file-name)) :regexp . ".*")))))
----------------------------------------------------------------

The problem here is, that the lambda evaluates to nil when
(buffer-file-name) is a member of org-agenda-files. And this nil in turn
isn't anything org-refile understands (Upon C-c C-w I get "Bad refiling
target description nil").

Does anyone know how to go about this and can give me soem pointers?


Regards,
  Alex

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Refile] Make agenda-files and current file targets
  2013-10-30 12:44 [Refile] Make agenda-files and current file targets Alexander Baier
@ 2013-10-30 16:44 ` Alexander Baier
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Baier @ 2013-10-30 16:44 UTC (permalink / raw)
  To: emacs-orgmode

Hello, it's me again,

I figured out, what was wrong with the original code.  I had gotten the
parentheses  of the lambda wrong, which messed all this up.

I modified the code and refactored the lambda out into a proper
function, as you can see below:

----------------------------------------------------------------
(defun dl-org-refile-targets ()
  (unless (member (buffer-file-name) org-agenda-files)
    (buffer-file-name)))

(setq org-refile-targets
      (quote ((org-agenda-files      :maxlevel . 4)
              (dl-org-refile-targets :regexp . ".*"))))
----------------------------------------------------------------

This does not throw any error anymore.  I have, however, come upon
another problem that manifests itself when calling org-refile with the
cursor upon a heading in a file that is not a member of
org-agenda-files: I see "Getting targets..." in the modeline, which
takes a long time (I canceled it after ~2 minutes).

What exactly does :regexp . ".*" do? I thought it would simply take
_all_ headlines in the file indicated by dl-org-refile-targets.  The
file I testet this with has less than 100 headlines and I have no
idea why this takes so long.

After changing the contraint to :maxlevel 4 as you can the below, it
works just fine.  (Note: The file in question has only headlines with
levels <= 2)

----------------------------------------------------------------
#+begin_src emacs-lisp
  (defun dl-org-refile-targets ()
    (unless (member (buffer-file-name) org-agenda-files)
      (buffer-file-name)))
  
  (setq org-refile-targets
        (quote ((org-agenda-files      :maxlevel . 4)
                (dl-org-refile-targets :maxlevel . 4))))
----------------------------------------------------------------

What did I miss here? Any help is appreciated.


Regards,
  Alex

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-10-30 16:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-30 12:44 [Refile] Make agenda-files and current file targets Alexander Baier
2013-10-30 16:44 ` Alexander Baier

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