emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Exporting agendas as org-mode files?
@ 2019-11-12 15:46 John Sturdy
  2019-11-13  2:50 ` Adam Porter
  0 siblings, 1 reply; 5+ messages in thread
From: John Sturdy @ 2019-11-12 15:46 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 591 bytes --]

I'd like to be able to export agendas as org-mode files, so that I can use
the agenda system's ability to make subsets of my tasks, then sync those
with Google tasks using michel-orgmode (so I don't end up with hundreds of
tasks to look through on my phone, but only the ones with tags such as
:soon: etc).  Is there an existing command for this?  I've tried the
manual, the wiki and the function names in the code, and nothing looks like
it will do this.  I don't mind writing it myself, I'm quite familiar with
emacs-lisp, but I'd rather pick up anything existing if there is one.

__John

[-- Attachment #2: Type: text/html, Size: 683 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Exporting agendas as org-mode files?
  2019-11-12 15:46 Exporting agendas as org-mode files? John Sturdy
@ 2019-11-13  2:50 ` Adam Porter
  2019-11-13 11:07   ` Mikhail Skorzhinskii
  0 siblings, 1 reply; 5+ messages in thread
From: Adam Porter @ 2019-11-13  2:50 UTC (permalink / raw)
  To: emacs-orgmode

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Exporting agendas as org-mode files?
  2019-11-13  2:50 ` Adam Porter
@ 2019-11-13 11:07   ` Mikhail Skorzhinskii
  2019-11-14 12:03     ` Adam Porter
  2019-11-18 12:11     ` John Sturdy
  0 siblings, 2 replies; 5+ messages in thread
From: Mikhail Skorzhinskii @ 2019-11-13 11:07 UTC (permalink / raw)
  To: John Sturdy, emacs-orgmode

Adam Porter <adam@alphapapa.net> 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 <jcg.sturdy@gmail.com> 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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Exporting agendas as org-mode files?
  2019-11-13 11:07   ` Mikhail Skorzhinskii
@ 2019-11-14 12:03     ` Adam Porter
  2019-11-18 12:11     ` John Sturdy
  1 sibling, 0 replies; 5+ messages in thread
From: Adam Porter @ 2019-11-14 12:03 UTC (permalink / raw)
  To: emacs-orgmode

Mikhail Skorzhinskii <mskorzhinskiy@eml.cc> writes:

> 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

Thanks, Mikhail, it's like you read my mind.  :)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Exporting agendas as org-mode files?
  2019-11-13 11:07   ` Mikhail Skorzhinskii
  2019-11-14 12:03     ` Adam Porter
@ 2019-11-18 12:11     ` John Sturdy
  1 sibling, 0 replies; 5+ messages in thread
From: John Sturdy @ 2019-11-18 12:11 UTC (permalink / raw)
  To: Mikhail Skorzhinskii; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2507 bytes --]

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 <mskorzhinskiy@eml.cc>
wrote:

> Adam Porter <adam@alphapapa.net> 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 <jcg.sturdy@gmail.com> 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.
>

[-- Attachment #2: Type: text/html, Size: 3582 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-11-18 12:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-12 15:46 Exporting agendas as org-mode files? John Sturdy
2019-11-13  2:50 ` Adam Porter
2019-11-13 11:07   ` Mikhail Skorzhinskii
2019-11-14 12:03     ` Adam Porter
2019-11-18 12:11     ` John Sturdy

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).