[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Emacs 23 Mac port
From: |
YAMAMOTO Mitsuharu |
Subject: |
Re: Emacs 23 Mac port |
Date: |
Fri, 30 Apr 2010 10:21:48 +0900 |
User-agent: |
Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.6 Emacs/22.3 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI) |
>>>>> On Wed, 28 Apr 2010 09:57:15 +0100, Leo <address@hidden> said:
> I sometimes run into alias files in dired and emacs treat them like
> a normal file. Do you think this can be fixed? Thank you.
Perhaps do-applescript can be used for resolving an alias file like:
(do-applescript "tell application \"Finder\" to get POSIX path of (the
original item of (the POSIX file \"SOME_ALIAS_FILE\" as alias) as alias)")
but this requires quoting and unquoting file name strings.
I'll add `mac-file-alias-p', which is supposed to be parallel to
`file-symlink-p', to the next release. This would enable you to
advise some dired function, I guess.
YAMAMOTO Mitsuharu
address@hidden
=== modified file 'src/mac.c'
*** src/mac.c 2010-04-15 00:55:57 +0000
--- src/mac.c 2010-04-29 03:18:20 +0000
***************
*** 1826,1831 ****
--- 1826,1833 ----
}
+ Lisp_Object Qmac_file_alias_p;
+
void
initialize_applescript ()
{
***************
*** 2044,2049 ****
--- 2046,2103 ----
return Qt;
}
+ DEFUN ("mac-file-alias-p", Fmac_file_alias_p, Smac_file_alias_p, 1, 1, 0,
+ doc: /* Return non-nil if file FILENAME is the name of an alias file.
+ The value is the file referred to by the alias file, as a string.
+ Otherwise it returns nil.
+
+ This function returns t when given the name of an alias file
+ containing a unresolvable alias. */)
+ (filename)
+ Lisp_Object filename;
+ {
+ OSStatus err;
+ Lisp_Object handler, result = Qnil;
+ FSRef fref;
+
+ CHECK_STRING (filename);
+ filename = Fexpand_file_name (filename, Qnil);
+
+ /* If the file name has special constructs in it,
+ call the corresponding file handler. */
+ handler = Ffind_file_name_handler (filename, Qmac_file_alias_p);
+ if (!NILP (handler))
+ return call2 (handler, Qmac_file_alias_p, filename);
+
+ BLOCK_INPUT;
+ err = FSPathMakeRef (SDATA (ENCODE_FILE (filename)), &fref, NULL);
+ if (err == noErr)
+ {
+ Boolean alias_p = false, folder_p;
+
+ err = FSResolveAliasFileWithMountFlags (&fref, false,
+ &folder_p, &alias_p,
+ kResolveAliasFileNoUI);
+ if (err != noErr)
+ result = Qt;
+ else if (alias_p)
+ {
+ char buf[MAXPATHLEN];
+
+ err = FSRefMakePath (&fref, buf, sizeof (buf));
+ if (err == noErr)
+ {
+ result = make_unibyte_string (buf, strlen (buf));
+ if (buf[0] == '/' && index (buf, ':'))
+ result = concat2 (build_string ("/:"), result);
+ result = DECODE_FILE (result);
+ }
+ }
+ }
+ UNBLOCK_INPUT;
+
+ return result;
+ }
/* Moving files to the system recycle bin.
Used by `move-file-to-trash' instead of the default moving to ~/.Trash */
***************
*** 3790,3795 ****
--- 3844,3852 ----
Qdictionary = intern_c_string ("dictionary"); staticpro
(&Qdictionary);
Qdescription = intern_c_string ("description"); staticpro (&Qdescription);
+ Qmac_file_alias_p = intern_c_string ("mac-file-alias-p");
+ staticpro (&Qmac_file_alias_p);
+
Qxml = intern_c_string ("xml");
staticpro (&Qxml);
***************
*** 3823,3828 ****
--- 3880,3886 ----
defsubr (&Smac_set_file_type);
defsubr (&Smac_get_file_creator);
defsubr (&Smac_get_file_type);
+ defsubr (&Smac_file_alias_p);
defsubr (&Ssystem_move_file_to_trash);
defsubr (&Sdo_applescript);