X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/2c82deee7fbb951a90ed3246350fbf9390af038a..960f90d057aa3b09f6f6f287e8996a6e9444c803:/lisp/term/ns-win.el diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el index 9264a1cf03..e737131d5b 100644 --- a/lisp/term/ns-win.el +++ b/lisp/term/ns-win.el @@ -1,6 +1,6 @@ ;;; ns-win.el --- lisp side of interface with NeXT/Open/GNUstep/MacOS X window system -*- lexical-binding: t -*- -;; Copyright (C) 1993-1994, 2005-2015 Free Software Foundation, Inc. +;; Copyright (C) 1993-1994, 2005-2016 Free Software Foundation, Inc. ;; Authors: Carl Edman ;; Christian Limpach @@ -51,6 +51,7 @@ (require 'menu-bar) (require 'fontset) (require 'dnd) +(require 'ucs-normalize) (defgroup ns nil "GNUstep/Mac OS X specific features." @@ -243,7 +244,7 @@ The properties returned may include `top', `left', `height', and `width'." (insert ns-input-spi-arg)) ((string-equal ns-input-spi-name "mail-to") (compose-mail ns-input-spi-arg)) - (t (error (concat "Service " ns-input-spi-name " not recognized"))))) + (t (error "Service %s not recognized" ns-input-spi-name)))) ;; Composed key sequence handling for Nextstep system input methods. @@ -337,29 +338,12 @@ See `ns-insert-working-text'." (setq ns-working-overlay nil)) -(declare-function ns-convert-utf8-nfd-to-nfc "nsfns.m" (str)) - -;;;; OS X file system Unicode UTF-8 NFD (decomposed form) support -;; Lisp code based on utf-8m.el, by Seiji Zenitani, Eiji Honjoh, and -;; Carsten Bormann. +;; OS X file system Unicode UTF-8 NFD (decomposed form) support. (when (eq system-type 'darwin) - (defun ns-utf8-nfd-post-read-conversion (length) - "Calls `ns-convert-utf8-nfd-to-nfc' to compose char sequences." - (save-excursion - (save-restriction - (narrow-to-region (point) (+ (point) length)) - (let ((str (buffer-string))) - (delete-region (point-min) (point-max)) - (insert (ns-convert-utf8-nfd-to-nfc str)) - (- (point-max) (point-min)))))) - - (define-coding-system 'utf-8-nfd - "UTF-8 NFD (decomposed) encoding." - :coding-type 'utf-8 - :mnemonic ?U - :charset-list '(unicode) - :post-read-conversion 'ns-utf8-nfd-post-read-conversion) - (set-file-name-coding-system 'utf-8-nfd)) + ;; Used prior to Emacs 25. + (define-coding-system-alias 'utf-8-nfd 'utf-8-hfs) + + (set-file-name-coding-system 'utf-8-hfs)) ;;;; Inter-app communications support. @@ -717,10 +701,6 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.") ;;;; Pasteboard support. -(declare-function ns-get-selection-internal "nsselect.m" (buffer)) - -(define-obsolete-function-alias 'ns-get-cut-buffer-internal - 'ns-get-selection-internal "24.1") (define-obsolete-function-alias 'ns-store-cut-buffer-internal 'gui-set-selection "24.1") @@ -732,7 +712,7 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.") (defun ns-paste-secondary () (interactive) - (insert (ns-get-selection-internal 'SECONDARY))) + (insert (gui-get-selection 'SECONDARY))) ;;;; Scrollbar handling. @@ -852,7 +832,8 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.") ;; Do the actual Nextstep Windows setup here; the above code just ;; defines functions and variables that we use now. -(defun ns-initialize-window-system (&optional _display) +(cl-defmethod window-system-initialization (&context (window-system ns) + &optional _display) "Initialize Emacs for Nextstep (Cocoa / GNUstep) windowing." (cl-assert (not ns-initialized)) @@ -925,18 +906,34 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.") ;; Any display name is OK. (add-to-list 'display-format-alist '(".*" . ns)) -(gui-method-define handle-args-function ns #'x-handle-args) -(gui-method-define frame-creation-function ns #'x-create-frame-with-faces) -(gui-method-define window-system-initialization ns - #'ns-initialize-window-system) - -(gui-method-define gui-set-selection ns - (lambda (selection value) - (if value (ns-own-selection-internal selection value) - (ns-disown-selection-internal selection)))) -(gui-method-define gui-selection-owner-p ns #'ns-selection-owner-p) -(gui-method-define gui-selection-exists-p ns #'ns-selection-exists-p) -(gui-method-define gui-get-selection ns #'ns-get-selection) +(cl-defmethod handle-args-function (args &context (window-system ns)) + (x-handle-args args)) + +(cl-defmethod frame-creation-function (params &context (window-system ns)) + (x-create-frame-with-faces params)) + +(declare-function ns-own-selection-internal "nsselect.m" (selection value)) +(declare-function ns-disown-selection-internal "nsselect.m" (selection)) +(declare-function ns-selection-owner-p "nsselect.m" (&optional selection)) +(declare-function ns-selection-exists-p "nsselect.m" (&optional selection)) +(declare-function ns-get-selection "nsselect.m" (selection-symbol target-type)) + +(cl-defmethod gui-backend-set-selection (selection value + &context (window-system ns)) + (if value (ns-own-selection-internal selection value) + (ns-disown-selection-internal selection))) + +(cl-defmethod gui-backend-selection-owner-p (selection + &context (window-system ns)) + (ns-selection-owner-p selection)) + +(cl-defmethod gui-backend-selection-exists-p (selection + &context (window-system ns)) + (ns-selection-exists-p selection)) + +(cl-defmethod gui-backend-get-selection (selection-symbol target-type + &context (window-system ns)) + (ns-get-selection selection-symbol target-type)) (provide 'ns-win)