From mboxrd@z Thu Jan 1 00:00:00 1970
Path: news.gmane.org!.POSTED!not-for-mail
From: Philipp Stephani
Newsgroups: gmane.emacs.devel
Subject: [PATCH] Add file name handler support for 'make-process' (Bug#28691)
Date: Mon, 17 Dec 2018 00:39:36 +0100
Message-ID: <20181216233936.208568-1-phst@google.com>
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: blaine.gmane.org 1545003520 18932 195.159.176.226 (16 Dec 2018 23:38:40 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 16 Dec 2018 23:38:40 +0000 (UTC)
Cc: Philipp Stephani
To: emacs-devel@gnu.org,
28691@debbugs.gnu.org
Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 17 00:38:36 2018
Return-path:
Envelope-to: ged-emacs-devel@m.gmane.org
Original-Received: from lists.gnu.org ([208.118.235.17])
by blaine.gmane.org with esmtp (Exim 4.84_2)
(envelope-from )
id 1gYfzW-0004oB-Te
for ged-emacs-devel@m.gmane.org; Mon, 17 Dec 2018 00:38:35 +0100
Original-Received: from localhost ([::1]:44200 helo=lists.gnu.org)
by lists.gnu.org with esmtp (Exim 4.71)
(envelope-from )
id 1gYg1d-00008w-NN
for ged-emacs-devel@m.gmane.org; Sun, 16 Dec 2018 18:40:45 -0500
Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36484)
by lists.gnu.org with esmtp (Exim 4.71)
(envelope-from ) id 1gYg10-00008a-QZ
for emacs-devel@gnu.org; Sun, 16 Dec 2018 18:40:07 -0500
Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
(envelope-from ) id 1gYg0z-0000hZ-Q1
for emacs-devel@gnu.org; Sun, 16 Dec 2018 18:40:06 -0500
Original-Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:38196)
by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
(Exim 4.71) (envelope-from )
id 1gYg0z-0000aX-Hp
for emacs-devel@gnu.org; Sun, 16 Dec 2018 18:40:05 -0500
Original-Received: by mail-wm1-x332.google.com with SMTP id m22so10873245wml.3
for ; Sun, 16 Dec 2018 15:40:04 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
h=from:to:cc:subject:date:message-id:mime-version
:content-transfer-encoding;
bh=DnV7KHn/qu55l5zBkDlPnuL7SIhhDJAmlTzZnUK3sLk=;
b=Fd8foJvmKpueQA/SAzCOvB4CRAuBrgd2zaBAj8wKYF6ks9OypyhuWZpsOVnbRATjXR
dCyjofPXOoVu/sE1hZQ9G+qOtt9zCCq33D+pg1ilnOk05LA78NtD8D1qwnJhOglirLG0
qGtddL7zsIkYBewbC+t6A8KDrOKwPsleoxrmfPBzinCE16IA10o7iF3H6SiROlV0zLsb
BUxiUg39lJNm7y1DuiVCxjRAPvLQi6VR5qAQDXsKwir9XTbZXNwmQeVAbz+tk3Pbh09U
QbfrZBW15OJYMjOht0c2Puxg5sH4hgOpxQ0H0VFAyS/T+f7F5Ghtqj8PGKrjG6jvB0Jj
aycQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version
:content-transfer-encoding;
bh=DnV7KHn/qu55l5zBkDlPnuL7SIhhDJAmlTzZnUK3sLk=;
b=AlxkdZQ/9cFCNuXYhV2xT5EZ1efw9+z9LkF6cEk1CVxkD3GEJPDLRnuVDfPEtbY/BB
0TcCHg79jRp9U2UnpF/+6rdwnB+F0Phydb44y7ZCpC0/YsOZK6rIUbpXx2BiSkmIvLU+
v3S+SLwP6GxwN0YhmT63UoKipZlhpCXkpKVqFSMPjdgAVYs8bvnAuSU/yxd6a6A7OjO1
CqWm33H0EWEMegwBDAaYBL+0nv+L8YMifhw2/WVtNtx4wAgu8GcOl5TGcEO/RTWB6Jbu
YcC2iDEsULirHEVHV5z7tbwhPR3cIWnm7deQfeLS9taZdEDYoynLtYOf4LAQqlsiHi04
+1vw==
X-Gm-Message-State: AA+aEWYG6CpsMDyg+jsy+gaeom9tF7w1cZ3FS6WSLoZET+Th8mCjW+wq
+JMq6aOE8ou7pGsisb4cF34mwKmjeAo=
X-Google-Smtp-Source: AFSGD/Ww0+EMBSqvum17imdZzFKOuFckPor62z2IZPFgcZ639g3v3bMPd+b7J3fNBIlenpFkAiQhwQ==
X-Received: by 2002:a1c:30b:: with SMTP id 11mr9603684wmd.110.1545003603006;
Sun, 16 Dec 2018 15:40:03 -0800 (PST)
Original-Received: from phst-glaptop.cm.cablesurf.de
([2001:4c50:25a:f300:2a16:adff:fe49:52c8])
by smtp.gmail.com with ESMTPSA id
b7sm10029213wrs.47.2018.12.16.15.40.01
(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
Sun, 16 Dec 2018 15:40:02 -0800 (PST)
X-Google-Original-From: Philipp Stephani
X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
recognized.
X-Received-From: 2a00:1450:4864:20::332
X-BeenThere: emacs-devel@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: "Emacs development discussions."
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org
Original-Sender: "Emacs-devel"
Xref: news.gmane.org gmane.emacs.devel:231861
Archived-At:
* src/process.c (Fmake_process): Add new keyword argument
':file-handler'.
(syms_of_process) : Define new symbols.
* test/src/process-tests.el (make-process/file-handler): New unit
test.
---
etc/NEWS | 4 ++++
src/process.c | 15 +++++++++++++++
test/src/process-tests.el | 22 ++++++++++++++++++++++
3 files changed, 41 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index c88f6ef5ca..0a5f915b33 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1407,6 +1407,10 @@ un-obsoleting it.
+++
** New function 'group-name' returns a group name corresponding to GID.
+** 'make-process' now takes a keyword argument ':file-handler'; if
+that is non-nil, it will search for a file name handler for
+'default-directory'.
+
* Changes in Emacs 27.1 on Non-Free Operating Systems
diff --git a/src/process.c b/src/process.c
index 8e0b2349f9..852431f421 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1661,6 +1661,9 @@ to the standard error of subprocess. Specifying this implies
`:connection-type' is set to `pipe'. If STDERR is nil, standard error
is mixed with standard output and sent to BUFFER or FILTER.
+:file-handler FILE-HANDLER -- If FILE-HANDLER is non-nil, then search
+for a file name handler for `default-directory'.
+
usage: (make-process &rest ARGS) */)
(ptrdiff_t nargs, Lisp_Object *args)
{
@@ -1674,6 +1677,15 @@ usage: (make-process &rest ARGS) */)
/* Save arguments for process-contact and clone-process. */
contact = Flist (nargs, args);
+ if (!NILP (Fplist_get (contact, QCfile_handler)))
+ {
+ Lisp_Object file_handler
+ = Ffind_file_name_handler (BVAR (current_buffer, directory),
+ Qmake_process);
+ if (!NILP (file_handler))
+ return CALLN (Fapply, file_handler, Qmake_process, contact);
+ }
+
buffer = Fplist_get (contact, QCbuffer);
if (!NILP (buffer))
buffer = Fget_buffer_create (buffer);
@@ -8098,6 +8110,8 @@ init_process_emacs (int sockfd)
void
syms_of_process (void)
{
+ DEFSYM (Qmake_process, "make-process");
+
#ifdef subprocesses
DEFSYM (Qprocessp, "processp");
@@ -8138,6 +8152,7 @@ syms_of_process (void)
DEFSYM (Qreal, "real");
DEFSYM (Qnetwork, "network");
DEFSYM (Qserial, "serial");
+ DEFSYM (QCfile_handler, ":file-handler");
DEFSYM (QCbuffer, ":buffer");
DEFSYM (QChost, ":host");
DEFSYM (QCservice, ":service");
diff --git a/test/src/process-tests.el b/test/src/process-tests.el
index 551b34ff37..3e72e9210d 100644
--- a/test/src/process-tests.el
+++ b/test/src/process-tests.el
@@ -215,5 +215,27 @@ process-tests--mixable
(string-to-list "stdout\n")
(string-to-list "stderr\n"))))))
+(ert-deftest make-process/file-handler ()
+ "Check that the ‘:file-handler’ argument of ‘make-process’
+works as expected."
+ (let ((file-handler-calls 0))
+ (cl-flet ((file-handler
+ (&rest args)
+ (should (equal default-directory "test-handler:/dir/"))
+ (should (equal args '(make-process :name "name"
+ :command ("/bin/true")
+ :file-handler t)))
+ (cl-incf file-handler-calls)
+ 'fake-process))
+ (let ((file-name-handler-alist
+ (cons (cons (rx bos "test-handler:") #'file-handler)
+ file-name-handler-alist))
+ (default-directory "test-handler:/dir/"))
+ (should (eq (make-process :name "name"
+ :command '("/bin/true")
+ :file-handler t)
+ 'fake-process))
+ (should (= file-handler-calls 1))))))
+
(provide 'process-tests)
;; process-tests.el ends here.
--
2.20.0.405.gbc1bbc6f85-goog