all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: John Mastro <john.b.mastro@gmail.com>
To: 42 147 <aeuster@gmail.com>
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Re: shell-command in Windows 7
Date: Sat, 15 Apr 2017 13:08:28 -0700	[thread overview]
Message-ID: <CAOj2CQRkM22Z-=gdcXPa5kgAVh75x27YOy-PLMe2AprDWOU89A@mail.gmail.com> (raw)
In-Reply-To: <CAOj2CQQCd06G9T8ixRx-nd77VvW03O_Tc0xJ12JDHu49xcmm3A@mail.gmail.com>

John Mastro <john.b.mastro@gmail.com> wrote:
> 42 147 <aeuster@gmail.com> wrote:
>> setup-cygwin.el is perfectly compatible with the code that John Mastro
>> suggested (which works better than what I had previously anyway). I need
>> setup-cygwin.el to run cygwin in Emacs. No way I'll stop loading it!
>
> I've been using native Windows builds of Emacs together with Cygwin for
> several years now. (Eli recommends against it for very sensible reasons,
> but I haven't found anything better and it works well enough for me).
>
> During that time, I've never used setup-cygwin.el. I don't even know
> what it does, so I could be missing out, but I wanted to mention that
> (at least in my use case) setup-cygwin.el isn't necessary to use Cygwin
> with Emacs.

I should mention that I do have some home-grown Cygwin-related settings
though.

I do not claim this is the best or right way to do it, but it's what I
ended up with over time, so I'll share it FWIW.

(defvar cygwin-path-directories
  '("/bin" "/usr/bin" "/usr/local/bin"
    "/Windows" "/ProgramData/Oracle/Java/javapath"))

(defun cygwinize-file-name (name)
  (if (string-match "\\`\\([A-Za-z]\\):\\(/\\|\\\\\\)" name)
      (let* ((drive (match-string 1 name))
             (sep   (match-string 2 name))
             (more  (substring name (match-end 2))))
        (concat (if (member drive '("c" "C")) "" (concat "/" drive))
                "/"
                (if (equal sep "\\")
                    (replace-regexp-in-string "\\\\" "/" more)
                  more)))
    name))

(defun init-for-cygwin ()
  (let* ((home (cygwinize-file-name (or (getenv "HOME")
                                        (error "HOME not defined"))))
         (home/bin (concat home
                           (unless (string-suffix-p "/" home) "/")
                           "bin"))
         (path (cons home/bin cygwin-path-directories)))
    (setenv "PATH" (mapconcat #'identity path ":"))
    (setq exec-path (mapcar (lambda (dir) (concat "c:" dir)) path))
    (let ((shell (or (executable-find "zsh")
                     (executable-find "bash")
                     (error "Can't find zsh or bash"))))
      (setq shell-file-name shell)
      (setq explicit-shell-file-name shell)
      (setq ediff-shell shell)
      (setq null-device "/dev/null")
      (setenv "SHELL" shell))))

(when (and (eq system-type 'windows-nt)
           (file-executable-p "c:/bin/bash.exe"))
  (init-for-cygwin))



  reply	other threads:[~2017-04-15 20:08 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-14  8:53 shell-command in Windows 7 42 147
2017-04-14 17:11 ` John Mastro
2017-04-14 17:13   ` John Mastro
2017-04-14 17:49     ` 42 147
2017-04-14 19:48     ` 42 147
2017-04-14 20:04       ` John Mastro
2017-04-15  7:40         ` 42 147
2017-04-15  8:30           ` Eli Zaretskii
2017-04-15 10:06         ` 42 147
2017-04-15 10:19           ` Eli Zaretskii
2017-04-15 17:17         ` 42 147
2017-04-15 18:02           ` Drew Adams
2017-04-15 18:33             ` 42 147
2017-04-15 19:54               ` John Mastro
2017-04-15 20:08                 ` John Mastro [this message]
2017-04-15 21:33                   ` 42 147
2017-04-20 23:43                   ` white line appears irregularly on left side of Emacs frame in GNU / Linux virtual machine 42 147
2017-04-15  7:04       ` shell-command in Windows 7 Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOj2CQRkM22Z-=gdcXPa5kgAVh75x27YOy-PLMe2AprDWOU89A@mail.gmail.com' \
    --to=john.b.mastro@gmail.com \
    --cc=aeuster@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.