* Refile: refile to any open file.
@ 2012-02-26 1:16 lngndvs
2012-02-26 9:11 ` suvayu ali
0 siblings, 1 reply; 8+ messages in thread
From: lngndvs @ 2012-02-26 1:16 UTC (permalink / raw)
To: org-mode
It occurs from time to time that I wish to refile to an open file, that
is not one of my org-refile-targets. It doesn't make sense to use
org-agenda-files for refile targets since I might have other files open
for various reasons. So I thought, why not either declare that any open
file is a refile target, or else write a function that will execture
org-refile with org-refile-targets set to include all open files. In
truth, it would be even better to include org-agenda-files in the set of
target files.
I have been using the function oog in org-occur-goto.el to search any
open file, so somewhere in that file is a way to find open files. What
remains is to use some condition from this file to declare
org-refile-targets. I understand that a function can be used as a
value of this variable.
I could spend all night working on this, or, ask on this list.
Can anyone point to a good way to declare that BOTH all open
buffers/files AND org-agenda-files as org-refile-targets?
A hint would help.
Alan Davis
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Refile: refile to any open file.
2012-02-26 1:16 Refile: refile to any open file lngndvs
@ 2012-02-26 9:11 ` suvayu ali
2014-08-13 20:15 ` Isaac
0 siblings, 1 reply; 8+ messages in thread
From: suvayu ali @ 2012-02-26 9:11 UTC (permalink / raw)
To: lngndvs; +Cc: org-mode
On Sun, Feb 26, 2012 at 02:16, <lngndvs@gmail.com> wrote:
> I have been using the function oog in org-occur-goto.el to search any
> open file, so somewhere in that file is a way to find open files. What
> remains is to use some condition from this file to declare
> org-refile-targets. I understand that a function can be used as a
> value of this variable.
Look at the function oog-check-input. I believe it checks buffer-list
and the major-mode for each buffer to determine whether to include it
in the search.
GL
--
Suvayu
Open source is the future. It sets us free.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Refile: refile to any open file.
2012-02-26 9:11 ` suvayu ali
@ 2014-08-13 20:15 ` Isaac
2014-08-13 21:16 ` Kyle Meyer
2014-08-13 21:24 ` Jorge A. Alfaro-Murillo
0 siblings, 2 replies; 8+ messages in thread
From: Isaac @ 2014-08-13 20:15 UTC (permalink / raw)
To: emacs-orgmode
suvayu ali <fatkasuvayu+linux <at> gmail.com> writes:
>
> On Sun, Feb 26, 2012 at 02:16, <lngndvs <at> gmail.com> wrote:
> > I have been using the function oog in org-occur-goto.el to search any
> > open file, so somewhere in that file is a way to find open files. What
> > remains is to use some condition from this file to declare
> > org-refile-targets. I understand that a function can be used as a
> > value of this variable.
>
> Look at the function oog-check-input. I believe it checks buffer-list
> and the major-mode for each buffer to determine whether to include it
> in the search.
>
> GL
>
Dear All,
Similar to this previous post, I am trying to file orgmode items to
files/buffers currently opened. Being elisp rookie, I tried and came up with
the following:
(defun opened-buffer-files ()
"Return the list of files currently opened in emacs"
(delq nil (mapcar (function buffer-file-name) (buffer-list)))
)
(setq org-refile-targets (quote ((opened-buffer-files :maxlevel . 5)
(org-agenda-files :maxlevel . 5))))
Not suprisingly, it's not working ... I still can not get to the opened
file/orgmode files, as target for filing. Can you help point out where I did
it all wrong?
Simiarly, I would like to add all opened buffers to agenda files list. I
would really appreciate your inputs.
Thanks,
Isaac
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Refile: refile to any open file.
2014-08-13 20:15 ` Isaac
@ 2014-08-13 21:16 ` Kyle Meyer
2014-08-13 21:24 ` Jorge A. Alfaro-Murillo
1 sibling, 0 replies; 8+ messages in thread
From: Kyle Meyer @ 2014-08-13 21:16 UTC (permalink / raw)
To: Isaac; +Cc: emacs-orgmode
Isaac <isaacpei@a1make.com> wrote:
[...]
> Similar to this previous post, I am trying to file orgmode items to
> files/buffers currently opened.
Some parts of my configuration [1,2] may be close to what you want (or
at least give you something to start with). More recently, I've been
using a slightly different approach [3] inspired by `dired-dwim-target'.
[1] http://kyleam.com/posts/dynamic-org-refile-targets/
[2] https://github.com/kyleam/emacs.d/blob/8ccfbdac75d09cf068348c138fe82787e0e8b809/lisp/init-org.el#L280-313
[3] https://github.com/kyleam/emacs.d/blob/8ccfbdac75d09cf068348c138fe82787e0e8b809/lisp/init-org.el#L256-278
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Refile: refile to any open file.
2014-08-13 20:15 ` Isaac
2014-08-13 21:16 ` Kyle Meyer
@ 2014-08-13 21:24 ` Jorge A. Alfaro-Murillo
2014-08-14 3:55 ` Nick Dokos
1 sibling, 1 reply; 8+ messages in thread
From: Jorge A. Alfaro-Murillo @ 2014-08-13 21:24 UTC (permalink / raw)
To: emacs-orgmode
Isaac writes:
> Similar to this previous post, I am trying to file orgmode items
> to files/buffers currently opened. Being elisp rookie, I tried
> and came up with the following:
>
> (defun opened-buffer-files ()
> "Return the list of files currently opened in emacs" (delq nil
> (mapcar (function buffer-file-name) (buffer-list))) )
Perhaps you should return instead only the org mode files that are
opened, something like this:
#+BEGIN_SRC emacs-lisp
(delq nil
(mapcar (lambda (x)
(if (and (buffer-file-name x)
(string-match "\\.org$"
(buffer-file-name x)))
(buffer-file-name x)))
(buffer-list)))
#+END_SRC
Best,
--
Jorge.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Refile: refile to any open file.
2014-08-13 21:24 ` Jorge A. Alfaro-Murillo
@ 2014-08-14 3:55 ` Nick Dokos
2014-08-14 4:45 ` Kyle Meyer
0 siblings, 1 reply; 8+ messages in thread
From: Nick Dokos @ 2014-08-14 3:55 UTC (permalink / raw)
To: emacs-orgmode
jorge.alfaro-murillo@yale.edu (Jorge A. Alfaro-Murillo) writes:
> Isaac writes:
>
>> Similar to this previous post, I am trying to file orgmode items
>> to files/buffers currently opened. Being elisp rookie, I tried
>> and came up with the following:
>>
>> (defun opened-buffer-files ()
>> "Return the list of files currently opened in emacs" (delq nil
>> (mapcar (function buffer-file-name) (buffer-list))) )
>
> Perhaps you should return instead only the org mode files that are
> opened, something like this:
>
Excellent idea: refiling to an arbitrary non-org-mode file will either
skip the file (if you are lucky, in which case you just pay a
performance penalty) or it will try to use it in which case you'll end
up with an error. There is no point in including arbitrary files into
the refile list.
> #+BEGIN_SRC emacs-lisp
> (delq nil
> (mapcar (lambda (x)
> (if (and (buffer-file-name x)
> (string-match "\\.org$"
> (buffer-file-name x)))
> (buffer-file-name x)))
> (buffer-list)))
> #+END_SRC
>
It might be better to check the major mode of the buffer, rather than
its filename: it is not necessarily true that foo.org is an org-mode
file, or foo.txt is not. But in general, I think it would be better to
use a more targeted approach, rather than trying to use whatever happens
to be open at the time.
--
Nick
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Refile: refile to any open file.
2014-08-14 3:55 ` Nick Dokos
@ 2014-08-14 4:45 ` Kyle Meyer
2014-08-14 14:30 ` Isaac
0 siblings, 1 reply; 8+ messages in thread
From: Kyle Meyer @ 2014-08-14 4:45 UTC (permalink / raw)
To: emacs-orgmode
Nick Dokos <ndokos@gmail.com> wrote:
> jorge.alfaro-murillo@yale.edu (Jorge A. Alfaro-Murillo) writes:
[...]
>> Perhaps you should return instead only the org mode files that are
>> opened, something like this:
>>
>
> Excellent idea: refiling to an arbitrary non-org-mode file will either
> skip the file (if you are lucky, in which case you just pay a
> performance penalty) or it will try to use it in which case you'll end
> up with an error. There is no point in including arbitrary files into
> the refile list.
[...]
> It might be better to check the major mode of the buffer, rather than
> its filename: it is not necessarily true that foo.org is an org-mode
> file, or foo.txt is not.
There's a built-in Org function that does this.
#+begin_src elisp
(org-buffer-list 'files)
#+end_src
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Refile: refile to any open file.
2014-08-14 4:45 ` Kyle Meyer
@ 2014-08-14 14:30 ` Isaac
0 siblings, 0 replies; 8+ messages in thread
From: Isaac @ 2014-08-14 14:30 UTC (permalink / raw)
To: emacs-orgmode
Kyle Meyer <kyle <at> kyleam.com> writes:
>
> Nick Dokos <ndokos <at> gmail.com> wrote:
> > jorge.alfaro-murillo <at> yale.edu (Jorge A. Alfaro-Murillo) writes:
> [...]
> >> Perhaps you should return instead only the org mode files that are
> >> opened, something like this:
> >>
> >
> > Excellent idea: refiling to an arbitrary non-org-mode file will either
> > skip the file (if you are lucky, in which case you just pay a
> > performance penalty) or it will try to use it in which case you'll end
> > up with an error. There is no point in including arbitrary files into
> > the refile list.
> [...]
> > It might be better to check the major mode of the buffer, rather than
> > its filename: it is not necessarily true that foo.org is an org-mode
> > file, or foo.txt is not.
>
> There's a built-in Org function that does this.
>
> #+begin_src elisp
> (org-buffer-list 'files)
> #+end_src
>
>
Thanks Kyle, Jorge, Nick and everybody!
Below is the working piece, I take pieces here and there,
grateful to everyone's help:
(defun ixp/org-buffer-files ()
"Return list of opened orgmode buffer files"
(mapcar (function buffer-file-name)
(org-buffer-list 'files)))
(setq org-refile-targets
(quote ((nil :maxlevel . 3)
(ixp/org-buffer-files :maxlevel . 1)
(org-agenda-files :maxlevel . 3))))
It's posted on emacs wiki as well
http://www.emacswiki.org/emacs/OrgMode#toc20
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-08-14 14:31 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-26 1:16 Refile: refile to any open file lngndvs
2012-02-26 9:11 ` suvayu ali
2014-08-13 20:15 ` Isaac
2014-08-13 21:16 ` Kyle Meyer
2014-08-13 21:24 ` Jorge A. Alfaro-Murillo
2014-08-14 3:55 ` Nick Dokos
2014-08-14 4:45 ` Kyle Meyer
2014-08-14 14:30 ` Isaac
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).