[Top][All Lists]

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

Re: macos: Finder's alias handling

From: Jean-Christophe Helary
Subject: Re: macos: Finder's alias handling
Date: Mon, 27 Sep 2021 19:34:04 +0900

> On Sep 27, 2021, at 8:30, Jean-Christophe Helary <lists@traduction-libre.org> 
> wrote:
>>> 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".
> Yes, but it adds a "..." around the ’...’ string and that doesn't work.

The Applescript's "quoted form of" part added the original quoting so removing 
it allowed me to work around the issue.

Now, for some reason, shell-command-to-string adds a line break at the end of 
the string to I had to split and car the thing to get the proper path:

(defun jc-macos-alias ()
   (car (split-string (shell-command-to-string (format "osascript -e \"tell 
application \\\"Finder\\\" to return POSIX path of (original item of file 
(POSIX file \\\"%s\\\") as alias)\"" (buffer-file-name))) "[\n\r]+" t))))

If there are cleaner ways to do this, I'm a taker :-)

Jean-Christophe Helary @brandelune

reply via email to

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