From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Third Newsgroups: gmane.emacs.devel Subject: Re: macos: Finder's alias handling Date: Mon, 27 Sep 2021 11:19:43 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13993"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Emacs developers , Daniel =?iso-8859-1?Q?Mart=EDn?= To: Jean-Christophe Helary Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Sep 27 14:09:24 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mUpRj-0003R0-4L for ged-emacs-devel@m.gmane-mx.org; Mon, 27 Sep 2021 14:09:23 +0200 Original-Received: from localhost ([::1]:46708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mUpRi-000460-2O for ged-emacs-devel@m.gmane-mx.org; Mon, 27 Sep 2021 08:09:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUpR2-0003BZ-T4 for emacs-devel@gnu.org; Mon, 27 Sep 2021 08:08:40 -0400 Original-Received: from outbound.soverin.net ([116.202.126.228]:51797) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUpQz-0002oW-0u for emacs-devel@gnu.org; Mon, 27 Sep 2021 08:08:40 -0400 Original-Received: from smtp.soverin.net (unknown [10.10.3.24]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by outbound.soverin.net (Postfix) with ESMTPS id 7A89952; Mon, 27 Sep 2021 12:08:33 +0000 (UTC) Original-Received: from smtp.soverin.net (smtp.soverin.net [159.69.232.138]) by soverin.net DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=idiocy.org; s=soverin; t=1632744512; bh=2eUUyY+sQZik0Wa9D936e8UzVXb1xmAk4EZmUD0KsQc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dMvMigGv3pL5+9TtPgHFkHEhz5vazibGXTRKpDB1V0NMxvc7ZQoGgCpJkX5biVxJT uzF4CboM5nXYHtCvQKRURGcFMvQE+enFpThGGVxTo6xR5MVnMHD/FFrW4aQIT5mq3A HcZbnPICaAJCdqAW2AklJSHs1uT0pIbMJBs+tRgcq7/f535VryDf01BFYefdBt/Skk gGWUc4a+kuSjgXFWvKmNwzRqxkd1n15he1RRByNYdOw73EEobcIGG/rLBdnP+2YG6P 4F3IEba80ykp0fk7tyB0PA6kGETQ+ZPjfOnuPPS6AeBNvxO4mf5GkGHCZHbpdKT1Rg 5KcgyiYzK1BeA== Original-Received: from alan by faroe.holly.idiocy.org with local (Exim 4.95-RC2) (envelope-from ) id 1mUnjb-000LL3-PL; Mon, 27 Sep 2021 11:19:43 +0100 Mail-Followup-To: Alan Third , Jean-Christophe Helary , Daniel =?iso-8859-1?Q?Mart=EDn?= , Emacs developers Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=116.202.126.228; envelope-from=alan@idiocy.org; helo=outbound.soverin.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:275576 Archived-At: On Mon, Sep 27, 2021 at 08:30:43AM +0900, Jean-Christophe Helary wrote: > > > > On Sep 27, 2021, at 1:31, Daniel Martín wrote: > > > > Jean-Christophe Helary writes: > > > >> 2) now, I'd like to generalize that so that Emacs automatically > >> triggers that code when entering such a file. So I guess that would > >> encompass dired and the likes, "find-file" and similar commands, > >> etc. Is that even possible? I guess the answer is yes, but at what > >> cost in terms of performance? And how would I go about that? > > > > If you see, macOS aliases always start with the same byte pattern, so > > you could modify magic-mode-alist and add a specific mapping between the > > regular expression that extracts that byte pattern and a new major mode > > that you create (macos-alias-mode, for example). This new major mode > > will ask osascript for the real path of the alias and then show its > > contents in the buffer, either on demand or automatically. That's how > > Emacs handle other binary file types like images or PDFs. > > > > This approach would work when visiting Finder aliases in general, not > > only from Dired. > > Excellent ! Thank you ! Potentially we could also add a function that would resolve them directly using NSFoundation, rather than parsing the files with a regex. The regex may be better if we want to support terminal only builds, though. (It's also unclear to me whether NSUrl resolves the final path or not... I think it must but the documentation doesn't mention it afaics.) -- Alan Third