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: Thu, 09 Nov 2023 13:01:09 -0500
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 11:38:26 -0500
>> 
>> > That's one way, yes.  Another one is to use define-error to define a
>> > new error type for this case.
>> 
>> Instead of defining a new error type, how about just signaling
>> file-locked instead?  e.g. the following patch:
>> 
>> diff --git a/lisp/userlock.el b/lisp/userlock.el
>> index 61f061d3e54..e4d23c56249 100644
>> --- a/lisp/userlock.el
>> +++ b/lisp/userlock.el
>> @@ -67,7 +67,7 @@ ask-user-about-lock
>>          (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"))
>> +    (if noninteractive (signal 'file-locked (list file opponent)))
>>      (let ((tem (let ((inhibit-quit t)
>>                       (cursor-in-echo-area t))
>>                   (prog1 (downcase (read-char))
>
> 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)







reply via email to

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