aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Lindgren2015-12-23 07:15:45 +0100
committerAnders Lindgren2015-12-23 07:15:45 +0100
commit09053075225fec8a6cf7a72017a6dfc1ec6b6f0c (patch)
treefd9ce26de7a7c7cd94502ca02a4155f821694aaa
parent781770b4dcfe44b255e94e16479fd14633803640 (diff)
downloademacs-09053075225fec8a6cf7a72017a6dfc1ec6b6f0c.tar.gz
emacs-09053075225fec8a6cf7a72017a6dfc1ec6b6f0c.zip
File-name completion of non-ASCII characters on OS X (bug#22169)
The coding system `utf-8-nfd', locally defined in ns-win.el, didn't provide a :pre-write-conversion method, causing file name completion of non-ASCII characters to fail. Solved by using the `utf-8-hfs' coding system provided by `ucs-normalize'. * lisp/loadup.el: Load international/ucs-normalize (when building for ns). * lisp/term/ns-win.el (utf-8-nfd): Made `utf-8-nfd' as alias for `utf-8-hfs' and removed the old implementation. Set `utf-8-hfs' as the file name coding system. * src/nsfns.c (ns-convert-utf8-nfd-to-nfc): Removed.
-rw-r--r--lisp/loadup.el1
-rw-r--r--lisp/term/ns-win.el28
-rw-r--r--src/nsfns.m34
3 files changed, 7 insertions, 56 deletions
diff --git a/lisp/loadup.el b/lisp/loadup.el
index f0caa8be349..dda433e4eaf 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -276,6 +276,7 @@
276(if (featurep 'ns) 276(if (featurep 'ns)
277 (progn 277 (progn
278 (load "term/common-win") 278 (load "term/common-win")
279 (load "international/ucs-normalize")
279 (load "term/ns-win"))) 280 (load "term/ns-win")))
280(if (fboundp 'x-create-frame) 281(if (fboundp 'x-create-frame)
281 ;; Do it after loading term/foo-win.el since the value of the 282 ;; Do it after loading term/foo-win.el since the value of the
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el
index 0b3e3bd9d9c..9bd59fc1954 100644
--- a/lisp/term/ns-win.el
+++ b/lisp/term/ns-win.el
@@ -51,6 +51,7 @@
51(require 'menu-bar) 51(require 'menu-bar)
52(require 'fontset) 52(require 'fontset)
53(require 'dnd) 53(require 'dnd)
54(require 'ucs-normalize)
54 55
55(defgroup ns nil 56(defgroup ns nil
56 "GNUstep/Mac OS X specific features." 57 "GNUstep/Mac OS X specific features."
@@ -337,29 +338,12 @@ See `ns-insert-working-text'."
337 (setq ns-working-overlay nil)) 338 (setq ns-working-overlay nil))
338 339
339 340
340(declare-function ns-convert-utf8-nfd-to-nfc "nsfns.m" (str)) 341;; OS X file system Unicode UTF-8 NFD (decomposed form) support.
341
342;;;; OS X file system Unicode UTF-8 NFD (decomposed form) support
343;; Lisp code based on utf-8m.el, by Seiji Zenitani, Eiji Honjoh, and
344;; Carsten Bormann.
345(when (eq system-type 'darwin) 342(when (eq system-type 'darwin)
346 (defun ns-utf8-nfd-post-read-conversion (length) 343 ;; Used prior to Emacs 25.
347 "Calls `ns-convert-utf8-nfd-to-nfc' to compose char sequences." 344 (define-coding-system-alias 'utf-8-nfd 'utf-8-hfs)
348 (save-excursion 345
349 (save-restriction 346 (set-file-name-coding-system 'utf-8-hfs))
350 (narrow-to-region (point) (+ (point) length))
351 (let ((str (buffer-string)))
352 (delete-region (point-min) (point-max))
353 (insert (ns-convert-utf8-nfd-to-nfc str))
354 (- (point-max) (point-min))))))
355
356 (define-coding-system 'utf-8-nfd
357 "UTF-8 NFD (decomposed) encoding."
358 :coding-type 'utf-8
359 :mnemonic ?U
360 :charset-list '(unicode)
361 :post-read-conversion 'ns-utf8-nfd-post-read-conversion)
362 (set-file-name-coding-system 'utf-8-nfd))
363 347
364;;;; Inter-app communications support. 348;;;; Inter-app communications support.
365 349
diff --git a/src/nsfns.m b/src/nsfns.m
index edc02e8350b..5fa68c0a15c 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -2099,39 +2099,6 @@ there was no result. */)
2099} 2099}
2100 2100
2101 2101
2102DEFUN ("ns-convert-utf8-nfd-to-nfc", Fns_convert_utf8_nfd_to_nfc,
2103 Sns_convert_utf8_nfd_to_nfc, 1, 1, 0,
2104 doc: /* Return an NFC string that matches the UTF-8 NFD string STR. */)
2105 (Lisp_Object str)
2106{
2107/* TODO: If GNUstep ever implements precomposedStringWithCanonicalMapping,
2108 remove this. */
2109 NSString *utfStr;
2110 Lisp_Object ret = Qnil;
2111 NSAutoreleasePool *pool;
2112
2113 CHECK_STRING (str);
2114 pool = [[NSAutoreleasePool alloc] init];
2115 utfStr = [NSString stringWithUTF8String: SSDATA (str)];
2116#ifdef NS_IMPL_COCOA
2117 if (utfStr)
2118 utfStr = [utfStr precomposedStringWithCanonicalMapping];
2119#endif
2120 if (utfStr)
2121 {
2122 const char *cstr = [utfStr UTF8String];
2123 if (cstr)
2124 ret = build_string (cstr);
2125 }
2126
2127 [pool release];
2128 if (NILP (ret))
2129 error ("Invalid UTF-8");
2130
2131 return ret;
2132}
2133
2134
2135#ifdef NS_IMPL_COCOA 2102#ifdef NS_IMPL_COCOA
2136 2103
2137/* Compile and execute the AppleScript SCRIPT and return the error 2104/* Compile and execute the AppleScript SCRIPT and return the error
@@ -3207,7 +3174,6 @@ be used as the image of the icon representing the frame. */);
3207 defsubr (&Sns_emacs_info_panel); 3174 defsubr (&Sns_emacs_info_panel);
3208 defsubr (&Sns_list_services); 3175 defsubr (&Sns_list_services);
3209 defsubr (&Sns_perform_service); 3176 defsubr (&Sns_perform_service);
3210 defsubr (&Sns_convert_utf8_nfd_to_nfc);
3211 defsubr (&Sns_popup_font_panel); 3177 defsubr (&Sns_popup_font_panel);
3212 defsubr (&Sns_popup_color_panel); 3178 defsubr (&Sns_popup_color_panel);
3213 3179