From d15a4805d6347412ae1d605dcf5e8d3fe0f8e743 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Helary Date: Thu, 4 May 2017 20:32:40 +0200 Subject: [PATCH] Multiline support in NS "Open Selected File" service. * lisp/term/ns-win.el (ns-open-file-service): new function. Wraps the original call in a (split-string) to create as many calls as there are lines. (ns-spi-service-call): Call `ns-open-file-service' instead of `dnd-open-file'. --- lisp/term/ns-win.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el index 70bd817d930..4df5f0abe21 100644 --- a/lisp/term/ns-win.el +++ b/lisp/term/ns-win.el @@ -229,6 +229,15 @@ The properties returned may include `top', `left', `height', and `width'." (declare-function dnd-open-file "dnd" (uri action)) +;; Handles multiline strings that are passed to the "open-file" service. +(defun ns-open-file-service (filenames) + "Open multiple files when selecting a multiline string FILENAMES." + (let ((filelist (split-string filenames "[\n\r]+" t "[ \u00A0\t]+"))) + ;; The path strings are trimmed for spaces, nbsp and tabs. + (dolist (filestring filelist) + (dnd-open-file filestring nil)))) + + (defun ns-spi-service-call () "Respond to a service request." (interactive) @@ -236,7 +245,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) -- 2.39.5