Browse Source

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

Carsten Dominik 14 years ago
parent
commit
d3432917ed
9 changed files with 104 additions and 65 deletions
  1. 2 1
      doc/org.texi
  2. 17 7
      lisp/ob.el
  3. 10 1
      lisp/org-agenda.el
  4. 15 1
      lisp/org-capture.el
  5. 8 6
      lisp/org-clock.el
  6. 1 1
      lisp/org-exp.el
  7. 16 16
      lisp/org-list.el
  8. 1 1
      lisp/org-publish.el
  9. 34 31
      lisp/org.el

+ 2 - 1
doc/org.texi

@@ -6316,7 +6316,8 @@ Specification of where the captured item should be placed.  In Org-mode
 files, targets usually define a node.  Entries will become children of this
 node.  Other types will be added to the table or list in the body of this
 node.  Most target specifications contain a file name.  If that file name is
-the empty string, it defaults to @code{org-default-notes-file}.
+the empty string, it defaults to @code{org-default-notes-file}.  A file can
+also be given as a variable, function, or Emacs Lisp form.
 
 Valid values are:
 @table @code

+ 17 - 7
lisp/ob.el

@@ -976,8 +976,11 @@ may be specified in the current buffer."
 			  (cdr (assoc :hlines params))
 			  (cdr (assoc :colnames params))
 			  (cdr (assoc :rownames params))))
+	 (raw-result (or (cdr (assoc :results params)) ""))
 	 (result-params (append
-			 (split-string (or (cdr (assoc :results params)) ""))
+			 (split-string (if (stringp raw-result)
+					   raw-result
+					 (eval raw-result)))
 			 (cdr (assoc :result-params params)))))
     (append
      (mapcar (lambda (var) (cons :var var)) (car vars-and-names))
@@ -1388,7 +1391,7 @@ following the source block."
 
 (defun org-babel-read-list ()
   "Read the list at `point' into emacs-lisp."
-  (mapcar #'org-babel-read (cdr (org-list-parse-list))))
+  (mapcar #'org-babel-read (mapcar #'cadr (cdr (org-list-parse-list)))))
 
 (defvar org-link-types-re)
 (defun org-babel-read-link ()
@@ -1516,9 +1519,13 @@ code ---- the results are extracted in the syntax of the source
 	 ((member "list" result-params)
 	  (insert
 	   (org-babel-trim
-	    (org-list-to-generic (cons 'unordered
-				       (if (listp result) result (list result)))
-				 '(:splicep nil :istart "- " :iend "\n")))))
+	    (org-list-to-generic
+	     (cons 'unordered
+		   (mapcar
+		    (lambda (el) (list nil (if (stringp el) el (format "%S" el))))
+		    (if (listp result) result (list result))))
+	     '(:splicep nil :istart "- " :iend "\n")))
+	   "\n"))
 	 ;; assume the result is a table if it's not a string
 	 ((not (stringp result))
 	  (goto-char beg)
@@ -1586,7 +1593,7 @@ code ---- the results are extracted in the syntax of the source
      ((org-at-table-p) (progn (goto-char (org-table-end)) (point)))
      ((org-at-item-p) (let* ((struct (org-list-struct))
 			     (prvs (org-list-prevs-alist struct)))
-			(1- (org-list-get-list-end (point-at-bol) struct prvs))))
+			(org-list-get-list-end (point-at-bol) struct prvs)))
      (t
       (let ((case-fold-search t)
 	    (blocks-re (regexp-opt
@@ -1703,7 +1710,10 @@ parameters when merging lists."
 				 vars))))))
 	      (:results
 	       (setq results (e-merge results-exclusive-groups
-				      results (split-string (cdr pair)))))
+				      results
+				      (split-string
+				       (let ((r (cdr pair)))
+					 (if (stringp r) r (eval r)))))))
 	      (:file
 	       (when (cdr pair)
 		 (setq results (e-merge results-exclusive-groups

+ 10 - 1
lisp/org-agenda.el

@@ -1765,6 +1765,7 @@ The following commands are available:
 (org-defkey org-agenda-mode-map "%"        'org-agenda-bulk-mark-regexp)
 (org-defkey org-agenda-mode-map "u"        'org-agenda-bulk-unmark)
 (org-defkey org-agenda-mode-map "U"        'org-agenda-bulk-remove-all-marks)
+(org-defkey org-agenda-mode-map "A"        'org-agenda-append-agenda)
 (org-defkey org-agenda-mode-map "B"        'org-agenda-bulk-action)
 (org-defkey org-agenda-mode-map "\C-c\C-x!" 'org-reload)
 (org-defkey org-agenda-mode-map "\C-c\C-x\C-a" 'org-agenda-archive-default)
@@ -2043,7 +2044,6 @@ The following commands are available:
 (defvar org-agenda-pending-undo-list nil
   "In a series of undo commands, this is the list of remaining undo items.")
 
-
 (defun org-agenda-undo ()
   "Undo a remote editing step in the agenda.
 This undoes changes both in the agenda buffer and in the remote buffer
@@ -2261,6 +2261,15 @@ Pressing `<' twice means to restrict to the current subtree or region
        ((equal keys "!") (customize-variable 'org-stuck-projects))
        (t (error "Invalid agenda key"))))))
 
+(defun org-agenda-append-agenda ()
+  "Append another agenda view to the current one.
+This function allows interactive building of block agendas.
+Agenda views are separated by `org-agenda-block-separator'."
+  (interactive)
+  (let ((org-agenda-multi t))
+    (org-agenda)
+    (widen)))
+
 (defun org-agenda-normalize-custom-commands (cmds)
   (delq nil
 	(mapcar

+ 15 - 1
lisp/org-capture.el

@@ -669,7 +669,9 @@ already gone.  Any prefix argument will be passed to the refile comand."
 	    (beginning-of-line 0))))
 
        ((eq (car target) 'file+olp)
-	(let ((m (org-find-olp (cdr target))))
+ 	(let ((m (org-find-olp
+		  (cons (org-capture-expand-file (nth 1 target))
+			(cddr target)))))
 	  (set-buffer (marker-buffer m))
 	  (goto-char m)))
 
@@ -729,8 +731,20 @@ already gone.  Any prefix argument will be passed to the refile comand."
       (org-capture-put :buffer (current-buffer) :pos (point)
 		       :target-entry-p target-entry-p))))
 
+(defun org-capture-expand-file (file)
+  "Expand functions and symbols for FILE.
+When FILE is a function, call it.  When it is a form, evaluate
+it.  When it is a variable, retrieve the value.  Return whatever we get."
+  (cond
+   ((org-string-nw-p file) file)
+   ((functionp file) (funcall file))
+   ((and (symbolp file) (boundp file)) (symbol-value file))
+   ((and file (consp file)) (eval file))
+   (t file)))
+
 (defun org-capture-target-buffer (file)
   "Get a buffer for FILE."
+  (setq file (org-capture-expand-file file))
   (setq file (or (org-string-nw-p file)
 		 org-default-notes-file
 		 (error "No notes file specified, and no default available")))

+ 8 - 6
lisp/org-clock.el

@@ -2021,13 +2021,15 @@ the currently selected interval size."
 TABLES is a list of tables with clocking data as produced by
 `org-clock-get-table-data'.  PARAMS is the parameter property list obtained
 from the dynamic block defintion."
-  ;; This function looks quite complicated, mainly because there are a lot
-  ;; of options which can add or remove columns.  I have massively commented
-  ;; function, to I hope it is understandable.  If someone want to write
-  ;; there own special formatter, this maybe much easier because there can
-  ;; be a fixed format with a well-defined number of columns...
+  ;; This function looks quite complicated, mainly because there are a
+  ;; lot of options which can add or remove columns.  I have massively
+  ;; commented this function, the I hope it is understandable.  If
+  ;; someone wants to write their own special formatter, this maybe
+  ;; much easier because there can be a fixed format with a
+  ;; well-defined number of columns...
   (let* ((hlchars '((1 . "*") (2 . "/")))
-	 (lwords (assoc (plist-get params :lang) 
+	 (lwords (assoc (or (plist-get params :lang) 
+			    org-export-default-language)
 			org-clock-clocktable-language-setup))
 	 (multifile (plist-get params :multifile))
 	 (block (plist-get params :block))

+ 1 - 1
lisp/org-exp.el

@@ -807,7 +807,7 @@ modified) list.")
 (defvar org-export-allow-BIND-local nil)
 (defun org-export-confirm-letbind ()
   "Can we use #+BIND values during export?
-By default this will ask fro confirmation by the user, to divert possible
+By default this will ask for confirmation by the user, to divert possible
 security risks."
   (cond
    ((not org-export-allow-BIND) nil)

+ 16 - 16
lisp/org-list.el

@@ -121,6 +121,7 @@
 (declare-function org-trim "org" (s))
 (declare-function org-uniquify "org" (list))
 (declare-function outline-invisible-p "outline" (&optional pos))
+(declare-function outline-flag-region "outline" (from to flag))
 (declare-function outline-next-heading "outline" ())
 (declare-function outline-previous-heading "outline" ())
 
@@ -1597,6 +1598,7 @@ Initial position of cursor is restored after the changes."
 	 (inlinetask-re (and (featurep 'org-inlinetask)
 			     (org-inlinetask-outline-regexp)))
 	 (item-re (org-item-re))
+	 (box-rule-p (cdr (assq 'checkbox org-list-automatic-rules)))
 	 (shift-body-ind
 	  (function
 	   ;; Shift the indentation between END and BEG by DELTA.
@@ -1635,9 +1637,8 @@ Initial position of cursor is restored after the changes."
 		 (replace-match new-bul nil nil nil 1))
 	       ;; b. Replace checkbox
 	       (cond
-		((and new-box
-		      (save-match-data (org-at-item-description-p))
-		      (cdr (assq 'checkbox org-list-automatic-rules)))
+		((and new-box box-rule-p
+		      (save-match-data (org-at-item-description-p)))
 		 (message "Cannot add a checkbox to a description list item"))
 		((equal (match-string 3) new-box))
 		((and (match-string 3) new-box)
@@ -2476,15 +2477,16 @@ Return t at each successful move."
 	   (struct (org-list-struct))
 	   (ind (org-list-get-ind (point-at-bol) struct))
 	   (bullet (org-list-get-bullet (point-at-bol) struct)))
-      ;; Check that item is really empty
-      (when (and (save-excursion
-		   (beginning-of-line)
-		   (looking-at org-list-full-item-re))
-		 (>= (match-end 0) (save-excursion
-				     (goto-char (org-list-get-item-end
-						 (point-at-bol) struct))
-				     (skip-chars-backward " \r\t\n")
-				     (point))))
+      ;; Accept empty items or if cycle has already started.
+      (when (or (eq last-command 'org-cycle-item-indentation)
+		(and (save-excursion
+		       (beginning-of-line)
+		       (looking-at org-list-full-item-re))
+		     (>= (match-end 0) (save-excursion
+					 (goto-char (org-list-get-item-end
+						     (point-at-bol) struct))
+					 (skip-chars-backward " \r\t\n")
+					 (point)))))
 	(setq this-command 'org-cycle-item-indentation)
 	;; When in the middle of the cycle, try to outdent first. If it
 	;; fails, and point is still at initial position, indent. Else,
@@ -2494,11 +2496,9 @@ Return t at each successful move."
 	     ((ignore-errors (org-list-indent-item-generic -1 t struct)))
 	     ((and (= ind (car org-tab-ind-state))
 		   (ignore-errors (org-list-indent-item-generic 1 t struct))))
-	     (t (back-to-indentation)
+	     (t (delete-region (point-at-bol) (point-at-eol))
 		(org-indent-to-column (car org-tab-ind-state))
-		(looking-at "\\S-+")
-		(replace-match (cdr org-tab-ind-state))
-		(end-of-line)
+		(insert (cdr org-tab-ind-state))
 		;; Break cycle
 		(setq this-command 'identity)))
 	  ;; If a cycle is starting, remember indentation and bullet,

+ 1 - 1
lisp/org-publish.el

@@ -295,7 +295,7 @@ You could use brackets to delimit on what part the link will be.
   "Return t if FILENAME should be published in PUB-DIR using PUB-FUNC.
 TRUE-PUB-DIR is where the file will truly end up.  Currently we are not using
 this - maybe it can eventually be used to check if the file is present at
-the target location, and how old it is.  Right ow we cannot do this, because
+the target location, and how old it is.  Right now we cannot do this, because
 we do not know under what file name the file will be stored - the publishing
 function can still decide about that independently."
   (let ((rtn

+ 34 - 31
lisp/org.el

@@ -2382,7 +2382,7 @@ a subtree."
   "Return the value of `org-log-into-drawer', but let properties overrule.
 If the current entry has or inherits a LOG_INTO_DRAWER property, it will be
 used instead of the default value."
-  (let ((p (ignore-errors (org-entry-get nil "LOG_INTO_DRAWER" 'inherit))))
+  (let ((p (org-entry-get nil "LOG_INTO_DRAWER" 'inherit)))
     (cond
      ((or (not p) (equal p "nil")) org-log-into-drawer)
      ((equal p "t") "LOGBOOK")
@@ -8416,7 +8416,7 @@ For file links, arg negates `org-context-in-file-links'."
 	       link (org-make-link cpltxt))))
 
       ((and (buffer-file-name (buffer-base-buffer)) (org-mode-p))
-       (setq custom-id (ignore-errors (org-entry-get nil "CUSTOM_ID")))
+       (setq custom-id (org-entry-get nil "CUSTOM_ID"))
        (cond
 	((org-in-regexp "<<\\(.*?\\)>>")
 	 (setq cpltxt
@@ -12275,7 +12275,7 @@ Can be set by the action argument to `org-scan-tag's and `org-map-entries'.")
 (defvar org-scanner-tags nil
   "The current tag list while the tags scanner is running.")
 (defvar org-trust-scanner-tags nil
-  "Should `org-get-tags-at' use the tags fro the scanner.
+  "Should `org-get-tags-at' use the tags for the scanner.
 This is for internal dynamical scoping only.
 When this is non-nil, the function `org-get-tags-at' will return the value
 of `org-scanner-tags' instead of building the list by itself.  This
@@ -17418,15 +17418,18 @@ This command does many different things, depending on context:
 	  (org-footnote-at-definition-p))
       (call-interactively 'org-footnote-action))
      ((org-at-item-checkbox-p)
-      ;; Use a light version of `org-toggle-checkbox' to avoid
-      ;; computing list structure twice.
+      ;; Cursor at a checkbox: repair list and update checkboxes. Send
+      ;; list only if at top item.
       (let* ((cbox (match-string 1))
 	     (struct (org-list-struct))
-	     (old-struct (mapcar (lambda (e) (copy-alist e)) struct))
+	     (old-struct (copy-tree struct))
 	     (parents (org-list-parents-alist struct))
 	     (prevs (org-list-prevs-alist struct))
-	     (orderedp (ignore-errors (org-entry-get nil "ORDERED")))
+	     (orderedp (org-entry-get nil "ORDERED"))
+	     (firstp (= (org-list-get-top-point struct) (point-at-bol)))
 	     block-item)
+	;; Use a light version of `org-toggle-checkbox' to avoid
+	;; computing list structure twice.
 	(org-list-set-checkbox (point-at-bol) struct
 			       (cond
 				((equal arg '(16)) "[-]")
@@ -17442,23 +17445,25 @@ This command does many different things, depending on context:
 	   "Checkboxes were removed due to unchecked box at line %d"
 	   (org-current-line block-item)))
 	(org-list-struct-apply-struct struct old-struct)
-	(org-update-checkbox-count-maybe))
-      (org-list-send-list 'maybe))
+	(org-update-checkbox-count-maybe)
+	(when firstp (org-list-send-list 'maybe))))
      ((org-at-item-p)
-      ;; Do checkbox related actions only if function was called with
-      ;; an argument
+      ;; Cursor at an item: repair list. Do checkbox related actions
+      ;; only if function was called with an argument. Send list only
+      ;; if at top item.
       (let* ((struct (org-list-struct))
 	     (old-struct (copy-tree struct))
 	     (parents (org-list-parents-alist struct))
-	     (prevs (org-list-prevs-alist struct)))
+	     (prevs (org-list-prevs-alist struct))
+	     (firstp (= (org-list-get-top-point struct) (point-at-bol))))
 	(org-list-struct-fix-ind struct parents)
 	(org-list-struct-fix-bul struct prevs)
 	(when arg
 	  (org-list-set-checkbox (point-at-bol) struct "[ ]")
 	  (org-list-struct-fix-box struct parents prevs))
 	(org-list-struct-apply-struct struct old-struct)
-	(when arg (org-update-checkbox-count-maybe)))
-      (org-list-send-list 'maybe))
+	(when arg (org-update-checkbox-count-maybe))
+	(when firstp (org-list-send-list 'maybe))))
      ((save-excursion (beginning-of-line 1) (looking-at org-dblock-start-re))
       ;; Dynamic block
       (beginning-of-line 1)
@@ -17887,10 +17892,10 @@ See the individual commands for more information."
       :selected org-enforce-todo-dependencies :style toggle :active t]
      "Settings for tree at point"
      ["Do Children sequentially" org-toggle-ordered-property :style radio
-      :selected (ignore-errors (org-entry-get nil "ORDERED"))
+      :selected (org-entry-get nil "ORDERED")
       :active org-enforce-todo-dependencies :keys "C-c C-x o"]
      ["Do Children parallel" org-toggle-ordered-property :style radio
-      :selected (ignore-errors (not (org-entry-get nil "ORDERED")))
+      :selected (not (org-entry-get nil "ORDERED"))
       :active org-enforce-todo-dependencies :keys "C-c C-x o"]
      "--"
      ["Set Priority" org-priority t]
@@ -19091,23 +19096,21 @@ the functionality can be provided as a fall-back.")
 	       (save-restriction
 		 (narrow-to-region beg end)
 		 (save-excursion (fill-paragraph justify)))) t))
-	  ;; Special case where point is not in a list but is on a
-	  ;; paragraph adjacent to a list: make sure this paragraph
+	  ;; Special case where point is not in a list but is on
+	  ;; a paragraph adjacent to a list: make sure this paragraph
 	  ;; doesn't get merged with the end of the list by narrowing
 	  ;; buffer first.
-	  ((save-excursion
-	     (fill-forward-paragraph -1)
-	     (setq itemp (org-in-item-p)))
-	   (save-excursion
-	     (goto-char itemp)
-	     (setq struct (org-list-struct)))
-	   (save-restriction
-	     (narrow-to-region (org-list-get-bottom-point struct)
-			       (save-excursion
-				 (fill-forward-paragraph 1)
-				 (point)))
-	     (fill-paragraph justify) t))
-	  (t nil))))			; call `fill-paragraph'
+	  ((save-excursion (fill-forward-paragraph -1)
+			   (setq itemp (org-in-item-p)))
+	   (let ((struct (save-excursion (goto-char itemp)
+					 (org-list-struct))))
+	     (save-restriction
+	       (narrow-to-region (org-list-get-bottom-point struct)
+				 (save-excursion (fill-forward-paragraph 1)
+						 (point)))
+	       (fill-paragraph justify) t)))
+	  ;; Else simply call `fill-paragraph'.
+	  (t nil))))
 
 ;; For reference, this is the default value of adaptive-fill-regexp
 ;;  "[ \t]*\\([-|#;>*]+[ \t]*\\|(?[0-9]+[.)][ \t]*\\)*"