소스 검색

Merge branch 'maint'

Bastien Guerry 12 년 전
부모
커밋
f43c8c8100
6개의 변경된 파일67개의 추가작업 그리고 115개의 파일을 삭제
  1. 11 18
      doc/org.texi
  2. 2 1
      lisp/ob-tangle.el
  3. 28 86
      lisp/org-agenda.el
  4. 17 3
      lisp/org-capture.el
  5. 4 2
      lisp/org-exp.el
  6. 5 5
      lisp/org.el

+ 11 - 18
doc/org.texi

@@ -8430,21 +8430,6 @@ Schedule this item.  With prefix arg remove the scheduling timestamp
 @orgcmd{C-c C-d,org-agenda-deadline}
 Set a deadline for this item.  With prefix arg remove the deadline.
 @c
-@orgcmd{k,org-agenda-action}
-Agenda actions, to set dates for selected items to the cursor date.
-This command also works in the calendar!  The command prompts for an
-additional key:
-@example
-m   @r{Mark the entry at point for action.  You can also make entries}
-    @r{in Org files with @kbd{C-c C-x C-k}.}
-d   @r{Set the deadline of the marked entry to the date at point.}
-s   @r{Schedule the marked entry at the date at point.}
-r   @r{Call @code{org-capture} with the cursor date as default date.}
-@end example
-@noindent
-Press @kbd{r} afterward to refresh the agenda and see the effect of the
-command.
-@c
 @orgcmd{S-@key{right},org-agenda-do-date-later}
 Change the timestamp associated with the current line by one day into the
 future.  If the date is in the past, the first call to this command will move
@@ -8477,6 +8462,13 @@ Cancel the currently running clock.
 @c
 @orgcmd{J,org-agenda-clock-goto}
 Jump to the running clock in another window.
+@c
+@orgcmd{k,org-agenda-capture}
+Like @code{org-capture}, but use the date at point as the default date for
+the capture template.  See @var{org-capture-use-agenda-date} to make this
+the default behavior of @code{org-capture}.
+@cindex capturing, from agenda
+@vindex org-capture-use-agenda-date
 
 @tsubheading{Bulk remote editing selected entries}
 @cindex remote editing, bulk, from agenda
@@ -8505,8 +8497,7 @@ you want them to persist, set @code{org-agenda-bulk-persistent-marks} to
 @code{t} or hit @kbd{p} at the prompt.
 
 @example
-r  @r{Prompt for a single refile target and move all entries.  The entries}
-   @r{will no longer be in the agenda; refresh (@kbd{g}) to bring them back.}
+*  @r{Toggle persistent marks.}
 $  @r{Archive all selected entries.}
 A  @r{Archive entries by moving them to their respective archive siblings.}
 t  @r{Change TODO state.  This prompts for a single TODO keyword and}
@@ -8517,9 +8508,11 @@ t  @r{Change TODO state.  This prompts for a single TODO keyword and}
 s  @r{Schedule all items to a new date.  To shift existing schedule dates}
    @r{by a fixed number of days, use something starting with double plus}
    @r{at the prompt, for example @samp{++8d} or @samp{++2w}.}
+d  @r{Set deadline to a specific date.}
+r  @r{Prompt for a single refile target and move all entries.  The entries}
+   @r{will no longer be in the agenda; refresh (@kbd{g}) to bring them back.}
 S  @r{Reschedule randomly into the coming N days.  N will be prompted for.}
    @r{With prefix arg (@kbd{C-u B S}), scatter only across weekdays.}
-d  @r{Set deadline to a specific date.}
 f  @r{Apply a function@footnote{You can also create persistent custom functions through@code{org-agenda-bulk-custom-functions}.} to marked entries.}
    @r{For example, the function below sets the CATEGORY property of the}
    @r{entries to web.}

+ 2 - 1
lisp/ob-tangle.el

@@ -360,7 +360,8 @@ code blocks by language."
 	   (setq block-counter (+ 1 block-counter))))
        (replace-regexp-in-string "[ \t]" "-"
 				 (condition-case nil
-				     (nth 4 (org-heading-components))
+				     (or (nth 4 (org-heading-components))
+					 "(dummy for heading without text)")
 				   (error (buffer-file-name)))))
       (let* ((start-line (save-restriction (widen)
 					   (+ 1 (line-number-at-pos (point)))))

+ 28 - 86
lisp/org-agenda.el

@@ -83,6 +83,7 @@
 		  (&optional buffer-or-name norecord label))
 (declare-function org-agenda-columns "org-colview" ())
 (declare-function org-add-archive-files "org-archive" (files))
+(declare-function org-capture "org-capture" (&optional goto keys))
 
 (defvar calendar-mode-map)                    ; defined in calendar.el
 (defvar org-clock-current-task nil)           ; defined in org-clock.el
@@ -2006,8 +2007,9 @@ 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-unmark-all)
-(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 "k"        'org-agenda-capture)
+(org-defkey org-agenda-mode-map "A"        'org-agenda-append-agenda)
 (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)
 (org-defkey org-agenda-mode-map "\C-c\C-xa"    'org-agenda-toggle-archive-tag)
@@ -2036,8 +2038,6 @@ The following commands are available:
 (org-defkey org-agenda-mode-map "y"        'org-agenda-year-view)
 (org-defkey org-agenda-mode-map "\C-c\C-z" 'org-agenda-add-note)
 (org-defkey org-agenda-mode-map "z"        'org-agenda-add-note)
-(org-defkey org-agenda-mode-map "k"        'org-agenda-action)
-(org-defkey org-agenda-mode-map "\C-c\C-x\C-k" 'org-agenda-action)
 (org-defkey org-agenda-mode-map [(shift right)] 'org-agenda-do-date-later)
 (org-defkey org-agenda-mode-map [(shift left)] 'org-agenda-do-date-earlier)
 (org-defkey org-agenda-mode-map [?\C-c ?\C-x (right)] 'org-agenda-do-date-later)
@@ -2192,6 +2192,7 @@ The following commands are available:
     ["Show original entry" org-agenda-show t]
     ["Go To (other window)" org-agenda-goto t]
     ["Go To (this window)" org-agenda-switch-to t]
+    ["Capture with cursor date" org-agenda-capture t]
     ["Follow Mode" org-agenda-follow-mode
      :style toggle :selected org-agenda-follow-mode :active t]
 					;    ["Tree to indirect frame" org-agenda-tree-to-indirect-buffer t]
@@ -2216,7 +2217,7 @@ The following commands are available:
      ["Mark all" org-agenda-bulk-mark-all t]
      ["Mark matching regexp" org-agenda-bulk-mark-regexp t]
      ["Unmark entry" org-agenda-bulk-unmark t]
-     ["Unmark all entries" org-agenda-bulk-unmark-all :active t :keys "C-u s"])
+     ["Unmark all entries" org-agenda-bulk-unmark-all :active t :keys "U"])
     ["Act on all marked" org-agenda-bulk-action t]
     "--"
     ("Tags and Properties"
@@ -2229,11 +2230,6 @@ The following commands are available:
      ["Schedule" org-agenda-schedule t]
      ["Set Deadline" org-agenda-deadline t]
      "--"
-     ["Mark item" org-agenda-action :active t :keys "k m"]
-     ["Show mark item" org-agenda-action :active t :keys "k v"]
-     ["Schedule marked item" org-agenda-action :active t :keys "k s"]
-     ["Set Deadline for marked item" org-agenda-action :active t :keys "k d"]
-     "--"
      ["Change Date +1 day" org-agenda-date-later (org-agenda-check-type nil 'agenda 'timeline)]
      ["Change Date -1 day" org-agenda-date-earlier (org-agenda-check-type nil 'agenda 'timeline)]
      ["Change Time +1 hour" org-agenda-do-date-later :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u S-right"]
@@ -8395,72 +8391,6 @@ ARG is passed through to `org-deadline'."
       (org-agenda-show-new-time marker ts "D"))
     (message "Deadline for this item set to %s" ts)))
 
-(defun org-agenda-action ()
-  "Select entry for agenda action, or execute an agenda action.
-This command prompts for another letter.  Valid inputs are:
-
-m     Mark the entry at point for an agenda action
-s     Schedule the marked entry to the date at the cursor
-d     Set the deadline of the marked entry to the date at the cursor
-r     Call `org-remember' with cursor date as the default date
-c     Call `org-capture' with cursor date as the default date
-SPC   Show marked entry in other window
-TAB   Visit marked entry in other window
-
-The cursor may be at a date in the calendar, or in the Org agenda."
-  (interactive)
-  (let (ans)
-    (message "Select action: [m]ark | [s]chedule [d]eadline [r]emember [c]apture [ ]show")
-    (setq ans (read-char-exclusive))
-    (cond
-     ((equal ans ?m)
-      ;; Mark this entry
-      (if (eq major-mode 'org-agenda-mode)
-	  (let ((m (or (org-get-at-bol 'org-hd-marker)
-		       (org-get-at-bol 'org-marker))))
-	    (if m
-		(progn
-		  (move-marker org-agenda-action-marker
-			       (marker-position m) (marker-buffer m))
-		  (message "Entry marked for action; press `k' at desired date in agenda or calendar"))
-	      (error "Don't know which entry to mark")))
-	(error "This command works only in the agenda")))
-     ((equal ans ?s)
-      (org-agenda-do-action '(org-schedule nil org-overriding-default-time)))
-     ((equal ans ?d)
-      (org-agenda-do-action '(org-deadline nil org-overriding-default-time)))
-     ((equal ans ?r)
-      (org-agenda-do-action '(org-remember) t))
-     ((equal ans ?c)
-      (org-agenda-do-action '(org-capture) t))
-     ((equal ans ?\ )
-      (let ((cw (selected-window)))
-	(org-switch-to-buffer-other-window
-	 (marker-buffer org-agenda-action-marker))
-	(goto-char org-agenda-action-marker)
-	(org-show-context 'agenda)
-	(select-window cw)))
-     ((equal ans ?\C-i)
-      (org-switch-to-buffer-other-window
-       (marker-buffer org-agenda-action-marker))
-      (goto-char org-agenda-action-marker)
-      (org-show-context 'agenda))
-     (t (error "Invalid agenda action %c" ans)))))
-
-(defun org-agenda-do-action (form &optional current-buffer)
-  "Evaluate FORM at the entry pointed to by `org-agenda-action-marker'."
-  (let ((org-overriding-default-time (org-get-cursor-date)))
-    (if current-buffer
-	(eval form)
-      (if (not (marker-buffer org-agenda-action-marker))
-	  (error "No entry has been selected for agenda action")
-	(with-current-buffer (marker-buffer org-agenda-action-marker)
-	  (save-excursion
-	    (save-restriction
-	      (widen)
-	      (goto-char org-agenda-action-marker)
-	      (eval form))))))))
-
 (defun org-agenda-clock-in (&optional arg)
   "Start the clock on the currently selected item."
   (interactive "P")
@@ -8967,8 +8897,8 @@ The prefix arg is passed through to the command if possible."
 
   ;; Prompt for the bulk command
   (let* ((msg (if org-agenda-persistent-marks "Bulk (persistent): " "Bulk: ")))
-    (message (concat msg "[r]efile [$]arch [A]rch->sib [t]odo"
-		     " [+/-]tag [s]chd [S]catter [d]eadline [f]unction    "
+    (message (concat msg "[$]arch [A]rch->sib [t]odo [+/-]tag [s]chd [d]eadline [r]efile "
+		     "[S]catter [f]unction    "
 		     (when org-agenda-bulk-custom-functions
 		       (concat " Custom: ["
 			       (mapconcat (lambda(f) (char-to-string (car f)))
@@ -8978,6 +8908,9 @@ The prefix arg is passed through to the command if possible."
       (let* ((action (read-char-exclusive))
 	     (org-log-refile (if org-log-refile 'time nil))
 	     (entries (reverse org-agenda-bulk-marked-entries))
+	     (org-overriding-default-time
+	      (if (get-text-property (point) 'org-agenda-date-header)
+		  (org-get-cursor-date)))
 	     redo-at-end
 	     cmd rfloc state e tag pos (cnt 0) (cntskip 0))
 	(cond
@@ -8996,7 +8929,7 @@ The prefix arg is passed through to the command if possible."
 	 ((member action '(?r ?w))
 	  (setq rfloc (org-refile-get-location
 		       "Refile to"
-		       (marker-buffer (car org-agenda-bulk-marked-entries))
+		       (marker-buffer (car entries))
 		       org-refile-allow-creating-parent-nodes))
 	  (if (nth 3 rfloc)
 	      (setcar (nthcdr 3 rfloc)
@@ -9028,9 +8961,12 @@ The prefix arg is passed through to the command if possible."
 
 	 ((memq action '(?s ?d))
 	  (let* ((date (unless arg
-			 (org-read-date
-			  nil nil nil
-			  (if (eq action ?s) "(Re)Schedule to" "Set Deadline to"))))
+			 (or org-overriding-default-time
+			     (org-read-date
+			      nil nil nil
+			      (if (eq action ?s) "(Re)Schedule to" "(Re)Set Deadline to")
+			      nil (format-time-string (car org-time-stamp-formats)
+						      (org-get-cursor-date))))))
 		 (ans (if arg nil org-read-date-final-answer))
 		 (c1 (if (eq action ?s) 'org-agenda-schedule 'org-agenda-deadline)))
 	    (setq cmd `(let* ((bound (fboundp 'read-string))
@@ -9104,13 +9040,10 @@ The prefix arg is passed through to the command if possible."
 	    (goto-char pos)
 	    (let (org-loop-over-headlines-in-active-region)
 	      (eval cmd))
-	    (when (not org-agenda-persistent-marks)
-	      (setq org-agenda-bulk-marked-entries
-		    (delete e org-agenda-bulk-marked-entries)))
 	    (setq cnt (1+ cnt))))
-	(when (not org-agenda-persistent-marks)
-	  (org-agenda-bulk-unmark-all))
 	(when redo-at-end (org-agenda-redo))
+	(unless org-agenda-persistent-marks
+	  (org-agenda-bulk-unmark-all))
 	(message "Acted on %d entries%s%s"
 		 cnt
 		 (if (= cntskip 0)
@@ -9120,6 +9053,15 @@ The prefix arg is passed through to the command if possible."
 		 (if (not org-agenda-persistent-marks)
 		     "" " (kept marked)"))))))
 
+(defun org-agenda-capture ()
+  "Call `org-capture' with the date at point."
+  (interactive)
+  (if (not (eq major-mode 'org-agenda-mode))
+      (error "You cannot do this outside of agenda buffers")
+    (let ((org-overriding-default-time
+	   (org-get-cursor-date)))
+      (call-interactively 'org-capture))))
+
 ;;; Flagging notes
 
 (defun org-agenda-show-the-flagging-note ()

+ 17 - 3
lisp/org-capture.el

@@ -483,6 +483,13 @@ to avoid duplicates.)"
 				     (regexp))
 			       (function :tag "Custom function"))))))
 
+(defcustom org-capture-use-agenda-date nil
+  "Non-nil means use the date at point when capturing from agendas.
+When nil, you can still capturing using the date at point with \\[org-agenda-capture]]."
+  :group 'org-capture
+  ;; :version "24.3"
+  :type 'boolean)
+
 ;;;###autoload
 (defun org-capture (&optional goto keys)
   "Capture something.
@@ -501,10 +508,17 @@ stored.
 
 When called with a `C-0' (zero) prefix, insert a template at point.
 
-Lisp programs can set KEYS to a string associated with a template in
-`org-capture-templates'.  In this case, interactive selection will be
-bypassed."
+Lisp programs can set KEYS to a string associated with a template
+in `org-capture-templates'.  In this case, interactive selection
+will be bypassed.
+
+If `org-capture-use-agenda-date' is non-nil, capturing from the
+agenda will use the date at point as the default date."
   (interactive "P")
+  (when (and org-capture-use-agenda-date
+	     (eq major-mode 'org-agenda-mode))
+    (setq org-overriding-default-time
+	  (org-get-cursor-date)))
   (cond
    ((equal goto '(4)) (org-capture-goto-target))
    ((equal goto '(16)) (org-capture-goto-last-stored))

+ 4 - 2
lisp/org-exp.el

@@ -1476,8 +1476,10 @@ the current file."
 	    "^[ \t]*:HTML_CONTAINER_CLASS:[ \t]+\\(.+\\)$" nil t)
       (setq class (match-string 1))
       (save-excursion
-	(org-back-to-heading t)
-	(put-text-property (point-at-bol) (point-at-eol) 'html-container-class class)))))
+	(when (re-search-backward "^\\*" (point-min) t)
+	  (org-back-to-heading t)
+	  (put-text-property (point-at-bol) (point-at-eol)
+			     'html-container-class class))))))
 
 (defvar org-export-format-drawer-function nil
   "Function to be called to format the contents of a drawer.

+ 5 - 5
lisp/org.el

@@ -15424,11 +15424,11 @@ If you don't like the calendar, turn it off with
 
 With optional argument TO-TIME, the date will immediately be converted
 to an internal time.
-With an optional argument WITH-TIME, the prompt will suggest to also
-insert a time.  Note that when WITH-TIME is not set, you can still
-enter a time, and this function will inform the calling routine about
-this change.  The calling routine may then choose to change the format
-used to insert the time stamp into the buffer to include the time.
+With an optional argument ORG-WITH-TIME, the prompt will suggest to
+also insert a time.  Note that when ORG-WITH-TIME is not set, you can
+still enter a time, and this function will inform the calling routine
+about this change.  The calling routine may then choose to change the
+format used to insert the time stamp into the buffer to include the time.
 With optional argument FROM-STRING, read from this string instead from
 the user.  PROMPT can overwrite the default prompt.  DEFAULT-TIME is
 the time/date that is used for everything that is not specified by the