Open the file directly in emacs (double click)

How can I configure all .rb files or all .py files to open in emacs if I double-click them; let's say from the desktop?

I'm on OS X 10.6.2.

I have a script:

on open of finderObjects
    repeat with currFile in finderObjects
        set unixPath to POSIX path of currFile

        set base to do shell script "dirname " & unixPath
        set fname to do shell script "basename " & unixPath
        do shell script "cd '" & base & "';" & " emacs  " & fname

    end repeat
end open

But if I drag the file (text.py - just prints the line), I get: emacs: standard input is not tty

And I'm not sure how to solve this.

Thank!

EDIT: Solved with reference: http://www.macosxhints.com/article.php?story=200310271426252582

set filecount to 0

on open filelist
    repeat with i in filelist
        set filecount to 1
        tell application "Terminal"
            set filename to do shell script ¬
                "perl -e \"print quotemeta ('" & POSIX path of i & "');\""
            do script "emacs " & filename & "; exit"
        end tell
    end repeat
end open

if filecount < 1 then
    tell application "Terminal"
        do script "emacs; exit"
    end tell
end if
+3
source share
2 answers

Finder, Get Info "". "" Open with emacs, ( ), Change All...

curses emacs , AppleScript ScriptEditor Automator, finder emacs . Get Info, .rb .py.

EDIT: . Launcher AppleScript: , emacs.

: script , script Terminal.app. :

        launch application "Terminal"
        tell application "Terminal"
            do script "cd '" & base & "';" & " emacs  " & fname
        end tell
+3

OS X, emacs Unix Windows, emacsclient emacs.

SO , multitty. , ?

+1

Source: https://habr.com/ru/post/1731059/


All Articles