组织截止日期 - 一举更改所选的块 [英] org-deadline -- change all in selected block in one fell swoop

查看:103
本文介绍了组织截止日期 - 一举更改所选的块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以指导我正确的方向自动执行此功能,以便我只输入一次日期(或从内置的弹出日历中选择鼠标),然后按回车键,然后重复该过程本身直到完成。

Could someone please steer me in the right direction towards automating this function so that I only type the date one time (or select it with the mouse from the built-in popup calendar) and hit the return key, and then it repeats the process all by itself until finished.

(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的主要功能


Here is the main function from .../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)))))


推荐答案

以下代码应该做到这一点。这只是一个问题的时间分开,他们把它自己传递到机构期限功能。

The following code should do the trick. It's just a matter of asking the time separately and them passing it yourself to the org-deadline function.

(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)

编辑:简化功能。

这篇关于组织截止日期 - 一举更改所选的块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆