.emacs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. ;(autoload 'perl-mode "cperl-mode" "alternate mode for editing Perl programs" t)
  2. ;;; You can either fine-tune the bells and whistles of this mode or
  3. ;;; bulk enable them by putting
  4. ;(setq cperl-hairy t)
  5. (global-unset-key "\C-h")
  6. (global-set-key "\C-h" 'delete-backward-char)
  7. ;(load "/usr/share/emacs/site-lisp/rng-auto.el")
  8. (require 'cc-mode)
  9. (defun my-build-tab-stop-list (width)
  10. (let ((num-tab-stops (/ 80 width))
  11. (counter 1)
  12. (ls nil))
  13. (while (<= counter num-tab-stops)
  14. (setq ls (cons (* width counter) ls))
  15. (setq counter (1+ counter)))
  16. (set (make-local-variable 'tab-stop-list) (nreverse ls))))
  17. (defun my-c-mode-common-hook ()
  18. (setq tab-width 4) ;; change this to taste, this is what K&R uses :)
  19. (my-build-tab-stop-list tab-width)
  20. (setq c-basic-offset tab-width)
  21. (setq indent-tabs-mode t)) ;; force only spaces for indentation
  22. (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
  23. (add-hook 'c-mode-common-hook
  24. (lambda()
  25. (local-set-key (kbd "C-c <right>") 'hs-show-block)
  26. (local-set-key (kbd "C-c <left>") 'hs-hide-block)
  27. (local-set-key (kbd "C-c <up>") 'hs-hide-all)
  28. (local-set-key (kbd "C-c <down>") 'hs-show-all)
  29. (hs-minor-mode t)))
  30. ;; replace C-s with C-\ in a much more general way so that C-\ can be typed
  31. ;; for every instance of C-s. It is at such a low level that emacs even thinks
  32. ;; that you typed a C-s. replace C-s with C-\ , globally
  33. ;; this disables any command which uses C-\ I believe there are two
  34. ;; Note That position \034(octal) which is C-\ is switched with \023(octal)
  35. ;; which is C-s
  36. (setq keyboard-translate-table "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\023\035\036\037 !\042#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\134]^_`abcdefghijklmnopqrstuvwxyz{|}~\177")
  37. ;; change ctrl-q so it can be used as flow control
  38. ;; remap C-q tp ESC `
  39. ;; (global-unset-key "\C-q")
  40. ;; (global-set-key "\e`" 'quoted-insert)
  41. ;; don't make backup files
  42. ;; (setq make-backup-files nil)
  43. (setq require-final-newline t)
  44. ;; change input mod to CBREAK mode for C-s C-q
  45. ;; emacs will never see C-s, C-q
  46. ;; (set-input-mode nil t)
  47. ;; change help command from C-h to ESC ?
  48. ;; so we can use C-h for backspace
  49. (global-unset-key "\C-h")
  50. (global-set-key "\C-h" 'delete-backward-char)
  51. (global-set-key "\e?" 'help-command)
  52. (global-set-key "\C-x\C-x" 'mail-send)
  53. ;; set backspace to delete a char same as DEL
  54. ;; (global-unset-key "\d")
  55. ;; (global-set-key "\d" 'delete-char)
  56. (global-set-key "\C-cg" 'goto-line)
  57. ;; set up the ispell spelling checker interface
  58. (global-unset-key "\C-o")
  59. (global-set-key "\C-o" 'undo)
  60. (global-set-key "\M-\]" 'copy-region-as-kill)
  61. (global-set-key "\C-\\" 'mark-word)
  62. (global-unset-key "\C-f" )
  63. (global-set-key "\C-f" 'forward-word)
  64. (global-unset-key "\C-b" )
  65. (global-set-key "\C-b" 'backward-word)
  66. (global-unset-key "\M-f" )
  67. (global-set-key "\M-f" 'find-file)
  68. (global-set-key "\M-o" 'find-file-other-window)
  69. (global-set-key "\M-\\" 'mark-word)
  70. (global-set-key "\M-{" 'mark-whole-buffer)
  71. ;(global-unset-key "\M-}")
  72. (global-set-key "\M-}" 'indent-region)
  73. (global-set-key "\C-x\C-m" 'save-buffer)
  74. (global-set-key "\C-c\C-m" 'delete-other-windows)
  75. (global-set-key "\C-c\'" 'split-window-vertically)
  76. (global-set-key "\C-c\;" 'split-window-horizontally)
  77. (global-set-key "\C-x\z" 'yank)
  78. (autoload 'ispell-word "ispell"
  79. "Check the spelling of word in buffer." t)
  80. (autoload 'ispell-complete-word "ispell" "Complete word at or before point" t)
  81. (autoload 'ispell-region "ispell"
  82. "Check spelling of every word in the region" t)
  83. (autoload 'ispell-buffer "ispell"
  84. "Check spelling of every word in the buffer" t)
  85. (global-set-key "\e$" 'ispell-word)
  86. (global-unset-key "\C-t")
  87. (global-set-key "\C-t" 'forward-word)
  88. ;; (global-unset-key "\C-&")
  89. ;; (global-set-key "\C-&" 'backward-word)
  90. (global-set-key "\C-cs" 'ispell-region)
  91. (global-set-key "\C-c," 'backward-paragraph)
  92. (global-set-key "\C-c." 'forward-paragraph)
  93. (global-set-key "\C-c\C-c" 'compile)
  94. (global-set-key "\C-c\/" 'compile)
  95. (global-set-key "\C-c\]" 'replace-string)
  96. (global-set-key "\C-ce" 'exchange-dot-and-mark)
  97. (global-set-key "\C-cs" 'shrink-window)
  98. ;; THE FOLLOWING ARE CUSTOMIZATIONS YOU CAN ADD IF YOU WANT THEM
  99. ;; YOU WILL HAVE TO EDIT THIS FILE TO DO SO
  100. ;; AUTO FILL
  101. ;; If you want emacs to automatically wrap when you reach the
  102. ;; end of a line (i.e. you don't have to type in the RETURN at the
  103. ;; end of each line, you just keep typing) remove the semicolons
  104. ;; from the two line after this paragraph (the ones with setq).
  105. ;; Set the default major mode to text mode and turn on auto fill
  106. ;;(setq default-major-mode 'text-mode)
  107. (setq text-mode-hook 'turn-on-auto-fill)
  108. ;; (setq load-path ("/usr/local/lib/emacs/lisp/" "/usr/local/test/lib/emacs/site-lisp" "/home/anthm/.lisp"))
  109. (setq term-file-prefix (concat (car load-path) "/term/"))
  110. (setq term-setup-hook '(lambda nil
  111. (if (fboundp 'enable-arrow-keys) (enable-arrow-keys))))
  112. ; (autoload 'html-mode "/home/anthm/.lisp/html-mode" "HTML major mode." t)
  113. ;(or (assoc "\\.html$" auto-mode-alist)
  114. ; (setq auto-mode-alist (cons '("\\.html$" . html-mode)
  115. ; auto-mode-alist)))
  116. (setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist))
  117. (setq auto-mode-alist (cons '("\\.cgi$" . cperl-mode) auto-mode-alist))
  118. (setq auto-mode-alist (cons '("\\.p[ml]$" . cperl-mode) auto-mode-alist))
  119. (setq auto-mode-alist (cons '("\\.xml$" . nxml-mode) auto-mode-alist))
  120. (setq html-helper-do-write-file-hooks t)
  121. (setq html-helper-build-new-buffer t)
  122. (add-hook 'cperl-mode-hook 'n-cperl-mode-hook t)
  123. (defun n-cperl-mode-hook ()
  124. ; (setq cperl-indent-level 4)
  125. ; (setq cperl-continued-statement-offset 0)
  126. ; (setq cperl-extra-newline-before-brace t)
  127. (set-face-background 'cperl-array-face "black")
  128. (set-face-background 'cperl-hash-face "black")
  129. )
  130. (cond ((fboundp 'global-font-lock-mode)
  131. ;; Customize face attributes
  132. (setq font-lock-face-attributes
  133. ;; Symbol-for-Face Foreground Background Bold Italic Underline
  134. '((font-lock-comment-face "green")
  135. (font-lock-preprocessor-face "gray")
  136. (font-lock-string-face "Sienna")
  137. (font-lock-keyword-face "purple")
  138. (font-lock-function-name-face "limegreen")
  139. (font-lock-variable-name-face "Yellow")
  140. (font-lock-type-face "Yellow")
  141. (font-lock-reference-face "Purple")
  142. (font-lock-builtin-face "limegreen")
  143. (font-lock-constant-face "yellow")
  144. (font-lock-doc-face "limegreen")
  145. (font-lock-highlighting-face "limegreen")
  146. (font-lock-warning-face "limegreen")
  147. ))
  148. ;; Load the font-lock package.
  149. (require 'font-lock)
  150. ;; Maximum colors
  151. (setq font-lock-maximum-decoration t)
  152. ;; Turn on font-lock in all modes that support it
  153. (global-font-lock-mode t)))
  154. ;; Fix for arrow key disease
  155. (define-key function-key-map "\eOA" [up])
  156. (define-key function-key-map "\e[A" [up])
  157. (define-key function-key-map "\eOB" [down])
  158. (define-key function-key-map "\e[B" [down])
  159. (define-key function-key-map "\eOC" [right])
  160. (define-key function-key-map "\e[C" [right])
  161. (define-key function-key-map "\eOD" [left])
  162. (define-key function-key-map "\e[D" [left])
  163. (set-background-color "black")
  164. (set-foreground-color "white")
  165. (set-cursor-color "white")