changelog shortlog tags changeset files revisions annotate raw

de_programming.el

changeset 66: 5b737eefe5ea
parent:340192631269
author: kim.vanwyk
date: Wed Nov 10 15:19:03 2010 +0200 (18 months ago)
permissions: -rw-r--r--
description: Adding CSharp Mode and Google Weather
1(require-if-exists 'c-funcs)
2(require-if-exists 'browse-funcs)
3(require-if-exists 'cq)
4;; Grab the tag-funcs for working with ctags and do some key-binding
5(require-if-exists 'tag-funcs)
6(global-set-key "\C-c\C-f" 'tag-file-find)
7
8;; Scroll compilation windows
9(setq compilation-scroll-output t)
10
11(require-if-exists 'etags-select)
12(global-set-key "\M-." 'etags-select-find-tag-at-point)
13
14;; Never use tabs to indent:
15(setq-default indent-tabs-mode nil)
16
17;; Tab stops:
18(setq tab-width 4)
19
20(global-set-key "\C-cc" 'comment-region)
21(global-set-key "\C-cu" 'uncomment-region)
22
23;; Rebind completion for python-mode
24;; (meta ?\/) is the key M-/
25(defun my-python-keys ()
26 (define-key python-mode-map [(meta ?\/)] 'python-complete-symbol))
27(add-hook 'python-mode-hook 'my-python-keys)
28
29;; Where am I?
30(which-func-mode t)
31
32(defun make-tags()
33 "Makes a tags file in current directory"
34 (interactive)
35 (message (concat "Making a TAGS file in " (file-name-directory (pwd))))
36 (shell-command "c:\\utils\\ctags\\ctags -e -R")
37 (message "TAGS file created")
38)
39
40;; Auto-load C-mode bindings for .c and .h files
41(setq auto-mode-alist
42 (append '(("\\.c$" . c-mode)
43 ("\\.h$" . c-mode))
44 auto-mode-alist))
45
46;; bind some keys for gud
47(global-set-key (quote [f5]) (quote gud-step))
48(global-set-key (quote [f6]) (quote gud-next))
49(global-set-key (quote [f9]) (quote gud-cont))
50
51;;Add a hook to let CR do indentation for C-mode at least
52(defun my-make-CR-do-indent ()
53 (define-key c-mode-base-map "" (quote newline-and-indent)))
54
55(add-hook 'c-initialization-hook 'my-make-CR-do-indent)
56
57(setq c-default-style '((java-mode . "java")
58 (awk-mode . "awk")
59 (c-mode . "gnu")))
60
61;; a function lister for C
62(defun list-functions ()
63 "Find occurrence of functions in buffer"
64 (interactive)
65 (occur "^\\w+.*)[^;]*$")
66)
67(global-set-key "\C-cf" 'list-functions)
68
69(defun run-current-file ()
70 "Execute or compile the current file.
71For example, if the current buffer is the file x.pl,
72then it'll call 'perl x.pl' in a shell.
73The file can be php, perl, python, java.
74File suffix is used to determine what program to run."
75(interactive)
76 (let (ext-map file-name file-ext prog-name cmd-str)
77; get the file name
78; get the program name
79; run it
80 (setq ext-map
81 '(
82 ("php" . "php")
83 ("pl" . "perl")
84 ("py" . "python")
85 ("sh" . "bash")
86 ("java" . "javac")
87 )
88 )
89 (setq suffix-map
90 '(
91 ("php" . "")
92 ("pl" . "")
93 ("py" . "debug")
94 ("sh" . "debug")
95 ("java" . "debug")
96 )
97 )
98
99 (setq file-name (buffer-file-name))
100 (setq file-ext (file-name-extension file-name))
101 (setq prog-name (cdr (assoc file-ext ext-map)))
102 (setq suffix (cdr (assoc file-ext suffix-map)))
103 (setq cmd-str (concat prog-name " \"" file-name "\"" " " suffix))
104 (shell-command cmd-str)))
105
106(global-set-key "\C-cR" 'run-current-file)
107
108;; Set compilation skip threshold to only go to errors
109(setq compilation-skip-threshold 2)
110
111;; A command to kill gud
112(defun kill-gud()
113(interactive)
114;; If the *gud* buffer is live, kill it
115(if (buffer-live-p (get-buffer "*gud*"))
116 (progn
117 (kill-buffer "*gud*")
118 (message "Buffer *gud* killed"))
119 (message "Buffer *gud* already killed")))
120
121; Add a function to remove double-quoted-strings as valid strings from delphi-mode, and add to the appropriate hook
122(load-file "~/emacs/lisp/addons/delphi-mode-changes.el")
123(add-hook 'delphi-mode-hook 'remove-double-string-from-delphi-mode)
124
125;; Over-ride auto-mode matching to use preferred modes for some files
126(setq auto-mode-alist
127(append '(("\\.pas\\'" . delphi-mode)) auto-mode-alist)
128)
129(setq auto-mode-alist
130(append '(("\\.rnc\\'" . rnc-mode)) auto-mode-alist)
131)
132
133;; NXML stuff
134;path to where nxml is
135(if (file-exists-p "~/emacs/lisp/addons/nxml-mode")
136(progn
137 (add-to-list 'load-path "~/emacs/lisp/addons/nxml-mode")
138 (set 'nxml-path "~/emacs/lisp/addons/nxml-mode/")
139 (load (concat nxml-path "rng-auto.el") t)
140 (add-to-list 'auto-mode-alist
141 (cons (concat "\\." (regexp-opt '("xml" "xsd" "sch" "rng" "xslt" "svg" "rss") t) "\\'")
142 'nxml-mode))
143 (unify-8859-on-decoding-mode 1)
144 (setq magic-mode-alist
145 (cons '("<\\?xml " . nxml-mode)
146 magic-mode-alist))
147 (fset 'xml-mode 'nxml-mode)
148))
149
150;; RNC mode is to syntax highlight RELAX NG schema's`
151(require-if-exists 'rnc-mode)
152
153;; Dos batch file mode
154(if (require-if-exists 'dosbat "dosbat/")
155(progn
156 (add-to-list 'auto-mode-alist '("\\.bat$" . bat-mode))
157 (add-hook 'bat-mode-hook 'turn-on-font-lock)))
158
159;; JS2 mode (Javascript mode from Steve Yegge)
160(autoload 'js2-mode' "js2" nil t)
161(setq auto-mode-alist
162 (append '(("\\.js$" . js2-mode)
163 ("\\.json$" . js2-mode))
164 auto-mode-alist))
165
166(require-if-exists 'json)
167
168;; Parenthesis highlighting
169(setq show-paren-delay 0)
170(show-paren-mode t)
171(setq show-paren-style 'expression)
172
173;; NSI Mode
174(if (require-if-exists 'nsi-mode)
175 (add-to-list 'auto-mode-alist '("\\.nsi$" . nsi-mode)))
176
177;; Add support for Wiki mode
178(require-if-exists 'wikipedia-mode)
179
180;; ASCII Table support
181(require-if-exists 'ascii-table)
182
183;; via http://emacs-fu.blogspot.com/2010/01/duplicating-lines-and-commenting-them.html
184(defun kvw-duplicate-line (&optional commentfirst)
185 "comment line at point; if COMMENTFIRST is non-nil, comment the original"
186 (interactive)
187 (beginning-of-line)
188 (push-mark)
189 (end-of-line)
190 (let ((str (buffer-substring (region-beginning) (region-end))))
191 (when commentfirst
192 (comment-region (region-beginning) (region-end)))
193 (insert-string
194 (concat (if (= 0 (forward-line 1)) "" "\n") str "\n"))
195 (forward-line -1)))
196
197;; duplicate a line
198(global-set-key (kbd "\C-cwd") 'kvw-duplicate-line)
199
200;; duplicate a line and comment the first
201(global-set-key (kbd "\C-cwc") (lambda()(interactive)(kvw-duplicate-line t)))
202
203;; Django major mode support
204(require-if-exists 'django-html-mode "django-html-mode/")
205
206(defun run_gdb (s)
207" kills gud and runs gdb with specified arg"
208(interactive "sGDB Argument:")
209(kill-gud)
210(gdb s))
211
212;; po-mode stuff
213(if (require-if-exists 'po-mode "po_mode/")
214 (progn
215 (autoload 'po-mode "po-mode+" "Major mode for translators to edit PO files" t)
216 (eval-after-load 'po-mode '(load "gb-po-mode"))
217 ))
218
219;; Require C-sharp mode
220(require-if-exists 'csharp-mode "csharp-mode/")
221
222(provide 'de_programming)