如果是org-agenda-mode,则替换" Args超出范围:0,0"为了更漂亮的消息

时间:2013-10-31 02:09:02

标签: emacs elisp

我理解错误消息表示没有符合搜索条件的todo条目:

org-agenda-find-same-or-today-or-agenda: Args out of range: 0, 0

有没有办法生成更漂亮的消息:

(if (and (eq major-mode 'org-agenda-mode)
      (org-agenda-find-same-or-today-or-agenda: Args out of range: 0, 0) )
  (message "There are no events that match your search criteria."))

1 个答案:

答案 0 :(得分:1)

您可以使用condition-case来处理该标准错误:

 (if (and (eq major-mode 'org-agenda-mode)
          (condition-case err
              (org-agenda-find-same-or-today-or-agenda ...) ; Whatever args you need to pass.
            (args-out-of-range (error "There are no events that match your search criteria"))
            (error (error (error-message-string err)))))
     ...)

但是,听起来您应该更正代码,以防止出现该错误。在调用它之前,你不能测试org-agenda-find-same-or-today-or-agenda的参数,只有在参数有效的情况下才调用它吗?