emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master d15a480: Multiline support in NS "Open Selected Fil


From: Anders Lindgren
Subject: [Emacs-diffs] master d15a480: Multiline support in NS "Open Selected File" service.
Date: Thu, 4 May 2017 14:34:17 -0400 (EDT)

branch: master
commit d15a4805d6347412ae1d605dcf5e8d3fe0f8e743
Author: Jean-Christophe Helary <address@hidden>
Commit: Anders Lindgren <address@hidden>

    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 70bd817..4df5f0a 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]