bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#66993: [PATCH] project.el: avoid asking user about project-list-file


From: Spencer Baugh
Subject: bug#66993: [PATCH] project.el: avoid asking user about project-list-file lock
Date: Fri, 10 Nov 2023 12:48:36 +0000 (UTC)
User-agent: Gnus/5.13 (Gnus v5.13)

Eli Zaretskii <eliz@gnu.org> writes:
>> From: Spencer Baugh <sbaugh@janestreet.com>
>> Cc: dmitry@gutov.dev,  66993@debbugs.gnu.org
>> Date: Thu, 09 Nov 2023 13:01:09 -0500
>> 
>> Eli Zaretskii <eliz@gnu.org> writes:
>> > Please show the result of this change on what Emacs prints in batch
>> > mode when this error is signaled.
>> 
>> Before:
>> 
>> $ ./src/emacs -Q --batch --eval '(write-region "foo" nil "~/file")'
>> /home/sbaugh/file locked by sbaugh@igm-qw... (pid 3781848): (s, q, p, ?)? 
>> 
>> Error: error ("Cannot resolve lock conflict in batch mode")
>>   mapbacktrace(#f(compiled-function (evald func args flags) #<bytecode 
>> 0x957865a77aef0ee>))
>>   debug-early-backtrace()
>>   debug-early(error (error "Cannot resolve lock conflict in batch mode"))
>>   signal(error ("Cannot resolve lock conflict in batch mode"))
>>   error("Cannot resolve lock conflict in batch mode")
>>   ask-user-about-lock("/home/sbaugh/file" "sbaugh@igm-qws-u22796a (pid 
>> 3781848)")
>>   write-region("foo" nil "~/file")
>>   eval((write-region "foo" nil "~/file") t)
>>   command-line-1(("--eval" "(write-region \"foo\" nil \"~/file\")"))
>>   command-line()
>>   normal-top-level()
>> Cannot resolve lock conflict in batch mode
>> 
>> 
>> After:
>> 
>> $ ./src/emacs -Q --batch --eval '(write-region "foo" nil "~/file")'
>> /home/sbaugh/file locked by sbaugh@igm-qw... (pid 3781848): (s, q, p, ?)? 
>> 
>> Error: file-locked ("/home/sbaugh/file" "sbaugh@igm-qws-u22796a (pid 
>> 3781848)")
>>   mapbacktrace(#f(compiled-function (evald func args flags) #<bytecode 
>> 0x179d0e5a77aef0e7>))
>>   debug-early-backtrace()
>>   debug-early(error (file-locked "/home/sbaugh/file" "sbaugh@igm-qws-u22796a 
>> (pid 3781848)"))
>>   signal(file-locked ("/home/sbaugh/file" "sbaugh@igm-qws-u22796a (pid 
>> 3781848)"))
>>   ask-user-about-lock("/home/sbaugh/file" "sbaugh@igm-qws-u22796a (pid 
>> 3781848)")
>>   write-region("foo" nil "~/file")
>>   eval((write-region "foo" nil "~/file") t)
>>   command-line-1(("--eval" "(write-region \"foo\" nil \"~/file\")"))
>>   command-line()
>>   normal-top-level()
>> /home/sbaugh/file: sbaugh@igm-qws-u22796a (pid 3781848)
>
> Thanks, that's what I thought: this loses information.  The "Cannot
> resolve lock conflict in batch mode" part is important, since it
> explains the "file-locked" part.  So please include the missing text
> in the list passed to 'signal' as its DATA argument, so as not to lose
> this explanation.

OK, how about this?  Which makes Emacs print:

Error: file-locked ("/home/sbaugh/file" "sbaugh@earth (pid 1852838)" "Cannot 
resolve lock conflict in batch mode")
  mapbacktrace(#f(compiled-function (evald func args flags) #<bytecode 
-0x1f22147a251783b>))
  debug-early-backtrace()
  debug-early(error (file-locked "/home/sbaugh/file" "sbaugh@earth (pid 
1852838)" "Cannot resolve lock conflict in batch mode"))
  signal(file-locked ("/home/sbaugh/file" "sbaugh@earth (pid 1852838)" "Cannot 
resolve lock conflict in batch mode"))
  ask-user-about-lock("/home/sbaugh/file" "sbaugh@earth (pid 1852838)")
  write-region("foo" nil "~/file")
  eval((write-region "foo" nil "~/file") t)
  command-line-1(("--eval" "(write-region \"foo\" nil \"~/file\")"))
  command-line()
  normal-top-level()
/home/sbaugh/file: sbaugh@earth (pid 1852838), Cannot resolve lock conflict in 
batch mode

>From 9f94d8975406a3f4bdaa97ed8bd6a08dbf8e3d9b Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh@catern.com>
Date: Fri, 10 Nov 2023 07:20:09 -0500
Subject: [PATCH] Signal file-locked on lock conflict with noninteractive=t

Previously we would signal a generic error on lock conflict when
noninteractive=t.  That meant that non-interactively handling a lock
conflict would require catching all errors and checking the string in
DATA.

Now we just signal file-locked instead, which matches the interactive
behavior when the user says "q" at the prompt.

Also, when noninteractive, we signal before we write the prompt about
the lock conflict.  That prompt usually gets in the way of
noninteractively handling and suppress lock conflict errors.  The
signal data contains all the necessary information, we don't need to
write a separate message for noninteractive.

* lisp/userlock.el (ask-user-about-lock): Signal file-locked on
noninteractive lock conflict.  (bug#66993)
---
 lisp/userlock.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/userlock.el b/lisp/userlock.el
index 4623608f1db..91d5b7308dd 100644
--- a/lisp/userlock.el
+++ b/lisp/userlock.el
@@ -64,10 +64,11 @@ ask-user-about-lock
                          (match-string 0 opponent)))
              opponent))
       (while (null answer)
+       (when noninteractive
+          (signal 'file-locked (list file opponent "Cannot resolve lock 
conflict in batch mode")))
         (message (substitute-command-keys
                   "%s locked by %s: (\\`s', \\`q', \\`p', \\`?')? ")
                  short-file short-opponent)
-       (if noninteractive (error "Cannot resolve lock conflict in batch mode"))
        (let ((tem (let ((inhibit-quit t)
                         (cursor-in-echo-area t))
                     (prog1 (downcase (read-char))
-- 
2.39.2


reply via email to

[Prev in Thread] Current Thread [Next in Thread]