emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: macos: Finder's alias handling


From: Daniel Martín
Subject: Re: macos: Finder's alias handling
Date: Sun, 26 Sep 2021 18:31:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (darwin)

Jean-Christophe Helary <lists@traduction-libre.org> writes:

>
> There is probably a way to use the contents of *Shell Command Output*
> and insert that as an argument to find-file, but I don't find that
> very elegant, and I'm probably missing something in the shell-command
> because I can't see how I can use the output as a direct argument to
> find-file...

Did you try shell-command-to-string? I found it by doing C-h d "shell
output string".

>
> 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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]