unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Jean-Christophe Helary <lists@traduction-libre.org>
To: Emacs developers <emacs-devel@gnu.org>
Subject: macos: Finder's alias handling
Date: Mon, 27 Sep 2021 00:42:55 +0900	[thread overview]
Message-ID: <D5EB0D62-DCE1-4FB0-871E-B771256C4E84@traduction-libre.org> (raw)

Finder's aliases are binary files that macOS recognizes as something akin to Unix soft links, but they're really very different, except that in dired, they don't look different, they just look like normal files, but opening them just displays a binary blob instead of following the link.

It's probably a problem that has already found a solution, and I'm trying to reinvent a wheel...

So, what I am trying to do is:

1) when I open such a file by mistake, I run a function that uses Applescript's ability to find the target file and I "find-file" that target in Emacs

That would go like this:

(shell-command (format "osascript -e \"tell application \\\"Finder\\\" to return quoted form of POSIX path of (original item of file (POSIX file \\\"%s\\\") as alias)\"" "/path/to/my/alias"))

This produces something like:

’/path/to/the/target/file’

but in *Shell Command Output*, so that I can't just to (find-file (shell-command...)).

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

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?

-- 
Jean-Christophe Helary @brandelune
https://mac4translators.blogspot.com
https://sr.ht/~brandelune/omegat-as-a-book/




             reply	other threads:[~2021-09-26 15:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-26 15:42 Jean-Christophe Helary [this message]
2021-09-26 16:31 ` macos: Finder's alias handling Daniel Martín
2021-09-26 23:30   ` Jean-Christophe Helary
2021-09-27 10:19     ` Alan Third
2021-09-27 12:27       ` Jean-Christophe Helary
2021-09-27 12:43         ` Alan Third
2021-09-27 13:36           ` Jean-Christophe Helary
2021-09-27 10:34     ` Jean-Christophe Helary

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D5EB0D62-DCE1-4FB0-871E-B771256C4E84@traduction-libre.org \
    --to=lists@traduction-libre.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).