emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* calfw-org, view single org file; very ugly hack
@ 2014-04-20  1:04 Brady Trainor
  2014-04-20  6:33 ` Bastien
  0 siblings, 1 reply; 3+ messages in thread
From: Brady Trainor @ 2014-04-20  1:04 UTC (permalink / raw)
  To: emacs-orgmode

[-- 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 --]

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

* Re: calfw-org, view single org file; very ugly hack
  2014-04-20  1:04 calfw-org, view single org file; very ugly hack Brady Trainor
@ 2014-04-20  6:33 ` Bastien
  2014-04-21  7:04   ` Brady Trainor
  0 siblings, 1 reply; 3+ messages in thread
From: Bastien @ 2014-04-20  6:33 UTC (permalink / raw)
  To: Brady Trainor; +Cc: emacs-orgmode

Brady Trainor <algebrat@uw.edu> writes:

> Was there a better way (outside of joining development of
> calfw-org)?

PS: Joining forces for development always seems like a good idea :)

-- 
 Bastien

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

* Re: calfw-org, view single org file; very ugly hack
  2014-04-20  6:33 ` Bastien
@ 2014-04-21  7:04   ` Brady Trainor
  0 siblings, 0 replies; 3+ messages in thread
From: Brady Trainor @ 2014-04-21  7:04 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

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

On 04/19/2014 11:33 PM, Bastien wrote:
> Brady Trainor <algebrat@uw.edu> writes:
>
>> Was there a better way (outside of joining development of
>> calfw-org)?
>
> PS: Joining forces for development always seems like a good idea :)
>


Of course, Bastien you have answered this question well in 2007. Link:

http://lists.gnu.org/archive/html/help-gnu-emacs/2007-10/msg00708.html

That is, I tried several things, and I'm ending up with pretty much the 
recipe you describe.


I can use icalendar.el to simply convert .ics files to diary format.

I can cut and paste between a diary and org-mode file if I want to. I 
can simply edit the .ics calendar from another app if I feel it's 
easier. I could even view the .ics file in Emacs with calfw-ical. I 
could compare these dates with plain text (diary and org-mode), 
calfw-ical, calfw-cal, calfw-org, and agenda-view.

I found the org-caldav too limiting in the syntax, as I'd like the 
freedom to use more diary sexp in my org files (won't allow times with 
diary sexp at this time). My use of org-mode is just to organic right 
now, so I prefer less restrictions by my use of .ics files. There seem 
to be many ical2org scripts out there, but I think I'd prefer at this 
point to just shoot for a cleaner break between .ics and Emacs formats.

I do find the conversion from .ics to diary to be sufficient, and will 
probably use this to empty out my .ics files from time to time and keep 
records in plain text diary format.

I think this is more or less a simple enough and effective system for my 
needs for now. And it should be flexible enough as well, if I want to 
try a different calendaring system down the road.


Brady



#+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 [ constraint = false ]
}
#+END_SRC



[-- Attachment #2: caldiagram.png --]
[-- Type: image/png, Size: 29551 bytes --]

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

end of thread, other threads:[~2014-04-21  7:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-20  1:04 calfw-org, view single org file; very ugly hack Brady Trainor
2014-04-20  6:33 ` Bastien
2014-04-21  7:04   ` Brady Trainor

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).