Made on 6.02.2010 new color-theme stuff and how tos
[cygwin_dotemacs.git] / .emacs
blobab2af64cf76212e43fe5dd42c684e89020f188d0
1 (add-to-list 'load-path "/cygdrive/c/cygwin-1.7/usr/will")\r
2 (add-to-list 'load-path "/cygdrive/c/cygwin-1.7/usr/share/emacs/site-lisp")\r
3 (add-to-list 'load-path "~/.emacs.d") ;Don't know why I have the next conf dir as it doesn't seem necessary...\r
4 (add-to-list 'load-path "~/.emacs.d/conf")\r
5 (add-to-list 'load-path "/cygdrive/c/cygwin-1.7/usr/share/emacs/site-lisp/includes")\r
6 \r
7 ;;my elisp functions\r
8 (load "wl-elisp-funcs")\r
9 \r
10 ;I like the Consolas font!\r
11 ;(set-frame-font "-microsoft-Consolas-normal-normal-normal-*-13-*-*-*-m-0-iso10646-1")\r
12 ;this font is better\r
13 (set-frame-font "Bitstream Vera Sans Mono-10")\r
15 ;Time settings\r
16 (setq display-time-day-and-date t)\r
17 (setq calendar-time-zone -360)\r
18 (setq calendar-standard-time-zone-name "EST")\r
19 (setq calendar-daylight-time-zone-name "EDT")\r
20 (display-time)\r
22 ;; disable bell function\r
23 (setq ring-bell-function 'ignore)\r
25 ;; arg >= 1 enable the menu bar.\r
26 (menu-bar-mode 0)\r
28 ;Enable save history\r
29 (savehist-mode 1)\r
31 ;;Disable the tool bar (with numeric ARG, display the tool bar if and only if ARG is positive)\r
32 (tool-bar-mode -1)\r
34 ;; current buffer name in title bar\r
35 (setq frame-title-format "%b")\r
37 ;;Disble scroll-bar-mode\r
38 (if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))\r
40 ;;Don't show the startup message\r
41 ;(setq inhibit-startup-message t)\r
43 ;; disable splash screen\r
44 (custom-set-variables\r
45   ;; custom-set-variables was added by Custom.\r
46   ;; If you edit it by hand, you could mess it up, so be careful.\r
47   ;; Your init file should contain only one such instance.\r
48   ;; If there is more than one, they won't work right.\r
50 ;;; In case you have trouble byte-compiling color-theme files (uncomment these 2 variable customs)\r
51 ;; '(max-specpdl-size 80000)\r
52 ;; '(max-lisp-eval-depth 100000)\r
53  '(autofit-frames-flag nil)\r
54  '(dired-details-hidden-string "")\r
55  '(color-theme-history-max-length 20)\r
56  '(color-theme-history nil)\r
57  '(display-time-24hr-format nil)\r
58  '(ecb-cache-directory-contents nil)\r
59  '(ecb-cache-directory-contents-not nil)\r
60  '(ecb-layout-name "left13")\r
61  '(ecb-options-version "2.32")\r
62  '(ecb-primary-secondary-mouse-buttons (quote mouse-1--C-mouse-1))\r
63  '(ecb-show-sources-in-directories-buffer (quote ("left7" "left13" "left14" "left15")))\r
64  '(ecb-source-path (quote (("/usr/will/" "\$HOME") ("/usr/will/notes" "notes") ("/usr/will/myrailsapps/" "Current Rails Projects") ("/cygdrive/c/Projects" "Older Projects") ("/cygdrive/z/" "Z Drive"))))\r
65  '(ecb-tip-of-the-day nil)\r
66  '(inhibit-startup-screen t)\r
67  '(org-agenda-files (quote ("~/notes/Personal/personal.org")))\r
68  '(org-file-apps (quote ((auto-mode . emacs) (directory . "cygstart %s") ("\\.mm\\'" . default) ("\\.x?html?\\'" . default) ("\\.pdf\\'" . "cygstart %s") ("\\.doc\\'" . "cygstart %s") ("\\.xls\\'" . "cygstart %s") ("\\.ppt\\'" . "cygstart %s"))))\r
69  '(ps-bottom-margin 25.51968503937008)\r
70  '(ps-font-family (quote Times))\r
71  '(ps-font-size (quote (12 . 12)))\r
72  '(ps-header-font-size (quote (12 . 12)))\r
73  '(ps-header-offset 18.346456692913385)\r
74  '(ps-inter-column 26.69291338582677)\r
75  '(ps-left-margin 12.69291338582677)\r
76  '(ps-line-number-font-size 10)\r
77  '(ps-print-header t)\r
78  '(ps-print-only-one-header t)\r
79  '(ps-right-margin 28.69291338582677)\r
80  '(ps-spool-duplex nil)\r
81  '(ps-top-margin 25.51968503937008)\r
82  '(tramp-encoding-command-switch "-c")\r
83  '(tramp-encoding-shell "/cygdrive/c/cygwin-1.7/bin/bash.exe"))\r
85 ;(setq default-frame-alist\r
86 ;      '((font . "Bitstream Vera Sans Mono-12")))\r
88 ; Globals for frame-sizing functions\r
89 (defvar MY_INITIAL_WIDTH 92)\r
90 (defvar MY_INITIAL_HEIGHT 52)\r
91 (defvar MY_INITIAL_LEFT 4)\r
92 (defvar MY_INITIAL_TOP 30)\r
94 ;;position emacs window in the left half of my screen\r
95 (setq initial-frame-alist\r
96       '((user-position t) (left . 1288) (top . 27)\r
97         (width . 80) (height . 50)\r
98         ))\r
100 ;;Clear the PID env var as emacs might inherit this if started from a bash shell\r
101 (setenv "PID" nil)\r
103 ; Override nasty Xfce Home/will\r
104 (setq default-directory "~/" )\r
106 ;;Set up printing using PDFCreator\r
107 (setenv "PRINTER" "PDFCreator")\r
108 (cond ((eq system-type 'cygwin)\r
109    (setq ps-printer-name "PDFCreator")\r
110    (setq ps-printer-name-option "-d")\r
111    (setq ps-lpr-command "/bin/lpr")))\r
113 ;;Something seems to have broken in the above (not working on other machine either)\r
114 ;;Try something different--doesn't work, try something else...\r
115 ;   (setenv "GS_LIB" "/cygdrive/c/Program Files/gs/gs8.64/lib;/cygdrive/c/Program Files/gs/gs8.64/fonts")\r
116 ;   (setq ps-lpr-command "/cygdrive/c/Program Files/gs/gs8.64/bin/gswin32c.exe")\r
117 ;   (setq ps-lpr-switches '("-q" "-dNOPAUSE" "-dBATCH" "-sDEVICE=mswinpr2"))\r
118 ;   (setq ps-printer-name t)\r
120 ;This works (prints with Courier, to change, see file:///C:/Program%20Files/gs/gs8.64/doc/Fonts.htm\r
121 ;(setq ps-printer-name t)\r
122 ;(setq ps-lpr-command "/cygdrive/c/Program Files/gs/gs8.64/bin/gswin32c.exe")\r
123 ;(setq ps-lpr-switches '("-q" "-dNOPAUSE" "-dBATCH"\r
124 ;                       "-sDEVICE=mswinpr2"\r
125 ;                       "-sPAPERSIZE=a4"))\r
127 ;;Popups (with reminders) currently not working\r
128 (defun djcb-popup (title msg &optional icon)\r
129   "Show a popup if we're on X, or echo it otherwise; TITLE is the title\r
130 of the message, MSG is the context. Optionally, you can provide an ICON and\r
131 a sound to be played"\r
133   (interactive)\r
134   (when sound (shell-command\r
135                 (concat "mplayer -really-quiet " sound " 2> /dev/null")))\r
136   (if (eq window-system 'x)\r
137     (shell-command (concat "notify-send "\r
139                      (if icon (concat "-i " icon) "")\r
140                      " '" title "' '" msg "'"))\r
141     ;; text only version\r
143     (message (concat title ": " msg))))\r
145 ;;Window-resizing Functions (note only work with a split window)\r
146 ;;With split windows, I only want the second window as a reference so keep these resize functions handy.\r
147 (defun joc-enlarge-by-ten()\r
148   "enlarges a window 10 lines"\r
149   (interactive)\r
150   (enlarge-window 10))\r
152 (defun joc-shrink-by-five()\r
153   "shrinks a window 5 lines"\r
154   (interactive)\r
155   (shrink-window 5))\r
157 (defun uniquify-region ()\r
158   "remove duplicate adjacent lines in the given region"\r
159   (interactive)\r
160   (shell-command-on-region (region-beginning) (region-end) "uniq" t)\r
163 ;;Stevey's Effective Emacs keybindings\r
164 (global-set-key "\C-x\C-m" 'execute-extended-command)\r
165 (global-set-key "\C-c\C-m" 'execute-extended-command)\r
166 (global-set-key "\C-w" 'backward-kill-word)\r
167 (global-set-key "\C-x\C-k" 'kill-region)\r
168 (global-set-key "\C-c\C-k" 'kill-region)\r
169 (global-set-key "\C-xt" 'beginning-of-buffer)\r
170 (global-set-key "\C-xn" 'end-of-buffer)\r
172 ;Need to make c-r a prefix key:\r
173 ;(global-set-key (kbd "C-r f") 'rename-file-and-buffer)\r
174 ;NOTE: Until I find myself using this a lot, don't bother keybinding\r
177 ;;Aliases\r
178 (defalias 'bcf 'byte-compile-file)\r
179 (defalias 'ftf 'fit-frame)\r
180 (defalias 'isf 'insertfile)\r
182 ;;Stevey's aliases\r
183 (defalias 'qrr 'query-replace-regexp)\r
185 ;;Which file was I editing?\r
186 (define-key global-map "\C-c\C-of"\r
187   '(lambda () (interactive nil) (message "%s" (buffer-file-name))))\r
188 ;  '(lambda () (interactive nil) (funcall kill-new buffer-file-name replace yank-handler)))\r
189 ;;My keybindings\r
190 (global-set-key [(f4)] 'ecb-activate)\r
191 (global-set-key [(shift f4)] 'ecb-hide-ecb-windows)\r
192 (global-set-key [(shift f3)] 'ecb-show-ecb-windows)\r
193 (global-set-key "\C-ca" 'org-agenda)\r
194 (global-set-key "\C-cg" 'goto-line)\r
195 ; NOTE: C-\ was formerly bound to the toggle-input-method is an interactive compiled Lisp function in `mule-cmds.el'.\r
196 ;;but since mule-cmds is for multi-lingual environments, I thought I'd use it for my replace-backslashes udf.\r
197 (global-set-key "\C-\\" 'replace-backslashes)\r
199 ;;Load macros\r
200 (load-file "~/macros")\r
202 (setq-default ispell-program-name "aspell")\r
204 ;;Useful package for viewing registers\r
205 (require 'list-register)\r
206 (global-set-key (kbd "C-x r v") 'list-register)\r
208 ;color-theme package\r
209 (add-to-list 'load-path "~/.emacs.d/color-theme")\r
210 (require 'color-theme)\r
211 (eval-after-load "color-theme"\r
212   '(progn\r
213      (color-theme-initialize)\r
214      ;(color-theme-hober) ; Not sure I like hober...use wombat instead defined in a fnc below.\r
215      ))\r
217 ;; Org mode settings\r
218 (require 'org-install)\r
219 (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))\r
220 (define-key global-map "\C-cl" 'org-store-link)\r
221 (define-key global-map "\C-ca" 'org-agenda)\r
222 (setq org-log-done t)\r
224 ;;If I want project support in ido (like TextMate)\r
225 (defun ido-find-file-in-tag-files ()\r
226   (interactive)\r
227   (save-excursion\r
228     (let ((enable-recursive-minibuffers t))\r
229       (visit-tags-table-buffer))\r
230     (ido-completing-read "Project file: "\r
231                          (tags-table-files)\r
232                          nil t)))\r
234 ;http://www.emacswiki.org/emacs/ColorTheme\r
235 ;Here are four alternative ways to cycle among color themes in a list. For illustration, they all use the same list.\r
236 (setq my-color-themes (list 'color-theme-billw 'color-theme-jsc-dark\r
237                               'color-theme-sitaramv-solaris 'color-theme-resolve\r
238                               'color-theme-classic 'color-theme-jonadabian-slate\r
239                               'color-theme-kingsajz 'color-theme-shaman\r
240                               'color-theme-subtle-blue 'color-theme-snowish\r
241                               'color-theme-sitaramv-nt 'color-theme-wheat\r
242                               'color-theme-railscasts 'color-theme-sunburst\r
243                               'color-theme-colorful-obsolescence 'color-theme-twilight))\r
245 (setq theme-current my-color-themes)\r
246 (setq color-theme-is-global nil) ; Initialization\r
248 (defun my-theme-set-default () ; Set the first row\r
249   (interactive)\r
250   (setq theme-current my-color-themes)\r
251   (funcall (car theme-current)))\r
253 (defun my-describe-theme () ; Show the current theme\r
254   (interactive)\r
255   (message "%s" (car theme-current)))\r
257    ; Set the next theme (fixed by Chris Webber - tanks)\r
258 (defun my-theme-cycle ()\r
259   (interactive)\r
260   (setq theme-current (cdr theme-current))\r
261   (if (null theme-current)\r
262       (setq theme-current my-color-themes))\r
263       (funcall (car theme-current))\r
264       (message "%S" (car theme-current)))\r
266 (my-theme-set-default)\r
267 (global-set-key [f12] 'my-theme-cycle)\r
269 (defun color-theme-undo ()\r
270   (interactive)\r
271   (color-theme-reset-faces)\r
272   (color-theme-snapshot))\r
274 ;; backup current color theme\r
275 (fset 'color-theme-snapshot (color-theme-make-snapshot))\r
276 ;;change color theme\r
277 ;;M-x color-theme-undo\r
279 ;Found this color theme\r
280 (require 'color-theme-ahei)\r
282 ;;tramp support\r
283 (require 'tramp)\r
284 (setq tramp-default-method "sshx")\r
285 ;;(setq tramp-debug-buffer t)\r
286 ;;(setq tramp-chunksize 500)\r
287 ;;(setq shell-prompt-pattern "^H")\r
289 ;dired-details+ is all you need to get dired-details.el loaded, plus it gives you some extras\r
290 (require 'dired-details+)\r
292 ;fit-frame.el Resize a frame.  In particular, fit a frame to its buffers.\r
293 (require 'fit-frame)\r
294 (add-hook 'after-make-frame-functions 'fit-frame)\r
296 ;dired-lis  Lets you isearch in dired-mode using a similar process that ido uses\r
297 (require 'dired-lis)\r
299 ;;Resize frames automatically with autofit-frame.el\r
300 (require 'autofit-frame)\r
301 (add-hook 'after-make-frame-functions 'fit-frame)\r
304 ;; For Common Lisp stuff\r
305 (require 'cl)\r
307 ;;use mmm mode\r
308 (require 'mmm-mode)\r
309 (require 'mmm-auto)\r
310 (setq mmm-global-mode 'maybe)\r
311 (setq mmm-submode-decoration-level 2)\r
312 (set-face-background 'mmm-output-submode-face  "LightBlue")\r
313 (set-face-background 'mmm-code-submode-face    "LightGray")\r
314 (set-face-background 'mmm-comment-submode-face "LightYellow")\r
315 (set-face-background 'mmm-special-submode-face "Yellow")\r
317 (mmm-add-classes\r
318  '((erb-code\r
319     :submode ruby-mode\r
320     :match-face (("<%#" . mmm-comment-submode-face)\r
321                  ("<%=" . mmm-output-submode-face)\r
322                  ("<%"  . mmm-code-submode-face))\r
323     :front "<%[#=]?"\r
324     :back "%>"\r
325     :insert ((?% erb-code       nil @ "<%"  @ " " _ " " @ "%>" @)\r
326              (?# erb-comment    nil @ "<%#" @ " " _ " " @ "%>" @)\r
327              (?= erb-expression nil @ "<%=" @ " " _ " " @ "%>" @))\r
328     )))\r
330 (mmm-add-classes\r
331  '((gettext\r
332     :submode gettext-mode\r
333     :front "_(['\"]"\r
334     :face mmm-special-submode-face\r
335     :back "[\"'])")))\r
337 (mmm-add-classes\r
338  '((html-script\r
339     :submode javascript-mode\r
340     :front "<script>"\r
341     :back "</script>")))\r
343 (add-to-list 'auto-mode-alist '("\\.rhtml$" . html-mode))\r
344 ;;WSL--I added the following line as an attempt to include those Rails 2.1 rhtml.erb files...\r
345 (add-to-list 'auto-mode-alist '("\\.erb$" . html-mode))\r
347 ; Major mode for editing YAML files\r
348 (require 'yaml-mode)\r
349 (add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))\r
351 (add-hook 'html-mode-hook\r
352           (lambda ()\r
353             (setq mmm-classes '(erb-code html-js html-script gettext embedded-css))\r
354             (mmm-mode-on)))\r
356 (add-to-list 'mmm-mode-ext-classes-alist '(ruby-mode nil gettext))\r
358 (global-set-key [f8] 'mmm-parse-buffer)\r
359 ;;END MMM Test\r
361 ;;use ido (interactive do)\r
362 (require 'ido)\r
363 (ido-mode t)\r
365 ;;load line-num.el\r
366 (require 'line-num "line-num.el")\r
368 ;; Load cedet NOTE: Why do I need this?  Maybe just a require\r
369 ;;(load-file "/cygdrive/c/cywin-1.7/usr/share/emacs/site-lisp/cedet-1.0pre4/common/cedet.el")\r
370 (require 'cedet)\r
372 (define-key-after (lookup-key global-map [menu-bar tools])\r
373       [speedbar] '("Speedbar" . speedbar-frame-mode) [calendar])\r
375 ;;turn font-lock on automatically\r
376 (if (fboundp 'global-font-lock-mode)\r
377     (global-font-lock-mode 1)        ; GNU Emacs\r
378   (setq font-lock-auto-fontify t))   ; XEmacs\r
380 ;; Enabling various SEMANTIC minor modes.  See semantic/INSTALL for more ideas.\r
381 ;; Select one of the following:\r
383 ;; * This enables the database and idle reparse engines\r
384 ;;(semantic-load-enable-minimum-features)\r
386 ;;Bind Refresh to F5 key\r
387 (global-set-key [f5]\r
388 '(lambda () "Refresh the buffer from the disk (prompt of modified)."\r
389 (interactive)\r
390 (revert-buffer t (not (buffer-modified-p)) t)))\r
392 ;; * This enables some tools useful for coding, such as summary mode\r
393 ;;   imenu support, and the semantic navigator\r
394 ;;(semantic-load-enable-code-helpers)\r
396 ;; * This enables even more coding tools such as the nascent intellisense mode\r
397 ;;   decoration mode, and stickyfunc mode (plus regular code helpers)\r
398 (semantic-load-enable-gaudy-code-helpers)\r
400 ;; * This turns on which-func support (Plus all other code helpers)\r
401 ;; (semantic-load-enable-excessive-code-helpers)\r
403 ;; This turns on modes that aid in grammar writing and semantic tool\r
404 ;; development.  It does not enable any other features such as code\r
405 ;; helpers above.\r
406 ;; (semantic-load-enable-semantic-debugging-helpers)\r
408 ;;Load ECB\r
409 ;;If you want to load the ECB first after starting it by ecb-activate (faster loading)\r
410 (require 'ecb)\r
412 ;;This loads all available autoloads of ECB, e.g. ecb-activate, ecb-minor-mode, ecb-byte-compile and ecb-show-help.\r
413 (require 'ecb-autoloads)\r
415 ;;Added automatically after activating ECB the 1st time.\r
419 (custom-set-faces\r
420   ;; custom-set-faces was added by Custom.\r
421   ;; If you edit it by hand, you could mess it up, so be careful.\r
422   ;; Your init file should contain only one such instance.\r
423   ;; If there is more than one, they won't work right.\r
424  )\r
426 ;; keep searching throughout the file\r
427 (require 'find-recursive)\r
429 ;;; ri-documentation\r
430 (add-to-list 'load-path "/cygdrive/c/cywin-1.7/usr/share/emacs/site-lisp/ri")\r
431 (setq ri-ruby-script "/cygdrive/c/cywin-1.7/usr/share/emacs/site-lisp/ri/ri-emacs.rb")\r
432 (autoload 'ri "/cygdrive/c/cywin-1.7/usr/share/emacs/site-lisp/ri/ri-ruby.el" nil t)\r
433 ;;Bind the ri command to a key\r
434 ;;Method/class completion is also available\r
435 (add-hook 'ruby-mode-hook (lambda ()\r
436     (local-set-key "\C-cd" 'ri)\r
437     (local-set-key "\C-cf" 'ri-ruby-complete-symbol)\r
438     (local-set-key "\C-ca" 'ri-ruby-show-args)\r
439 ))\r
441 ;;use the ruby-mode for ruby (*.rb) files\r
442 (add-to-list 'load-path "/cygdrive/c/cywin-1.7/usr/share/emacs/site-lisp/ruby-mode")\r
443 (autoload 'ruby-mode "ruby-mode" "Ruby editing mode." t)\r
444 (add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode))\r
445 (add-to-list 'interpreter-mode-alist '("ruby" . ruby-mode))\r
446 (autoload 'run-ruby "inf-ruby"\r
447     "Run an inferior Ruby process")\r
448 (autoload 'inf-ruby-keys "inf-ruby"\r
449     "Set local key defs for inf-ruby in ruby-mode")\r
450 (add-hook 'ruby-mode-hook\r
451     '(lambda ()\r
452         (inf-ruby-keys)))\r
454 ;;use electric mode for ruby\r
455 (require 'ruby-electric)\r
456 (add-hook 'ruby-mode-hook (lambda () (ruby-electric-mode t)))\r
458 ;;FlymakeRuby\r
459 ;(require 'flymake)\r
460 ;; Change the default colors :)\r
461 ;(set-face-background 'flymake-errline "red4")\r
462 ;(set-face-background 'flymake-warnline "dark slate blue")\r
464 ;NOTE: This includes the flymake-create-temp-in-system-tempdir fnc which\r
465 ; keeps temp files in the system temp dir instead of the same directory as the file.\r
466 ; but until that becomes a problem, I'm going to use the flymake for ruby configuration included in\r
467 ; C:\cygwin-1.7\usr\share\emacs\site-lisp\rails\rails-ruby.el\r
468 ;(require 'flymake-ruby)\r
469 ;(add-hook 'ruby-mode-hook 'flymake-ruby-load)\r
471 ;;emacs-rails\r
472 (setq load-path (cons "/cygdrive/c/cywin-1.7/usr/share/emacs/site-lisp/rails" load-path))\r
473 (require 'snippet)\r
474 (require 'rails)\r
476 ;;use the 4gl-mode for Informix .4gl files\r
477 (autoload '4gl-mode "4gl-mode" "Informix 4gl editing mode." t)\r
478 (add-to-list 'auto-mode-alist '("\.4gl$" . 4gl-mode))\r
479 (add-to-list 'interpreter-mode-alist '("4gl" . 4gl-mode))\r
481 ;;; Set up PSGML\r
482 ;; Add PSGML to load-path so Emacs can find it.\r
483 ;; Note the forward slashes in the path... this is platform-independent so I\r
484 ;; would suggest using them over back slashes. If you use back slashes, they\r
485 ;; MUST BE doubled, as Emacs treats backslash as an escape character.\r
486 (setq load-path (append (list nil "/cygdrive/c/cywin-1.7/usr/share/emacs/site-lisp/psgml/") load-path))\r
488 ;; Use PSGML for sgml and xml major modes.  No, use Jim Clark's nXML major mode\r
489 ;;(autoload 'sgml-mode "psgml" "Major mode to edit SGML files." t)\r
490 ;;(autoload 'xml-mode "psgml" "Major mode to edit XML files." t)\r
492 ;;nXML Mode by Jim Clark\r
493 ;;For documentation of this mode, see http://www.nmt.edu/tcc/help/pubs/nxml/\r
494 ;; Add the nxml files to emacs's search\r
495 ;; path for loading:\r
496 ;;--\r
497 (setq load-path\r
498         (append load-path\r
499                 '("~/.emacs.d/plugins/nxml-mode-20041004/")))\r
500 ;;--\r
501 ;; Make sure nxml-mode can autoload\r
502 ;;--\r
503 ;;File rng-auto.el will not be loaded until needed (for example by opening some .xml file)\r
504 (autoload 'nxml-mode "rng-auto.el" nil t)\r
507 ;;--\r
508 ;; Load nxml-mode for files ending in .xml, .xsl, .rng, .xhtml\r
509 ;;--\r
510   (setq auto-mode-alist\r
511                 (cons '("\\.\\(xml\\|xsl\\|rng\\|xhtml\\|xsd\\)\\'" . nxml-mode)\r
512               auto-mode-alist))\r
515 ;; Use cperl-mode instead of the default perl-mode\r
516 ;;brevity is the soul of wit\r
517 (defalias 'perl-mode 'cperl-mode)\r
519 ;;Customize the tabs for CPerl\r
520 (add-hook 'cperl-mode-hook 'n-cperl-mode-hook t)\r
521 (defun n-cperl-mode-hook ()\r
522   (setq cperl-indent-level 4)\r
523   (setq cperl-continued-statement-offset 0)\r
524   (setq cperl-extra-newline-before-brace t)\r
525   (set-face-background 'cperl-array-face "wheat")\r
526   (set-face-background 'cperl-hash-face "wheat")\r
527   )\r
528 ;;Customizing CPerl mode\r
529 ;;Disable underscore spacebar feature\r
530 (setq cperl-invalid-face nil)\r
531 ;;Expand keywords like foreach, while, etc...\r
532 (setq cperl-electric-keywords t)\r
533 ;;electic parenthesis\r
534 (setq cperl-electric-parens t)\r
535 ;;automatically add newlines before and after braces, colons, semicolons\r
536 (setq cperl-auto-newline nil)\r
538 ;; cmd-mode is automatically activated when you open a file whose\r
539 ;; extention is "cmd" or "bat".\r
540 (autoload 'cmd-mode "cmd-mode" "CMD mode." t)\r
541 (setq auto-mode-alist (append '(("\\.\\(cmd\\|bat\\)$" . cmd-mode))\r
542                                   auto-mode-alist))\r
544 ;;Per Steve Yegge, he always, always, always runs a shell in emacs--until I need to, I'm turning this off...\r
545 ;;(shell)\r
547 ;;Yegge's JavaScript mode\r
548 (autoload 'js2-mode "js2" nil t)\r
549 (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))\r
550 (setq js2-basic-offset 2)\r
551 (setq js2-use-font-lock-faces t)\r
553 ;;More Yegge Stuff (fonts)  currently not working (parchment-screen nope...linux-font...nope)\r
554 (global-font-lock-mode t)\r
555 ; (parchment-screen)\r
556 ; (set-default-font linux-font)\r
557 ; (set-mouse-color "black")\r
559 ;;Highlights erroneous lines and displays associated error messages.\r
560 ;;set colors in PSGML mode:\r
561 (setq screenshots nil)   ; t for screenshot color settings, else nil\r
563 (make-face 'sgml-comment-face)\r
564 (make-face 'sgml-start-tag-face)\r
565 (make-face 'sgml-end-tag-face)\r
566 (make-face 'sgml-entity-face)\r
567 (make-face 'sgml-doctype-face)\r
569 (cond ((equal screenshots nil)\r
570    (set-face-foreground 'sgml-comment-face "FireBrick")\r
571    (set-face-foreground 'sgml-start-tag-face "SlateBlue")\r
572    (set-face-foreground 'sgml-end-tag-face "SlateBlue")\r
573    (set-face-background 'sgml-entity-face "SlateBlue")\r
574    (set-face-foreground 'sgml-entity-face "Red")\r
575    (set-face-foreground 'sgml-doctype-face "FireBrick")\r
576   )\r
577   ((equal screenshots t)\r
578    ; This set for screen shots\r
579    (set-background-color "White")\r
580    (set-face-foreground 'sgml-comment-face "White")  ; Comments: white on\r
581    (set-face-background 'sgml-comment-face "Gray")   ; gray.\r
582    (set-face-background 'sgml-start-tag-face "Gray") ; Tags: black (default)\r
583    (set-face-background 'sgml-end-tag-face "Gray")   ; on gray.\r
584    (set-face-foreground 'sgml-entity-face "White")   ; Entity references:\r
585    (set-face-background 'sgml-entity-face "Black")   ; white on black.\r
586   )\r
587 (t nil))\r
589 (setq sgml-set-face t)  ; without this, all SGML text is in same color\r
590 (setq sgml-markup-faces\r
591    '((comment   . sgml-comment-face)\r
592      (start-tag . sgml-start-tag-face)\r
593      (end-tag   . sgml-end-tag-face)\r
594      (doctype   . sgml-doctype-face)\r
595      (entity    . sgml-entity-face)))\r
598 (defvar sgml-font-lock-keywords\r
599   '(; Highlight the text between these tags in SGML mode.\r
600       ("<indexterm[^>]*>" . font-lock-comment-face)\r
601       ("</indexterm>" . font-lock-comment-face)\r
602       ("<primary[^<]+</primary>" . font-lock-comment-face)\r
603       ("<secondary[^<]+</secondary>" . font-lock-comment-face)\r
604       ("<see[^<]+</see>" . font-lock-comment-face)\r
605       ("<seealso[^<]+</seealso>" . font-lock-comment-face)\r
606    )\r
607   "Additional expressions to highlight in SGML mode.")\r
609   (setq font-lock-defaults '(sgml-font-lock-keywords t))\r
611 ;;Emulate the clear command from bash to clear the entire shell buffer\r
612 (add-hook 'shell-mode-hook 'n-shell-mode-hook)\r
613 (defun n-shell-mode-hook ()\r
614   "12Jan2002 - sailor, shell mode customizations."\r
615   (local-set-key '[up] 'comint-previous-input)\r
616   (local-set-key '[down] 'comint-next-input)\r
617   (local-set-key '[(shift tab)] 'comint-next-matching-input-from-input)\r
618   (setq comint-input-sender 'n-shell-simple-send)\r
619   )\r
621 (defun n-shell-simple-send (proc command)\r
622   "17Jan02 - sailor. Various commands pre-processing before sending to shell."\r
623   (cond\r
624    ;; Checking for clear command and execute it.\r
625    ((string-match "^[ \t]*clear[ \t]*$" command)\r
626     (comint-send-string proc "\n")\r
627     (erase-buffer)\r
628     )\r
629 ;; Checking for man command and execute it.\r
630    ((string-match "^[ \t]*man[ \t]*" command)\r
631     (comint-send-string proc "\n")\r
632     (setq command (replace-regexp-in-string "^[ \t]*man[ \t]*" "" command))\r
633     (setq command (replace-regexp-in-string "[ \t]+$" "" command))\r
634     ;;(message (format "command %s command" command))\r
635     (funcall 'man command)\r
636     )\r
637    ;; Send other commands to the default handler.\r
638    (t (comint-simple-send proc command))\r
639    )\r
640   )\r
642 (add-to-list 'load-path "/cygdrive/c/cywin-1.7/usr/share/emacs/site-lisp/rhtml/")\r
643     (require 'rhtml-mode)\r
645 ; Install mode-compile to give friendlier compiling support!\r
646 (autoload 'mode-compile "mode-compile"\r
647 "Command to compile current buffer file based on the major mode" t)\r
648 (global-set-key "\C-cc" 'mode-compile)\r
649 (autoload 'mode-compile-kill "mode-compile"\r
650  "Command to kill a compilation launched by `mode-compile'" t)\r
651 (global-set-key "\C-ck" 'mode-compile-kill)\r
653 ;;more from Yegge's "My .emacs file" blog entry\r
654 (defun swap-windows ()\r
655  "If you have 2 windows, it swaps them." (interactive) (cond ((not (= (count-windows) 2)) (message "You need exactly 2 windows to do this."))\r
656  (t\r
657  (let* ((w1 (first (window-list)))\r
658          (w2 (second (window-list)))\r
659          (b1 (window-buffer w1))\r
660          (b2 (window-buffer w2))\r
661          (s1 (window-start w1))\r
662          (s2 (window-start w2)))\r
663  (set-window-buffer w1 b2)\r
664  (set-window-buffer w2 b1)\r
665  (set-window-start w1 s2)\r
666  (set-window-start w2 s1)))))\r
668 ;; Never understood why Emacs doesn't have this function.\r
669 (defun rename-file-and-buffer (new-name)\r
670  "Renames both current buffer and file it's visiting to NEW-NAME." (interactive "sNew name: ")\r
671  (let ((name (buffer-name))\r
672         (filename (buffer-file-name)))\r
673  (if (not filename)\r
674         (message "Buffer '%s' is not visiting a file!" name)\r
675  (if (get-buffer new-name)\r
676          (message "A buffer named '%s' already exists!" new-name)\r
677         (progn   (rename-file name new-name 1)   (rename-buffer new-name)        (set-visited-file-name new-name)        (set-buffer-modified-p nil)))))) ;;\r
679 ;; Never understood why Emacs doesn't have this function, either.\r
680 (defun move-buffer-file (dir)\r
681  "Moves both current buffer and file it's visiting to DIR." (interactive "DNew directory: ")\r
682  (let* ((name (buffer-name))\r
683          (filename (buffer-file-name))\r
684          (dir\r
685          (if (string-match dir "\\(?:/\\|\\\\)$")\r
686          (substring dir 0 -1) dir))\r
687          (newname (concat dir "/" name)))\r
689  (if (not filename)\r
690         (message "Buffer '%s' is not visiting a file!" name)\r
691  (progn  (copy-file filename newname 1)\r
692          (delete-file filename)\r
693          (set-visited-file-name newname)\r
694          (set-buffer-modified-p nil)     t))))\r