2

誰かがこの機能を自動化するための正しい方向に私を導いてくれますか?完了するまで単独で。

(setq org-loop-over-headlines-in-active-region t)

(defun change-all-deadlines ()
  "Change all deadlines in the group of tasks that are selected / highlighted."
  (interactive)
  (org-deadline)
  (org-map-entries)
  (let (new-date
        (minibuffer-message "Please insert the new date, and then press RET to continue.")
        [User enters (with choice to use built-in calendar popup):  July 5, 2013]
        (format "%s" (new-date))
        [Then magic happens automatically -- :)]
    (minibuffer-message "Congratulations -- all dates have been changed to %s." new-date))))

編集: これは .../lisp/org.el のメイン関数です。

(defun org-deadline (&optional remove time)
  "Insert the \"DEADLINE:\" string with a timestamp to make a deadline.
With argument REMOVE, remove any deadline from the item.
With argument TIME, set the deadline at the corresponding date.  TIME
can either be an Org date like \"2011-07-24\" or a delta like \"+2d\"."
  (interactive "P")
  (if (and (org-region-active-p) org-loop-over-headlines-in-active-region)
      (let ((cl (if (eq org-loop-over-headlines-in-active-region 'start-level)
            'region-start-level 'region))
        org-loop-over-headlines-in-active-region)
    (org-map-entries
     `(org-deadline ',remove ,time)
     org-loop-over-headlines-in-active-region
     cl (if (outline-invisible-p) (org-end-of-subtree nil t))))
    (let* ((old-date (org-entry-get nil "DEADLINE"))
       (repeater (and old-date
              (string-match
               "\\([.+-]+[0-9]+[hdwmy]\\(?:[/ ][-+]?[0-9]+[hdwmy]\\)?\\) ?"
               old-date)
              (match-string 1 old-date))))
      (if remove
      (progn
        (when (and old-date org-log-redeadline)
          (org-add-log-setup 'deldeadline nil old-date 'findpos
                 org-log-redeadline))
        (org-remove-timestamp-with-keyword org-deadline-string)
        (message "Item no longer has a deadline."))
    (org-add-planning-info 'deadline time 'closed)
    (when (and old-date org-log-redeadline
           (not (equal old-date
                   (substring org-last-inserted-timestamp 1 -1))))
      (org-add-log-setup 'redeadline nil old-date 'findpos
                 org-log-redeadline))
    (when repeater
      (save-excursion
        (org-back-to-heading t)
        (when (re-search-forward (concat org-deadline-string " "
                         org-last-inserted-timestamp)
                     (save-excursion
                       (outline-next-heading) (point)) t)
          (goto-char (1- (match-end 0)))
          (insert " " repeater)
          (setq org-last-inserted-timestamp
            (concat (substring org-last-inserted-timestamp 0 -1)
                " " repeater
                (substring org-last-inserted-timestamp -1))))))
    (message "Deadline on %s" org-last-inserted-timestamp)))))
4

1 に答える 1

1

次のコードでうまくいくはずです。時間を個別に尋ねて、自分で org-deadline 関数に渡すだけです。

(defun org/deadline (remove)
  "like `org-deadline', except ask only once."
  (interactive "P")
  (unless remove (with-temp-buffer (org-time-stamp nil)))
  (org-deadline remove org-last-inserted-timestamp))


(global-set-key [remap org-deadline] 'org/deadline)

編集:機能を簡素化しました。

于 2013-07-06T12:18:30.227 に答える