Re: [O] Refile: refile to any open file.

2014-08-14 Thread Isaac
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








Re: [O] Refile: refile to any open file.

2014-08-13 Thread Isaac
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





Re: [O] Refile: refile to any open file.

2014-08-13 Thread Kyle Meyer
Isaac isaac...@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



Re: [O] Refile: refile to any open file.

2014-08-13 Thread Jorge A. Alfaro-Murillo
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.




Re: [O] Refile: refile to any open file.

2014-08-13 Thread Nick Dokos
jorge.alfaro-muri...@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




Re: [O] Refile: refile to any open file.

2014-08-13 Thread Kyle Meyer
Nick Dokos ndo...@gmail.com wrote:
 jorge.alfaro-muri...@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




Re: [O] Refile: refile to any open file.

2012-02-26 Thread suvayu ali
On Sun, Feb 26, 2012 at 02:16,  lngn...@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.