From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Refile: refile to any open file. Date: Wed, 13 Aug 2014 23:55:25 -0400 Message-ID: <87r40jg1xu.fsf@pierrot.dokosmarshall.org> References: <83r4xis8ah.fsf@gmail.com> <87zjf8hym9.fsf@yale.edu> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHm8h-0007UZ-ML for emacs-orgmode@gnu.org; Wed, 13 Aug 2014 23:55:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XHm8c-0002BH-BI for emacs-orgmode@gnu.org; Wed, 13 Aug 2014 23:55:47 -0400 Received: from plane.gmane.org ([80.91.229.3]:35746) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHm8c-0002BB-4W for emacs-orgmode@gnu.org; Wed, 13 Aug 2014 23:55:42 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XHm8a-00019A-9d for emacs-orgmode@gnu.org; Thu, 14 Aug 2014 05:55:40 +0200 Received: from pool-173-48-174-104.bstnma.fios.verizon.net ([173.48.174.104]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 14 Aug 2014 05:55:40 +0200 Received: from ndokos by pool-173-48-174-104.bstnma.fios.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 14 Aug 2014 05:55:40 +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 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