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

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

Re: How to build the C language environment in Emacs?


From: Oleksandr Gavenko
Subject: Re: How to build the C language environment in Emacs?
Date: Fri, 09 Jan 2015 21:21:01 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

On 2015-01-03, Filipp Gunbin wrote:

>> On Sat, Jan 03 2015 at 12:34:59 +0800, Liu Shengyu wrote:
>>
>> well...IIRC, using Emacs in windows is terrible...
>
> Very usable on Cygwin.  I've worked in it for years.

I ever use native Emacs with 'cygwin-mount!!

Because I used to use MS VS toolchain and Cygwin Emacs can't understand
Windows path at all...

See my http://sourceforge.net/u/gavenkoa/dot-emacs/ci/default/tree/.emacs-my

Here some tricks (may be outdated, I sat at Windows host last time 3 year ago)
which integrate native Emacs and Cygwin:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "shell, bash, Cygwin, MSYS")

(defvar my-use-windows-shell nil
  "If t 'cmdproxy.exe' will be used as shell. Affect on M-x shell like
  commands. If nil, 'sh' will be used." )

(defun follow-cygwin-symlink ()
  "Follow new-style (and also UCS-16) Cygwin symlinks."
  (save-excursion
    (goto-char 0)
    (when (looking-at "!<symlink>\xff\xfe")
      (find-alternate-file
       (substring
        (decode-coding-string
         (buffer-substring (match-end 0) (point-max))
         'utf-16-le)
        0 -1)                           ; -1 for stripping final \0.
       ))))

(defun my-dos2cygwin-path (path)
  "Convert DOS path to Cygwin according to current mount table."
  (interactive (list (read-directory-name "Enter DOS path: ")))
  (setq path (replace-regexp-in-string "\\\\" "/" (expand-file-name path)))
  (let ( (table cygwin-mount-table--internal) item prefix )
    (while table
      (setq item (car table))
      (setq prefix (concat "\\`" (regexp-quote (car item))))
      (setq table (cdr table))
      (when (string-match prefix path)
        (setq path (replace-regexp-in-string prefix (cdr item) path))
        (setq table nil)
        ) )
    path
    ))

(when (eq system-type 'windows-nt)
  (ignore-errors
    (require 'cygwin-mount)
    (cygwin-mount-activate)
    )
  (add-hook 'find-file-hook 'follow-cygwin-symlink)
  ;; Workaround for Cygwin shell, when set 'CYGWIN=noglob'. By default 
'shell-quote-argument'
  ;; quoted by double '\' chars this cause failure.
  (defun shell-quote-argument (argument)
    (concat "'" argument "'")
    )
  ;; Workaround for Cygwin when 'shell-file-name' is 'bash'.
  (setq null-device "/dev/null")
  ;; Use shell from Cygwin/MinGW.
  (setq shell-file-name "bash")
  (setenv "SHELL" "/bin/bash")
  (modify-coding-system-alist 'process "bash" '(cp1251-unix . cp1251-unix))
  )

(when (eq window-system 'w32)
  ;; Fix 'starttls.el' on native Windows Emacs with gnutls-cli from Cygwin.
  ;; 'gnutls-cli' run with '-s' opt and process wait for SIGALRM.
  ;; But build-in native Emacs 'kill' command can not send such Cygwin
  ;; specific sygnal. So 'starttls-negotiate-gnutls' function infinitely
  ;; wait for 'gnutls-cli' output.
  (defadvice signal-process (around cygwin (process sigcode))
    "Use 'kill.exe' instead build-in Emacs 'kill'."
    (if (eq sigcode 'SIGALRM)
        (shell-command
         (format "kill.exe -s SIGALRM %d"
                 (if (processp process) (process-id process) process)))
      ad-do-it
      ))
  (ad-activate 'signal-process)
  (modify-coding-system-alist 'process "gnutls-cli" '(binary . binary))
  )

(when (eq window-system 'w32)
  (add-to-list 'exec-suffixes ".py")
  (add-to-list 'exec-suffixes ".sh")
  (defun executable-find (command) (locate-file command exec-path 
exec-suffixes))
  )

(ansi-color-for-comint-mode-on)

(setq explicit-bash-args '("-i"))
(setq explicit-sh-args '("-i"))

(if (memq system-type '(windows-nt cygwin))
    (setq ls-lisp-verbosity nil)
  (setq  ls-lisp-verbosity '(links uid gid)))

(when (featurep 'cygwin-mount)
  (setenv "INFOPATH" "/usr/share/info/:~/usr/share/info/:")
  ;; Redefine path-separator to UNIX to update Info-directory-list.
  (let ( (path-separator ":") )
    (require 'info)
    (info-initialize)
    ))

;; Assume that cygwin-mount already activated.
(when (featurep 'cygwin-mount)
  (let ( (path (expand-file-name "~")) )
    (when (string-match "\\([c-z]\\):/" path)
      (setenv "MANPATH" (concat "/cygdrive/" (substring path 0 1) "/" 
(substring path 3) "/usr/share/man/:"))
      ) ))

;; I prefer EN man pages.
(when (memq system-type '(windows-nt cygwin))
  (setq manual-program "LANG=C man")
  )

(setq recentf-save-file "~/.recentf")
(when (eq system-type 'cygwin)
  (setq recentf-save-file "~/.recentf-cygwin"))

(setq desktop-base-file-name ".emacs.desktop")
(setq desktop-base-lock-name ".emacs.desktop.lock")
(when (eq system-type 'cygwin)
  (setq desktop-base-file-name ".emacs.desktop-cygwin")
  (setq desktop-base-lock-name ".emacs.desktop-cygwin.lock")
  )




-- 
Best regards!




reply via email to

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