========================================================================== */
+#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
+/* Moving files to the system recycle bin.
+ Used by `move-file-to-trash' instead of the default moving to ~/.Trash */
+DEFUN ("system-move-file-to-trash", Fsystem_move_file_to_trash,
+ Ssystem_move_file_to_trash, 1, 1, 0,
+ doc: /* Move file or directory named FILENAME to the recycle bin. */)
+ (Lisp_Object filename)
+{
+ Lisp_Object handler;
+ Lisp_Object operation;
+
+ operation = Qdelete_file;
+ if (!NILP (Ffile_directory_p (filename))
+ && NILP (Ffile_symlink_p (filename)))
+ {
+ operation = intern ("delete-directory");
+ filename = Fdirectory_file_name (filename);
+ }
+
+ /* Must have fully qualified file names for moving files to Trash. */
+ filename = Fexpand_file_name (filename, Qnil);
+
+ handler = Ffind_file_name_handler (filename, operation);
+ if (!NILP (handler))
+ return call2 (handler, operation, filename);
+ else
+ {
+ NSFileManager *fm = [NSFileManager defaultManager];
+ BOOL result = NO;
+ NSURL *fileURL = [NSURL fileURLWithPath:[NSString stringWithLispString:filename]
+ isDirectory:!NILP (Ffile_directory_p (filename))];
+ if ([fm respondsToSelector:@selector(trashItemAtURL:resultingItemURL:error:)])
+ result = [fm trashItemAtURL:fileURL resultingItemURL:nil error:nil];
+
+ if (!result)
+ report_file_error ("Removing old name", list1 (filename));
+ }
+ return Qnil;
+}
+#endif
+
DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
doc: /* SKIP: real doc in xfns.c. */)
(Lisp_Object color, Lisp_Object frame)
defsubr (&Sx_show_tip);
defsubr (&Sx_hide_tip);
+#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
+ defsubr (&Ssystem_move_file_to_trash);
+#endif
+
as_status = 0;
as_script = Qnil;
staticpro (&as_script);