GNU bug report logs - #11358
24.1.50; Feature request: A way to abort emacs-client

Previous Next

Package: emacs;

Reported by: Harald Hanche-Olsen <hanche <at> math.ntnu.no>

Date: Fri, 27 Apr 2012 07:47:01 UTC

Severity: wishlist

Tags: moreinfo

Found in version 24.1.50

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 11358 in the body.
You can then email your comments to 11358 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#11358; Package emacs. (Fri, 27 Apr 2012 07:47:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Harald Hanche-Olsen <hanche <at> math.ntnu.no>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 27 Apr 2012 07:47:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Harald Hanche-Olsen <hanche <at> math.ntnu.no>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.1.50; Feature request: A way to abort emacs-client
Date: Fri, 27 Apr 2012 09:44:58 +0200 (CEST)
There should be a way, from within a server editing buffer, to cause
the corresponding emacs-client process to exit with a nonzero exit
status. This can then be used by the calling process as an indication
that the user has abandoned the edit.

If there is already a way to achieve this, consider this a
documentation bug: I am certainly unable to find this feature.

In GNU Emacs 24.1.50.2 (x86_64-unknown-linux-gnu, GTK+ Version 2.20.1)
 of 2012-04-10 on fia.math.ntnu.no
Bzr revision: 107840 larsi <at> gnus.org-20120410112744-slbrfdrrjb0x1mfy

- Harald




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11358; Package emacs. (Thu, 07 Jul 2016 01:08:02 GMT) Full text and rfc822 format available.

Message #8 received at 11358 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Harald Hanche-Olsen <hanche <at> math.ntnu.no>
Cc: 11358 <at> debbugs.gnu.org
Subject: Re: bug#11358: 24.1.50; Feature request: A way to abort emacs-client
Date: Wed, 06 Jul 2016 21:07:30 -0400
Harald Hanche-Olsen <hanche <at> math.ntnu.no> writes:

> There should be a way, from within a server editing buffer, to cause
> the corresponding emacs-client process to exit with a nonzero exit
> status. This can then be used by the calling process as an indication
> that the user has abandoned the edit.
>
> If there is already a way to achieve this, consider this a
> documentation bug: I am certainly unable to find this feature.

There is a way to do this, I know because it's used by magit to tell git
to cancel the commit message editing (with-editor is a library that was
spun off from magit):

(defun with-editor-return (cancel)
  (let ...
        (clients server-buffer-clients)
...
               (dolist (client clients)
                 (ignore-errors
                   (server-send-string client "-error Canceled by user"))
...


The only documentation I could find on it was in server-process-filter
docstring:

(cl-defun server-process-filter (proc string)
  "Process a request from the server to edit some files.
PROC is the server process. [...]
The following commands are accepted by the client:
[...]
`-error DESCRIPTION'
  Signal an error and delete process PROC.

Probably it should be mentioned in the elisp manual somewhere, not sure
where, there doesn't seem to be an appropriate existing chapter.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11358; Package emacs. (Wed, 02 Jun 2021 06:39:02 GMT) Full text and rfc822 format available.

Message #11 received at 11358 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: npostavs <at> users.sourceforge.net
Cc: 11358 <at> debbugs.gnu.org, Harald Hanche-Olsen <hanche <at> math.ntnu.no>
Subject: Re: bug#11358: 24.1.50; Feature request: A way to abort emacs-client
Date: Wed, 02 Jun 2021 08:38:29 +0200
npostavs <at> users.sourceforge.net writes:

> Harald Hanche-Olsen <hanche <at> math.ntnu.no> writes:
>
>> There should be a way, from within a server editing buffer, to cause
>> the corresponding emacs-client process to exit with a nonzero exit
>> status. This can then be used by the calling process as an indication
>> that the user has abandoned the edit.
>>
>> If there is already a way to achieve this, consider this a
>> documentation bug: I am certainly unable to find this feature.
>
> There is a way to do this, I know because it's used by magit to tell git
> to cancel the commit message editing (with-editor is a library that was
> spun off from magit):

[...]

>                    (server-send-string client "-error Canceled by user"))

[...]

> Probably it should be mentioned in the elisp manual somewhere, not sure
> where, there doesn't seem to be an appropriate existing chapter.

Yes, the server isn't discussed in the elisp manual at all.

Anyway -- was the request here to add a new command to work like
`C-x #', but instead send "-error Canceled by user"?  

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 02 Jun 2021 06:39:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11358; Package emacs. (Wed, 02 Jun 2021 14:45:01 GMT) Full text and rfc822 format available.

Message #16 received at 11358 <at> debbugs.gnu.org (full text, mbox):

From: Harald Hanche-Olsen <harald.hanche-olsen <at> ntnu.no>
To: Lars Ingebrigtsen <larsi <at> gnus.org>, "npostavs <at> users.sourceforge.net"
 <npostavs <at> users.sourceforge.net>
Cc: "11358 <at> debbugs.gnu.org" <11358 <at> debbugs.gnu.org>
Subject: Re: bug#11358: 24.1.50; Feature request: A way to abort emacs-client
Date: Wed, 2 Jun 2021 07:05:31 +0000
From: Lars Ingebrigtsen <larsi <at> gnus.org>

> Anyway -- was the request here to add a new command to work like
> `C-x #', but instead send "-error Canceled by user"?  

That was my thought, yes. It would not need to be bound to any key by default.
Perhaps ‘server-edit-abort’ is a good name?

– Harald (new email address, formerly hanche <at> math.ntnu.no)


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11358; Package emacs. (Thu, 03 Jun 2021 07:09:02 GMT) Full text and rfc822 format available.

Message #19 received at 11358 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Harald Hanche-Olsen <harald.hanche-olsen <at> ntnu.no>
Cc: "11358 <at> debbugs.gnu.org" <11358 <at> debbugs.gnu.org>,
 "npostavs <at> users.sourceforge.net" <npostavs <at> users.sourceforge.net>
Subject: Re: bug#11358: 24.1.50; Feature request: A way to abort emacs-client
Date: Thu, 03 Jun 2021 09:07:52 +0200
Harald Hanche-Olsen <harald.hanche-olsen <at> ntnu.no> writes:

> From: Lars Ingebrigtsen <larsi <at> gnus.org>
>
>> Anyway -- was the request here to add a new command to work like
>> `C-x #', but instead send "-error Canceled by user"?  
>
> That was my thought, yes. It would not need to be bound to any key by default.
> Perhaps ‘server-edit-abort’ is a good name?

Sure.  I'm not that familiar with how server.el/emacsclient works,
though -- can somebody else propose a patch to implement this command?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11358; Package emacs. (Thu, 03 Jun 2021 07:56:01 GMT) Full text and rfc822 format available.

Message #22 received at 11358 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 11358 <at> debbugs.gnu.org, harald.hanche-olsen <at> ntnu.no,
 npostavs <at> users.sourceforge.net
Subject: Re: bug#11358: 24.1.50; Feature request: A way to abort emacs-client
Date: Thu, 03 Jun 2021 10:54:47 +0300
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Date: Thu, 03 Jun 2021 09:07:52 +0200
> Cc: "11358 <at> debbugs.gnu.org" <11358 <at> debbugs.gnu.org>,
>  "npostavs <at> users.sourceforge.net" <npostavs <at> users.sourceforge.net>
> 
> Harald Hanche-Olsen <harald.hanche-olsen <at> ntnu.no> writes:
> 
> > From: Lars Ingebrigtsen <larsi <at> gnus.org>
> >
> >> Anyway -- was the request here to add a new command to work like
> >> `C-x #', but instead send "-error Canceled by user"?  
> >
> > That was my thought, yes. It would not need to be bound to any key by default.
> > Perhaps ‘server-edit-abort’ is a good name?
> 
> Sure.  I'm not that familiar with how server.el/emacsclient works,
> though -- can somebody else propose a patch to implement this command?

The commands accepted by the client are documented in the doc string
of server-process-filter.  There's already a command that causes the
client to exit with a non-zero exit status: "-error MESSAGE".  Maybe
just reusing it would do.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11358; Package emacs. (Thu, 03 Jun 2021 14:47:01 GMT) Full text and rfc822 format available.

Message #25 received at 11358 <at> debbugs.gnu.org (full text, mbox):

From: Harald Hanche-Olsen <harald.hanche-olsen <at> ntnu.no>
To: Eli Zaretskii <eliz <at> gnu.org>, Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: "11358 <at> debbugs.gnu.org" <11358 <at> debbugs.gnu.org>,
 "npostavs <at> users.sourceforge.net" <npostavs <at> users.sourceforge.net>
Subject: Re: bug#11358: 24.1.50; Feature request: A way to abort emacs-client
Date: Thu, 3 Jun 2021 14:46:33 +0000
Here is a very naive first stab:

(defun server-abort ()
  (interactive)
  (if server-clients
      (mapc (lambda (proc)
              (server-send-string
               proc (concat "-error "
                            (server-quote-arg "Aborted by the user"))))
            server-clients)
    (message "This buffer has no clients")))

That is good enough for me, but ‘server-edit’ (or ‘server-done’, really)
does a bit of housekeeping that this one does not.
Most importantly, what this code does not is decide what to do
with the buffer. It appears that, if it is unmodified, a process sentinel
will delete it, but if it is modified, it remains. Perhaps that is okay.
Perhaps aborting a server is such an exceptional event, one should
leave the cleanup to the user anyhow.
Further ‘server-edit’ will try to switch to a different server buffer,
if one exists. This code does not. Again, perhaps that is as it should be.

– Harald



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11358; Package emacs. (Fri, 04 Jun 2021 09:14:02 GMT) Full text and rfc822 format available.

Message #28 received at 11358 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Harald Hanche-Olsen <harald.hanche-olsen <at> ntnu.no>
Cc: "11358 <at> debbugs.gnu.org" <11358 <at> debbugs.gnu.org>,
 Eli Zaretskii <eliz <at> gnu.org>,
 "npostavs <at> users.sourceforge.net" <npostavs <at> users.sourceforge.net>
Subject: Re: bug#11358: 24.1.50; Feature request: A way to abort emacs-client
Date: Fri, 04 Jun 2021 11:13:24 +0200
Harald Hanche-Olsen <harald.hanche-olsen <at> ntnu.no> writes:

> Here is a very naive first stab:
>
> (defun server-abort ()
>   (interactive)
>   (if server-clients
>       (mapc (lambda (proc)
>               (server-send-string
>                proc (concat "-error "
>                             (server-quote-arg "Aborted by the user"))))
>             server-clients)
>     (message "This buffer has no clients")))
>
> That is good enough for me, but ‘server-edit’ (or ‘server-done’, really)
> does a bit of housekeeping that this one does not.

Thanks, I installed this in Emacs 28 (under the name
server-edit-abort).  This, along with your previous patch, reaches the
limit of the number of lines we can accept into Emacs without a
copyright assignment.  Would you be willing to sign such paperwork?

> Most importantly, what this code does not is decide what to do
> with the buffer. It appears that, if it is unmodified, a process sentinel
> will delete it, but if it is modified, it remains. Perhaps that is okay.
> Perhaps aborting a server is such an exceptional event, one should
> leave the cleanup to the user anyhow.

Yes, I think that makes sense.  If somebody wants to add more logic
here (to query the user for something), that might also be nice.  But it
may not be necessary.

> Further ‘server-edit’ will try to switch to a different server buffer,
> if one exists. This code does not. Again, perhaps that is as it should be.

Yeah, I think aborting just the current buffer makes sense, but I can
see somebody wanting this to behave more like `server-edit' -- I guess
we'll see.  But I think this is fine for now, at least, so I'm closing
this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 28.1, send any further explanations to 11358 <at> debbugs.gnu.org and Harald Hanche-Olsen <hanche <at> math.ntnu.no> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 04 Jun 2021 09:14:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 02 Jul 2021 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 293 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.