unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 28066@debbugs.gnu.org, rms@gnu.org, yegortimoshenko@gmail.com
Subject: bug#28066: eshell-tramp sudo ignores C-c
Date: Mon, 21 Aug 2017 13:36:06 +0200	[thread overview]
Message-ID: <87y3qdnoex.fsf@detlef> (raw)
In-Reply-To: <837exyc9ok.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 20 Aug 2017 22:37:31 +0300")

[-- Attachment #1: Type: text/plain, Size: 355 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

Hi Eli,

> In such cases, we usually provide a variable whose value is a
> function.  The default value is a function that does whatever
> interrupt-process is doing now, and Tramp can replace it with its own
> function.
>
> Does this make sense in your case?

What about the appended patch?

Best regards, Michael.


[-- Attachment #2: Type: text/plain, Size: 2805 bytes --]

diff --git a/src/process.c b/src/process.c
index 1900951533..e7ee99ab3d 100644
--- a/src/process.c
+++ b/src/process.c
@@ -6677,6 +6677,18 @@ process_send_signal (Lisp_Object process, int signo, Lisp_Object current_group,
   unblock_child_signal (&oldset);
 }
 
+DEFUN ("internal-default-interrupt-process",
+       Finternal_default_interrupt_process,
+       Sinternal_default_interrupt_process, 0, 2, 0,
+       doc: /* Default function to interrupt process PROCESS.
+It shall be the last element in list `interrupt-process-functions'.
+See function `interrupt-process' for more details on usage.  */)
+  (Lisp_Object process, Lisp_Object current_group)
+{
+  process_send_signal (process, SIGINT, current_group, 0);
+  return process;
+}
+
 DEFUN ("interrupt-process", Finterrupt_process, Sinterrupt_process, 0, 2, 0,
        doc: /* Interrupt process PROCESS.
 PROCESS may be a process, a buffer, or the name of a process or buffer.
@@ -6688,11 +6700,14 @@ If the process is a shell, this means interrupt current subjob
 rather than the shell.
 
 If CURRENT-GROUP is `lambda', and if the shell owns the terminal,
-don't send the signal.  */)
+don't send the signal.
+
+This function calls the functions of `interrupt-process-functions' in
+the order of the list, until one of them returns non-`nil'.  */)
   (Lisp_Object process, Lisp_Object current_group)
 {
-  process_send_signal (process, SIGINT, current_group, 0);
-  return process;
+  return CALLN (Frun_hook_with_args_until_success, Qinterrupt_process_functions,
+		process, current_group);
 }
 
 DEFUN ("kill-process", Fkill_process, Skill_process, 0, 2, 0,
@@ -8176,6 +8191,17 @@ non-nil value means that the delay is not reset on write.
 The variable takes effect when `start-process' is called.  */);
   Vprocess_adaptive_read_buffering = Qt;
 
+  DEFVAR_LISP ("interrupt-process-functions", Vinterrupt_process_functions,
+	       doc: /* List of functions to be called for `interrupt-function'.
+The arguments of the functions are the same as for `interrupt-function'.
+These functions are called in the order of the list, until one of them
+returns non-`nil'.  */);
+  Vinterrupt_process_functions = list1 (Qinternal_default_interrupt_process);
+
+  DEFSYM (Qinternal_default_interrupt_process,
+	  "internal-default-interrupt-process");
+  DEFSYM (Qinterrupt_process_functions, "interrupt-process-functions");
+
   defsubr (&Sprocessp);
   defsubr (&Sget_process);
   defsubr (&Sdelete_process);
@@ -8218,6 +8244,7 @@ The variable takes effect when `start-process' is called.  */);
   defsubr (&Saccept_process_output);
   defsubr (&Sprocess_send_region);
   defsubr (&Sprocess_send_string);
+  defsubr (&Sinternal_default_interrupt_process);
   defsubr (&Sinterrupt_process);
   defsubr (&Skill_process);
   defsubr (&Squit_process);

  parent reply	other threads:[~2017-08-21 11:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-12 14:45 bug#28066: eshell-tramp sudo ignores C-c Yegor Timoshenko
2017-08-13  8:39 ` Michael Albinus
2017-08-14  1:51   ` Richard Stallman
2017-08-20 19:29     ` Michael Albinus
2017-08-20 19:37       ` Eli Zaretskii
2017-08-20 19:46         ` Michael Albinus
2017-08-21 11:36         ` Michael Albinus [this message]
2017-08-21 14:34           ` Eli Zaretskii
2017-08-21 15:01             ` Michael Albinus
2017-08-20 22:31       ` Yegor Timoshenko
2017-08-21  7:29         ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y3qdnoex.fsf@detlef \
    --to=michael.albinus@gmx.de \
    --cc=28066@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=rms@gnu.org \
    --cc=yegortimoshenko@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).