Вопрос по macos – Как запустить графический интерфейс Emacs из командной строки в OSX?

82

Как запустить графический интерфейс Emacs из командной строки в OSX?

Я скачал и установил Emacs изhttp://emacsformacosx.com/.

Я принимаю ответ, отвечающий всем следующим критериям:

The emacs window opens in front of my terminal window. Typing "emacs" launches a GUI Emacs window. Finding files in that window will default to looking in the directory from where I started Emacs. Typing "emacs foo.txt" when foo.txt exists launches a GUI Emacs window with foo.txt loaded. Typing "emacs foo.txt" when foo.txt does not exist launches a GUI Emacs window with an empty text buffer named "foo.txt". Doing ^X^S in that buffer will save foo.txt in the directory from where I started Emacs.
Я не знаю, работает ли он на OSX, но вы можете попробовать:emacsclient -c -a "" "[email protected]" command jfs
Error: User Rate Limit Exceeded alexurba
Какой из этих критериев не соответствует введению "emacs"? в терминальной подсказке? Ваши требования описывают поведение по умолчанию в Linux. Я давно не использовал Mac, но думаю, что хитрость заключалась в том, чтобы просто найти подходящую программу для выполнения - возможно, emacs.app? Tyler
Тайлер, выходец из Linux, я с тобой все время; просто наберите "emacs" в подсказке должно быть все, что мне нужно сделать. Однако выполнение этого в OSX запускает текстовый режим Emacs в окне терминала (таким образом, не удовлетворяя критериям 1), и это не то, что я хочу. Johan Walles
Error: User Rate Limit Exceeded Johan Walles

Ваш Ответ

11   ответов
5

Error: User Rate Limit Exceeded

  • Start the emacs daemon on login
  • Have (server-start) in your .emacs
  • Don't mind having lots of separate copies of emacs running

Error: User Rate Limit Exceeded

  1. The emacs window opens in front of my terminal window.

Error: User Rate Limit Exceeded

  1. Typing "emacs" launches a GUI Emacs window. Finding files in that window will default to looking in the directory from where I started Emacs.

Error: User Rate Limit Exceeded

  1. Typing "emacs foo.txt" when foo.txt exists launches a GUI Emacs window with foo.txt loaded.

Error: User Rate Limit Exceeded

  1. Typing "emacs foo.txt" when foo.txt does not exist launches a GUI Emacs window with an empty text buffer named "foo.txt". Doing ^X^S in that buffer will save foo.txt in the directory from where I started Emacs.

Error: User Rate Limit Exceeded

One extra:

Error: User Rate Limit Exceeded

~ / Bin / Emacs

#!/bin/bash
EMACSPATH=/Applications/Emacs.app/Contents/MacOS

# Check if an emacs server is available 
# (by checking to see if it will evaluate a lisp statement)

if ! (${EMACSPATH}/bin/emacsclient --eval "t"  2> /dev/null > /dev/null )
then
    # There is no server available so,
    # Start Emacs.app detached from the terminal 
    # and change Emac's directory to PWD

    nohup ${EMACSPATH}/Emacs --chdir "${PWD}" "${@}" 2>&1 > /dev/null &
else
    # The emacs server is available so use emacsclient

    if [ -z "${@}" ]
    then
        # There are no arguments, so
        # tell emacs to open a new window

        ${EMACSPATH}/bin/emacsclient --eval "(list-directory \"${PWD}\")"
    else    
        # There are arguments, so
        # tell emacs to open them

        ${EMACSPATH}/bin/emacsclient --no-wait "${@}"
    fi

    # Bring emacs to the foreground

    ${EMACSPATH}/bin/emacsclient --eval "(x-focus-frame nil)"
fi
Error: User Rate Limit Exceeded
8

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

#!/bin/sh
$(/Applications/Emacs.app/Contents/MacOS/Emacs "[email protected]") &

Error: User Rate Limit Exceeded(x-focus-frame nil).

Error: User Rate Limit ExceedednotError: User Rate Limit Exceededemacs .)

# NOT RECOMMENDED
#!/bin/sh
/Applications/Emacs.app/Contents/MacOS/Emacs "[email protected]" &
Error: User Rate Limit Exceeded
4

Error: User Rate Limit Exceeded

Error: User Rate Limit ExceededError: User Rate Limit Exceeded

open -a /Applications/Emacs.app <file-name>

Error: User Rate Limit ExceededemaxError: User Rate Limit Exceeded~/bin

#!/bin/bash
(open -a /Applications/Emacs.app "[email protected]") &

CaveatError: User Rate Limit ExceededDired by nameError: User Rate Limit Exceeded

emax .

Error: User Rate Limit Exceeded

  • OS X Yosemite Version 10.10.2
  • GNU Emacs 24.4.2 (x86_64-apple-darwin14.0.0, NS apple-appkit-1343.14) of 2014-11-13
107

Вызовите следующий скрипт «emacs» и положи в свойPATH где-то:

#!/bin/sh
/Applications/Emacs.app/Contents/MacOS/Emacs "[email protected]"

Error: User Rate Limit Exceeded

Для # 1, поместите это где-нибудь в свой файл .emacs:

(x-focus-frame nil)

emacsformacosx.com сайт теперь имеетСтраница с инструкциямиError: User Rate Limit Exceededemacsclient и подключить Emacs доgit mergetool.

Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded Johan Walles
Error: User Rate Limit Exceeded~/fooError: User Rate Limit Exceededbar.txtError: User Rate Limit Exceededgmacs bar.txtError: User Rate Limit Exceeded~/bar.txtError: User Rate Limit Exceeded~foo/bar.txtError: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
1

Simple solution...

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

ec() {
  emacsclient -n [email protected] 2> /dev/null
  if [[ $? == 1 ]]; then
    open -a Emacs.app  -- [email protected]
  fi
}

Usage

ec file [...]

Let's unpack what's happening:

  1. pass all the ec arguments to emacsclient and don't (-n) wait for emacs before continuing.
    1. If Emacs is already running, we're all done and you're editing.
  2. swallow up the error message posted by emacsclient when there's no emacs running. (2> /dev/null)
  3. Manually handle the exit code 1 ([[ $? == 1 ]])
    1. open Emacs.app and pass file arguments to it (paths will be correctly opened.)
    2. You're all done, and Emacs has opened your files.
1

Error: User Rate Limit Exceeded

#!/bin/sh
/Applications/Emacs.app/Contents/MacOS/Emacs "[email protected]" 

Error: User Rate Limit Exceeded

#!/bin/sh
/Applications/Emacs.app/Contents/MacOS/Emacs "$PWD/[email protected]"

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded
69

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

alias emacs='open -a /Applications/Emacs.app $1'

Затем, введя emacs в командной строке, запустите приложение emacs.

Error: User Rate Limit Exceeded

alias ec='/Applications/Emacs.app/Contents/MacOS/bin/emacsclient'

Error: User Rate Limit Exceeded

;;========================================
;; start the emacsserver that listens to emacsclient
(server-start)

Тогда вы можете напечатать

ec .bashrc

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded Johan Walles
Error: User Rate Limit Exceeded Johan Walles
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
0

Error: User Rate Limit Exceeded

#!/bin/bash

# Ensure (server-start) is added in your emacs init script.

EMACS=/Applications/MacPorts/Emacs.app/Contents/MacOS/Emacs
EMACSCLIENT=/Applications/Macports/Emacs.app/\
Contents/MacOS/bin/emacsclient

# test if client already exsit.
$EMACSCLIENT -e "(frames-on-display-list)" &>/dev/null

# use emacsclient to connect existing server.
if [ $? -eq 0 ]; then
    $EMACSCLIENT -n "[email protected]"
# open emacs.app instead.
else
    `$EMACS "[email protected]"` &
fi
3

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded
4

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

alias emacs=/Applications/Emacs.app/Contents/MacOS/Emacs

Error: User Rate Limit Exceeded

0

Error: User Rate Limit Exceeded

./configure --with-x --prefix=/usr
make
sudo make install

Error: User Rate Limit Exceeded

Похожие вопросы