From: Brady Trainor <algebrat@uw.edu>
To: emacs-orgmode@gnu.org
Subject: calfw-org, view single org file; very ugly hack
Date: Sat, 19 Apr 2014 18:04:17 -0700 [thread overview]
Message-ID: <liv6f5$oq9$1@ger.gmane.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 6511 bytes --]
I'm basically showing this horrible hack for any that might like how I
setup a cloud calendar, and as a catalyst for the topic "will calfw for
org find improvement?".
(Meta: also, a test to see if pics can be included on gmane, the
graphviz source is at bottom. What's the best way to use graphics in
discussion? Links?)
---
So I think I'm gravitating to the org-caldav package, with an easy to
acquire owncloud calendar.
This will allow me to work on my use of orgmode sheltered from outside
awkward apps in a convenient and effective way. For now I will probably
just cut and paste between the org files I'm really working in, and the
org-caldav result pulled in from a cloud calendar.
So I think of the owncloudcalendar.org file as being sandboxed from all
my org-agenda-files that I'm really working in.
Further, I have a feeling having the calfw calendar framework view would
be really nice to have as an option. Unfortunately, It doesn't seem to
interact very natively with Org-modes multitudinous options and filters.
I wanted to be able to include calfw "sources" optionally from agenda
files versus the owncloudcalendar.org file.
So I searched for what seems to be a linear string of functions between
`cfw:org-create-source' and `org-agenda-files', and made these horrible
modifications which do the trick for me.
Was there a better way (outside of joining development of calfw-org)?
my road map:
org-agenda-files (var) -> org-agenda-files (func) ->
cfw:org-collect-schedules-period -> cfw:org-schedule-period-to-calendar
-> cfw:org-create-source-> cfw:open-org-calendar
(Word search on sandbox and brady will reveal where I made edits below.
For example, `cfw:org-collect-schedules-period' |-->
`cfw:brady-org-collect-schedules-period'.)
____________
/
#+BEGIN_SRC emacs-lisp
(setq sandboxed-org-caldav-file '("/e/org/owndrivecalendar.org"))
#+END_SRC
#+BEGIN_SRC emacs-lisp
(defun sandboxed-org-caldav-file (&optional unrestricted archives)
"Get the list of agenda files.
Optional UNRESTRICTED means return the full list even if a restriction
is currently in place.
When ARCHIVES is t, include all archive files that are really being
used by the agenda files. If ARCHIVE is `ifmode', do this only if
`org-agenda-archives-mode' is t."
(let ((files
(cond
((and (not unrestricted) (get 'sandboxed-org-caldav-file 'org-restrict)))
((stringp sandboxed-org-caldav-file) (org-read-agenda-file-list))
((listp sandboxed-org-caldav-file) sandboxed-org-caldav-file)
(t (error "Invalid value of `sandboxed-org-caldav-file'")))))
(setq files (apply 'append
(mapcar (lambda (f)
(if (file-directory-p f)
(directory-files
f t org-agenda-file-regexp)
(list f)))
files)))
(when org-agenda-skip-unavailable-files
(setq files (delq nil
(mapcar (function
(lambda (file)
(and (file-readable-p file) file)))
files))))
(when (or (eq archives t)
(and (eq archives 'ifmode) (eq org-agenda-archives-mode t)))
(setq files (org-add-archive-files files)))
files))
#+END_SRC
#+BEGIN_SRC emacs-lisp
(defun cfw:brady-org-collect-schedules-period (begin end)
"[internal] Return org schedule items between BEGIN and END."
(let ((org-agenda-prefix-format " ")
(span 'day))
(setq org-agenda-buffer
(when (buffer-live-p org-agenda-buffer)
org-agenda-buffer))
(org-compile-prefix-format nil)
(loop for date in (cfw:enumerate-days begin end) append
(loop for file in (or cfw:org-icalendars
(sandboxed-org-caldav-file nil 'ifmode))
append
(progn
(org-check-agenda-file file)
(apply 'org-agenda-get-day-entries
file date
cfw:org-agenda-schedule-args))))))
#+END_SRC
#+BEGIN_SRC emacs-lisp
(defun cfw:brady-org-schedule-period-to-calendar (begin end)
"[internal] Return calfw calendar items between BEGIN and END
from the org schedule data."
(loop
with cfw:org-todo-keywords-regexp = (regexp-opt
org-todo-keywords-for-agenda) ; dynamic bind
with contents = nil with periods = nil
for i in (cfw:brady-org-collect-schedules-period begin end)
for date = (cfw:org-tp i 'date)
for line = (funcall cfw:org-schedule-summary-transformer i)
for range = (cfw:org-get-timerange line)
if range do
(unless (member range periods)
(push range periods))
else do
(setq contents (cfw:contents-add
(cfw:org-normalize-date date)
line contents))
finally return (nconc contents (list (cons 'periods periods)))))
#+END_SRC
#+BEGIN_SRC emacs-lisp
(defun cfw:brady-org-create-source (&optional color)
"Create org-agenda source."
(make-cfw:source
:name "org-agenda"
:color (or color "Seagreen4")
:data 'cfw:brady-org-schedule-period-to-calendar))
#+END_SRC
#+BEGIN_SRC emacs-lisp
(defun cfw:brady-open-org-calendar ()
"Open an org schedule calendar in the new buffer."
(interactive)
(let* ((source1 (cfw:brady-org-create-source))
(cp (cfw:create-calendar-component-buffer
:view 'month
:contents-sources (list source1)
:custom-map cfw:org-schedule-map
:sorter 'cfw:org-schedule-sorter)))
(switch-to-buffer (cfw:cp-get-buffer cp))))
#+END_SRC
\____________
/
(defun my-calfw-both ()
(interactive)
(cfw:open-calendar-buffer
:contents-sources
(list (cfw:brady-org-create-source "Green")
(cfw:org-create-source "Blue")
)))
\____________
/
#+BEGIN_SRC dot :file ./gv/caldiagram.png :cache yes :cmdline -Tpng
digraph {
{ rank = same
orgmode
diary
}
gcal -> ics [ dir = "both" label = "GCALDaemon (sync)" ]
owncloud -> ics2 [ dir = "both" ]
ics2 -> orgmode [ dir = "both" label = "org-caldav" ]
ics2 [ label = "ics" ]
ics -> diary [ dir = "both"
// label = "icalendar.el (manual)"
]
diary -> agendaview
orgmode -> ics [ constraint = false
// label =
"org-export-icalendar-combine-agenda-files"
]
orgmode -> agendaview
diary -> calendar
diary -> calfw
ics -> calfw
orgmode -> calfw
}
#+END_SRC
\____________
Brady
[-- Attachment #2: caldiagram.png --]
[-- Type: image/png, Size: 43677 bytes --]
next reply other threads:[~2014-04-20 1:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-20 1:04 Brady Trainor [this message]
2014-04-20 6:33 ` calfw-org, view single org file; very ugly hack Bastien
2014-04-21 7:04 ` Brady Trainor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='liv6f5$oq9$1@ger.gmane.org' \
--to=algebrat@uw.edu \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).