Subject: Re: bug#77744: 31.0.50; Inconsistent error signal in up-list-default-function and treesit-up-list

From: Juri Linkov <[email-masked]>
Date: Mon, 14 Apr 2025 21:05:36 +0300

>> This is because 'up-list-default-function' signals both:
>>
>>   (if no-syntax-crossing
>>       ;; Assume called interactively; don't signal an error.
>>       (user-error "At top level")
>>     (signal (car err) (cdr err)))
> Yes, I forgot to mention it in the initial report. 'scan-error' is signaled
> by 'up-list-default-function' when it's called non-interactively, but
> 'treesit-up-list' signals 'user-error' in this case.

Thanks for the bug report.  I will push this patch tomorrow
since currently the repo is down:

diff --git a/lisp/treesit.el b/lisp/treesit.el
index ae0ef56c65a..3cf3be5122c 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -3193,7 +3183,12 @@ treesit-up-list
               (goto-char (if (> arg 0)
                              (treesit-node-end parent)
                            (treesit-node-start parent))))
-            (user-error "At top level")))
+            (if no-syntax-crossing
+                ;; Assume called interactively; don't signal an error.
+                (user-error "At top level")
+              (signal 'scan-error
+                      (list (format-message "No more %S to move across" pred)
+                            (point) (point))))))
       (setq cnt (- cnt inc)))))
 
 (defun treesit-cycle-sexp-type ()