deadline
とtoday
は両方とも別の関数内で定義された数値です。私の最近のスレッドに似た関数内で、未満または等しい、またはより大きいまたは等しいを使用しようとしています: How to test for org-todo state "xyz" with締め切りは今日と同じではありません
この特定のケースでは、私の関数には の条件が含まれており、(<= deadline today)
無意識のうちに事前にマークを設定しなければ、関数は適切に機能します。事前に無意識にマークを設定すると (たとえば、関数を実行する前にバッファーの最後に移動するなど)、エラー メッセージが表示されますand: Wrong type argument: number-or-marker-p, nil
。(deactivate-mark)
at と setq および mark nil と を使用して関数に挿入しようとしましたtransient-mark-mode -1
が、そのエラーを回避できません。マークリングからすべてのマーカーをクリアする方法が見つかりません。何か案は?
編集:
(defun carry-forward-uncompleted-todo (&optional from-state to-state)
"Carry forward uncompleted todo."
(interactive)
(let* (
(element (org-element-at-point))
(todo-state (org-element-property :todo-keyword element))
(deadline
(ignore-errors ;; avoids throwing error message if there is no deadline.
(time-to-days
(org-time-string-to-time
(org-element-property :deadline element) ))))
(today (time-to-days (current-time))) )
(goto-char (point-min))
(while
(re-search-forward "^\*\* Active" nil t)
(when (< deadline today) ;; condition -- past-due
(org-deadline nil ".") ;; make deadline today
)
)
)
)
サンプル *.org ファイル。
* TASKS
** Active [#A] First task due today. :lawlist:
DEADLINE: <2013-07-11 Thu >
** Active [#A] Second task due today. :lawlist:
DEADLINE: <2013-07-11 Thu >
** Next Action [#E] Test One -- make Active with deadline today. :lawlist:
DEADLINE: <2013-07-31 Wed >
** Next Action [#E] Test Two -- make Active with deadline today. :lawlist:
DEADLINE: <2013-07-31 Wed >
編集 - 解決策 - 問題のトラブルシューティングを支援してくれた Nicholas Riley に感謝します。
(defvar from-state nil)
(defvar to-state nil)
(defun carry-forward-uncompleted-tasks ()
"Carry forward uncompleted tasks."
(interactive)
(goto-char (point-min))
(while (re-search-forward "^\*\* Active" nil t)
(unless (org-at-heading-p)
(org-back-to-heading))
(let* (
(element (org-element-at-point))
(todo-state (org-element-property :todo-keyword element))
(deadline
(ignore-errors ;; avoids throwing an error message if there is no deadline.
(time-to-days
(org-time-string-to-time
(org-element-property :deadline element) ))))
(today (time-to-days (current-time)))
(title (org-element-property :raw-value element)) )
(setq from-state "Active")
(setq to-state "Active")
(if (and
(> today deadline) ;; condition -- deadline is overdue
(string= todo-state from-state) ) ;; condition -- todo-state equals from-state
(progn ;; Process following list if conditions were met.
(message "\nMODIFIED => Active + Today: %s" title)
(org-deadline nil ".") )
(message "\nNO CHANGES: %s" title)) )))