English 中文(简体)
Trying to get a terminal to work in Emacs
原标题:

I ve been having a lot of problems with emacs and trying to get the terminal to work with:

    M-x term

I installed cygwin and I fixed up my .emacs to include the paths:

    (setenv "PATH" (concat "c:/cygwin/bin;" (getenv "PATH")))
    (setq exec-path (cons "c:/cygwin/bin" exec-path))
    (require  cygwin-mount)
    (cygwin-mount-activate)
    (add-hook  comint-output-filter-functions
     shell-strip-ctrl-m nil t)
    (add-hook  comint-output-filter-functions
     comint-watch-for-password-prompt nil t)
    (setq explicit-shell-file-name "bash.exe")
    ;; For subprocesses invoked via the shell
    ;; (e.g., "shell -c command")
    (setq shell-file-name explicit-shell-file-name)

However now when I launch terminal, it seems to give nothing but a blank screen and "hang"

When I launch:

    M-x shell

It does indeed launch the bash shell and flying around the file directories is okay (with cd, ls, cp, rm, etc.). However, when I do something like try to open up a Python shell, it again hands, and I type in ... and the shell crashes. Is there anything significantly wrong with what I am doing or perhaps somebody could direct me towards solutions online? (I ve looked quite extensively.)

SSH also gives the error:

"Pseudo-terminal will not be allocated because stdin is not a terminal."

最佳回答

Are you using the default Cygwin Bash Shell ? This is the one that launches inside a Windows cmd shell, and you can t drag to resize the screen. This shell is horribly broken, because of the underlying Windows component. Try using something like rxvt, or one of the putty forks.

If this is all set, then the issue is likely a termcap issue. Some people set their Cygwin TERM variable to xterm , because many remote machines don t have termcaps installed for things like rxvt-cygwin-native. Overridding it locally will cause problems with programs that attempt a range of terminal operations.

In your ~/.bash_profile, you can set your terminal to the following. export TERM=rxvt-cygwin-native

See my rxvt install guide and tips for more on rxvt.

问题回答

SSH also gives the error:

"Pseudo-terminal will not be allocated because stdin is not a terminal."

To solve this problem in NTEmacs (NOT cygwin s emacs), I did the following:

  1. Install cygwin s gcc
  2. Use it to compile fakecygpty.c into fakecygpty.exe
  3. Run fakecygpty ssh my_server instead of just ssh my_server in an emacs shell (easiest if fakecygpty is on your path).

I tested this in *shell* running cmd, cygwin bash, and git bash, and they all work fine. My understanding is that fakecygpty.c present NTEmacs as a valid cygwin tty so that ssh is willing to talk to it. More information about fakecygpty and SSH with ntemacs.


You can also make NTEmacs edit files properly over SSH by adding this to init.el:

(eval-after-load "tramp"
   (progn
     (add-to-list  tramp-methods
                  (mapcar
                   (lambda (x)
                     (cond
                      ((equal x "sshx") "cygssh")
                      ((eq (car x)  tramp-login-program) (list  tramp-login-program "fakecygpty ssh"))
                      (t x)))
                   (assoc "sshx" tramp-methods)))
     (setq tramp-default-method "cygssh")))

I also needed to update my Tramp to 2.2.7 to be able to edit files over ssh from ntemacs.

Hope this saves someone some trouble. :)





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签