From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mikhail Skorzhinskii Subject: Re: Exporting agendas as org-mode files? Date: Wed, 13 Nov 2019 12:07:33 +0100 Message-ID: <87a790uj9m.fsf@eml.cc> References: <8736esv69z.fsf@alphapapa.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:55847) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUqV7-0001Ew-0f for emacs-orgmode@gnu.org; Wed, 13 Nov 2019 06:07:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUqV5-0008Qh-Q1 for emacs-orgmode@gnu.org; Wed, 13 Nov 2019 06:07:52 -0500 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:50351) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iUqV5-0008Pk-Eh for emacs-orgmode@gnu.org; Wed, 13 Nov 2019 06:07:51 -0500 In-reply-to: <8736esv69z.fsf@alphapapa.net> 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" To: John Sturdy , emacs-orgmode@gnu.org Adam Porter writes: > org-ql would make this pretty easy, I think. Use an org-ql query to > select entries, and for the :action function, use a simple function that > copies the entry or subtree and yanks it into a buffer. Then save that > buffer to a file. Yes, it is. Although just picking some entries from huge org-mode base and write them into separate file is a base feature of org-mode itself. org-ql package just making the process of finding entries of interest much easier and faster. John Sturdy writes: > I'd like to be able to export agendas as org-mode files If you're looking into the pure org-mode approach, then what you're looking for ~org-agenda-write~ function or custom agenda view written with exporting in mind. In order to export to org all you need to do is to specify .org extension. https://orgmode.org/manual/Exporting-agenda-views.html I was using this small snippet to export some of my agenda seacrhes: #+begin_src emacs-lisp (org-agenda nil "a") (org-agenda-write "~/example.org" nil t "*Org Agenda*") #+end_src Be aware that this will regenerate your *Org Agenda* buffer, so either use sticky agendas or export agendas in separate emacs process. But I would highly recommend using org-ql for these purpouses. Besides pretty solid and easy-to-use interface it is noticably faster. Here is the snippet I am currently using to export all subtress directly tagged with :info: to the separate file. (Sorry for the lack of proper parametrisation). #+begin_src emacs-lisp (defun org-user/store-info () (let ((file "~/org/cals/info.org") (heading (org-format-outline-path (org-get-outline-path t)))) (save-excursion (org-copy-subtree) (find-file file) (end-of-buffer) (org-paste-subtree) (org-edit-headline heading)))) (defun org-user/export-info () "Export all information entries into one file." (find-file "~/org/cals/info.org") (erase-buffer) (insert "#+TITLE: Information") (org-ql-select (org-agenda-files) '(tags-local "info") :action #'org-user/store-info) (save-buffer)) #+end_src You need to invoke (org-user/export-info), obviosuly.