소스 검색

`k' now calls org-agenda-capture from agenda. Also add `org-capture-use-agenda-date' option.

* org-capture.el (org-capture-use-agenda-date): New option.
(org-capture): Use it.

* org-agenda.el (org-agenda-capture): New command.
(org-agenda-mode-map): Bind it to `k'.
(org-agenda-menu): Add it to the menu.

* org.texi (Agenda commands): Document the new command and the
new option.

Thanks to Eric Abrahamsen who suggested this change, along with
other merging about bulk actions.
Bastien Guerry 12 년 전
부모
커밋
f011496ceb
3개의 변경된 파일35개의 추가작업 그리고 8개의 파일을 삭제
  1. 7 0
      doc/org.texi
  2. 12 0
      lisp/org-agenda.el
  3. 16 8
      lisp/org-capture.el

+ 7 - 0
doc/org.texi

@@ -8459,6 +8459,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

+ 12 - 0
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
@@ -2007,6 +2008,7 @@ The following commands are available:
 (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 "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)
@@ -2190,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]
@@ -9048,6 +9051,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 ()

+ 16 - 8
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,16 +508,17 @@ stored.
 
 When called with a `C-0' (zero) prefix, insert a template at point.
 
-When called from an agenda buffer, use the date of the cursor at point
-as the default date for the capture template.
+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")
-  (if (eq major-mode 'org-agenda-mode)
-      (setq org-overriding-default-time
-	    (org-get-cursor-date)))
+  (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))