From mboxrd@z Thu Jan 1 00:00:00 1970 From: Isaac Subject: Re: Refile: refile to any open file. Date: Thu, 14 Aug 2014 14:30:59 +0000 (UTC) Message-ID: References: <83r4xis8ah.fsf@gmail.com> <87zjf8hym9.fsf@yale.edu> <87r40jg1xu.fsf@pierrot.dokosmarshall.org> <87iolvhe71.fsf@kmlap.domain.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHw3y-0001pq-3n for emacs-orgmode@gnu.org; Thu, 14 Aug 2014 10:31:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XHw3t-0003S3-8q for emacs-orgmode@gnu.org; Thu, 14 Aug 2014 10:31:34 -0400 Received: from plane.gmane.org ([80.91.229.3]:41899) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHw3t-0003Rw-1R for emacs-orgmode@gnu.org; Thu, 14 Aug 2014 10:31:29 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XHw3m-00041x-Jd for emacs-orgmode@gnu.org; Thu, 14 Aug 2014 16:31:22 +0200 Received: from fx.mskcc.org ([140.163.254.158]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 14 Aug 2014 16:31:22 +0200 Received: from isaacpei by fx.mskcc.org with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 14 Aug 2014 16:31:22 +0200 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Kyle Meyer kyleam.com> writes: > > Nick Dokos 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 > > 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