Skip to content

Commit

Permalink
Merge pull request kiwanami#29 from skyer9/patch-1
Browse files Browse the repository at this point in the history
patch agenda buffer related bug and etc
  • Loading branch information
kiwanami committed Sep 23, 2013
2 parents 43c0438 + 646ab11 commit 46d6482
Showing 1 changed file with 34 additions and 18 deletions.
52 changes: 34 additions & 18 deletions calfw-org.el
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
;;; -*- coding: utf-8 -*-
;;;
;;; calfw-org.el --- calendar view for org-agenda

;; Copyright (C) 2011 SAKURAI Masashi
Expand All @@ -21,11 +23,11 @@
;;; Commentary:

;; Display org-agenda items in the calfw buffer.
;; (Because I don't use the org-agenda mainly,
;; (Because I don't use the org-agenda mainly,
;; I hope someone continue integration with the org.)

;; (require 'calfw-org)
;;
;;
;; M-x cfw:open-org-calendar

;;; Code:
Expand All @@ -50,14 +52,17 @@ different agenda files from the default agenda ones.")
"[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 (org-agenda-files nil 'ifmode))
append
(progn
(org-check-agenda-file file)
(apply 'org-agenda-get-day-entries
file date
(apply 'org-agenda-get-day-entries
file date
cfw:org-agenda-schedule-args))))))

(defun cfw:org-onclick ()
Expand All @@ -73,7 +78,7 @@ different agenda files from the default agenda ones.")
(org-reveal)))))


(defvar cfw:org-text-keymap
(defvar cfw:org-text-keymap
(let ((map (make-sparse-keymap)))
(define-key map [mouse-1] 'cfw:org-onclick)
(define-key map (kbd "RET") 'cfw:org-onclick)
Expand All @@ -96,22 +101,33 @@ different agenda files from the default agenda ones.")
"Format an item. (How should be displayed?)"
(let* ((time (cfw:org-tp item 'time))
(time-of-day (cfw:org-tp item 'time-of-day))
(time-str (and time-of-day
(time-str (and time-of-day
(format "%02i:%02i " (/ time-of-day 100) (% time-of-day 100))))
(category (cfw:org-tp item 'org-category))
(tags (cfw:org-tp item 'tags))
(marker (cfw:org-tp item 'org-marker))
(buffer (and marker (marker-buffer marker)))
(text (cfw:org-extract-summary item))
(props (cfw:extract-text-props item 'face 'keymap)))
(props (cfw:extract-text-props item 'face 'keymap))
(extra (cfw:org-tp item 'extra))
(i 0))
(setq text (replace-regexp-in-string "[0-9]+:[0-9]+\\(-[0-9]+:[0-9]+\\)?[\t ]+" "" text))
(if tags
(while (< i (length tags))
(setq text (replace-regexp-in-string (concat ":" (elt tags i) ":") "" text))
(setq i (+ i 1))))
(setq text (replace-regexp-in-string "[\t ]+:?$" "" text))
(propertize
(concat
(if time-str (apply 'propertize time-str props)) text " "
(and buffer (buffer-name buffer)))
'keymap cfw:org-text-keymap
;; Delete the display property, since displaying images will break our
;; table layout.
'display nil)))
(concat
(if time-str
(apply 'propertize time-str props))
(if (string-match "^Deadline:.*" extra)
text
(substring-no-properties text)))
'keymap cfw:org-text-keymap
;; Delete the display property, since displaying images will break our
;; table layout.
'display nil)))

(defvar cfw:org-schedule-summary-transformer 'cfw:org-summary-format
"Transformation function which transforms the org item string to calendar title.
Expand All @@ -134,13 +150,13 @@ If TEXT does not have a range, return nil."
(s2 (match-string 2 dotime))
(d1 (time-to-days (org-time-string-to-time s1)))
(d2 (time-to-days (org-time-string-to-time s2))))
(list (calendar-gregorian-from-absolute d1)
(list (calendar-gregorian-from-absolute d1)
(calendar-gregorian-from-absolute d2) text)))))

(defun cfw:org-schedule-period-to-calendar (begin end)
"[internal] Return calfw calendar items between BEGIN and END
from the org schedule data."
(loop
(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:org-collect-schedules-period begin end)
Expand All @@ -165,7 +181,7 @@ TEXT1 < TEXT2."
(cond
((and time1 time2) (< time1 time2))
(time1 t) ; time object is moved to upper
(time2 nil) ;
(time2 nil) ;
(t (string-lessp text1 text2))))
(error (string-lessp text1 text2))))

Expand All @@ -178,7 +194,7 @@ TEXT1 < TEXT2. This function makes no-time items in front of timed-items."
(cond
((and time1 time2) (< time1 time2))
(time1 nil) ; time object is moved to upper
(time2 t) ;
(time2 t) ;
(t (string-lessp text1 text2))))
(error (string-lessp text1 text2))))

Expand Down

0 comments on commit 46d6482

Please sign in to comment.