Browse Source

Merge branch 'master' of orgmode.org:org-mode

Eric Schulte 14 years ago
parent
commit
bb2dd85938
10 changed files with 112 additions and 90 deletions
  1. 12 7
      lisp/org-agenda.el
  2. 8 3
      lisp/org-attach.el
  3. 9 5
      lisp/org-clock.el
  4. 2 3
      lisp/org-exp.el
  5. 2 2
      lisp/org-footnote.el
  6. 25 24
      lisp/org-html.el
  7. 22 12
      lisp/org-list.el
  8. 5 7
      lisp/org-macs.el
  9. 4 5
      lisp/org-timer.el
  10. 23 22
      lisp/org.el

+ 12 - 7
lisp/org-agenda.el

@@ -3492,7 +3492,7 @@ given in `org-agenda-start-on-weekday'."
   (setq org-agenda-last-arguments (list include-all start-day span))
   (setq org-agenda-last-arguments (list include-all start-day span))
   (org-compile-prefix-format 'agenda)
   (org-compile-prefix-format 'agenda)
   (org-set-sorting-strategy 'agenda)
   (org-set-sorting-strategy 'agenda)
-  (let* ((span (org-agenda-ndays-to-span 
+  (let* ((span (org-agenda-ndays-to-span
 		(or span org-agenda-ndays org-agenda-span)))
 		(or span org-agenda-ndays org-agenda-span)))
 	 (today (org-today))
 	 (today (org-today))
 	 (sd (or start-day today))
 	 (sd (or start-day today))
@@ -4339,7 +4339,7 @@ of what a project is and how to check if it stuck, customize the variable
 	  (if (zerop (buffer-size))
 	  (if (zerop (buffer-size))
 	      (setq entries nil)
 	      (setq entries nil)
 	    (setq entries (buffer-substring (point-min) (- (point-max) 1)))
 	    (setq entries (buffer-substring (point-min) (- (point-max) 1)))
-	    (setq entries 
+	    (setq entries
 		  (with-temp-buffer
 		  (with-temp-buffer
 		    (insert entries) (goto-char (point-min))
 		    (insert entries) (goto-char (point-min))
 		    (while (re-search-forward "\n[ \t]+\\(.+\\)$" nil t)
 		    (while (re-search-forward "\n[ \t]+\\(.+\\)$" nil t)
@@ -4702,7 +4702,7 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
 	    b3 (match-beginning 3) e3 (match-end 3)
 	    b3 (match-beginning 3) e3 (match-end 3)
 	    todo-state (save-match-data (ignore-errors (org-get-todo-state)))
 	    todo-state (save-match-data (ignore-errors (org-get-todo-state)))
 	    show-all (or (eq org-agenda-repeating-timestamp-show-all t)
 	    show-all (or (eq org-agenda-repeating-timestamp-show-all t)
-			 (member todo-state 
+			 (member todo-state
 				 org-agenda-repeating-timestamp-show-all)))
 				 org-agenda-repeating-timestamp-show-all)))
       (catch :skip
       (catch :skip
 	(and (org-at-date-range-p) (throw :skip nil))
 	(and (org-at-date-range-p) (throw :skip nil))
@@ -4956,7 +4956,7 @@ be skipped."
 	      pos (1- (match-beginning 1))
 	      pos (1- (match-beginning 1))
 	      todo-state (save-match-data (org-get-todo-state))
 	      todo-state (save-match-data (org-get-todo-state))
 	      show-all (or (eq org-agenda-repeating-timestamp-show-all t)
 	      show-all (or (eq org-agenda-repeating-timestamp-show-all t)
-			   (member todo-state 
+			   (member todo-state
 				    org-agenda-repeating-timestamp-show-all))
 				    org-agenda-repeating-timestamp-show-all))
 	      d2 (org-time-string-to-absolute
 	      d2 (org-time-string-to-absolute
 		  (match-string 1) d1 'past show-all)
 		  (match-string 1) d1 'past show-all)
@@ -5461,7 +5461,7 @@ The modified list may contain inherited tags, and tags matched by
 	   2 (length (car new)) 'face 'org-time-grid (car new))))
 	   2 (length (car new)) 'face 'org-time-grid (car new))))
       (when (and todayp org-agenda-show-current-time-in-grid)
       (when (and todayp org-agenda-show-current-time-in-grid)
 	(push (org-format-agenda-item
 	(push (org-format-agenda-item
-	       nil 
+	       nil
 	       org-agenda-current-time-string
 	       org-agenda-current-time-string
 	       "" nil
 	       "" nil
 	       (format-time-string "%H:%M "))
 	       (format-time-string "%H:%M "))
@@ -7918,7 +7918,7 @@ This is a command that has to be installed in `calendar-mode-map'."
 	(when (string-match regexp (get-text-property (point) 'txt))
 	(when (string-match regexp (get-text-property (point) 'txt))
 	  (setq entries-marked (+ entries-marked 1))
 	  (setq entries-marked (+ entries-marked 1))
 	  (call-interactively 'org-agenda-bulk-mark))))
 	  (call-interactively 'org-agenda-bulk-mark))))
-    (if (not entries-marked) 
+    (if (not entries-marked)
 	(message "No entry matching this regexp."))))
 	(message "No entry matching this regexp."))))
 
 
 (defun org-agenda-bulk-unmark ()
 (defun org-agenda-bulk-unmark ()
@@ -7969,7 +7969,7 @@ The prefix arg is passed through to the command if possible."
   (interactive "P")
   (interactive "P")
   (unless org-agenda-bulk-marked-entries
   (unless org-agenda-bulk-marked-entries
     (error "No entries are marked"))
     (error "No entries are marked"))
-  (message "Bulk: [r]efile [$]arch [A]rch->sib [t]odo [+/-]tag [s]chd [S]catter [d]eadline")
+  (message "Bulk: [r]efile [$]arch [A]rch->sib [t]odo [+/-]tag [s]chd [S]catter [d]eadline [f]unction")
   (let* ((action (read-char-exclusive))
   (let* ((action (read-char-exclusive))
 	 (org-log-refile (if org-log-refile 'time nil))
 	 (org-log-refile (if org-log-refile 'time nil))
 	 (entries (reverse org-agenda-bulk-marked-entries))
 	 (entries (reverse org-agenda-bulk-marked-entries))
@@ -8059,6 +8059,11 @@ The prefix arg is passed through to the command if possible."
 		       (org-agenda-date-later distance)
 		       (org-agenda-date-later distance)
 		     (error nil)))))))
 		     (error nil)))))))
 
 
+     ((equal action ?f)
+      (setq cmd (list (intern
+		       (org-icompleting-read "Function: "
+					     obarray 'fboundp t nil nil)))))
+
      (t (error "Invalid bulk action")))
      (t (error "Invalid bulk action")))
 
 
     ;; Sort the markers, to make sure that parents are handled before children
     ;; Sort the markers, to make sure that parents are handled before children

+ 8 - 3
lisp/org-attach.el

@@ -102,7 +102,10 @@ ln    create a hard link.  Note that this is not supported
 (defcustom org-attach-store-link-p nil
 (defcustom org-attach-store-link-p nil
   "Non-nil means store a link to a file when attaching it."
   "Non-nil means store a link to a file when attaching it."
   :group 'org-attach
   :group 'org-attach
-  :type 'boolean)
+  :type '(choice
+	  (const :tag "Don't store link" nil)
+	  (const :tag "Link to origin location" t)
+	  (const :tag "Link to the attach-dir location" 'attached)))
 
 
 ;;;###autoload
 ;;;###autoload
 (defun org-attach ()
 (defun org-attach ()
@@ -294,8 +297,10 @@ METHOD may be `cp', `mv', or `ln', default taken from `org-attach-method'."
        ((eq method 'ln) (add-name-to-file file fname)))
        ((eq method 'ln) (add-name-to-file file fname)))
       (org-attach-commit)
       (org-attach-commit)
       (org-attach-tag)
       (org-attach-tag)
-      (when org-attach-store-link-p 
-	(org-attach-store-link file))
+      (cond ((eq org-attach-store-link-p 'attached)
+	     (org-attach-store-link fname))
+	    ((eq org-attach-store-link-p t)
+	     (org-attach-store-link file)))
       (if visit-dir
       (if visit-dir
 	  (dired attach-dir)
 	  (dired attach-dir)
 	(message "File \"%s\" is now a task attachment." basename)))))
 	(message "File \"%s\" is now a task attachment." basename)))))

+ 9 - 5
lisp/org-clock.el

@@ -992,6 +992,7 @@ the clocking selection, associated with the letter `d'."
 	  ts selected-task target-pos (msg-extra "")
 	  ts selected-task target-pos (msg-extra "")
 	  (leftover (and (not org-clock-resolving-clocks)
 	  (leftover (and (not org-clock-resolving-clocks)
 			  org-clock-leftover-time)))
 			  org-clock-leftover-time)))
+
       (when (and org-clock-auto-clock-resolution
       (when (and org-clock-auto-clock-resolution
 		 (or (not interrupting)
 		 (or (not interrupting)
 		     (eq t org-clock-auto-clock-resolution))
 		     (eq t org-clock-auto-clock-resolution))
@@ -1000,11 +1001,17 @@ the clocking selection, associated with the letter `d'."
 	(setq org-clock-leftover-time nil)
 	(setq org-clock-leftover-time nil)
 	(let ((org-clock-clocking-in t))
 	(let ((org-clock-clocking-in t))
 	  (org-resolve-clocks)))	; check if any clocks are dangling
 	  (org-resolve-clocks)))	; check if any clocks are dangling
+
       (when (equal select '(4))
       (when (equal select '(4))
 	(setq selected-task (org-clock-select-task "Clock-in on task: "))
 	(setq selected-task (org-clock-select-task "Clock-in on task: "))
 	(if selected-task
 	(if selected-task
 	    (setq selected-task (copy-marker selected-task))
 	    (setq selected-task (copy-marker selected-task))
 	  (error "Abort")))
 	  (error "Abort")))
+
+      (when (equal select '(16))
+	;; Mark as default clocking task
+	(org-clock-mark-default-task))
+
       (when interrupting
       (when interrupting
 	;; We are interrupting the clocking of a different task.
 	;; We are interrupting the clocking of a different task.
 	;; Save a marker to this task, so that we can go back.
 	;; Save a marker to this task, so that we can go back.
@@ -1019,7 +1026,8 @@ the clocking selection, associated with the letter `d'."
 		     (= (marker-position org-clock-hd-marker)
 		     (= (marker-position org-clock-hd-marker)
 			(if selected-task
 			(if selected-task
 			    (marker-position selected-task)
 			    (marker-position selected-task)
-			  (point)))))
+			  (point)))
+		     (equal org-clock-current-task (nth 4 (org-heading-components)))))
 	  (message "Clock continues in \"%s\"" org-clock-heading)
 	  (message "Clock continues in \"%s\"" org-clock-heading)
 	  (throw 'abort nil))
 	  (throw 'abort nil))
 	(move-marker org-clock-interrupted-task
 	(move-marker org-clock-interrupted-task
@@ -1028,10 +1036,6 @@ the clocking selection, associated with the letter `d'."
 	(let ((org-clock-clocking-in t))
 	(let ((org-clock-clocking-in t))
 	  (org-clock-out t)))
 	  (org-clock-out t)))
 
 
-      (when (equal select '(16))
-	;; Mark as default clocking task
-	(org-clock-mark-default-task))
-
       ;; Clock in at which position?
       ;; Clock in at which position?
       (setq target-pos
       (setq target-pos
 	    (if (and (eobp) (not (org-on-heading-p)))
 	    (if (and (eobp) (not (org-on-heading-p)))

+ 2 - 3
lisp/org-exp.el

@@ -1042,7 +1042,7 @@ Pressing `1' will switch between these two options."
   "Alist of code references and line numbers.")
   "Alist of code references and line numbers.")
 
 
 (defun org-export-preprocess-string (string &rest parameters)
 (defun org-export-preprocess-string (string &rest parameters)
-  "Cleanup STRING so that that the true exported has a more consistent source.
+  "Cleanup STRING so that the true exported has a more consistent source.
 This function takes STRING, which should be a buffer-string of an org-file
 This function takes STRING, which should be a buffer-string of an org-file
 to export.  It then creates a temporary buffer where it does its job.
 to export.  It then creates a temporary buffer where it does its job.
 The result is then again returned as a string, and the exporter works
 The result is then again returned as a string, and the exporter works
@@ -2062,7 +2062,7 @@ can work correctly."
     (let* ((rtn
     (let* ((rtn
 	    (mapconcat
 	    (mapconcat
 	     'identity
 	     'identity
-	     (org-split-string s "[^a-zA-Z0-9_\\.-]+") "--"))
+	     (org-split-string s "[^a-zA-Z0-9_\\.-]+") "-"))
 	   (a (assoc rtn alist)))
 	   (a (assoc rtn alist)))
       (or (cdr a) rtn))))
       (or (cdr a) rtn))))
 
 
@@ -3084,4 +3084,3 @@ The depends on the variable `org-export-copy-to-kill'."
 ;; arch-tag: 65985fe9-095c-49c7-a7b6-cb4ee15c0a95
 ;; arch-tag: 65985fe9-095c-49c7-a7b6-cb4ee15c0a95
 
 
 ;;; org-exp.el ends here
 ;;; org-exp.el ends here
-

+ 2 - 2
lisp/org-footnote.el

@@ -314,7 +314,7 @@ or new, let the user edit the definition of the footnote."
     ;; Skip existing footnotes
     ;; Skip existing footnotes
     (while (re-search-forward "^[[:space:]]*\\[[^]]+\\] " nil t)
     (while (re-search-forward "^[[:space:]]*\\[[^]]+\\] " nil t)
       (forward-line))
       (forward-line))
-    (insert "[" label "] \n")
+    (insert "\n[" label "] \n")
     (goto-char (1- (point)))
     (goto-char (1- (point)))
     (message "Edit definition and go back with `C-c &' or, if unique, with `C-c C-c'.")))
     (message "Edit definition and go back with `C-c &' or, if unique, with `C-c C-c'.")))
 
 
@@ -500,7 +500,7 @@ ENTRY is (fn-label num-mark definition)."
     (when (re-search-forward (format ".\\[%s[]:]" (regexp-quote (car entry)))
     (when (re-search-forward (format ".\\[%s[]:]" (regexp-quote (car entry)))
 			     nil t)
 			     nil t)
       (org-footnote-goto-local-insertion-point)
       (org-footnote-goto-local-insertion-point)
-      (insert (format "\n\n[%s] %s" (car entry) (nth 2 entry))))))
+      (insert (format "\n[%s] %s\n" (car entry) (nth 2 entry))))))
 
 
 (defun org-footnote-goto-local-insertion-point ()
 (defun org-footnote-goto-local-insertion-point ()
   "Find insertion point for footnote, just before next outline heading."
   "Find insertion point for footnote, just before next outline heading."

+ 25 - 24
lisp/org-html.el

@@ -826,9 +826,9 @@ MAY-INLINE-P allows inlining it as an image."
 	       (message "image %s %s" thefile org-par-open)
 	       (message "image %s %s" thefile org-par-open)
 	       (org-export-html-format-image thefile org-par-open))
 	       (org-export-html-format-image thefile org-par-open))
 	    (concat
 	    (concat
-	       "<a href=\"" thefile "\"" (if attr (concat " " attr)) ">"
+	       "@<a href=\"" thefile "\"" (if attr (concat " " attr)) ">"
 	       (org-export-html-format-desc desc)
 	       (org-export-html-format-desc desc)
-	       "</a>")))))
+	       "@</a>")))))
 
 
 (defun org-html-handle-links (line opt-plist)
 (defun org-html-handle-links (line opt-plist)
   "Return LINE with markup of Org mode links.
   "Return LINE with markup of Org mode links.
@@ -864,7 +864,7 @@ OPT-PLIST is the export options list."
 	  (if (string-match "^file:" desc)
 	  (if (string-match "^file:" desc)
 	      (setq desc (substring desc (match-end 0)))))
 	      (setq desc (substring desc (match-end 0)))))
 	(setq desc (org-add-props
 	(setq desc (org-add-props
-		       (concat "<img src=\"" desc "\"/>")
+		       (concat "@<img src=\"" desc "\"/>")
 		       '(org-protected t))))
 		       '(org-protected t))))
       (cond
       (cond
        ((equal type "internal")
        ((equal type "internal")
@@ -990,9 +990,9 @@ OPT-PLIST is the export options list."
 
 
        (t
        (t
 	;; just publish the path, as default
 	;; just publish the path, as default
-	(setq rpl (concat "<i>&lt;" type ":"
+	(setq rpl (concat "@<i>&lt;" type ":"
 			  (save-match-data (org-link-unescape path))
 			  (save-match-data (org-link-unescape path))
-			  "&gt;</i>"))))
+			  "&gt;@</i>"))))
       (setq line (replace-match rpl t t line)
       (setq line (replace-match rpl t t line)
 	    start (+ start (length rpl))))
 	    start (+ start (length rpl))))
     line))
     line))
@@ -1289,7 +1289,7 @@ lang=\"%s\" xml:lang=\"%s\">
 				   `((?t . ,title)
 				   `((?t . ,title)
 				     (?a . ,author) (?d . ,date) (?e . ,email)))))
 				     (?a . ,author) (?d . ,date) (?e . ,email)))))
 	  (insert  "<h1 class=\"title\">" title "</h1>")))
 	  (insert  "<h1 class=\"title\">" title "</h1>")))
-      
+
       (if (and org-export-with-toc (not body-only))
       (if (and org-export-with-toc (not body-only))
 	  (progn
 	  (progn
 	    (push (format "<h%d>%s</h%d>\n"
 	    (push (format "<h%d>%s</h%d>\n"
@@ -1504,17 +1504,17 @@ lang=\"%s\" xml:lang=\"%s\">
 				  "@</a> ")
 				  "@</a> ")
 			  t t line)))))
 			  t t line)))))
 
 
+	  ;; Format the links
+	  (setq line (org-html-handle-links line opt-plist))
+
+	  (setq line (org-html-handle-time-stamps line))
+
 	  ;; replace "&" by "&amp;", "<" and ">" by "&lt;" and "&gt;"
 	  ;; replace "&" by "&amp;", "<" and ">" by "&lt;" and "&gt;"
 	  ;; handle @<..> HTML tags (replace "@&gt;..&lt;" by "<..>")
 	  ;; handle @<..> HTML tags (replace "@&gt;..&lt;" by "<..>")
 	  ;; Also handle sub_superscripts and checkboxes
 	  ;; Also handle sub_superscripts and checkboxes
 	  (or (string-match org-table-hline-regexp line)
 	  (or (string-match org-table-hline-regexp line)
 	      (setq line (org-html-expand line)))
 	      (setq line (org-html-expand line)))
 
 
-	  ;; Format the links
-	  (setq line (org-html-handle-links line opt-plist))
-
-	  (setq line (org-html-handle-time-stamps line))
-
 	  ;; TODO items
 	  ;; TODO items
 	  (if (and (string-match org-todo-line-regexp line)
 	  (if (and (string-match org-todo-line-regexp line)
 		   (match-beginning 2))
 		   (match-beginning 2))
@@ -1705,7 +1705,8 @@ lang=\"%s\" xml:lang=\"%s\">
 	  (when (and (plist-get opt-plist :author-info) author)
 	  (when (and (plist-get opt-plist :author-info) author)
 	    (insert "<p class=\"author\">" (nth 1 lang-words) ": " author "</p>\n"))
 	    (insert "<p class=\"author\">" (nth 1 lang-words) ": " author "</p>\n"))
 	  (when (and (plist-get opt-plist :email-info) email)
 	  (when (and (plist-get opt-plist :email-info) email)
-	    (insert "<p class=\"mailto:" email "\">&lt;" email "&gt;</p>\n"))
+	    (insert "<p class=\"email\"><a href=\"mailto:"
+		    email "\">&lt;" email "&gt;</a></p>\n"))
 	  (when (plist-get opt-plist :creator-info)
 	  (when (plist-get opt-plist :creator-info)
 	    (insert "<p class=\"creator\">"
 	    (insert "<p class=\"creator\">"
 		    (concat "Org version " org-version " with Emacs version "
 		    (concat "Org version " org-version " with Emacs version "
@@ -1715,7 +1716,7 @@ lang=\"%s\" xml:lang=\"%s\">
       (if org-export-html-with-timestamp
       (if org-export-html-with-timestamp
 	  (insert org-export-html-html-helper-timestamp))
 	  (insert org-export-html-html-helper-timestamp))
 
 
-      (insert "\n</div>\n</body>\n</html>\n")
+      (unless body-only (insert "\n</div>\n</body>\n</html>\n"))
 
 
       (unless (plist-get opt-plist :buffer-will-be-killed)
       (unless (plist-get opt-plist :buffer-will-be-killed)
 	(normal-mode)
 	(normal-mode)
@@ -1996,8 +1997,8 @@ for formatting.  This is required for the DocBook exporter."
       ;; DocBook document, we want to always include the caption to make
       ;; DocBook document, we want to always include the caption to make
       ;; DocBook XML file valid.
       ;; DocBook XML file valid.
       (push (format "<caption>%s</caption>" (or caption "")) html)
       (push (format "<caption>%s</caption>" (or caption "")) html)
-      (when label (push (format "<a name=\"%s\" id=\"%s\"></a>" (org-solidify-link-text label) (org-solidify-link-text label))
-			html))
+      (when label
+	      (setq html-table-tag (org-export-splice-attributes html-table-tag (format "id=\"%s\"" (org-solidify-link-text label)))))
       (push html-table-tag html))
       (push html-table-tag html))
     (setq html (mapcar
     (setq html (mapcar
 		(lambda (x)
 		(lambda (x)
@@ -2112,14 +2113,14 @@ But it has the disadvantage, that Org-mode's HTML conversions cannot be used."
 	(or b (setq b (substring s 0 (match-beginning 0))))
 	(or b (setq b (substring s 0 (match-beginning 0))))
 	(setq r (concat
 	(setq r (concat
 		 r (substring s 0 (match-beginning 0))
 		 r (substring s 0 (match-beginning 0))
-		 " <span class=\"timestamp-wrapper\">"
+		 " @<span class=\"timestamp-wrapper\">"
 		 (if (match-end 1)
 		 (if (match-end 1)
-		     (format "<span class=\"timestamp-kwd\">%s </span>"
+		     (format "@<span class=\"timestamp-kwd\">%s @</span>"
 			     (match-string 1 s)))
 			     (match-string 1 s)))
-		 (format " <span class=\"timestamp\">%s</span>"
+		 (format " @<span class=\"timestamp\">%s@</span>"
 			 (substring
 			 (substring
 			  (org-translate-time (match-string 3 s)) 1 -1))
 			  (org-translate-time (match-string 3 s)) 1 -1))
-		 "</span>")
+		 "@</span>")
 	      s (substring s (match-end 0))))
 	      s (substring s (match-end 0))))
       ;; Line break if line started and ended with time stamp stuff
       ;; Line break if line started and ended with time stamp stuff
       (if (not r)
       (if (not r)
@@ -2181,12 +2182,12 @@ that uses these same face definitions."
 (defun org-html-protect (s)
 (defun org-html-protect (s)
   "Convert characters to HTML equivalent.
   "Convert characters to HTML equivalent.
 Possible conversions are set in `org-export-html-protect-char-alist'."
 Possible conversions are set in `org-export-html-protect-char-alist'."
-  (let ((start 0)
-	(cl org-export-html-protect-char-alist) c)
+  (let ((cl org-export-html-protect-char-alist) c)
     (while (setq c (pop cl))
     (while (setq c (pop cl))
-      (while (string-match (car c) s start)
-	(setq s (replace-match (cdr c) t t s)
-	      start (1+ (match-beginning 0)))))
+      (let ((start 0))
+	(while (string-match (car c) s start)
+	  (setq s (replace-match (cdr c) t t s)
+		start (1+ (match-beginning 0))))))
     s))
     s))
 
 
 (defun org-html-expand (string)
 (defun org-html-expand (string)

+ 22 - 12
lisp/org-list.el

@@ -400,6 +400,17 @@ group 4: description tag")
            (goto-char (match-end 0)))
            (goto-char (match-end 0)))
 	 (looking-at regexp))))
 	 (looking-at regexp))))
 
 
+(defun org-list-in-valid-block-p ()
+  "Non-nil if point is in a valid block.
+Invalid blocks are referring to `org-list-forbidden-blocks'."
+  (save-match-data
+    (let ((case-fold-search t))
+      (not (org-in-regexps-block-p
+	    (concat "^[ \t]*#\\+begin_\\("
+		    (mapconcat 'regexp-quote org-list-forbidden-blocks "\\|")
+		    "\\)")
+	    '(concat "^[ \t]*#\\+end_" (match-string 1)))))))
+
 (defun org-in-item-p ()
 (defun org-in-item-p ()
   "Return item beginning position when in a plain list, nil otherwise.
   "Return item beginning position when in a plain list, nil otherwise.
 This checks `org-list-ending-method'."
 This checks `org-list-ending-method'."
@@ -476,8 +487,7 @@ This checks `org-list-ending-method'."
   "Is point in a line starting a hand-formatted item?"
   "Is point in a line starting a hand-formatted item?"
   (save-excursion
   (save-excursion
     (beginning-of-line)
     (beginning-of-line)
-    (and (looking-at (org-item-re))
-	 (not (eq (nth 2 (org-list-context)) 'invalid)))))
+    (and (looking-at (org-item-re)) (org-list-in-valid-block-p))))
 
 
 (defun org-at-item-bullet-p ()
 (defun org-at-item-bullet-p ()
   "Is point at the bullet of a plain list item?"
   "Is point at the bullet of a plain list item?"
@@ -1037,9 +1047,9 @@ in `re-search-forward'."
 	(unless (funcall search re bound noerr)
 	(unless (funcall search re bound noerr)
 	  (throw 'exit (and (goto-char (if (memq noerr '(t nil)) origin bound))
 	  (throw 'exit (and (goto-char (if (memq noerr '(t nil)) origin bound))
 			    nil)))
 			    nil)))
-	;; 2. Match in an `invalid' context: continue searching. Else,
-	;;    return point.
-	(unless (eq (org-list-context) 'invalid) (throw 'exit (point)))))))
+	;; 2. Match in valid context: return point. Else, continue
+	;;    searching.
+	(when (org-list-in-valid-block-p) (throw 'exit (point)))))))
 
 
 (defun org-list-search-backward (regexp &optional bound noerror)
 (defun org-list-search-backward (regexp &optional bound noerror)
   "Like `re-search-backward' but stop only where lists are recognized.
   "Like `re-search-backward' but stop only where lists are recognized.
@@ -1150,10 +1160,10 @@ This function modifies STRUCT."
 	   ;;    BEFOREP and SPLIT-LINE-P. The difference of size
 	   ;;    BEFOREP and SPLIT-LINE-P. The difference of size
 	   ;;    between what was cut and what was inserted in buffer
 	   ;;    between what was cut and what was inserted in buffer
 	   ;;    is stored in SIZE-OFFSET.
 	   ;;    is stored in SIZE-OFFSET.
-	   (ind (let ((ind-ref (org-list-get-ind item struct)))
-		  (if (not indent-tabs-mode)
-		      ind-ref
-		    (+ (/ ind-ref tab-width) (mod ind-ref tab-width)))))
+	   (ind (org-list-get-ind item struct))
+	   (ind-size (if indent-tabs-mode
+			 (+ (/ ind tab-width) (mod ind tab-width))
+		       ind))
 	   (bullet (org-list-bullet-string (org-list-get-bullet item struct)))
 	   (bullet (org-list-bullet-string (org-list-get-bullet item struct)))
 	   (box (when checkbox "[ ]"))
 	   (box (when checkbox "[ ]"))
 	   (text-cut
 	   (text-cut
@@ -1170,7 +1180,7 @@ This function modifies STRUCT."
 				    text-cut))
 				    text-cut))
 			     "")))
 			     "")))
 	   (item-sep (make-string  (1+ blank-nb) ?\n))
 	   (item-sep (make-string  (1+ blank-nb) ?\n))
-	   (item-size (+ ind (length body) (length item-sep)))
+	   (item-size (+ ind-size (length body) (length item-sep)))
 	   (size-offset (- item-size (length text-cut))))
 	   (size-offset (- item-size (length text-cut))))
       ;; 4. Insert effectively item into buffer
       ;; 4. Insert effectively item into buffer
       (goto-char item)
       (goto-char item)
@@ -2097,8 +2107,8 @@ in subtree, ignoring drawers."
 		 ((equal toggle-presence '(16)) "[-]")
 		 ((equal toggle-presence '(16)) "[-]")
 		 ((equal toggle-presence '(4))
 		 ((equal toggle-presence '(4))
 		  (unless cbox "[ ]"))
 		  (unless cbox "[ ]"))
-		 ((equal "[ ]" cbox) "[X]")
-		 (t "[ ]"))))))
+		 ((equal "[X]" cbox) "[ ]")
+		 (t "[X]"))))))
       ;; When an item is found within bounds, grab the full list at
       ;; When an item is found within bounds, grab the full list at
       ;; point structure, then: 1. set checkbox of all its items
       ;; point structure, then: 1. set checkbox of all its items
       ;; within bounds to ref-checkbox; 2. fix checkboxes of the whole
       ;; within bounds to ref-checkbox; 2. fix checkboxes of the whole

+ 5 - 7
lisp/org-macs.el

@@ -334,13 +334,11 @@ point nowhere."
 	       data)))))
 	       data)))))
 
 
 (defmacro org-with-wide-buffer (&rest body)
 (defmacro org-with-wide-buffer (&rest body)
-  "Execute body while temporarily widening the buffer."
-  `(let ((beg (point-min)) (end (point-max)) (pos (point)))
-     (prog2
-	 (widen)
-	 ,@body
-       (narrow-to-region beg end)
-       (goto-char pos))))
+ "Execute body while temporarily widening the buffer."
+ `(save-excursion
+    (save-restriction
+       (widen)
+       ,@body)))
 
 
 (defmacro org-with-limited-levels (&rest body)
 (defmacro org-with-limited-levels (&rest body)
   "Execute BODY with limited number of outline levels."
   "Execute BODY with limited number of outline levels."

+ 4 - 5
lisp/org-timer.el

@@ -207,21 +207,20 @@ it in the buffer."
 (defun org-timer-item (&optional arg)
 (defun org-timer-item (&optional arg)
   "Insert a description-type item with the current timer value."
   "Insert a description-type item with the current timer value."
   (interactive "P")
   (interactive "P")
-  (let ((itemp (org-in-item-p)))
+  (let ((itemp (org-in-item-p)) (pos (point)))
     (cond
     (cond
      ;; In a timer list, insert with `org-list-insert-item',
      ;; In a timer list, insert with `org-list-insert-item',
      ;; then fix the list.
      ;; then fix the list.
-     ((and itemp
-	   (save-excursion (goto-char itemp) (org-at-item-timer-p)))
+     ((and itemp (goto-char itemp) (org-at-item-timer-p))
       (let* ((struct (org-list-struct))
       (let* ((struct (org-list-struct))
 	     (prevs (org-list-prevs-alist struct))
 	     (prevs (org-list-prevs-alist struct))
 	     (s (concat (org-timer (when arg '(4)) t) ":: ")))
 	     (s (concat (org-timer (when arg '(4)) t) ":: ")))
-	(setq struct (org-list-insert-item (point) struct prevs nil s))
+	(setq struct (org-list-insert-item pos struct prevs nil s))
 	(org-list-write-struct struct (org-list-parents-alist struct))
 	(org-list-write-struct struct (org-list-parents-alist struct))
 	(looking-at org-list-full-item-re)
 	(looking-at org-list-full-item-re)
 	(goto-char (match-end 0))))
 	(goto-char (match-end 0))))
      ;; In a list of another type, don't break anything: throw an error.
      ;; In a list of another type, don't break anything: throw an error.
-     (itemp (error "This is not a timer list"))
+     (itemp (goto-char pos) (error "This is not a timer list"))
      ;; Else, start a new list.
      ;; Else, start a new list.
      (t
      (t
       (beginning-of-line)
       (beginning-of-line)

+ 23 - 22
lisp/org.el

@@ -10390,7 +10390,7 @@ This can be done with a 0 prefix: `C-0 C-c C-w'"
 (defun org-refile-get-location (&optional prompt default-buffer new-nodes)
 (defun org-refile-get-location (&optional prompt default-buffer new-nodes)
   "Prompt the user for a refile location, using PROMPT.
   "Prompt the user for a refile location, using PROMPT.
 PROMPT should not be suffixed with a colon and a space, because
 PROMPT should not be suffixed with a colon and a space, because
-this function appends the default value from 
+this function appends the default value from
 `org-refile-history' automatically, if that is not empty."
 `org-refile-history' automatically, if that is not empty."
   (let ((org-refile-targets org-refile-targets)
   (let ((org-refile-targets org-refile-targets)
 	(org-refile-use-outline-path org-refile-use-outline-path))
 	(org-refile-use-outline-path org-refile-use-outline-path))
@@ -13402,7 +13402,8 @@ but in some other way.")
   '("ARCHIVE" "CATEGORY" "SUMMARY" "DESCRIPTION" "CUSTOM_ID"
   '("ARCHIVE" "CATEGORY" "SUMMARY" "DESCRIPTION" "CUSTOM_ID"
     "LOCATION" "LOGGING" "COLUMNS" "VISIBILITY"
     "LOCATION" "LOGGING" "COLUMNS" "VISIBILITY"
     "TABLE_EXPORT_FORMAT" "TABLE_EXPORT_FILE"
     "TABLE_EXPORT_FORMAT" "TABLE_EXPORT_FILE"
-    "EXPORT_FILE_NAME" "EXPORT_TITLE" "EXPORT_AUTHOR" "EXPORT_DATE"
+    "EXPORT_OPTIONS" "EXPORT_TEXT" "EXPORT_FILE_NAME"
+    "EXPORT_TITLE" "EXPORT_AUTHOR" "EXPORT_DATE"
     "ORDERED" "NOBLOCKING" "COOKIE_DATA" "LOG_INTO_DRAWER" "REPEAT_TO_STATE"
     "ORDERED" "NOBLOCKING" "COOKIE_DATA" "LOG_INTO_DRAWER" "REPEAT_TO_STATE"
     "CLOCK_MODELINE_TOTAL" "STYLE" "HTML_CONTAINER_CLASS")
     "CLOCK_MODELINE_TOTAL" "STYLE" "HTML_CONTAINER_CLASS")
   "Some properties that are used by Org-mode for various purposes.
   "Some properties that are used by Org-mode for various purposes.
@@ -13853,7 +13854,8 @@ and the new value.")
 With INCLUDE-SPECIALS, also list the special properties that reflect things
 With INCLUDE-SPECIALS, also list the special properties that reflect things
 like tags and TODO state.
 like tags and TODO state.
 With INCLUDE-DEFAULTS, also include properties that has special meaning
 With INCLUDE-DEFAULTS, also include properties that has special meaning
-internally: ARCHIVE, CATEGORY, SUMMARY, DESCRIPTION, LOCATION, and LOGGING.
+internally: ARCHIVE, CATEGORY, SUMMARY, DESCRIPTION, LOCATION, and LOGGING
+and others.
 With INCLUDE-COLUMNS, also include property names given in COLUMN
 With INCLUDE-COLUMNS, also include property names given in COLUMN
 formats in the current buffer."
 formats in the current buffer."
   (let (rtn range cfmt s p)
   (let (rtn range cfmt s p)
@@ -15553,7 +15555,7 @@ customizing `org-effort-durations' (which see).
 Entries containing a colon are interpreted as H:MM by
 Entries containing a colon are interpreted as H:MM by
 `org-hh:mm-string-to-minutes'."
 `org-hh:mm-string-to-minutes'."
   (let ((result 0)
   (let ((result 0)
-	(re (concat "\\([0-9]+\\) *\\(" 
+	(re (concat "\\([0-9]+\\) *\\("
 		    (regexp-opt (mapcar 'car org-effort-durations))
 		    (regexp-opt (mapcar 'car org-effort-durations))
 		    "\\)")))
 		    "\\)")))
     (while (string-match re s)
     (while (string-match re s)
@@ -17512,8 +17514,8 @@ This command does many different things, depending on context:
 			       (cond
 			       (cond
 				((equal arg '(16)) "[-]")
 				((equal arg '(16)) "[-]")
 				((equal arg '(4)) nil)
 				((equal arg '(4)) nil)
-				((equal "[ ]" cbox) "[X]")
-				(t "[ ]")))
+				((equal "[X]" cbox) "[ ]")
+				(t "[X]")))
 	(org-list-struct-fix-ind struct parents)
 	(org-list-struct-fix-ind struct parents)
 	(org-list-struct-fix-bul struct prevs)
 	(org-list-struct-fix-bul struct prevs)
 	(setq block-item
 	(setq block-item
@@ -18773,10 +18775,9 @@ Taken from `count' in cl-seq.el with all keyword arguments removed."
   "Move backwards over whitespace, to the beginning of the first empty line.
   "Move backwards over whitespace, to the beginning of the first empty line.
 Returns the number of empty lines passed."
 Returns the number of empty lines passed."
   (let ((pos (point)))
   (let ((pos (point)))
-    (skip-chars-backward " \t\n\r")
-    ;; (if (cdr (assoc 'heading org-blank-before-new-entry))
-    ;;    (skip-chars-backward " \t\n\r")
-    ;;   (forward-line -1))
+    (if (cdr (assoc 'heading org-blank-before-new-entry))
+       (skip-chars-backward " \t\n\r")
+      (forward-line -1))
     (beginning-of-line 2)
     (beginning-of-line 2)
     (goto-char (min (point) pos))
     (goto-char (min (point) pos))
     (count-lines (point) pos)))
     (count-lines (point) pos)))
@@ -18990,6 +18991,12 @@ If point is in an inline task, mark that task instead."
      ;; Literal examples
      ;; Literal examples
      ((looking-at "[ \t]*:[ \t]")
      ((looking-at "[ \t]*:[ \t]")
       (setq column (org-get-indentation))) ; do nothing
       (setq column (org-get-indentation))) ; do nothing
+     ;; Lists
+     ((ignore-errors (goto-char (org-in-item-p)))
+      (setq column (if itemp
+		       (org-get-indentation)
+		     (org-list-item-body-column (point))))
+      (goto-char pos))
      ;; Drawers
      ;; Drawers
      ((and (looking-at "[ \t]*:END:")
      ((and (looking-at "[ \t]*:END:")
 	   (save-excursion (re-search-backward org-drawer-regexp nil t)))
 	   (save-excursion (re-search-backward org-drawer-regexp nil t)))
@@ -19011,12 +19018,6 @@ If point is in an inline task, mark that task instead."
 		;; src blocks: let `org-edit-src-exit' handle them
 		;; src blocks: let `org-edit-src-exit' handle them
 		(org-get-indentation)
 		(org-get-indentation)
 	      (org-get-indentation (match-string 0)))))
 	      (org-get-indentation (match-string 0)))))
-     ;; Lists
-     ((ignore-errors (goto-char (org-in-item-p)))
-      (setq column (if itemp
-		       (org-get-indentation)
-		     (org-list-item-body-column (point))))
-      (goto-char pos))
      ;; This line has nothing special, look at the previous relevant
      ;; This line has nothing special, look at the previous relevant
      ;; line to compute indentation
      ;; line to compute indentation
      (t
      (t
@@ -19184,13 +19185,13 @@ the functionality can be provided as a fall-back.")
 	  ;; a paragraph adjacent to a list: make sure this paragraph
 	  ;; a paragraph adjacent to a list: make sure this paragraph
 	  ;; doesn't get merged with the end of the list by narrowing
 	  ;; doesn't get merged with the end of the list by narrowing
 	  ;; buffer first.
 	  ;; buffer first.
-	  ((save-excursion (fill-forward-paragraph -1)
+	  ((save-excursion (forward-paragraph -1)
 			   (setq itemp (org-in-item-p)))
 			   (setq itemp (org-in-item-p)))
 	   (let ((struct (save-excursion (goto-char itemp)
 	   (let ((struct (save-excursion (goto-char itemp)
 					 (org-list-struct))))
 					 (org-list-struct))))
 	     (save-restriction
 	     (save-restriction
 	       (narrow-to-region (org-list-get-bottom-point struct)
 	       (narrow-to-region (org-list-get-bottom-point struct)
-				 (save-excursion (fill-forward-paragraph 1)
+				 (save-excursion (forward-paragraph 1)
 						 (point)))
 						 (point)))
 	       (fill-paragraph justify) t)))
 	       (fill-paragraph justify) t)))
 	  ;; Else simply call `fill-paragraph'.
 	  ;; Else simply call `fill-paragraph'.
@@ -19207,15 +19208,15 @@ the functionality can be provided as a fall-back.")
        ;; Comment line
        ;; Comment line
        ((looking-at "#[ \t]+")
        ((looking-at "#[ \t]+")
 	(match-string-no-properties 0))
 	(match-string-no-properties 0))
+       ;; Plain list item
+       ((org-at-item-p)
+	(make-string (org-list-item-body-column (point-at-bol)) ?\ ))
        ;; Point is in a list after `backward-paragraph': original
        ;; Point is in a list after `backward-paragraph': original
        ;; point wasn't in the list, or filling would have been taken
        ;; point wasn't in the list, or filling would have been taken
        ;; care of by `org-auto-fill-function', but the list and the
        ;; care of by `org-auto-fill-function', but the list and the
        ;; real paragraph are not separated by a blank line. Thus, move
        ;; real paragraph are not separated by a blank line. Thus, move
        ;; point after the list to go back to real paragraph and
        ;; point after the list to go back to real paragraph and
-       ;; determine fill-prefix. If point is at an item, do not
-       ;; compute prefix and list structure, as first line of
-       ;; paragraph will be skipped anyway.
-       ((org-at-item-p) "")
+       ;; determine fill-prefix.
        ((setq itemp (org-in-item-p))
        ((setq itemp (org-in-item-p))
 	(goto-char itemp)
 	(goto-char itemp)
 	(let* ((struct (org-list-struct))
 	(let* ((struct (org-list-struct))