all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jean-Christophe Helary <jean.christophe.helary@gmail.com>
To: emacs-devel <emacs-devel@gnu.org>
Subject: Re: lisp/term/ns-win.el modification
Date: Tue, 2 May 2017 00:12:41 +0900	[thread overview]
Message-ID: <0FED46C2-B8D7-40B3-BEF0-1515E7E5DE9F@gmail.com> (raw)
In-Reply-To: <83efw9j6l0.fsf@gnu.org>

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


> On May 1, 2017, at 17:59, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: Jean-Christophe Helary <jean.christophe.helary@gmail.com>
>> Date: Mon, 1 May 2017 17:23:19 +0900
>> 
>> 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.
> 
> OK, thanks.
> 
> 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 


[-- Attachment #2: ns-win.el.diff --]
[-- Type: application/octet-stream, Size: 1280 bytes --]

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)

  parent reply	other threads:[~2017-05-01 15:12 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-27  4:50 lisp/term/ns-win.el modification Jean-Christophe Helary
2017-04-27  9:02 ` Anders Lindgren
2017-04-27 10:13   ` Jean-Christophe Helary
2017-04-27 11:30     ` Anders Lindgren
2017-04-27 14:53       ` Jean-Christophe Helary
2017-04-27 15:09         ` Davis Herring
2017-04-27 15:31           ` Jean-Christophe Helary
2017-04-27 23:32           ` Jean-Christophe Helary
     [not found]             ` <15112485-03CC-4FFF-8A9D-BA28D2490A91-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-04-28  1:49               ` Jean-Christophe Helary
2017-04-29 12:24                 ` Anders Lindgren
     [not found]                   ` <CABr8ebaB1Fp0BgVy7LWwtOnSs1UOXr3CJumMfOWR4JOooQMT4g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-29 12:49                     ` Jean-Christophe Helary
2017-04-30  5:36                       ` Anders Lindgren
2017-04-30 12:14                         ` Noam Postavsky
2017-04-30  6:41                   ` Jean-Christophe Helary
2017-04-30 14:12                     ` Eli Zaretskii
2017-04-30 15:06                       ` Clément Pit-Claudel
2017-04-30 15:24                         ` Eli Zaretskii
2017-04-30 22:28                           ` Jean-Christophe Helary
2017-05-01  6:33                             ` Eli Zaretskii
2017-05-01  8:23                               ` Jean-Christophe Helary
2017-05-01  8:59                                 ` Eli Zaretskii
2017-05-01 10:53                                   ` Jean-Christophe Helary
2017-05-01 11:27                                     ` Eli Zaretskii
2017-05-02  4:00                                       ` Jean-Christophe Helary
2017-05-02  6:44                                         ` Eli Zaretskii
2017-05-02  6:47                                           ` Jean-Christophe Helary
2017-05-01 15:12                                   ` Jean-Christophe Helary [this message]
2017-05-01 15:27                                     ` Eli Zaretskii
2017-05-01 15:58                                       ` Jean-Christophe Helary
2017-05-01 16:25                                         ` Eli Zaretskii
2017-05-02 12:57                                           ` Jean-Christophe Helary
2017-05-03 20:40                                             ` Anders Lindgren
2017-05-04  0:10                                               ` Jean-Christophe Helary
2017-05-04  8:50                                               ` Jean-Christophe Helary
2017-05-04 18:37                                                 ` Anders Lindgren
2017-05-05  8:36                                                   ` Jean-Christophe Helary
2017-04-30 22:23                       ` Jean-Christophe Helary
2017-05-01  6:30                         ` Eli Zaretskii
2017-04-27 12:24     ` Noam Postavsky
2017-04-27 14:53       ` Jean-Christophe Helary
2017-04-27 12:51     ` mituharu
2017-04-27 14:55       ` Jean-Christophe Helary
2017-04-27 15:35       ` Jean-Christophe Helary
2017-04-27 18:28         ` mituharu
2017-04-27 23:29           ` Jean-Christophe Helary

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

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

  git send-email \
    --in-reply-to=0FED46C2-B8D7-40B3-BEF0-1515E7E5DE9F@gmail.com \
    --to=jean.christophe.helary@gmail.com \
    --cc=emacs-devel@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.