From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Jean-Christophe Helary Newsgroups: gmane.emacs.devel Subject: Re: lisp/term/ns-win.el modification Date: Tue, 2 May 2017 00:12:41 +0900 Message-ID: <0FED46C2-B8D7-40B3-BEF0-1515E7E5DE9F@gmail.com> References: <44D4AA3B-8F87-42B6-A2D2-00487B066183@gmail.com> <74D20593-63B6-46FB-BAC3-D841D0BCD461@gmail.com> <0A49E755-3D18-48E8-81D4-253160F60A16@gmail.com> <40f503a4-49eb-a3ff-fe5f-993c8f346c33@lanl.gov> <15112485-03CC-4FFF-8A9D-BA28D2490A91@gmail.com> <42CDF1D0-015D-4F0D-A8A2-A55776D34FEE@gmail.com> <83inlmkmqq.fsf@gnu.org> <5d3d3f3d-e49e-2b83-0591-14b3e19f8cb0@gmail.com> <834lx5lxz6.fsf@gnu.org> <7A82B268-C40B-4D45-8973-68A2408F7F28@gmail.com> <83r309jdcj.fsf@gnu.org> <00A24BD4-FE6F-4098-A8DD-73240899FA13@gmail.com> <83efw9j6l0.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_14A94440-494D-4A94-B2D3-240A30D95567" X-Trace: blaine.gmane.org 1493651577 9084 195.159.176.226 (1 May 2017 15:12:57 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 1 May 2017 15:12:57 +0000 (UTC) To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon May 01 17:12:53 2017 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 1d5D0P-0002H7-2p for ged-emacs-devel@m.gmane.org; Mon, 01 May 2017 17:12:53 +0200 Original-Received: from localhost ([::1]:54712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5D0U-0003S8-QG for ged-emacs-devel@m.gmane.org; Mon, 01 May 2017 11:12:58 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5D0L-0003Qc-R5 for emacs-devel@gnu.org; Mon, 01 May 2017 11:12:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5D0I-0001nt-Ky for emacs-devel@gnu.org; Mon, 01 May 2017 11:12:49 -0400 Original-Received: from mail-pg0-x230.google.com ([2607:f8b0:400e:c05::230]:36387) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d5D0I-0001no-EO for emacs-devel@gnu.org; Mon, 01 May 2017 11:12:46 -0400 Original-Received: by mail-pg0-x230.google.com with SMTP id t7so46107900pgt.3 for ; Mon, 01 May 2017 08:12:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:mime-version:subject:date:references:to:in-reply-to:message-id; bh=lnrFF3cSjqq5ZksMWdbnN71HsisUqToLDlZtvTsAwcU=; b=QXBfewRoSuEvh/DAuD80gr3ePb1F41tKni6saVDVQtkrSsNzxZDhYgDL3Jv6r5a/gD qrXBR6nO3BnAs6HyprRYbmyY129sP0IPUC0uvNEUDYpxxnWDYjqgK3Kpsrl1qORrnNiN rtfInPXYhitAAkfhEQ2L9UvKTXAPPJGHEzZS57ZbC5Hn7+x8YKeXLZbZpcTyvMI7sOUF L1E4xrJXwqTZUDSetwObFrzRDcF6vXtVomEglYuKB82gfgmdhPYhLn3TRLoJXsMqK45D GnRPFPPu7DD+vUrnLZ0zLlEFrNOfLh7+q/PqFv1JaA8RNNWgvdLYXs48fbpREzDBohHZ MUzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:mime-version:subject:date:references:to :in-reply-to:message-id; bh=lnrFF3cSjqq5ZksMWdbnN71HsisUqToLDlZtvTsAwcU=; b=OFnxV5E4BcxlzJ6HtjV0/wLBGcdCm7quLmZRkCzTAHSUSFSF9oGwxC/9GXnVzK+MHL 8q3hDDAnZq33OOFe5kMQquM86pDjJ/qZsATBVENXfUUeG93depyr/WQxhrnrgHH8kdds zXLM9rVq60BNF1x5r83kaDQkveoAvFc02P2wlNEHst1fY/9/v9TBU6BOkrw31h8wXobm 82aaU4rrUJBu24vWdzDbe1KT55pwfehRzDzB+tlTh+JuCVgBqydcBf1UuQHkEZmVjUtQ jgfvl+S99PNkKb/+KerUKZhX4bgX9mex1aglgqwLsQGTa82HDAeGQA+vOpvbdJnb1Gnv 3tlQ== X-Gm-Message-State: AN3rC/675DpaL/btO2d+97wtAobGA7VD3E2a7CvaLMB57Uf8X4+1WDqp NWxjGECU7Jj0GtFKaJM= X-Received: by 10.84.236.70 with SMTP id h6mr35005919pln.145.1493651565322; Mon, 01 May 2017 08:12:45 -0700 (PDT) Original-Received: from [192.168.24.54] (pl25298.ag0304.nttpc.ne.jp. [133.232.153.210]) by smtp.gmail.com with ESMTPSA id d3sm30641889pgc.37.2017.05.01.08.12.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 May 2017 08:12:44 -0700 (PDT) In-Reply-To: <83efw9j6l0.fsf@gnu.org> X-Mailer: Apple Mail (2.3273) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c05::230 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:214487 Archived-At: --Apple-Mail=_14A94440-494D-4A94-B2D3-240A30D95567 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On May 1, 2017, at 17:59, Eli Zaretskii wrote: >=20 >> From: Jean-Christophe Helary >> Date: Mon, 1 May 2017 17:23:19 +0900 >>=20 >> The function only understand paths that start from / or from ~, so = the path can't start with ws. As for paths ending with ws, that's a very = marginal case. Currently, in a triple-click all the ws ending the string = is selected and the function will thus fail to open the selected path. = It should be possible to test incrementally whether the trimmed path = points to a file, or if the path ending with the first ws does, etc = until the end of the trailing ws list, but that's not practical. >=20 > OK, thanks. >=20 > Then I'd suggest to use split-string, which can trim any regexp > specified by its 4th argument. That way, you can include NBSP in the > characters to trim. I don't think we should include any additional > characters that have the Zs Unicode category need to be trimmed, as I > believe they are unlikely to be encountered in this scenario. Perhaps > a comment to that effect is in order. Ok, I have something that works here. I'm attaching a diff. Let me know = if that is satisfactory. Jean-Christophe=20 --Apple-Mail=_14A94440-494D-4A94-B2D3-240A30D95567 Content-Disposition: attachment; filename=ns-win.el.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="ns-win.el.diff" Content-Transfer-Encoding: 7bit diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el index 70bd817d93..d0a95dd701 100644 --- a/lisp/term/ns-win.el +++ b/lisp/term/ns-win.el @@ -229,6 +229,19 @@ The properties returned may include `top', `left', `height', and `width'." (declare-function dnd-open-file "dnd" (uri action)) +;; Handles multi line strings that are passed to the "open-file" service. +(defun ns-open-file-service (filepaths) + "Opens multiple files at once when a multiline string is selected." + (let ((path_list (split-string filepaths "[\n\r]+"))) + (dolist (path_string path_list) + (if (not (equal "" path_string)) + (dnd-open-file + ;; The path string is timmed for spaces, nbsp and tabs. + (car (split-string path_string nil nil "[ \u00A0\t]+")) nil))))) + + + + (defun ns-spi-service-call () "Respond to a service request." (interactive) @@ -236,7 +249,7 @@ The properties returned may include `top', `left', `height', and `width'." (switch-to-buffer (generate-new-buffer "*untitled*")) (insert ns-input-spi-arg)) ((string-equal ns-input-spi-name "open-file") - (dnd-open-file ns-input-spi-arg nil)) + (ns-open-file-service ns-input-spi-arg)) ((string-equal ns-input-spi-name "mail-selection") (compose-mail) (rfc822-goto-eoh) --Apple-Mail=_14A94440-494D-4A94-B2D3-240A30D95567--