Merge branch 'js'

This commit is contained in:
Carsten Dominik 2008-09-21 08:34:45 +02:00
commit d6d72b3436
10 changed files with 261 additions and 43 deletions

View File

@ -10,6 +10,20 @@
#+LINK_UP: index.html
#+LINK_HOME: http://orgmode.org
* Version 6.08 (in preparation)
:PROPERTIES:
:VISIBILITY: content
:END:
** Details
*** New remember template escape to add a property
Thanks to James TD Smith for a patch to this effect.
*** Clicking with mouse-2 on clock info in mode-line visits the clock.
Thanks to James TD Smith for a patch to this effect.
*** New file in contrib: lisp/org-checklist.el
Thanks to James TD Smith for a patch to this effect.
* Version 6.07
:PROPERTIES:
:VISIBILITY: content

View File

@ -1,3 +1,7 @@
2008-09-20 James TD Smith <ahktenzero@mohorovi.cc>
* lisp/org-checklist.el: New file.
2008-09-02 Carsten Dominik <dominik@science.uva.nl>
* lisp/org-mairix.el: Update to version 0.5.

View File

@ -0,0 +1,113 @@
;;; org-checklist.el --- org functions for checklist handling
;;
;; Copyright (C) 2008 James TD Smith
;;
;; Author: James TD Smith (@ ahktenzero (. mohorovi cc))
;; Version: 1.0
;; Keywords: org, checklists
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;;
;;; Commentary:
;; This file provides some functions for handing repeated tasks which involve
;; checking off a list of items. By setting the RESET_CHECK_BOXES property in an
;; item, when the TODO state is set to done all checkboxes under that item are
;; cleared. If the LIST_EXPORT_BASENAME property is set, a file will be created
;; using the value of that property plus a timestamp, containing all the items
;; in the list which are not checked. Additionally the user will be prompted to
;; print the list.
;;
;; I use this for to keep track of stores of various things (food stores,
;; components etc) which I check periodically and use the exported list of items
;; which are not present as a shopping list.
;;
;;; Usage:
;; (require 'org-checklist)
;;
;; Set the RESET_CHECK_BOXES and LIST_EXPORT_BASENAME properties in items as
;; needed.
;;
;;; Code:
(require 'org)
(defvar export-time-format "%Y%m%d%H%M"
"format of timestamp appended to export file")
(defvar export-function 'org-export-as-ascii
"function used to prepare the export file for printing")
(defun org-reset-checkbox-state-maybe ()
"Reset all checkboxes in an entry if the `RESET_CHECK_BOXES' property is set"
(interactive "*")
(if (org-entry-get (point) "RESET_CHECK_BOXES")
(save-restriction
(save-excursion
(org-narrow-to-subtree)
(org-show-subtree)
(goto-char (point-min))
(let ((end (point-max)))
(while (< (point) end)
(when (org-at-item-checkbox-p)
(replace-match "[ ]" t t))
(beginning-of-line 2))))
(org-update-checkbox-count-maybe))))
(defun org-make-checklist-export ()
"Produce a checklist containing all unchecked items from a list
of checkbox items"
(interactive "*")
(if (org-entry-get (point) "LIST_EXPORT_BASENAME")
(let* ((export-file (concat (org-entry-get (point) "LIST_EXPORT_BASENAME")
"-" (format-time-string export-time-format)
".org"))
exported-lines
title)
(save-restriction
(save-excursion
(org-narrow-to-subtree)
(org-show-subtree)
(goto-char (point-min))
(if (looking-at org-complex-heading-regexp)
(setq title (match-string 4)))
(goto-char (point-min))
(let ((end (point-max)))
(while (< (point) end)
(when (and (org-at-item-checkbox-p)
(or (string= (match-string 0) "[ ]")
(string= (match-string 0) "[-]")))
(add-to-list 'exported-lines (thing-at-point 'line) t))
(beginning-of-line 2)))
(set-buffer (get-buffer-create export-file))
(org-insert-heading)
(insert (or title export-file) "\n")
(dolist (entry exported-lines) (insert entry))
(org-update-checkbox-count-maybe)
(write-file export-file)
(if (y-or-n-p "Print list? ")
((funcall export-function)
(a2ps-buffer))))))))
(defun org-checklist ()
(if (member state org-done-keywords)
(org-make-checklist-export))
(org-reset-checkbox-state-maybe))
(add-hook 'org-after-todo-state-change-hook 'org-checklist)
(provide 'org-checklist)
;;; org-checklist.el ends here

View File

@ -4922,6 +4922,7 @@ insertion of content:
%^L @r{Like @code{%^C}, but insert as link.}
%^g @r{prompt for tags, with completion on tags in target file.}
%^G @r{prompt for tags, with completion all tags in all agenda files.}
%^{prop}p @r{Prompt the user for a value for property @code{prop}}
%:keyword @r{specific information for certain link types, see below}
%[pathname] @r{insert the contents of the file given by @code{pathname}}
%(sexp) @r{evaluate elisp @code{(sexp)} and replace with the result}

View File

@ -1,3 +1,35 @@
2008-09-20 James TD Smith <ahktenzero@mohorovi.cc>
* org-remember.el (org-remember-apply-template): Add a new
expansion for adding properties to remember items.
* org.el (org-add-log-setup): Skip over drawers (properties,
clocks etc) when adding notes.
* org-agenda.el (org-agenda-get-closed): show durations of clocked
items as well as the start and end times.
* org-compat.el (org-get-x-clipboard-compat): Add a compat
function for fetching the X clipboard on XEmacs and GNU Emacs 21.
* org-remember.el (org-get-x-clipboard): Use the compat
function to get clipboard values when x-selection-value is
unavailable. Use substring-no-properties instead of
set-text-properties to remove text properties from the clipboard
value.
* lisp/org-clock.el (org-update-mode-line): Support limiting the
modeline clock string, and display the full todo value in the
tooltip. Set a local keymap so mouse-3 on the clock string goes to
the currently clocked task.
(org-clock-string-limit): Add a custom value for the maximum
length of the clock string in the modeline.
(org-clock-mode-map): Add a keymap for the modeline string
2008-09-21 Carsten Dominik <dominik@science.uva.nl>
* org-compat.el (org-propertize): New function.
2008-09-20 Bastien Guerry <bzg@altern.org>
* org-export-latex.el (org-export-latex-tables): protect exported
@ -255,7 +287,7 @@
* org-agenda.el (org-batch-store-agenda-views): Fix parsing bug.
2008-07-20 Juri Linkov <juri@jurta.org>
2008-07-20 Juri Linkov <juri@jurta.org>
* org.el (narrow-map): Bind `org-narrow-to-subtree' to "s" on the
new keymap `narrow-map' instead of binding "\C-xns".

View File

@ -3337,7 +3337,7 @@ the documentation of `org-diary'."
(list 0 0 0 (nth 1 date) (car date) (nth 2 date))))
1 11))))
marker hdmarker priority category tags closedp
ee txt timestr rest)
ee txt timestr rest clocked)
(goto-char (point-min))
(while (re-search-forward regexp nil t)
(catch :skip
@ -3353,10 +3353,11 @@ the documentation of `org-diary'."
(setq rest (substring timestr (match-end 0))
timestr (substring timestr 0 (match-end 0)))
(if (and (not closedp)
(string-match "\\([0-9]\\{1,2\\}:[0-9]\\{2\\}\\)\\]" rest))
(setq timestr (concat (substring timestr 0 -1)
"-" (match-string 1 rest) "]"))))
(string-match "\\([0-9]\\{1,2\\}:[0-9]\\{2\\}\\)\\].*\\([0-9]\\{1,2\\}:[0-9]\\{2\\}\\)" rest))
(progn (setq timestr (concat (substring timestr 0 -1)
"-" (match-string 1 rest) "]"))
(setq clocked (match-string 2 rest)))
(setq clocked "-")))
(save-excursion
(if (re-search-backward "^\\*+ " nil t)
(progn
@ -3365,7 +3366,8 @@ the documentation of `org-diary'."
tags (org-get-tags-at))
(looking-at "\\*+[ \t]+\\([^\r\n]+\\)")
(setq txt (org-format-agenda-item
(if closedp "Closed: " "Clocked: ")
(if closedp "Closed: "
(concat "Clocked: (" clocked ")"))
(match-string 1) category tags timestr)))
(setq txt org-agenda-no-heading-message))
(setq priority 100000)

View File

@ -86,6 +86,10 @@ The function is called with point at the beginning of the headline."
:group 'org-clock
:type 'function)
(defcustom org-clock-string-limit 0
"Maximum length of clock strings in the modeline. 0 means no limit"
:group 'org-clock
:type 'integer)
;;; The clock for measuring work time.
@ -107,6 +111,9 @@ of a different task.")
(defvar org-clock-interrupted-task (make-marker)
"Marker pointing to the task that has been interrupted by the current clock.")
(defvar org-clock-mode-map (make-sparse-keymap))
(define-key org-clock-mode-map [mode-line mouse-2] 'org-clock-goto)
(defun org-clock-history-push (&optional pos buffer)
"Push a marker to the clock history."
(setq org-clock-history-length (max 1 (min 35 org-clock-history-length)))
@ -190,15 +197,24 @@ of a different task.")
(when (and cat task)
(insert (format "[%c] %-15s %s\n" i cat task))
(cons i marker)))))
(defun org-update-mode-line ()
(let* ((delta (- (time-to-seconds (current-time))
(time-to-seconds org-clock-start-time)))
(time-to-seconds org-clock-start-time)))
(h (floor delta 3600))
(m (floor (- delta (* 3600 h)) 60)))
(setq org-mode-line-string
(propertize (format (concat "-[" org-time-clocksum-format " (%s)]") h m org-clock-heading)
'help-echo "Org-mode clock is running"))
(org-propertize
(let ((clock-string (format (concat "-[" org-time-clocksum-format " (%s)]")
h m org-clock-heading))
(help-text "Org-mode clock is running. Mouse-2 to go there."))
(if (and (> org-clock-string-limit 0)
(> (length clock-string) org-clock-string-limit))
(org-propertize (substring clock-string 0 org-clock-string-limit)
'help-echo (concat help-text ": " org-clock-heading))
(org-propertize clock-string 'help-echo help-text)))
'local-map org-clock-mode-map
'mouse-face '(face mode-line-highlight)))
(force-mode-line-update)))
(defvar org-clock-mode-line-entry nil
@ -253,13 +269,14 @@ the clocking selection, associated with the letter `d'."
org-clock-in-switch-to-state
"\\>"))))
(org-todo org-clock-in-switch-to-state))
(if (and org-clock-heading-function
(functionp org-clock-heading-function))
(setq org-clock-heading (funcall org-clock-heading-function))
(if (looking-at org-complex-heading-regexp)
(setq org-clock-heading (match-string 4))
(setq org-clock-heading "???")))
(setq org-clock-heading (propertize org-clock-heading 'face nil))
(setq org-clock-heading
(cond ((and org-clock-heading-function
(functionp org-clock-heading-function))
(funcall org-clock-heading-function))
((looking-at org-complex-heading-regexp)
(match-string 4))
(t "???")))
(setq org-clock-heading (org-propertize org-clock-heading 'face nil))
(org-clock-find-position)
(insert "\n") (backward-char 1)

View File

@ -245,6 +245,22 @@ that can be added."
(set-extent-property (car ext-inv-spec) 'invisible
(cadr ext-inv-spec))))
(move-to-column column force)))
(defun org-get-x-clipboard-compat (value)
"Get the clipboard value on XEmacs or Emacs 21"
(cond (org-xemacs-p (org-no-warnings (get-selection-no-error value)))
((fboundp 'x-get-selection)
(condition-case nil
(or (x-get-selection value 'UTF8_STRING)
(x-get-selection value 'COMPOUND_TEXT)
(x-get-selection value 'STRING)
(x-get-selection value 'TEXT))
(error nil)))))
(defun org-propertize (string &rest properties)
(if (featurep 'xemacs)
(add-text-properties 0 (length string) properties string)
(apply 'propertize string properties)))
(provide 'org-compat)

View File

@ -135,6 +135,7 @@ Furthermore, the following %-escapes will be replaced with content:
%^L Like %^C, but insert as link
%^g prompt for tags, with completion on tags in target file
%^G prompt for tags, with completion all tags in all agenda files
%^{prop}p Prompt the user for a value for property `prop'
%:keyword specific information for certain link types, see below
%[pathname] insert the contents of the file given by `pathname'
%(sexp) evaluate elisp `(sexp)' and replace with the result
@ -301,13 +302,10 @@ RET at beg-of-buf -> Append to file as level 2 headline
(cddr (assoc char templates)))))
(defun org-get-x-clipboard (value)
"Get the value of the x clibboard, in a way that also works with XEmacs."
"Get the value of the x clibboard, compatible with XEmacs, and GNU Emacs 21."
(if (eq window-system 'x)
(let ((x (if org-xemacs-p
(org-no-warnings (get-selection-no-error value))
(and (fboundp 'x-selection-value)
(x-selection-value value)))))
(and (> (length x) 0) (set-text-properties 0 (length x) nil x) x))))
(let ((x (org-get-x-clipboard-compat value)))
(if x (org-no-properties x)))))
;;;###autoload
(defun org-remember-apply-template (&optional use-char skip-interactive)
@ -438,7 +436,7 @@ to be run from that hook to function properly."
(org-set-local 'org-remember-default-headline headline))
;; Interactive template entries
(goto-char (point-min))
(while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGtTuUCL]\\)?" nil t)
(while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGtTuUCLp]\\)?" nil t)
(setq char (if (match-end 3) (match-string 3))
prompt (if (match-end 2) (match-string 2)))
(goto-char (match-beginning 0))
@ -483,6 +481,22 @@ to be run from that hook to function properly."
(car clipboards)
'(clipboards . 1)
(car clipboards))))))
((equal char "p")
(let*
((prop (substring-no-properties prompt))
(allowed (with-current-buffer
(get-buffer (file-name-nondirectory file))
(org-property-get-allowed-values nil prop 'table)))
(existing (with-current-buffer
(get-buffer (file-name-nondirectory file))
(mapcar 'list (org-property-values prop))))
(propprompt (concat "Value for " prop ": "))
(val (if allowed
(org-completing-read propprompt allowed nil
'req-match)
(org-completing-read propprompt existing nil nil
"" nil ""))))
(org-set-property prop val)))
(char
;; These are the date/time related ones
(setq org-time-was-given (equal (upcase char) char))

View File

@ -9035,7 +9035,7 @@ The auto-repeater uses this.")
"Add a note to the current entry.
This is done in the same way as adding a state change note."
(interactive)
(org-add-log-setup 'note nil t nil))
(org-add-log-setup 'note nil 'findpos nil))
(defun org-add-log-setup (&optional purpose state findpos how &optional extra)
"Set up the post command hook to take a note.
@ -9044,23 +9044,28 @@ When FINDPOS is non-nil, find the correct position for the note in
the current entry. If not, assume that it can be inserted at point.
HOW is an indicator what kind of note should be created.
EXTRA is additional text that will be inserted into the notes buffer."
(save-excursion
(when findpos
(org-back-to-heading t)
(looking-at (concat outline-regexp "\\( *\\)[^\r\n]*"
"\\(\n[^\r\n]*?" org-keyword-time-not-clock-regexp
"[^\r\n]*\\)?"))
(goto-char (match-end 0))
(unless org-log-states-order-reversed
(and (= (char-after) ?\n) (forward-char 1))
(org-skip-over-state-notes)
(skip-chars-backward " \t\n\r")))
(move-marker org-log-note-marker (point))
(setq org-log-note-purpose purpose
org-log-note-state state
org-log-note-how how
org-log-note-extra extra)
(add-hook 'post-command-hook 'org-add-log-note 'append)))
(save-restriction
(save-excursion
(when findpos
(org-back-to-heading t)
(org-narrow-to-subtree)
(while (re-search-forward
(concat "\\(" org-drawer-regexp "\\|" org-property-end-re "\\)")
(point-max) t) (forward-line))
(looking-at (concat outline-regexp "\\( *\\)[^\r\n]*"
"\\(\n[^\r\n]*?" org-keyword-time-not-clock-regexp
"[^\r\n]*\\)?"))
(goto-char (match-end 0))
(unless org-log-states-order-reversed
(and (= (char-after) ?\n) (forward-char 1))
(org-skip-over-state-notes)
(skip-chars-backward " \t\n\r")))
(move-marker org-log-note-marker (point))
(setq org-log-note-purpose purpose
org-log-note-state state
org-log-note-how how
org-log-note-extra extra)
(add-hook 'post-command-hook 'org-add-log-note 'append))))
(defun org-skip-over-state-notes ()
"Skip past the list of State notes in an entry."