From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: YAMAMOTO Mitsuharu Newsgroups: gmane.emacs.devel Subject: Re: Emacs 23 Mac port Date: Fri, 30 Apr 2010 10:21:48 +0900 Organization: Faculty of Science, Chiba University Message-ID: References: <2282B3B4-D844-4E26-BB94-9F79EEA2E847@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Trace: dough.gmane.org 1272590524 27268 80.91.229.12 (30 Apr 2010 01:22:04 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 30 Apr 2010 01:22:04 +0000 (UTC) Cc: emacs-devel@gnu.org To: Leo Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Apr 30 03:22:03 2010 connect(): No such file or directory Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1O7eva-0004Jh-FR for ged-emacs-devel@m.gmane.org; Fri, 30 Apr 2010 03:22:02 +0200 Original-Received: from localhost ([127.0.0.1]:47573 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O7evZ-0000Ng-QE for ged-emacs-devel@m.gmane.org; Thu, 29 Apr 2010 21:22:01 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O7evV-0000MN-3b for emacs-devel@gnu.org; Thu, 29 Apr 2010 21:21:57 -0400 Original-Received: from [140.186.70.92] (port=36949 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O7evT-0000LI-OR for emacs-devel@gnu.org; Thu, 29 Apr 2010 21:21:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O7evR-0003gb-QQ for emacs-devel@gnu.org; Thu, 29 Apr 2010 21:21:55 -0400 Original-Received: from mathmail.math.s.chiba-u.ac.jp ([133.82.132.2]:62809) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O7evR-0003fi-9L for emacs-devel@gnu.org; Thu, 29 Apr 2010 21:21:53 -0400 Original-Received: from church.math.s.chiba-u.ac.jp (church [133.82.132.36]) by mathmail.math.s.chiba-u.ac.jp (Postfix) with ESMTP id 42463C0557; Fri, 30 Apr 2010 10:21:48 +0900 (JST) In-Reply-To: User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?ISO-8859-4?Q?Shij=F2?=) APEL/10.6 Emacs/22.3 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI) X-detected-operating-system: by eggs.gnu.org: NetBSD 3.0 (DF) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:124333 Archived-At: >>>>> On Wed, 28 Apr 2010 09:57:15 +0100, Leo 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 mituharu@math.s.chiba-u.ac.jp === 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);