From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Sturdy Subject: Re: Exporting agendas as org-mode files? Date: Mon, 18 Nov 2019 12:11:58 +0000 Message-ID: References: <8736esv69z.fsf@alphapapa.net> <87a790uj9m.fsf@eml.cc> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000006bfbab05979ddbc4" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:56291) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iWft8-0005Pt-Ba for emacs-orgmode@gnu.org; Mon, 18 Nov 2019 07:12:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iWft6-0004sv-TI for emacs-orgmode@gnu.org; Mon, 18 Nov 2019 07:12:14 -0500 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]:46185) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iWft6-0004qs-Iz for emacs-orgmode@gnu.org; Mon, 18 Nov 2019 07:12:12 -0500 Received: by mail-lj1-x22e.google.com with SMTP id e9so18629609ljp.13 for ; Mon, 18 Nov 2019 04:12:12 -0800 (PST) In-Reply-To: <87a790uj9m.fsf@eml.cc> 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: Mikhail Skorzhinskii Cc: emacs-orgmode@gnu.org --0000000000006bfbab05979ddbc4 Content-Type: text/plain; charset="UTF-8" Thanks, I'll try switching to org-ql for my main queries, and then build on that. __John On Wed, Nov 13, 2019 at 11:07 AM Mikhail Skorzhinskii wrote: > 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. > --0000000000006bfbab05979ddbc4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks, I'll try switching to org-ql for my main = queries, and then build on that.

__John
<= /div>
O= n Wed, Nov 13, 2019 at 11:07 AM Mikhail Skorzhinskii <mskorzhinskiy@eml.= cc> wrote:
Ad= am Porter <adam@= alphapapa.net> writes:

=C2=A0> org-ql would make this pretty easy, I think.=C2=A0 Use an org-ql= query to
=C2=A0> select entries, and for the :action function, use a simple funct= ion that
=C2=A0> copies the entry or subtree and yanks it into a buffer.=C2=A0 Th= en save that
=C2=A0> 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 <j= cg.sturdy@gmail.com> writes:

=C2=A0 > 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.

=C2=A0 https://orgmode.org/manual/Exporting-ag= enda-views.html

I was using this small snippet to export some of my agenda seacrhes:

#+begin_src emacs-lisp
=C2=A0 (org-agenda nil "a")
=C2=A0 (org-agenda-write "~/example.org" nil t "*Org Agenda*&qu= ot;)
#+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 ()
=C2=A0 (let ((file "~/org/cals/info.org")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (heading (org-format-outline-path (org-get-outl= ine-path t))))
=C2=A0 =C2=A0 (save-excursion
=C2=A0 =C2=A0 =C2=A0 (org-copy-subtree)
=C2=A0 =C2=A0 =C2=A0 (find-file file)
=C2=A0 =C2=A0 =C2=A0 (end-of-buffer)
=C2=A0 =C2=A0 =C2=A0 (org-paste-subtree)
=C2=A0 =C2=A0 =C2=A0 (org-edit-headline heading))))

(defun org-user/export-info ()
=C2=A0 "Export all information entries into one file."
=C2=A0 (find-file "~/org/cals/info.org")
=C2=A0 (erase-buffer)
=C2=A0 (insert "#+TITLE: Information")
=C2=A0 (org-ql-select
=C2=A0 =C2=A0 (org-agenda-files)
=C2=A0 =C2=A0 '(tags-local "info")
=C2=A0 =C2=A0 :action #'org-user/store-info)
=C2=A0 (save-buffer))
#+end_src

You need to invoke (org-user/export-info), obviosuly.
--0000000000006bfbab05979ddbc4--