help-emacs-windows
[Top][All Lists]
Advanced

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

RE: [h-e-w] bash and tex-shell


From: Ken Brown
Subject: RE: [h-e-w] bash and tex-shell
Date: Sun, 19 May 2002 08:28:35 -0400

Thanks for your response. The cygwin distribution that I installed doesn't contain tex, so that wasn't the problem. But it turned out that I was able to solve the problem by modifying tex-mode.el, following work of Richard Heiberger on a previous version emacs. First, I had to add "-i" to make bash run interactively when the tex-shell is created. Second, I had to remove all calls to tex-kill-job, which didn't work well with bash for some reason.

Ken

At 04:01 PM 5/18/02 -0400, Underwood, Jonathan wrote:
Hi

If you're using a windows based latex distribution (eg. Miketex) then i may
be able to help, having had a similar problem myself. On the other hand if
you're intentionally trying to use the Tex distribution included with
cygwin, i'm afraid i can't help much.

So, if you try and run the Miktex tex binaries using auctex or whatever,
you'll see exactly the symptoms you describe. The reason for it is that the
cygwin distribution contains a tex/latex distribution (tetex). By having the
line (setenv "PATH" (concat "C:\\cygwin\\bin;" (getenv "PATH"))) in your
emacs, you're putting the cygwin tex executables in the path BEFORE the
Miktex ones, and so the tex that is run is the tetex one, which screws up
things in the manner you describe. I have no idea what the problem is with
the tetex binaries included with cygwin, as i've never wanted to use them.
There's then two solutions:

1) Don't put the cygwin binary directory on your path. Actually it's
generally a BAD idea to put the cygwin binary directory on your path, as
explained in the cygwin manual etc. Why the ntemacs and cygwin FAQ's
instruct you to do so is a mystery to me. I've written a small package which
allows you to add and remove the cygwin binary directory from your path on
the fly within emacs, and also sets up other stuff for cygwin bash under
emacs in a more elegant fashion. It's included below.

or

2) Uninstall the tetex package via the cygwin setup program.

hope that helps

jonathan

Here's the w32-shells.el file.  You'll need to add these 3 lines to your
.emacs:
(require 'w32-shells)
(set-shell-bash)
(bash-path-env)

;; Time-stamp: <Tue 30 Apr, 2002. 16:59>

;; w32-shells.el v1.1.1
;; Jonathan Underwood <address@hidden>

;; Some general stuff to allow easy switching between cygwin bash and cmd
;; shell. Adds a submenu to the Tools menu, defines two shell selecting
;; functions and sets up relevant paths etc. See also shell.el and comint.el
and
;; bash man pages for further info.

;; To do:
;; o Include support for telnet, ftp, ssh.
;; o eventually add w32-shells to "External" customization group. Currently
;;   however gnuserv breaks this group.

;; History
;; 1.1.1 setq w32-quote-process-args statements commented out, as supposed
to be
;; no longer required, as emacs has new functionality to cope with different
;; outputs. Testing.
;; 1.1.0 rewrittten to separate implicit and explicit shells, add menu
options etc.
;; 1.0.4 cygwin ls in dired support. not yet functional...
;; 1.0.3 Dynamic changing of PATH environment added. Optional loading of
;; cygwin-mount.
;; 1.0.2 Made menu flag a single variable rather than two.
;; 1.0.1 Some support for customization

(require 'shell)
(require 'easymenu)

(defgroup w32-shells nil
  "Simple package to allow switching between bash and cmd shells under
windows
NT variants."
  :group 'emacs)

;---------------------------------------------------------------------------
-------------
;; set up some general stuff for bash
;---------------------------------------------------------------------------
-------------

(defcustom cygwin-bin-dir (list "c:/cygwin/bin"
                                "c:/cygwin/usr/local/bin/")
  "*List of directories appended to exec-path containing binaries used by
cygwin
bash."
  :type 'string
  :group 'w32-shells)

(defcustom cygwin-info-dir (list "c:/cygwin/usr/info/"
                                "c:/cygwin/usr/local/info/")
  "*List of directories appended to Info-default-directory list for cygwin
bash."
  :type 'string
  :group 'w32-shells)

(defcustom cygwin-bash_env "~/.bashpath"
  "*File read when a non-interactive bash shell is started. This should set
the
path for bash. Note that the bash path is NOT added to the system PATH
variable
as this can cause much confusion when switching back to using the system cmd
shell. See man bash for my details, particularly the invocation section."
  :type 'string
  :group 'w32-shells)

(setq exec-path (append cygwin-bin-dir exec-path))
(setenv "BASH_ENV" cygwin-bash_env)
(setq Info-default-directory-list (append cygwin-info-dir
Info-default-directory-list))
(setq process-coding-system-alist (append process-coding-system-alist
                                          '(("bash" . undecided-unix))))
(add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m)

;---------------------------------------------------------------------------
-------------
;; ls in dired
;---------------------------------------------------------------------------
-------------

(defcustom cygwin-ls "c:/cygwin/bin/ls"
  "*Path of the ls program to use when using ls in dired."
  :type 'string
  :group 'w32-shells)

(setq insert-directory-program cygwin-ls)
(defvar cygwin-ls-flag nil)

(defun toggle-cygwin-ls ()
  (interactive)
  (if cygwin-ls-flag (use-emacs-ls) (use-cygwin-ls))
  )

(defun use-cygwin-ls ()
  (interactive)
  (setq ls-lisp-use-insert-directory-program t)
  (setq cygwin-ls-flag t)
  (message "Using cygwin ls in dired")
  )

(defun use-emacs-ls ()
  (interactive)
  (setq ls-lisp-use-insert-directory-program nil)
  (setq cygwin-ls-flag nil)
  (message "Using emacs ls in dired")
  )

;---------------------------------------------------------------------------
-------------
;; cygwin dll in PATH
;---------------------------------------------------------------------------
-------------

(defcustom cygwin-dll-dir "c:\\cygwin\\bin;"
  "*Directory where the cygwin dll file resides. This is added to the SYSTEM
path environment variable for when emacs starts a process thru'
eg. call-process. Must be in the format c:\\usr\\cygwin\\bin;."
  :type 'string
  :group 'w32-shells)
(defvar cmd-path-env (getenv "PATH"))
(defvar bash-path-env (concat cygwin-dll-dir (getenv "PATH")))
(defvar cygwin-dll-in-path-flag nil)

(defun toggle-cygwin-dll-to-path ()
  "*Prepends cygwin-dll-dir to PATH environment if not there already,
otherwise
removes it."
  (interactive)
  (if cygwin-dll-in-path-flag (cmd-path-env) (bash-path-env))
  )

(defun cmd-path-env ()
  "*Sets the windows PATH environment to be that normally set by windows."
  (interactive)
  (setenv "PATH" cmd-path-env)
  (setq cygwin-dll-in-path-flag nil)
  (message "cygwin-dll-dir removed from PATH.")
  )

(defun bash-path-env ()
  (interactive)
  (setenv "PATH" bash-path-env)
  (setq cygwin-dll-in-path-flag t)
  (message "cygwin-dll-dir added to PATH.")
  )

;---------------------------------------------------------------------------
-------------
;; shell switching for shell commands
;---------------------------------------------------------------------------
-------------

(defvar shell-flag nil)

(defun toggle-implicit-shell ()
  (interactive)
  (if shell-flag (set-shell-cmd) (set-shell-bash))
  )

(defun set-shell-cmd()
  "Sets the shell used by emacs for shell commands to cmd.exe"
  (interactive)
;  (if (boundp 'w32-quote-process-args)
;      (setq w32-quote-process-args t))
  (setenv "SHELL" "cmd")
  (setq shell-command-switch "/c")
  (setq shell-flag nil)
  (message "Shell set to cmd")
)

(defun set-shell-bash ()
  "Sets the shell used by emacs for shell commands to bash"
  (interactive)
;  (if (boundp 'w32-quote-process-args)
;      (setq w32-quote-process-args ?\"))
  (setenv "SHELL" "bash")
  (setq shell-command-switch "-c")
  (setq shell-flag t)
  (message "Shell set to bash")
  )

;---------------------------------------------------------------------------
-------------
;; explcit shells
;---------------------------------------------------------------------------
-------------

;; load the ansi-color.el package so that colours don't screw up the shell
buffer.
(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)

(defvar explicit-cmd-args '("/q"))
(defvar explicit-bash-args '("--login" "-i"))

(defun bash ()
  "Starts an explicit bash shell"
  (interactive)
  (setq explicit-shell-file-name "bash")
  (shell)
  (rename-buffer "bash" t)
)

(defun cmd ()
  "Starts an explicit cmd shell"
  (interactive)
  (setq explicit-shell-file-name "cmd")
  (shell)
  (rename-buffer "cmd" t)
)

;---------------------------------------------------------------------------
-------------
;; Menu
;---------------------------------------------------------------------------
-------------
(easy-menu-add-item
 nil nil
 (easy-menu-create-menu
 "w32-shell"
 '(
   ["Use bash for shell commands" toggle-implicit-shell
    :style toggle
    :selected (eq shell-flag t)
    :help "Use cygwin bash shell for shell comands"
    :active t]
   ["Use cmd for shell commands" toggle-implicit-shell
    :style toggle
    :selected (eq shell-flag nil)
    :help "Use cmd shell for shell comands"
    :active t]
   ["Add cygwin-bin-dir to path" toggle-cygwin-dll-to-path
    :style toggle
    :selected (eq cygwin-dll-in-path-flag t)
    :help "Adds cygwin-bin-dir to PATH"
    :active t]
   ["Use cygwin ls in dired" toggle-cygwin-ls
    :style toggle
    :selected (eq cygwin-ls-flag t)
    :help "Use cygwin ls for dired listings"
    :acitve t]
   )))

(provide 'w32-shells)






> -----Original Message-----
> From: Ken Brown [mailto:address@hidden
> Sent: May 18, 2002 2:35 PM
> To: address@hidden
> Subject: [h-e-w] bash and tex-shell
>
>
> I'm having trouble running tex under emacs, with bash as my
> shell.  've
> just upgraded ntemacs to 21.2 and cygwin to 1.3.10, running
> under windows
> NT.  I previously had ntemacs 19.x and cygwin B20, and tex
> worked fine.  My
> .emacs is appended below.  It contains the lines involving
> bash that are
> recommended in the ntemacs faq and the cygwin faq.
>
> I have no trouble running bash as a shell under emacs, and I
> can also run
> tex from within that shell.  But when I try to run tex by
> giving the c-c
> c-f or c-c c-b commands, I hear a lot of hard disk activity
> but tex doesn't
> run and I finally have to hit c-g.  I am then able to see
> that a tex-shell
> buffer was created, but nothing is in it.
>
> If I comment out the part of my .emacs that sets up bash as
> the shell,
> emacs runs tex without a problem in a regular windows command shell.
>
> Any help would be appreciated.
>
> Ken Brown
> ==============================================================
> ==============================
>
> (custom-set-variables
>    ;; custom-set-variables was added by Custom -- don't edit
> or cut/paste it!
>    ;; Your init file should contain only one such instance.
>   '(case-fold-search t)
>   '(current-language-environment "Latin-1")
>   '(default-input-method "latin-1-prefix")
>   '(global-font-lock-mode t nil (font-lock))
>   '(text-mode-hook (quote (turn-on-auto-fill
> text-mode-hook-identify)))
>   '(transient-mark-mode t))
> (custom-set-faces
>    ;; custom-set-faces was added by Custom -- don't edit or
> cut/paste it!
>    ;; Your init file should contain only one such instance.
>   )
>
> ;; The following was copied from the cygwin faq
>
> (setq exec-path (cons "C:/cygwin/bin" exec-path))
> (setenv "PATH" (concat "C:\\cygwin\\bin;" (getenv "PATH")))
> ;;
> ;; NT-emacs assumes a Windows command shell, which you change
> ;; here.
> ;;
> (setq process-coding-system-alist '(("bash" . undecided-unix)))
> (setq shell-file-name "bash")
> (setenv "SHELL" shell-file-name)
> (setq explicit-shell-file-name shell-file-name)
> ;;
> ;; This removes unsightly ^M characters that would otherwise
> ;; appear in the output of java applications.
> ;;
> (add-hook 'comint-output-filter-functions
>           'comint-strip-ctrl-m)
>
> ;; The following comes from the ntemacs faq
>
> (defun my-shell-setup ()
>    "For Cygwin bash under Emacs 20"
>    (setq comint-scroll-show-maximum-output 'this)
>    (setq comint-completion-addsuffix t)
>    ;; (setq comint-process-echoes t) ;; reported that this is
> no longer needed
>    (setq comint-eol-on-send t)
>    (setq w32-quote-process-args ?\")
>    (make-variable-buffer-local 'comint-completion-addsuffix))
>
> (setq shell-mode-hook 'my-shell-setup)
>
>




reply via email to

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