-;;; w32-win.el --- parse switches controlling interface with W32 window system
+;;; w32-win.el --- parse switches controlling interface with W32 window system -*- lexical-binding: t -*-
-;; Copyright (C) 1993-1994, 2001-2012 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1994, 2001-2013 Free Software Foundation, Inc.
;; Author: Kevin Gallo
;; Keywords: terminals
;; (if (not (eq window-system 'w32))
;; (error "%s: Loading w32-win.el but not compiled for w32" (invocation-name)))
+(eval-when-compile (require 'cl-lib))
(require 'frame)
(require 'mouse)
(require 'scroll-bar)
(make-obsolete 'w32-default-color-map nil "24.1")
(declare-function w32-send-sys-command "w32fns.c")
-(declare-function set-message-beep "w32console.c")
+(declare-function set-message-beep "w32fns.c")
+
+(declare-function cygwin-convert-file-name-from-windows "cygw32.c"
+ (path &optional absolute_p))
;; Conditional on new-fontset so bootstrapping works on non-GUI compiles
(if (fboundp 'new-fontset)
;; (interactive "e")
;; (princ event))
-(defun w32-drag-n-drop (event)
+(defun w32-handle-dropped-file (window file-name)
+ (let ((f (if (eq system-type 'cygwin)
+ (cygwin-convert-file-name-from-windows file-name t)
+ (subst-char-in-string ?\\ ?/ file-name)))
+ (coding (or file-name-coding-system
+ default-file-name-coding-system)))
+
+ (setq file-name
+ (mapconcat 'url-hexify-string
+ (split-string (encode-coding-string f coding)
+ "/")
+ "/")))
+ (dnd-handle-one-url window 'private
+ (concat
+ (if (eq system-type 'cygwin)
+ "file://"
+ "file:")
+ file-name)))
+
+(defun w32-drag-n-drop (event &optional new-frame)
"Edit the files listed in the drag-n-drop EVENT.
Switch to a buffer editing the last file dropped."
(interactive "e")
(y (cdr coords)))
(if (and (> x 0) (> y 0))
(set-frame-selected-window nil window))
- (mapc (lambda (file-name)
- (let ((f (subst-char-in-string ?\\ ?/ file-name))
- (coding (or file-name-coding-system
- default-file-name-coding-system)))
- (setq file-name
- (mapconcat 'url-hexify-string
- (split-string (encode-coding-string f coding)
- "/")
- "/")))
- (dnd-handle-one-url window 'private
- (concat "file:" file-name)))
- (car (cdr (cdr event)))))
- (raise-frame)))
+
+ (when new-frame
+ (select-frame (make-frame)))
+ (raise-frame)
+ (setq window (selected-window))
+
+ (mapc (apply-partially #'w32-handle-dropped-file window)
+ (car (cdr (cdr event)))))))
(defun w32-drag-n-drop-other-frame (event)
"Edit the files listed in the drag-n-drop EVENT, in other frames.
May create new frames, or reuse existing ones. The frame editing
the last file dropped is selected."
(interactive "e")
- (mapcar 'find-file-other-frame (car (cdr (cdr event)))))
+ (w32-drag-n-drop event t))
;; Bind the drag-n-drop event.
(global-set-key [drag-n-drop] 'w32-drag-n-drop)
(defun w32-initialize-window-system ()
"Initialize Emacs for W32 GUI frames."
+ (cl-assert (not w32-initialized))
;; Do the actual Windows setup here; the above code just defines
;; functions and variables that we use now.
;; so as not to choke when we use it in X resource queries.
(replace-regexp-in-string "[.*]" "-" (invocation-name))))
- (x-open-connection "" x-command-line-resources
+ (x-open-connection "w32" x-command-line-resources
;; Exit with a fatal error if this fails and we
;; are the initial display
(eq initial-window-system 'w32))
(setq default-frame-alist
(cons '(reverse . t) default-frame-alist)))))
- ;; Don't let Emacs suspend under w32 gui
+ ;; Don't let Emacs suspend under Windows.
(add-hook 'suspend-hook 'x-win-suspend-error)
;; Turn off window-splitting optimization; w32 is usually fast enough
;; Set to a system sound if you want a fancy bell.
(set-message-beep 'ok)
+ (x-apply-session-resources)
(setq w32-initialized t))
+(add-to-list 'display-format-alist '("\\`w32\\'" . w32))
(add-to-list 'handle-args-function-alist '(w32 . x-handle-args))
(add-to-list 'frame-creation-function-alist '(w32 . x-create-frame-with-faces))
(add-to-list 'window-system-initialization-alist '(w32 . w32-initialize-window-system))