summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2008-04-03 07:44:36 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2008-04-03 10:10:33 +0200
commit2d899ae97fec3a4db4d8a7815c17d1e78c1ca660 (patch)
tree5eccc5f28a62b9172ffb21954fc7301af74927b1
parent10d856c97f298f56892ce8c402810b9f5441c4c9 (diff)
downloadorg-mode-2d899ae97fec3a4db4d8a7815c17d1e78c1ca660.tar.gz
Implement org-info.js support. And bug fixes.
Now you can set this stuff directly from the org-mode file. Documentation is still missing, this is a work-in-progress commit and still needs check with Sebastian's script. Bug fix with note taking when auto-repeating a task: There was a problem if the state change already triggered the recording of a time, then the request for a *note* in `org-log-repeat' was ignored. Reported by Bernt Hansen.
-rw-r--r--ChangeLog8
-rw-r--r--lisp/org-exp.el80
-rw-r--r--lisp/org.el19
3 files changed, 92 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index f10bb02..a397867 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-04-03 Carsten Dominik <dominik@science.uva.nl>
+
+ * lisp/org-exp.el (org-export-html-handle-js-options): New function.
+ (org-export-html-infojs-setup): New option.
+ (org-export-as-html): Call `org-export-html-handle-js-options'.
+
+ * lisp/org.el (org-auto-repeat-maybe): Make sure that a note can
+ be enforces if `org-log-repeat' is `note'.
2008-04-01 Carsten Dominik <dominik@science.uva.nl>
diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index c7c988c..38f34bd 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -405,7 +405,7 @@ Org-mode file."
:group 'org-export)
(defcustom org-export-html-coding-system nil
- ""
+ "FIXME"
:group 'org-export-html
:type 'coding-system)
@@ -463,6 +463,17 @@ you can \"misuse\" it to add arbitrary text to the header."
:group 'org-export-html
:type 'string)
+(defcustom org-export-html-infojs-setup
+ "<script =\"text/javascript\" language=\"JavaScript\" src=\"org-info.js\"></script>
+<script type=\"text/javascript\" language=\"JavaScript\">
+/* <![CDATA[ */
+%MANAGER-OPTIONS
+/* ]]> */
+</script>"
+ "The template for the export style additions when org-info.js is used.
+Option settings will replace the %MANAGER-OPTIONS cookie."
+ :group 'org-export-html
+ :type 'string)
(defcustom org-export-html-title-format "<h1 class=\"title\">%s</h1>\n"
"Format for typesetting the document title in HTML export."
@@ -652,8 +663,9 @@ The text will be inserted into the DESCRIPTION field."
(widen)
(goto-char 0)
(let ((re (org-make-options-regexp
- '("TITLE" "AUTHOR" "DATE" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE")))
- p key val text options)
+ '("TITLE" "AUTHOR" "DATE" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE"
+ "INFOJS_UP" "INFOJS_HOME" "INFOJS_OPT")))
+ p key val text options js-up js-main js-css js-opt)
(while (re-search-forward re nil t)
(setq key (org-match-string-no-properties 1)
val (org-match-string-no-properties 2))
@@ -665,7 +677,13 @@ The text will be inserted into the DESCRIPTION field."
((string-equal key "LANGUAGE") (setq p (plist-put p :language val)))
((string-equal key "TEXT")
(setq text (if text (concat text "\n" val) val)))
- ((string-equal key "OPTIONS") (setq options val))))
+ ((string-equal key "OPTIONS") (setq options val))
+ ((string-equal key "INFOJS_UP")
+ (setq p (plist-put p :infojs-up val)))
+ ((string-equal key "INFOJS_HOME")
+ (setq p (plist-put p :infojs-home val)))
+ ((string-equal key "INFOJS_OPT")
+ (setq p (plist-put p :infojs-opt val)))))
(setq p (plist-put p :text text))
(when options
(let ((op '(("H" . :headline-levels)
@@ -703,6 +721,52 @@ The text will be inserted into the DESCRIPTION field."
val)))
dir))
+(defun org-export-html-handle-js-options (exp-plist)
+ "Analyze JavaScript options in INFO-PLIST and modify EXP-PLIST accordingly.
+Both P and PJ are property lists."
+ (let (p1 (s "") p v a1 tmp)
+ (setq p1 (plist-put p1 'TOC (if (not (plist-get exp-plist
+ :table-of-contents))
+ "0" "1")))
+ (when (setq v (plist-get exp-plist :infojs-opt))
+ (when (string-match "\\<view:\\(\\S-+\\)" v)
+ (setq tmp (match-string 1 v))
+ (unless (member tmp '("info" "overview" "content" "showall"))
+ (error "Invalid value \"%s\" for `view' in #+INFOJS_OPT" tmp))
+ (setq p1 (plist-put p1 'VIEW tmp)))
+ (when (string-match "\\<mouse:\\(\\S-+\\)" v)
+ (setq tmp (match-string 1 v))
+ (unless (string-match "^underline$\\|^#[0-9a-fA-F]\\{6\\}" tmp)
+ (error "Invalid value \"%s\" for `mouse' in #+INFOJS_OPT" tmp))
+ (setq p1 (plist-put p1 'MOUSE_HINT tmp)))
+ (when (string-match "\\<toc:\\(\\S-+\\)" v)
+ (setq p1 (plist-put p1 'TOC
+ (if (equal (match-string 1 v) "nil") "0" "1"))))
+ (when (string-match "\\<runs:\\([0-9]+\\)" v)
+ (setq p1 (plist-put p1 'MAX_RUNS (match-string 1 v))))
+ (when (string-match "\\<buttons:\\(\\S-+\\)" v)
+ (setq p1 (plist-put p1 'VIEW_BUTTONS
+ (if (equal (match-string 1 v) "nil") "0" "1")))))
+ (when (setq v (plist-get exp-plist :infojs-up))
+ (setq p1 (plist-put p1 'LINK_UP v)))
+ (when (setq v (plist-get exp-plist :infojs-home))
+ (setq p1 (plist-put p1 'LINK_HOME v)))
+ (while p1
+ (setq p (pop p1) v (pop p1))
+ (push (cons p v) a1))
+ (setq s (mapconcat
+ (lambda (x) (format "org_html_manager.set(\"%s\", \"%s\");"
+ (car x) (cdr x)))
+ a1 "\n"))
+ (when (> (length s) 0)
+ (and (string-match "%MANAGER-OPTIONS" org-export-html-infojs-setup)
+ (setq s (replace-match s t t org-export-html-infojs-setup))
+ (setq exp-plist
+ (plist-put
+ exp-plist :style
+ (concat (or (plist-get exp-plist :style) "") "\n" s)))))
+ exp-plist))
+
;;;###autoload
(defun org-export (&optional arg)
"Export dispatcher for Org-mode."
@@ -1999,9 +2063,11 @@ PUB-DIR is set, use this as the publishing directory."
(setq-default org-deadline-line-regexp org-deadline-line-regexp)
(setq-default org-done-keywords org-done-keywords)
(setq-default org-maybe-keyword-time-regexp org-maybe-keyword-time-regexp)
- (let* ((opt-plist (org-combine-plists (org-default-export-plist)
- ext-plist
- (org-infile-export-plist)))
+ (let* ((opt-plist
+ (org-export-html-handle-js-options
+ (org-combine-plists (org-default-export-plist)
+ ext-plist
+ (org-infile-export-plist))))
(style (plist-get opt-plist :style))
(html-extension (plist-get opt-plist :html-extension))
diff --git a/lisp/org.el b/lisp/org.el
index a92df5b..e2c901f 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8679,13 +8679,16 @@ This function is run automatically after each state change to a DONE state."
(when repeat
(if (eq org-log-repeat t) (setq org-log-repeat 'state))
(org-todo (if (eq interpret 'type) last-state head))
- (when (and org-log-repeat
- (or (not (memq 'org-add-log-note
- (default-value 'post-command-hook)))
- (eq org-log-note-purpose 'done)))
- ;; Make sure a note is taken;
- (org-add-log-setup 'state (or done-word (car org-done-keywords))
- 'findpos org-log-repeat))
+ (when org-log-repeat
+ (if (or (memq 'org-add-log-note (default-value 'post-command-hook))
+ (memq 'org-add-log-note post-command-hook))
+ ;; OK, we are already setup for some record
+ (if (eq org-log-repeat 'note)
+ ;; make sure we take a note, not only a time stamp
+ (setq org-log-note-how 'note))
+ ;; Set up for taking a record
+ (org-add-log-setup 'state (or done-word (car org-done-keywords))
+ 'findpos org-log-repeat)))
(org-back-to-heading t)
(org-add-planning-info nil nil 'closed)
(setq re (concat "\\(" org-scheduled-time-regexp "\\)\\|\\("
@@ -13067,7 +13070,7 @@ the currently selected interval size."
(when (looking-at "#\\+BEGIN: clocktable\\>.*?:block[ \t]+\\(\\S-+\\)")
(let* ((b (match-beginning 1)) (e (match-end 1))
(s (match-string 1))
- block shift ins y mw d date)
+ block shift ins y mw d date wp m)
(cond
((string-match "^\\(today\\|thisweek\\|thismonth\\|thisyear\\)\\([-+][0-9]+\\)?$" s)
(setq block (match-string 1 s)