emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/textmodes/org.el,v


From: Carsten Dominik
Subject: [Emacs-diffs] Changes to emacs/lisp/textmodes/org.el,v
Date: Sat, 10 Jun 2006 14:15:26 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Carsten Dominik <cdominik>      06/06/10 14:15:26

Index: org.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/textmodes/org.el,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -b -r1.94 -r1.95
--- org.el      6 Jun 2006 08:26:10 -0000       1.94
+++ org.el      10 Jun 2006 14:15:25 -0000      1.95
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <dominik at science dot uva dot nl>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/
-;; Version: 4.36
+;; Version: 4.36b
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -90,6 +90,10 @@
 ;;
 ;; Recent changes
 ;; --------------
+;; Version 4.37
+;;    - Clock-feature for measuring time spent on specific items.
+;;    - Improved emphasizing allows configuration and stacking.
+;;
 ;; Version 4.36
 ;;    - Improved indentation of ASCII export, when headlines become items.
 ;;    - Handling of 12am and 12pm fixed.  Times beyond 24:00 can be used
@@ -172,7 +176,7 @@
 
 ;;; Customization variables
 
-(defvar org-version "4.36"
+(defvar org-version "4.36b"
   "The version number of the file org.el.")
 (defun org-version ()
   (interactive)
@@ -333,6 +337,11 @@
   :group 'org-keywords
   :type 'string)
 
+(defcustom org-clock-string "CLOCK:"
+  "String used as prefix for timestamps clocking work hours on an item."
+  :group 'org-keywords
+  :type 'string)
+
 (defcustom org-comment-string "COMMENT"
   "Entries starting with this keyword will never be exported.
 An entry can be toggled between COMMENT and normal with
@@ -2134,6 +2143,95 @@
   :group 'org-font-lock
   :type 'boolean)
 
+(defvar org-emph-re nil
+  "Regular expression for matching emphasis.")
+(defvar org-emphasis-regexp-components) ; defined just below
+(defvar org-emphasis-alist) ; defined just below
+(defun org-set-emph-re (var val)
+  "Set variable and compute the emphasis regular expression."
+  (set var val)
+  (when (and (boundp 'org-emphasis-alist)
+            (boundp 'org-emphasis-regexp-components)
+            org-emphasis-alist org-emphasis-regexp-components)
+    (let* ((e org-emphasis-regexp-components)
+          (pre (car e))
+          (post (nth 1 e))
+          (border (nth 2 e))
+          (body (nth 3 e))
+          (nl (nth 4 e))
+          (stacked (nth 5 e))
+          (body1 (concat body "*?"))
+          (markers (mapconcat 'car org-emphasis-alist "")))
+      ;; make sure special characters appear at the right position in the class
+      (if (string-match "\\^" markers)
+         (setq markers (concat (replace-match "" t t markers) "^")))
+      (if (string-match "-" markers)
+         (setq markers (concat (replace-match "" t t markers) "-")))
+      (while (>= (setq nl (1- nl)) 0) (setq body1 (concat body1 "\n?" body 
"*?")))
+      ;; Make the regexp
+      (setq org-emph-re
+           (concat "\\([" pre (if stacked markers) "]\\|^\\)"
+                   "\\("
+                   "\\([" markers "]\\)"
+                   "\\("
+                   "[^" border markers "]"
+                   body1
+                   "[^" border markers "]"
+                   "\\)"
+                   "\\3\\)"
+                   "\\([" post (if stacked markers) "]\\|$\\)")))))
+
+(defcustom org-emphasis-regexp-components
+  '(" \t(" " \t.,?;:'\")" " \t\r\n,." "." 1 nil)
+  "Components used to build the reqular expression for emphasis.
+This is a list with 6 entries.  Terminology:  In an emphasis string
+like \" *strong word* \", we call the initial space PREMATCH, the final
+space POSTMATCH, the stars MARKERS, \"s\" and \"d\" are BORDER characters
+and \"trong wor\" is the body.  The different components in this variable
+specify what is allowed/forbidden in each part:
+
+pre          Chars allowed as prematch.  Beginning of line will be allowed too.
+post         Chars allowed as postmatch.  End of line will be allowed too.
+border       The chars *forbidden* as border characters.  In addition to the
+             characters given here, all marker characters are forbidden too.
+body-regexp  A regexp like \".\" to match a body character.  Don't use
+             non-shy groups here, and don't allow newline here.
+newline      The maximum number of newlines allowed in an emphasis exp.
+stacked      Non-nil means, allow stacked styles.  This works only in HTML
+             export.  When this is set, all marker characters (as given in
+             `org-emphasis-alist') will be allowed as pre/post, aiding
+             inside-out matching.
+Use customize to modify this, or restart emacs after changing it."
+  :group 'org-fixme
+  :set 'org-set-emph-re
+  :type '(list
+         (sexp    :tag "Allowed chars in pre      ")
+         (sexp    :tag "Allowed chars in post     ")
+         (sexp    :tag "Forbidden chars in border ")
+         (sexp    :tag "Regexp for body           ")
+         (integer :tag "number of newlines allowed")
+         (boolean :tag "Stacking allowed          ")))
+
+(defcustom org-emphasis-alist
+  '(("*" bold "<b>" "</b>")
+    ("/" italic "<i>" "</i>")
+    ("_" underline "<u>" "</u>")
+    ("=" shadow "<code>" "</code>"))
+"Special syntax for emphasised text.
+Text starting and ending with a special character will be emphasized, for
+example *bold*, _underlined_ and /italic/.  This variable sets the marker
+characters, the face to bbe used by font-lock for highlighting in Org-mode
+emacs buffers, and the HTML tags to be used for this.
+Use customize to modify this, or restart emacs after changing it."
+  :group 'org-fixme
+  :set 'org-set-emph-re
+  :type '(repeat
+         (list
+          (string :tag "Marker character")
+          (face :tag "Font-lock-face")
+          (string :tag "HTML start tag")
+          (string :tag "HTML end tag"))))
+
 (defgroup org-faces nil
   "Faces in Org-mode."
   :tag "Org Faces"
@@ -2374,21 +2472,6 @@
     ))
 (defconst org-n-levels (length org-level-faces))
 
-(defconst org-bold-re
-  (if (featurep 'xemacs)
-      "\\([ ]\\|^\\)\\(\\*\\(\\w[a-zA-Z0-9-_ ]*?\\w\\)\\*\\)\\([ ,.]\\|$\\)"
-    "\\([ ]\\|^\\)\\(\\*\\(\\w[[:word:] -_]*?\\w\\)\\*\\)\\([ ,.]\\|$\\)")
-  "Regular expression for bold emphasis.")
-(defconst org-italic-re
-  (if (featurep 'xemacs)
-      "\\([ ]\\|^\\)\\(/\\(\\w[a-zA-Z0-9-_ ]*?\\w\\)/\\)\\([ ,.]\\|$\\)"
-    "\\([ ]\\|^\\)\\(/\\(\\w[[:word:] -_]*?\\w\\)/\\)\\([ ,.]\\|$\\)")
-  "Regular expression for italic emphasis.")
-(defconst org-underline-re
-  (if (featurep 'xemacs)
-      "\\([ ]\\|^\\)\\(_\\(\\w[a-zA-Z0-9-_ ]*?\\w\\)_\\)\\([ ,.]\\|$\\)"
-    "\\([ ]\\|^\\)\\(_\\(\\w[[:word:] -_]*?\\w\\)_\\)\\([ ,.]\\|$\\)")
-  "Regular expression for underline emphasis.")
 
 ;; Variables for pre-computed regular expressions, all buffer local
 (defvar org-done-string nil
@@ -2582,12 +2665,14 @@
          org-keyword-time-regexp
          (concat "\\<\\(" org-scheduled-string
                  "\\|" org-deadline-string
-                 "\\|" org-closed-string "\\)"
+                 "\\|" org-closed-string
+                 "\\|" org-clock-string "\\)"
                  " *[[<]\\([^]>]+\\)[]>]")
          org-maybe-keyword-time-regexp
          (concat "\\(\\<\\(" org-scheduled-string
                  "\\|" org-deadline-string
-                 "\\|" org-closed-string "\\)\\)?"
+                 "\\|" org-closed-string
+                 "\\|" org-clock-string "\\)\\)?"
                  " 
*\\([[<][0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}[^]\r\n>]*?[]>]\\)"))
 
     (org-set-font-lock-defaults)))
@@ -2609,6 +2694,7 @@
 (defvar timecnt) ; dynamically scoped parameter
 (defvar levels-open) ; dynamically scoped parameter
 (defvar entry) ; dynamically scoped parameter
+(defvar state) ; dynamically scoped into `org-after-todo-state-change-hook'
 (defvar date) ; dynamically scoped parameter
 (defvar description) ; dynamically scoped parameter
 (defvar ans1) ; dynamically scoped parameter
@@ -2715,6 +2801,7 @@
                            4 (string-to-vector org-ellipsis))
     (setq buffer-display-table org-display-table))
   (org-set-regexps-and-options)
+  (modify-syntax-entry ?# "<")
   (if org-startup-truncated (setq truncate-lines t))
   (set (make-local-variable 'font-lock-unfontify-region-function)
        'org-unfontify-region)
@@ -2722,6 +2809,8 @@
   (set (make-local-variable 'org-table-may-need-update) t)
   (org-add-hook 'before-change-functions 'org-before-change-function nil
                'local)
+  ;; Check for running clock before killing a buffer
+  (org-add-hook 'kill-buffer-hook 'org-check-running-clock nil 'local)
   ;; Paragraphs and auto-filling
   (org-set-autofill-regexps)
   (org-update-radio-target-regexp)
@@ -2859,6 +2948,21 @@
                                 org-ts-regexp "\\)?")
   "Regular expression matching a time stamp or time stamp range.")
 
+(defvar org-§emph-face nil)
+
+(defun org-do-emphasis-faces (limit)
+  "Run through the buffer and add overlays to links."
+  (if (re-search-forward org-emph-re limit t)
+      (progn
+       (font-lock-prepend-text-property (match-beginning 2) (match-end 2)
+                                        'face
+                                        (nth 1 (assoc (match-string 3)
+                                                      org-emphasis-alist)))
+       (add-text-properties (match-beginning 2) (match-end 2)
+                            '(font-lock-multiline t))
+       (backward-char 1)
+       t)))
+
 (defun org-activate-plain-links (limit)
   "Run through the buffer and add overlays to links."
   (if (re-search-forward org-plain-link-re limit t)
@@ -3050,10 +3154,9 @@
           (list (concat "\\<" org-deadline-string) '(0 'org-special-keyword t))
           (list (concat "\\<" org-scheduled-string) '(0 'org-special-keyword 
t))
           (list (concat "\\<" org-closed-string) '(0 'org-special-keyword t))
+          (list (concat "\\<" org-clock-string) '(0 'org-special-keyword t))
           ;; Emphasis
-          (if em (list org-bold-re 2 ''bold 'prepend))
-          (if em (list org-italic-re 2 ''italic 'prepend))
-          (if em (list org-underline-re 2 ''underline 'prepend))
+          (if em '(org-do-emphasis-faces))
           ;; Checkboxes, similar to Frank Ruell's org-checklet.el
           '("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[ X]\\]\\)"
             2 'bold prepend)
@@ -3268,10 +3371,15 @@
          (org-cycle))))))
 
 ;;;###autoload
-(defun org-global-cycle ()
+(defun org-global-cycle (&optional arg)
   "Cycle the global visibility.  For details see `org-cycle'."
-  (interactive)
-  (org-cycle '(4)))
+  (interactive "P")
+  (if (integerp arg)
+      (progn
+       (show-all)
+       (hide-sublevels arg)
+       (setq org-cycle-global-status 'contents))
+    (org-cycle '(4))))
 
 (defun org-overview ()
   "Switch to overview mode, shoing only top-level headlines.
@@ -3488,7 +3596,9 @@
         ((and (org-on-heading-p) (bolp) 
               (save-excursion (backward-char 1) (not (org-invisible-p))))
          (open-line 1))
-        ((bolp) nil)
+        ((and (bolp) (save-excursion
+                       (backward-char 1) (not (org-invisible-p))))
+         nil)
         (t (newline)))
        (insert head) (just-one-space)
        (setq pos (point))
@@ -3657,6 +3767,7 @@
                  (not (eobp)))
        (funcall fun)))))
 
+;; FIXME: this does not work well with Tabulators.  This has to be re-written 
entirely.
 (defun org-fixup-indentation (from to prohibit)
   "Change the indentation in the current entry by re-replacing FROM with TO.
 However, if the regexp PROHIBIT matches at all, don't do anything.
@@ -4560,7 +4671,8 @@
       (goto-char (1+ (match-end 0)))
       (if (and (not (looking-at outline-regexp))
               (looking-at (concat "[^\r\n]*?" org-keyword-time-regexp
-                                  "[^\r\n]*")))
+                                  "[^\r\n]*"))
+              (not (equal (match-string 1) org-clock-string)))
          (narrow-to-region (match-beginning 0) (match-end 0))
        (insert "\n")
        (backward-char 1)
@@ -5258,6 +5370,193 @@
   (interactive)
   (org-timestamp-change 0 'calendar))
 
+;;; The clock for measuring work time.
+
+(defvar org-clock-marker (make-marker)
+  "Marker recording the last clock-in.")
+
+(defun org-clock-in ()
+  "Start the clock on the current item.
+If necessary, clock-out of the currently active clock."
+  (interactive)
+  (org-clock-out t)
+  (let (ts)
+    (save-excursion
+      (org-back-to-heading t)
+      (beginning-of-line 2)
+      (if (and (looking-at (concat "[ \t]*" org-keyword-time-regexp))
+              (not (equal (match-string 1) org-clock-string)))
+         (beginning-of-line 1))
+      (insert "\n") (backward-char 1)
+      (indent-relative)
+      (insert org-clock-string " "
+             (setq ts (concat "[" (format-time-string
+                                   (substring
+                                    (cdr org-time-stamp-formats) 1 -1)
+                                   (current-time))
+                              "]")))
+      (move-marker org-clock-marker (point))
+      (message "Clock started at %s" ts))))
+
+(defun org-clock-out (&optional fail-quietly)
+  "Stop the currently running clock.
+If there is no running clock, throw an error, unless FAIL-QUIETLY is set."
+  (interactive)
+  (catch 'exit
+  (if (not (marker-buffer org-clock-marker))
+      (if fail-quietly (throw 'exit t) (error "No active clock")))
+  (let (ts te s h m)
+    (save-excursion
+      (set-buffer (marker-buffer org-clock-marker))
+      (goto-char org-clock-marker)
+      (beginning-of-line 1)
+      (if (and (looking-at (concat "[ \t]*" org-keyword-time-regexp))
+              (equal (match-string 1) org-clock-string))
+         (setq ts (match-string 2))
+       (if fail-quietly (throw 'exit nil) (error "Clock start time is gone")))
+      (goto-char org-clock-marker)
+      (setq te (concat "[" (format-time-string
+                           (substring
+                            (cdr org-time-stamp-formats) 1 -1)
+                           (current-time))
+                      "]"))
+      (setq s (- (time-to-seconds (apply 'encode-time (org-parse-time-string 
te)))
+                (time-to-seconds (apply 'encode-time (org-parse-time-string 
ts))))
+           h (floor (/ s 3600))
+           s (- s (* 3600 h))
+           m (floor (/ s 60))
+           s (- s (* 60 s)))
+      (insert "--" te " => " (format "%2d:%02d" h m))
+      (move-marker org-clock-marker nil)
+      (message "Clock stopped at %s after HH:MM = %d:%02d" te h m)))))
+
+(defun org-clock-cancel ()
+  "Cancel the running clock be removing the start timestamp."
+  (interactive)
+  (if (not (marker-buffer org-clock-marker))
+      (error "No active clock"))
+  (save-excursion
+    (set-buffer (marker-buffer org-clock-marker))
+    (goto-char org-clock-marker)
+    (delete-region (1- (point-at-bol)) (point-at-eol)))
+  (message "Clock canceled"))
+
+(defvar org-clock-file-total-minutes nil
+  "Holds the file total time in minutes, after a call to `org-clock-sum'.")
+  (make-variable-buffer-local 'org-clock-file-total-minutes)
+
+(defun org-clock-sum ()
+  "Sum the times for each subtree.
+Puts the resulting times in minutes as a text property on each headline."
+  (interactive)
+  (remove-text-properties (point-min) (point-max) '(:org-clock-minutes t))
+  (let* ((re (concat "^\\(\\*+\\)[ \t]\\|^[ \t]*"
+                    org-clock-string
+                    ".*=>[ \t]*\\([0-9]+\\):\\([0-9]+\\)[ \t]*$"))
+        (lmax 30)
+        (ltimes (make-vector lmax 0))
+        (t1 0)
+        (level 0)
+        (lastlevel 0) time)
+    (save-excursion
+      (goto-char (point-max))
+      (while (re-search-backward re nil t)
+       (if (match-end 2)
+           ;; A time
+           (setq t1 (+ t1 (* 60 (string-to-number (match-string 2)))
+                       (string-to-number (match-string 3))))
+         ;; A headline
+         (setq level (- (match-end 1) (match-beginning 1)))
+         (when (or (> t1 0) (> (aref ltimes level) 0))
+           (loop for l from 0 to level do
+                 (aset ltimes l (+ (aref ltimes l) t1)))
+           (setq t1 0 time (aref ltimes level))
+           (loop for l from level to (1- lmax) do
+                 (aset ltimes l 0))
+           (goto-char (match-beginning 0))
+           (put-text-property (point) (point-at-eol) :org-clock-minutes 
time))))
+      (setq org-clock-file-total-minutes (aref ltimes 0)))))
+
+(defun org-clock-display (&optional total-only)
+  "Show subtree times in the entire buffer.
+If TOTAL-ONLY is non-nil, only show the total time for the entire file
+in the echo area."
+  (interactive)
+  (org-remove-clock-overlays)
+  (let (time h m p)
+    (org-clock-sum)
+    (unless total-only
+      (save-excursion
+       (goto-char (point-min))
+       (while (setq p (next-single-property-change (point) :org-clock-minutes))
+         (goto-char p)
+         (when (setq time (get-text-property p :org-clock-minutes))
+           (org-put-clock-overlay time (funcall outline-level))))
+       (setq h (/ org-clock-file-total-minutes 60)
+             m (- org-clock-file-total-minutes (* 60 h)))
+       ;; Arrange to remove the overlays upon next change.
+       (org-add-hook 'before-change-functions 'org-remove-clock-overlays
+                     nil 'local)))
+  (message "Total file time: %d:%02d (%d hours and %d minutes)" h m h m)))
+
+(defvar org-clock-overlays nil)
+(defun org-put-clock-overlay (time &optional level)
+  "Put an overlays on the current line, displaying TIME.
+If LEVEL is given, prefix time with a corresponding number of stars.
+This creates a new overlay and stores it in `org-clock-overlays', so that it
+will be easy to remove."
+  (let* ((c 60) (h (floor (/ time 60))) (m (- time (* 60 h)))
+        (l (if level (org-get-legal-level level 0) 0))
+        (off 0)
+        ov tx)
+    (move-to-column c)
+    (if (eolp) (setq off 1))
+    (unless (eolp) (skip-chars-backward "^ \t"))
+    (skip-chars-backward " \t")
+    (setq ov (org-make-overlay (- (point) off) (point-at-eol))
+         tx (concat (make-string (+ off (max 0 (- c (current-column)))) ?.)
+                    (org-add-props (format "%s %2d:%02d%s"
+                                           (make-string l ?*) h m
+                                           (make-string (- 10 l) ?\ ))
+                        '(face secondary-selection))
+                    ""))
+    (org-overlay-put ov 'display tx)
+    (push ov org-clock-overlays)))
+
+(defun org-remove-clock-overlays (&optional beg end noremove)
+  "Remove the occur highlights from the buffer.
+BEG and END are ignored.  If NOREMOVE is nil, remove this function
+from the `before-change-functions' in the current buffer."
+  (interactive)
+  (mapc 'org-delete-overlay org-clock-overlays)
+  (setq org-clock-overlays nil)
+  (unless noremove
+    (remove-hook 'before-change-functions
+                'org-remove-clock-overlays 'local)))
+
+(defun org-clock-out-if-current ()
+  "Clock out if the current entry contains the running clock.
+This is used to stop the clock after a TODO entry is marked DONE."
+  (when (and (equal state org-done-string)
+            (equal (marker-buffer org-clock-marker) (current-buffer))
+            (< (point) org-clock-marker)
+            (> (save-excursion (outline-next-heading) (point))
+               org-clock-marker))
+    (org-clock-out)))
+
+(add-hook 'org-after-todo-state-change-hook
+         'org-clock-out-if-current)
+
+(defun org-check-running-clock ()
+  "Check if the current buffer contains the running clock.
+If yes, offer to stop it and to save the buffer with the changes."
+  (when (and (equal (marker-buffer org-clock-marker) (current-buffer))
+            (y-or-n-p (format "Clock-out in buffer %s before killing it? "
+                              (buffer-name))))
+    (org-clock-out)
+    (when (y-or-n-p "Save changed buffer?")
+      (save-buffer))))
+
 ;;; Agenda, and Diary Integration
 
 ;;; Define the mode
@@ -5361,6 +5660,9 @@
 (define-key org-agenda-mode-map "h" 'org-agenda-holidays)
 (define-key org-agenda-mode-map "H" 'org-agenda-holidays)
 (define-key org-agenda-mode-map "+" 'org-agenda-priority-up)
+(define-key org-agenda-mode-map "I" 'org-agenda-clock-in)
+(define-key org-agenda-mode-map "O" 'org-clock-out)
+(define-key org-agenda-mode-map "X" 'org-clock-cancel)
 (define-key org-agenda-mode-map "-" 'org-agenda-priority-down)
 (define-key org-agenda-mode-map (org-key 'S-up) 'org-agenda-priority-up)
 (define-key org-agenda-mode-map (org-key 'S-down) 'org-agenda-priority-down)
@@ -6619,7 +6921,7 @@
                      (format "mouse-2 or RET jump to org file %s"
                              (abbreviate-file-name buffer-file-name))))
         (regexp (concat
-                 "\\<" org-closed-string " *\\["
+                 "\\<\\(" org-closed-string "\\|" org-clock-string "\\) *\\["
                  (regexp-quote
                   (substring
                    (format-time-string
@@ -6627,13 +6929,14 @@
                     (apply 'encode-time  ; DATE bound by calendar
                            (list 0 0 0 (nth 1 date) (car date) (nth 2 date))))
                    1 11))))
-        marker hdmarker priority category tags
+        marker hdmarker priority category tags closedp
         ee txt timestr)
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
       (if (not (save-match-data (org-at-date-range-p)))
          (progn
            (setq marker (org-agenda-new-marker (match-beginning 0))
+                 closedp (equal (match-string 1) org-closed-string)
                  category (org-get-category (match-beginning 0))
                  timestr (buffer-substring (match-beginning 0) (point-at-eol))
                  ;; donep (org-entry-is-done-p)
@@ -6649,7 +6952,7 @@
                          tags (org-get-tags-at))
                    (looking-at "\\*+[ \t]*\\([^\r\n]+\\)")
                    (setq txt (org-format-agenda-item
-                              "Closed:    "
+                              (if closedp "Closed:    " "Clocked:   ")
                               (match-string 1) category tags timestr)))
                (setq txt org-agenda-no-heading-message))
              (setq priority 100000)
@@ -7400,6 +7703,20 @@
        (match-string 1)
       "")))
 
+(defun org-agenda-clock-in (&optional arg)
+  "Start the clock on the currently selected item."
+  (interactive "P")
+  (org-agenda-check-no-diary)
+  (let* ((marker (or (get-text-property (point) 'org-marker)
+                    (org-agenda-error)))
+        (buffer (marker-buffer marker))
+        (pos (marker-position marker))
+        (hdmarker (get-text-property (point) 'org-hd-marker)))
+    (with-current-buffer (marker-buffer marker)
+      (widen)
+      (goto-char pos)
+      (org-clock-in))))
+
 (defun org-agenda-diary-entry ()
   "Make a diary entry, like the `i' command from the calendar.
 All the standard commands work: block, weekly etc."
@@ -11863,6 +12180,49 @@
        (t (setq rtn (cons line rtn)))))
     (nreverse rtn)))
 
+(defun org-export (&optional arg)
+  (interactive)
+  (let ((help "[t]   insert the export option template
+\[v]   limit export to visible part of outline tree
+
+\[a] export as ASCII
+\[h] export as HTML
+\[b] export as HTML and browse immediately
+\[x] export as XOXO
+
+\[i] export current file as iCalendar file
+\[I] export all agenda files as iCalendar files
+\[c] export agenda files into combined iCalendar file
+
+\[F] publish current file
+\[P] publish current project
+\[X] publish... (project will be prompted for)
+\[A] publish all projects")
+       (cmds
+        '((?v . org-export-visible)
+          (?a . org-export-as-ascii)
+          (?h . org-export-as-html)
+          (?b . org-export-as-html-and-open)
+          (?x . org-export-as-xoxo)
+          (?i . org-export-icalendar-this-file)
+          (?I . org-export-icalendar-all-agenda-files)
+          (?c . org-export-icalendar-combine-agenda-files)
+          (?F . org-publish-current-file)
+          (?P . org-publish-current-project)
+          (?X . org-publish)
+          (?A . org-publish-all)))
+       r1 r2 ass)
+    (save-window-excursion
+      (delete-other-windows)
+      (with-output-to-temp-buffer "*Org Export/Publishing Help*"
+       (princ help))
+      (message "Select command: ")
+      (setq r1 (read-char-exclusive)))
+    (setq r2 (if (< r1 27) (+ r1 96) r1))
+    (if (setq ass (assq r2 cmds))
+       (call-interactively (cdr ass))
+      (error "No command associated with key %c" r1))))
+
 ;; ASCII
 
 (defconst org-html-entities
@@ -12163,7 +12523,7 @@
 It is supplemented by a number of commonly used TeX macros with appropriate
 translations.  There is currently no way for users to extend this.")
 
-(defun org-cleaned-string-for-export (string)
+(defun org-cleaned-string-for-export (string &rest parameters)
   "Cleanup a buffer substring so that links can be created safely."
   (interactive)
   (let* ((cb (current-buffer))
@@ -12205,6 +12565,12 @@
         (concat 
          (match-string 1) "[[" (match-string 2) ":" (match-string 3) "]]")
         t t))
+      ;; Find multiline emphasis and put them into single line
+      (when (assq :emph-multiline parameters)
+       (goto-char (point-min))
+       (while (re-search-forward org-emph-re nil t)
+         (subst-char-in-region (match-beginning 0) (match-end 0) ?\n ?\  t)
+         (goto-char (1- (match-end 0)))))
 
       ;; Remove comments
       (goto-char (point-min))
@@ -12496,6 +12862,7 @@
         current-prefix-arg))
   (if (not (member type '("a" "\C-a" "b" "\C-b" "h" "x" " ")))
       (error "Invalid export key"))
+  ;; FIXME: do this more explicit?
   (let* ((binding (key-binding (concat "\C-c\C-x" type)))
         (keepp (equal type " "))
         (file buffer-file-name)
@@ -12690,7 +13057,8 @@
            (if region-p (region-end) (point-max))))
          (all_lines
           (org-skip-comments (org-split-string
-                             (org-cleaned-string-for-export region)
+                             (org-cleaned-string-for-export
+                              region :emph-multiline)
                              "[\r\n]")))
          (lines (org-export-find-first-heading-line all_lines))
          (level 0) (line "") (origline "") txt todo
@@ -13403,12 +13771,9 @@
   string)
 
 (defun org-export-html-convert-emphasize (string)
-  (while (string-match org-italic-re string)
-    (setq string (replace-match "\\1<i>\\3</i>\\4" t nil string)))
-  (while (string-match org-bold-re string)
-    (setq string (replace-match "\\1<b>\\3</b>\\4" t nil string)))
-  (while (string-match org-underline-re string)
-    (setq string (replace-match "\\1<u>\\3</u>\\4" t nil string)))
+  "Apply emphasis."
+  (while (string-match org-emph-re string)
+    (setq string (replace-match (concat "\\1" (nth 2 (assoc (match-string 3 
string) org-emphasis-alist)) "\\4" (nth 3 (assoc (match-string 3 string) 
org-emphasis-alist)) "\\5") t nil string)))
   string)
 
 (defvar org-par-open nil)
@@ -13527,6 +13892,7 @@
     string))
 
 
+;;;###autoload
 (defun org-export-icalendar-this-file ()
   "Export current file as an iCalendar file.
 The iCalendar file will be located in the same directory as the Org-mode
@@ -13793,7 +14159,6 @@
 
 ;; Make `C-c C-x' a prefix key
 (define-key org-mode-map "\C-c\C-x" (make-sparse-keymap))
-(define-key org-mode-map "\C-c\C-e" (make-sparse-keymap))
 
 ;; TAB key with modifiers
 (define-key org-mode-map "\C-i"       'org-cycle)
@@ -13889,38 +14254,44 @@
 (define-key org-mode-map [(control ?#)]   'org-table-rotate-recalc-marks)
 (define-key org-mode-map "\C-c~"          'org-table-create-with-table.el)
 (define-key org-mode-map "\C-c\C-q"       'org-table-wrap-region)
-(define-key org-mode-map "\C-c\C-xa"      'org-export-as-ascii)
-(define-key org-mode-map "\C-c\C-x\C-a"   'org-export-as-ascii)
-(define-key org-mode-map "\C-c\C-xv"      'org-export-visible)
-(define-key org-mode-map "\C-c\C-x\C-v"   'org-export-visible)
+(define-key org-mode-map "\C-c\C-e"       'org-export)
+;(define-key org-mode-map "\C-c\C-xa"      'org-export-as-ascii)
+;(define-key org-mode-map "\C-c\C-x\C-a"   'org-export-as-ascii)
+;(define-key org-mode-map "\C-c\C-xv"      'org-export-visible)
+;(define-key org-mode-map "\C-c\C-x\C-v"   'org-export-visible)
 ;; OPML support is only an option for the future
 ;(define-key org-mode-map "\C-c\C-xo"      'org-export-as-opml)
 ;(define-key org-mode-map "\C-c\C-x\C-o"   'org-export-as-opml)
-(define-key org-mode-map "\C-c\C-xi"      'org-export-icalendar-this-file)
-(define-key org-mode-map "\C-c\C-x\C-i"   
'org-export-icalendar-all-agenda-files)
-(define-key org-mode-map "\C-c\C-xc"      
'org-export-icalendar-combine-agenda-files)
-(define-key org-mode-map "\C-c\C-x\C-c"   
'org-export-icalendar-combine-agenda-files)
-(define-key org-mode-map "\C-c\C-xt"      'org-insert-export-options-template)
+;(define-key org-mode-map "\C-c\C-xi"      'org-export-icalendar-this-file)
+;(define-key org-mode-map "\C-c\C-x\C-i"   
'org-export-icalendar-all-agenda-files)
+;(define-key org-mode-map "\C-c\C-xc"      
'org-export-icalendar-combine-agenda-files)
+;(define-key org-mode-map "\C-c\C-x\C-c"   
'org-export-icalendar-combine-agenda-files)
+;(define-key org-mode-map "\C-c\C-xt"      'org-insert-export-options-template)
 (define-key org-mode-map "\C-c:"          'org-toggle-fixed-width-section)
-(define-key org-mode-map "\C-c\C-xh"      'org-export-as-html)
-(define-key org-mode-map "\C-c\C-xx"      'org-export-as-xoxo)
-(define-key org-mode-map "\C-c\C-x\C-x"   'org-export-as-xoxo)
-(define-key org-mode-map "\C-c\C-xb"      'org-export-as-html-and-open)
-(define-key org-mode-map "\C-c\C-x\C-b"   'org-export-as-html-and-open)
+;(define-key org-mode-map "\C-c\C-xh"      'org-export-as-html)
+;(define-key org-mode-map "\C-c\C-xx"      'org-export-as-xoxo)
+;(define-key org-mode-map "\C-c\C-x\C-x"   'org-export-as-xoxo)
+;(define-key org-mode-map "\C-c\C-xb"      'org-export-as-html-and-open)
+;(define-key org-mode-map "\C-c\C-x\C-b"   'org-export-as-html-and-open)
 
 (define-key org-mode-map "\C-c\C-x\C-k"   'org-cut-special)
 (define-key org-mode-map "\C-c\C-x\C-w"   'org-cut-special)
 (define-key org-mode-map "\C-c\C-x\M-w"   'org-copy-special)
 (define-key org-mode-map "\C-c\C-x\C-y"   'org-paste-special)
 
-(define-key org-mode-map "\C-c\C-ef"    'org-publish-current-file)
-(define-key org-mode-map "\C-c\C-ep"    'org-publish-current-project)
-(define-key org-mode-map "\C-c\C-ec"    'org-publish)
-(define-key org-mode-map "\C-c\C-ea"    'org-publish-all)
-(define-key org-mode-map "\C-c\C-e\C-f" 'org-publish-current-file)
-(define-key org-mode-map "\C-c\C-e\C-p" 'org-publish-current-project)
-(define-key org-mode-map "\C-c\C-e\C-c" 'org-publish)
-(define-key org-mode-map "\C-c\C-e\C-a" 'org-publish-all)
+(define-key org-mode-map "\C-c\C-x\C-i" 'org-clock-in)
+(define-key org-mode-map "\C-c\C-x\C-o" 'org-clock-out)
+(define-key org-mode-map "\C-c\C-x\C-x" 'org-clock-cancel)
+(define-key org-mode-map "\C-c\C-x\C-d" 'org-clock-display)
+
+;(define-key org-mode-map "\C-c\C-ef"    'org-publish-current-file)
+;(define-key org-mode-map "\C-c\C-ep"    'org-publish-current-project)
+;(define-key org-mode-map "\C-c\C-ec"    'org-publish)
+;(define-key org-mode-map "\C-c\C-ea"    'org-publish-all)
+;(define-key org-mode-map "\C-c\C-e\C-f" 'org-publish-current-file)
+;(define-key org-mode-map "\C-c\C-e\C-p" 'org-publish-current-project)
+;(define-key org-mode-map "\C-c\C-e\C-c" 'org-publish)
+;(define-key org-mode-map "\C-c\C-e\C-a" 'org-publish-all)
 
 (when (featurep 'xemacs) 
   (define-key org-mode-map 'button3   'popup-mode-menu))
@@ -14028,12 +14399,12 @@
   "Throw an error because Shift-Cursor command was applied in wrong context."
   (error "This command is active in special context like tables, headlines or 
timestamps"))
 
-(defun org-shifttab ()
+(defun org-shifttab (&optional arg)
   "Global visibility cycling or move to previous table field.
 Calls `org-cycle' with argument t, or `org-table-previous-field', depending
 on context.
 See the individual commands for more information."
-  (interactive)
+  (interactive "P")
   (cond
    ((org-at-table-p) (call-interactively 'org-table-previous-field))
    (t (call-interactively 'org-global-cycle))))
@@ -14227,6 +14598,12 @@
   (interactive "P")
   (let  ((org-enable-table-editor t))
     (cond
+     (org-clock-overlays 
+      (org-remove-clock-overlays)
+      (message "Clock overlays removed"))
+     (org-occur-highlights
+      (org-remove-occur-highlights)
+      (message "occur highlights removed"))
      ((and (local-variable-p 'org-finish-function (current-buffer))
           (fboundp org-finish-function))
       (funcall org-finish-function))
@@ -14403,6 +14780,18 @@
      "--"
      ["Goto Calendar" org-goto-calendar t]
      ["Date from Calendar" org-date-from-calendar t])
+    ("Logging work"
+     ["Clock in" org-clock-in t]
+     ["Clock out" org-clock-out t]
+     ["Clock cancel" org-clock-cancel t]
+     ["Display times" org-clock-display t]
+     "--"
+     ["Record DONE time"
+      (progn (setq org-log-done (not org-log-done))
+            (message "Switching to %s will %s record a timestamp"
+                     org-done-string
+                     (if org-log-done "automatically" "not")))
+      :style toggle :selected org-log-done])
     "--"
     ["Agenda Command" org-agenda t]
     ("File List for Agenda")
@@ -14429,25 +14818,7 @@
       (save-excursion (goto-char (point-min)) 
                      (re-search-forward "<[a-z]+:" nil t))])
     "--"
-    ("Export"
-     ["ASCII" org-export-as-ascii t]
-     ["Export visible part..." org-export-visible t]
-     ["HTML"  org-export-as-html t]
-     ["HTML and Open" org-export-as-html-and-open t]
-     ["XOXO" org-export-as-xoxo t]
-     "--"
-     ["iCalendar this file" org-export-icalendar-this-file t]
-     ["iCalendar all agenda files" org-export-icalendar-all-agenda-files
-      :active t :keys "C-c C-x C-i"]
-     ["iCalendar combined" org-export-icalendar-combine-agenda-files t]
-     "--"
-     ["Option Template" org-insert-export-options-template t]
-     ["Toggle Fixed Width" org-toggle-fixed-width-section t])
-    ("Publish"
-     ["Current File" org-publish-current-file t]
-     ["Current Project" org-publish-current-project t]
-     ["Project..." org-publish t]
-     ["All Projects" org-publish-all t])
+    ["Export/Publish" org-export t]
     "--"
     ("Documentation"
      ["Show Version" org-version t]
@@ -14649,6 +15020,7 @@
   ;; But only if the user has not turned off tables or fixed-width regions
   (set (make-local-variable 'auto-fill-inhibit-regexp)
        (concat "\\*\\|#"
+              "\\|[ \t]*" org-keyword-time-regexp
               (if (or org-enable-table-editor org-enable-fixed-width-editor)
                   (concat
                    "\\|[ \t]*["
@@ -14968,10 +15340,5 @@
 
 (run-hooks 'org-load-hook)
 
-
 ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd
 ;;; org.el ends here
-
-
-
-      




reply via email to

[Prev in Thread] Current Thread [Next in Thread]