forked from magnars/.emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwin.el
executable file
·105 lines (86 loc) · 4.17 KB
/
win.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
(when nil
(gnu-font-sz "Verdana" "8")
(gnu-font "Axel")
(gnu-font "Franklin Gothic Medium"))
(gnu-font-sz "Consolas" "10")
;; We don't know what this does but Brad swears it helps with NT
;;
(when t
(require 'comint)
(fset 'original-comint-exec-1 (symbol-function 'comint-exec-1))
(defun comint-exec-1 (name buffer command switches)
(let ((binary-process-input t)
(binary-process-output nil))
(original-comint-exec-1 name buffer command switches)))
(setq comint-completion-addsuffix t)
(setq comint-scroll-show-maximum-output 'this)
;; (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) ; shell-mode-hook
;; (setq comint-process-echoes t) ;; reported that this is no longer needed
)
(setq w32-quote-process-args ?\")
(defadvice find-file (after my-gud-translate-cygwin-paths activate)
;; if the file doesn't exist yet and is empty
(if (and (equal (buffer-size) 0)
(not (file-exists-p (buffer-file-name))))
;; try to find an initialization function
(let ((initializer
(find-if
(lambda (pair) (string-match (car pair) (buffer-file-name)))
my-buffer-initialization-alist)))
;; if found, call it
(if initializer
(progn (eval (list (cdr initializer)))
(set-buffer-modified-p nil))))))
;;
;; Path translation for cygwin
;;
(defun my-translate-cygwin-paths (file)
"Adjust paths generated by cygwin so that they can be opened by tools running under emacs."
;; If it's not a windows system, or the file doesn't begin with /, don't do any filtering
(if (and (eq system-type 'windows-nt) (string-match "^/" file))
;; Replace paths of the form /cygdrive/c/... or //c/... with c:/...
(if (string-match "^\\(//\\|/cygdrive/\\)\\([a-zA-Z]\\)/" file)
(setq file (file-truename (replace-match "\\2:/" t nil file)))
;; ELSE
;; Replace names of the form /... with <cygnus installation>/...
;; try to find the cygwin installation
(let ((paths (parse-colon-path (getenv "path"))) ; Get $(PATH) from the environment
(found nil))
;; While there are unprocessed paths and cygwin is not found
(while (and (not found) paths)
(let ((path (car paths))) ; grab the first path
(setq paths (cdr paths)) ; walk down the list
(if (and (string-match "/bin/?$" path) ; if it ends with /bin
(file-exists-p ; and cygwin.bat is in the parent
(concat
(if (string-match "/$" path) path (concat path "/"))
"../cygwin.bat")))
(progn
(setq found t) ; done looping
(string-match "^\\(.*\\)/bin/?$" path)
(setq file (file-truename (concat (match-string 1 path) file))))
))))))
file)
;(defadvice gud-find-file (before my-gud-translate-cygwin-paths activate) (ad-set-arg 0 (my-translate-cygwin-paths (ad-get-arg 0)) t))
;(defadvice compilation-find-file (before my-compilation-translate-cygwin-paths activate) (ad-set-arg 1 (my-translate-cygwin-paths (ad-get-arg 1)) t))
;(size-frame 200 40)
(default-size-frame 160 45)
(provide 'win)
(setq win32-tempdir "c:/windows/temp")
(defun add-PATH (d) "" (interactive)
(add-to-list 'exec-path d)
(setenv "PATH" (concat (my-backward-slashes d) ";" (getenv "PATH"))))
(defun my-backward-slashes (filename)
"convert each slash in filename to a backward slash"
(concat (mapcar (function (lambda (c)
(if (= c ?/) ?\\ c)))
filename)))
(defun shell-msys ()
(interactive)
(let ((explicit-sh.exe-args '("--login" "-i")))
(shell-explicit "c:/msys/bin/bash.exe" "Msys" ?/ nil)))
(load-file (expand-file-name "win-termkeys.el" dotfiles-dir))
(require 'setup-cygwin)