From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.bugs Subject: bug#28691: [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__21526.1563113474$1545003551$gmane$org@google.com> References: 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 1545003551 21039 195.159.176.226 (16 Dec 2018 23:39:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 16 Dec 2018 23:39:11 +0000 (UTC) Cc: Philipp Stephani To: emacs-devel@gnu.org, 28691@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Dec 17 00:39:07 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1gYg02-0005OU-Pj for geb-bug-gnu-emacs@m.gmane.org; Mon, 17 Dec 2018 00:39:07 +0100 Original-Received: from localhost ([::1]:44206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYg29-0000kL-L6 for geb-bug-gnu-emacs@m.gmane.org; Sun, 16 Dec 2018 18:41:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37000) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYg1y-0000ip-3W for bug-gnu-emacs@gnu.org; Sun, 16 Dec 2018 18:41:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gYg1u-0004z2-0L for bug-gnu-emacs@gnu.org; Sun, 16 Dec 2018 18:41:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:46430) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gYg1t-0004y8-S3 for bug-gnu-emacs@gnu.org; Sun, 16 Dec 2018 18:41:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gYg1t-0005rQ-Kw for bug-gnu-emacs@gnu.org; Sun, 16 Dec 2018 18:41:01 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Philipp Stephani Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 16 Dec 2018 23:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28691 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 28691-submit@debbugs.gnu.org id=B28691.154500361122460 (code B ref 28691); Sun, 16 Dec 2018 23:41:01 +0000 Original-Received: (at 28691) by debbugs.gnu.org; 16 Dec 2018 23:40:11 +0000 Original-Received: from localhost ([127.0.0.1]:50688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gYg14-0005qC-Lx for submit@debbugs.gnu.org; Sun, 16 Dec 2018 18:40:10 -0500 Original-Received: from mail-wm1-f43.google.com ([209.85.128.43]:35574) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gYg12-0005pt-SH for 28691@debbugs.gnu.org; Sun, 16 Dec 2018 18:40:09 -0500 Original-Received: by mail-wm1-f43.google.com with SMTP id c126so10841967wmh.0 for <28691@debbugs.gnu.org>; Sun, 16 Dec 2018 15:40:08 -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=To+qjrBB30+tY05RhA2nuv+4fvPdEqjuYnKQ05jqtsyjhr5OahksjinD0bXLcIhG7i +fGMzd3qBZtSudWUzMmbnPP+974oDGJbEzCArjW+aVQukOYnQfYQSDMcJ2eD2vOlV5dX XmB8nqUcFmx/YGp1A2MiqSy6ytQ4JvQ24bIRdfPSN/sJEzVhxN3dMxS9lVQsAsPej9d+ oCkbYHnPKh4x+mfWhqTZBqtTM9qZK8AUnsIFE6XrKqb6Q629LRaX6Ya/3DKv5L+zYKcV cbKXP2eU5+op4VwdxyEmorAF6a6dzDWbVBlAQPAtIfyhMr8g0tFL8vsO5R5YyyTl6InO n2Jg== X-Gm-Message-State: AA+aEWa1fKdhNN/MrRsGLohmY7sGil2YBIOA4Efxp6RfObFYs6DeOgRe Ss1zmsefhFjLHhagFV0RFYc= 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:153502 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