On Sat, Jan 1, 2022 at 9:31 AM Allen Li <darkfel...@felesatra.moe> wrote:

> It seems like the right fix here is to make - behave the same as -1, and
> raise a user error for any other negative numeric prefix, since it is
> likely not doing whatever the user wanted.
>

Attached a small patch fixing this, which I tested manually.

Feel free to remove the negative arg error if it's not desired (although I
don't think there is a use case for, e.g., typing M-- M-2 instead of M-1).
From 16ff89c309b8bd9aa11183cc9620c56ed96e3ff7 Mon Sep 17 00:00:00 2001
From: Allen Li <darkfel...@felesatra.moe>
Date: Sat, 1 Jan 2022 01:38:35 -0800
Subject: [PATCH] org: Improve org-todo handling of negative prefix args

* lisp/org.el (org-todo): Handle -1 prefix args consistently and error
on other negative args.
---
 lisp/org.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index e2f315a4c..6b48f660e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9785,7 +9785,8 @@ When called through ELisp, arg is also interpreted in the following way:
 	 nil cl
 	 (when (org-invisible-p) (org-end-of-subtree nil t))))
     (when (equal arg '(16)) (setq arg 'nextset))
-    (when (equal arg -1) (org-cancel-repeater) (setq arg nil))
+    (when (equal (prefix-numeric-value arg) -1) (org-cancel-repeater) (setq arg nil))
+    (when (< (prefix-numeric-value arg) -1) (user-error "Prefix argument %d not supported" arg))
     (let ((org-blocker-hook org-blocker-hook)
 	  commentp
 	  case-fold-search)
-- 
2.34.1

Reply via email to