0

deadlinetodayは両方とも別の関数内で定義された数値です。私の最近のスレッドに似た関数内で、未満または等しい、またはより大きいまたは等しいを使用しようとしています: 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)) )))
4

1 に答える 1

2

あなたの質問は少し混乱しています。説明しようとしている問題を引き起こす自己完結型の elisp の例を投稿できれば最高です。

そうは言っても、私は答えようとします:あなたが期待しているものではなく、 どちらdeadlineかのように見えます。両方の引数が数値またはマーカーのいずれかであると想定しているため、. おそらく、マークの設定に関連する何かがこれらの変数の 1 つに書き込まれます。todaynil<=number-or-marker-pnil

「別の関数内で定義された数値」が何を意味するのかは不明です — 変数はどのようにどこで定義されており ( defvar?? let)、どこに書かれていますか? Emacs のスコープと動的バインディング (および Emacs 24+ での字句バインディング) を理解していない場合は、それらについて読む必要があります。これらの変数名には接頭辞がありません。これは、スコープによってはかなり危険です。

于 2013-07-14T20:28:42.150 に答える