Created
February 26, 2013 13:30
-
-
Save gorenje/5038408 to your computer and use it in GitHub Desktop.
emac configuration file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; -*- MODE: LISP-INTERACTION -*- | |
(require 'mmm-mode) | |
(require 'mmm-auto) | |
(require 'saveplace) | |
;;(require 'psvn) | |
;;; THIS IS A SAMPLE .EMACS FILE. | |
;;; | |
;;; The .emacs file, which should reside in your home directory, allows you to | |
;;; customize the behavior of Emacs. In general, changes to your .emacs file | |
;;; will not take effect until the next time you start up Emacs. You can load | |
;;; it explicitly with `M-x load-file RET ~/.emacs RET'. | |
;;; | |
;;; There is a great deal of documentation on customization in the Emacs | |
;;; manual. You can read this manual with the online Info browser: type | |
;;; `C-h i' or select "Emacs Info" from the "Help" menu. | |
;; | |
;; $Id: .emacs,v 1.53 2005/01/05 21:01:07 riessen Exp $ | |
;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Basic Customization ;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; hey flymake: shut the fuck up! | |
(setq flymake-gui-warnings-enabled nil) | |
;; use set-input-method for defining umlauts. | |
;(set-input-method 'german-postfix) | |
;; allows defining umlauts (ü,ö,ä,ß) | |
(defun german-postfix () | |
(interactive) | |
(set-input-method 'german-postfix)) | |
;; define the shell prompt pattern to match my shell-RC file | |
(custom-set-variables | |
;; custom-set-variables was added by Custom. | |
;; If you edit it by hand, you could mess it up, so be careful. | |
;; Your init file should contain only one such instance. | |
;; If there is more than one, they won't work right. | |
'(ange-ftp-ftp-program-name "/usr/bin/netkit-ftp") | |
'(blink-cursor-mode nil) | |
'(c-basic-offset 2) | |
'(case-fold-search t) | |
'(completion-ignored-extensions (quote (".o" ".elc" ".class"))) | |
'(csv-separators (quote (";"))) | |
'(current-language-environment "German") | |
'(default-input-method "german-postfix") | |
'(file-coding-system-alist (quote (("\\.\\(erb\\|rhtml\\|rxml\\|rjs\\|haml\\|m\\|h\\|liquid\\)$" utf-8 . utf-8) ("Rakefile$" utf-8 . utf-8) ("\\.rake$" utf-8 . utf-8) ("\\.rb$" utf-8 . utf-8) ("\\.dz\\'" no-conversion . no-conversion) ("\\.g?z\\(~\\|\\.~[0-9]+~\\)?\\'" no-conversion . no-conversion) ("\\.tgz\\'" no-conversion . no-conversion) ("\\.tbz\\'" no-conversion . no-conversion) ("\\.bz2\\(~\\|\\.~[0-9]+~\\)?\\'" no-conversion . no-conversion) ("\\.Z\\(~\\|\\.~[0-9]+~\\)?\\'" no-conversion . no-conversion) ("\\.elc\\'" emacs-mule . emacs-mule) ("\\.utf\\(-8\\)?\\'" . utf-8) ("\\(\\`\\|/\\)loaddefs.el\\'" raw-text . raw-text-unix) ("\\.tar\\'" no-conversion . no-conversion) ("\\.po[tx]?\\'\\|\\.po\\." . po-find-file-coding-system) ("\\.\\(tex\\|ltx\\|dtx\\|drv\\)\\'" . latexenc-find-file-coding-system) ("" undecided . undecided)))) | |
'(fill-column 1024) | |
'(ftp-program "/usr/bin/netkit-ftp") | |
'(global-font-lock-mode t nil (font-lock)) | |
'(mouse-wheel-scroll-amount (quote (1 ((shift) . 1) ((control))))) | |
'(remote-shell-program "/usr/bin/ssh") | |
'(require-final-newline (quote ask)) | |
'(safe-local-variable-values (quote ((encoding . utf-8)))) | |
'(save-place t nil (saveplace)) | |
'(shell-prompt-pattern "^[^#$%> | |
]*[>] *") | |
'(show-paren-mode t) | |
'(speedbar-directory-button-trim-method nil) | |
'(speedbar-directory-unshown-regexp (quote "__________")) | |
'(speedbar-ignored-directory-expressions nil) | |
'(speedbar-select-frame-method 0) | |
'(speedbar-show-unknown-files t) | |
'(speedbar-track-mouse-flag t) | |
'(speedbar-use-images nil) | |
'(speedbar-verbosity-level 0) | |
'(tab-width 4) | |
'(text-mode-hook (quote (text-mode-hook-identify))) | |
'(transient-mark-mode t)) | |
;;(setq speedbar-file-unshown-regexp "^$") | |
;;(setq speedbar-directory-unshown-regexp "^$") | |
;;(desktop-read) | |
(prefer-coding-system 'utf-8) | |
;(desktop-load-default) | |
;(desktop-save-mode 1) | |
;; allow emacsclient to connect. | |
;; following doesn't really work | |
;;(setq server-socket-dir (format "/tmp/emacs%d" (user-uid))) | |
(require 'server) | |
(server-start) | |
(when (eq system-type 'darwin) ;; mac specific settings | |
(setq mac-option-modifier 'alt) | |
(setq mac-command-modifier 'meta) | |
(global-set-key [kp-delete] 'delete-char) ;; sets fn-delete to be right-delete | |
) | |
;; avoid prompt 'are you sure you want to kill buffer?' when editing | |
;; emacsclient opened files. | |
(add-hook 'server-switch-hook | |
(lambda () | |
(when (current-local-map) | |
(use-local-map (copy-keymap (current-local-map)))) | |
(when server-buffer-clients | |
(local-set-key (kbd "C-x k") 'server-edit)))) | |
;; store the backup files somewhere else ... not in the directories that i'm editing | |
(setq backup-directory-alist `(("." . "~/.emacs_backups"))) | |
;; it says what it does! | |
(mouse-wheel-mode 't) | |
;(load "/usr/share/emacs/site-lisp/site-gentoo") | |
(winner-mode 't) | |
(if (>= emacs-major-version 20) | |
(progn | |
(setq load-path (cons "/usr/local/lib/emacs/tools/" load-path)) | |
(setq load-path (cons "~/.emacs.d/" load-path)) | |
(setq load-path (cons "~/.emacs.d/gist.el" load-path)) | |
(setq load-path (cons "~/.emacs.d/emacs-rails" load-path)) | |
(setq load-path (cons "~/.emacs.d/treetop-mode" load-path)) | |
(setq load-path (cons "~/.emacs.d/haml/extra" load-path)) | |
(setq load-path (cons "~/.emacs.d/coffee-mode" load-path)) | |
(setq load-path (cons "/usr/local/lib/emacs/lisp/" load-path)) | |
(setq load-path (cons "/usr/local/lib/emacs/tools/jde-2.2.5/lisp/" | |
load-path)) | |
(setq load-path (cons "/usr/local/lib/emacs/tools/semantic-1.2.1/" | |
load-path)) | |
(setq load-path (cons "/usr/local/lib/emacs/tools/eieio-0.15/" | |
load-path)) | |
(setq load-path (cons "/usr/local/lib/erlang/lib/tools-2.6.8/emacs" | |
load-path)) | |
(setq load-path (cons "/usr/local/lib/emacs/tools/elib-1.0/" | |
load-path)))) | |
(if (>= emacs-major-version 23) | |
(progn | |
(setq line-move-visual nil))) | |
(setq erlang-root-dir "/opt/local/lib/erlang") | |
(setq exec-path (cons "/opt/local/lib/erlang/bin" exec-path)) | |
(require 'erlang-start) | |
(require 'revbufs) | |
(require 'git) | |
(require 'haml-mode) | |
(require 'sass-mode) | |
(require 'actionscript-mode) | |
(require 'puppet-mode) | |
(require 'xml-rpc) | |
(require 'trac-wiki) | |
(require 'objj-mode) | |
(require 'smart-tab) | |
(require 'gist) | |
(require 'treetop-mode) | |
(require 'coffee-mode) | |
(require 'csv-mode) | |
(require 'markdown-mode) | |
(require 'yaml-mode) | |
(require 'mustache-mode) | |
(setq ring-bell-function 'ignore) | |
;; (autoload 'ruby-mode "ruby-mode" "Major mode for ruby files" t) | |
;; (add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode)) | |
;; (add-to-list 'interpreter-mode-alist '("ruby" . ruby-mode)) | |
;; (require 'ruby-style) | |
;; (add-hook 'c-mode-hook 'ruby-style-c-mode) | |
;; (add-hook 'c++-mode-hook 'ruby-style-c-mode) | |
(global-smart-tab-mode 1) | |
(autoload 'js2-mode "js2" nil t) | |
;; This is a fix for js2 mode that does not do tab completion, only | |
;; indentation using the tab key. | |
(defun my-tab-fix () | |
(local-set-key [tab] 'indent-or-complete)) | |
(add-hook 'js2-mode-hook 'my-tab-fix) | |
;; Looks like this code came from: | |
;; http://emacsblog.org/2007/03/12/tab-completion-everywhere/ | |
(defun indent-or-expand-for-objj (arg) | |
"Either indent according to mode, or expand the word preceding point." | |
(interactive "*P") | |
(if (and | |
(or (bobp) (= ?w (char-syntax (char-before)))) | |
(or (eobp) (not (= ?w (char-syntax (char-after)))))) | |
(hippie-expand arg) | |
(indent-according-to-mode))) | |
(defun my-tab-fix-for-objj () | |
(local-set-key [tab] 'indent-or-expand-for-objj)) | |
;;(add-hook 'objj-mode-hook 'my-tab-fix-for-objj) | |
(defun trac-wiki-auto-mode-function () | |
(if (and (eq major-mode 'text-mode) | |
(member (file-name-extension (buffer-file-name)) | |
'("wiki")) | |
(re-search-forward "^=+ [^=\n]+ =+\\s *$" nil t)) | |
(trac-wiki-mode))) | |
(add-hook 'find-file-hook | |
'trac-wiki-auto-mode-function) | |
(defun sort-words (reverse beg end) | |
"Sort words in region alphabetically, in REVERSE if negative. | |
Prefixed with negative \\[universal-argument], sorts in reverse. | |
The variable `sort-fold-case' determines whether alphabetic case | |
affects the sort order. | |
See `sort-regexp-fields'." | |
(interactive "P\nr") | |
(sort-regexp-fields reverse "\\w+" "\\&" beg end)) | |
(defun sort-words-in-lines (start end) | |
"sorts all words on the line that has been marked, region is ignored." | |
(interactive "r") | |
(goto-char start) | |
(beginning-of-line) | |
(while (< (setq start (point)) end) | |
(let ((words (sort (split-string (buffer-substring start (line-end-position))) | |
(function string-lessp)))) | |
(delete-region start (line-end-position)) | |
(dolist (word words ) (insert word " "))) | |
(beginning-of-line) (forward-line 1))) | |
;; if using version 21 or higher, kill the tool bar and load the speedbar | |
(if (>= emacs-major-version 21) | |
(progn | |
(tool-bar-mode 0) | |
(blink-cursor-mode 0) | |
;(defvar cedet-path "/usr/local/share/emacs/21.3/site-lisp/cedet-1.0beta3a/") | |
;(setq load-path (cons cedet-path load-path)) | |
;(load-file (concat cedet-path "common/cedet.el")) | |
;(semantic-load-enable-code-helpers) | |
)) | |
(defface font-lock-comment-face | |
'((((class grayscale) (background light)) | |
(:foreground "DimGray" :bold t :italic t)) | |
(((class grayscale) (background dark)) | |
(:foreground "LightGray" :bold t :italic t)) | |
(((class color) (background light)) (:foreground "brown")) | |
(((class color) (background dark)) (:foreground "orange")) | |
(t (:bold t :italic t))) | |
"Font Lock mode face used to highlight comments." | |
:group 'font-lock-highlighting-faces) | |
(defface font-lock-string-face | |
'((((class grayscale) (background light)) (:foreground "DimGray" :italic t)) | |
(((class grayscale) (background dark)) (:foreground "LightGray" :italic t)) | |
(((class color) (background light)) (:foreground "DodgerBlue4")) | |
(((class color) (background dark)) (:foreground "violet")) | |
(t (:italic t))) | |
"Font Lock mode face used to highlight strings." | |
:group 'font-lock-highlighting-faces) | |
(defface font-lock-keyword-face | |
'((((class grayscale) (background light)) (:foreground "LightGray" :bold t)) | |
(((class grayscale) (background dark)) (:foreground "DimGray" :bold t)) | |
(((class color) (background light)) (:foreground "red")) | |
(((class color) (background dark)) (:foreground "pink")) | |
(t (:bold t))) | |
"Font Lock mode face used to highlight keywords." | |
:group 'font-lock-highlighting-faces) | |
(defface font-lock-builtin-face | |
'((((class grayscale) (background light)) (:foreground "LightGray" :bold t)) | |
(((class grayscale) (background dark)) (:foreground "DimGray" :bold t)) | |
(((class color) (background light)) (:foreground "Orchid")) | |
(((class color) (background dark)) (:foreground "LightSteelBlue")) | |
(t (:bold t))) | |
"Font Lock mode face used to highlight builtins." | |
:group 'font-lock-highlighting-faces) | |
(defface font-lock-function-name-face | |
'((((class color) (background light)) (:foreground "green")) | |
(((class color) (background dark)) (:foreground "white")) | |
(t (:inverse-video t :bold t))) | |
"Font Lock mode face used to highlight function names." | |
:group 'font-lock-highlighting-faces) | |
(defface font-lock-variable-name-face | |
'((((class grayscale) (background light)) | |
(:foreground "Gray90" :bold t :italic t)) | |
(((class grayscale) (background dark)) | |
(:foreground "DimGray" :bold t :italic t)) | |
(((class color) (background light)) (:foreground "IndianRed4")) | |
(((class color) (background dark)) (:foreground "beige")) | |
(t (:bold t :italic t))) | |
"Font Lock mode face used to highlight variable names." | |
:group 'font-lock-highlighting-faces) | |
(defface font-lock-type-face | |
'((((class grayscale) (background light)) (:foreground "Gray90" :bold t)) | |
(((class grayscale) (background dark)) (:foreground "DimGray" :bold t)) | |
(((class color) (background light)) (:foreground "SpringGreen4")) | |
(((class color) (background dark)) (:foreground "aquamarine")) | |
(t (:bold t :underline t))) | |
"Font Lock mode face used to highlight type and classes." | |
:group 'font-lock-highlighting-faces) | |
(defface font-lock-constant-face | |
'((((class grayscale) (background light)) | |
(:foreground "LightGray" :bold t :underline t)) | |
(((class grayscale) (background dark)) | |
(:foreground "Gray50" :bold t :underline t)) | |
(((class color) (background light)) (:foreground "CadetBlue")) | |
(((class color) (background dark)) (:foreground "PaleGreen")) | |
(t (:bold t :underline t))) | |
"Font Lock mode face used to highlight constants and labels." | |
:group 'font-lock-highlighting-faces) | |
(defface font-lock-warning-face | |
'((((class color) (background light)) (:foreground "Red" :bold t)) | |
(((class color) (background dark)) (:foreground "Red" :bold t)) | |
(t (:inverse-video t :bold t))) | |
"Font Lock mode face used to highlight warnings." | |
:group 'font-lock-highlighting-faces) | |
(custom-set-faces | |
;; custom-set-faces was added by Custom. | |
;; If you edit it by hand, you could mess it up, so be careful. | |
;; Your init file should contain only one such instance. | |
;; If there is more than one, they won't work right. | |
'(flymake-errline ((((class color)) (:overline "red" :underline "red")))) | |
'(flymake-warnline ((((class color)) (:background "#222222" :overline "red" :underline "red")))) | |
'(hi-pink ((((background dark)) (:background "lightblue" :foreground "black")))) | |
'(js2-external-variable-face ((t (:foreground "#f3ff32")))) | |
'(mmm-code-submode-face ((t (:background "#333")))) | |
'(mmm-output-submode-face ((t (:background "#333")))) | |
'(nxml-attribute-prefix-face ((t (:inherit nxml-name-face :foreground "beige")))) | |
'(nxml-attribute-value-face ((t (:inherit nxml-delimited-data-face :foreground "violet")))) | |
'(nxml-comment-content-face ((t (:foreground "orange" :slant italic)))) | |
'(nxml-comment-delimiter-face ((t (:inherit nxml-delimiter-face :foreground "orange")))) | |
'(nxml-element-colon-face ((t (:inherit nxml-name-face :foreground "white")))) | |
'(nxml-element-local-name-face ((t (:inherit nxml-name-face :foreground "white")))) | |
'(nxml-element-prefix-face ((t (:inherit nxml-name-face :foreground "white")))) | |
'(nxml-namespace-attribute-value-face ((t (:inherit nxml-attribute-value-face :foreground "violet")))) | |
'(show-paren-match ((t (:inverse-video t)))) | |
'(yaml-tab-face ((t (:background "red" :foreground "grey" :weight bold))))) | |
;; modify isearch so that C-y does a yank-kill instead of M-y | |
(load-library "isearch") | |
(define-key isearch-mode-map "\C-y" 'isearch-yank-kill) | |
(define-key isearch-mode-map "\M-y" 'isearch-yank-line) | |
;; load wiki-mode | |
(setq wiki-directory (expand-file-name "/www/development/wiki")) | |
;; this seems to work .... | |
(setq sendmail-program "sendmail") | |
;; all variables relating to cc-mode (i.e. java-mode) are defined | |
;; as local variables to the buffer. | |
(setq c-style-variables-are-local-p 't) | |
;; what's my name? | |
(setq user-full-name "Gerrit Riessen") | |
;; Start a speedbar after initialisation but only if we're using | |
;; some sort of windowing system | |
;(if window-system | |
; (add-hook 'after-init-hook 'speedbar)) | |
(if (getenv "EMACS_EMAIL_ADDR") | |
(setq user-mail-address (getenv "EMACS_EMAIL_ADDR")) | |
(setq user-mail-address "[email protected]")) | |
(if (getenv "EMACS_COMPANY") | |
(setq my-company-name (getenv "EMACS_COMPANY")) | |
(setq my-company-name "Wooga")) | |
;; don't bother ringing the bell. | |
(setq visible-bell 't) | |
;; use the bash shell | |
(setq explicit-shell-file-name "/bin/bash") | |
;; my styles for various indentations. | |
;; can be set using the 'c-set-style' command. | |
;; To see the syntactic formating of a particular | |
;; line: C-c C-s or c-show-syntactic-information | |
(c-add-style "cappuccino" | |
'((c-basic-offset . 4) | |
(c-comment-only-line-offset . 0) | |
(c-hanging-braces-alist . | |
((substatement-open before after))) | |
(c-offsets-alist . ((inexpr-class . +) | |
(inexpr-statement . +) | |
(lambda-intro-cont . +) | |
(inlambda . c-lineup-inexpr-block) | |
(template-args-cont c-lineup-template-args +) | |
(incomposition . +) | |
(inmodule . +) | |
(innamespace . +) | |
(inextern-lang . +) | |
(composition-close . 0) | |
(module-close . 0) | |
(namespace-close . 0) | |
(extern-lang-close . 0) | |
(composition-open . 0) | |
(module-open . 0) | |
(namespace-open . 0) | |
(extern-lang-open . 0) | |
(objc-method-args-cont . c-lineup-ObjC-method-args) | |
(objc-method-intro . | |
[0]) | |
(friend . 0) | |
(cpp-define-intro c-lineup-cpp-define +) | |
(cpp-macro-cont . +) | |
(cpp-macro . | |
[0]) | |
(inclass . +) | |
(stream-op . c-lineup-streamop) | |
(arglist-cont-nonempty c-lineup-gcc-asm-reg c-lineup-arglist) | |
(arglist-cont c-lineup-gcc-asm-reg 0) | |
(comment-intro c-lineup-knr-region-comment c-lineup-comment) | |
(catch-clause . 0) | |
(else-clause . 0) | |
(do-while-closure . 0) | |
(access-label . -) | |
(case-label . 0) | |
(substatement . +) | |
(statement-case-intro . +) | |
(statement . 0) | |
(brace-entry-open . 0) | |
(brace-list-open . *) | |
(brace-list-entry . 0) | |
(brace-list-intro . *) | |
(brace-list-close . 0) | |
(block-close . 0) | |
(block-open . 0) | |
(inher-cont . c-lineup-multi-inher) | |
(inher-intro . +) | |
(member-init-cont . c-lineup-multi-inher) | |
(member-init-intro . +) | |
(topmost-intro . 0) | |
(knr-argdecl . 0) | |
(func-decl-cont . +) | |
(inline-close . 0) | |
(class-close . 0) | |
(class-open . 0) | |
(defun-block-intro . +) | |
(defun-close . 0) | |
(defun-open . 0) | |
(c . c-lineup-C-comments) | |
(string . c-lineup-dont-change) | |
(topmost-intro-cont first c-lineup-topmost-intro-cont c-lineup-gnu-DEFUN-intro-cont) | |
(inline-open . 0) | |
(arglist-close . c-lineup-arglist) | |
(arglist-intro . c-lineup-arglist-intro-after-paren) | |
(statement-cont . +) | |
(statement-case-open . +) | |
(objc-method-call-cont c-lineup-ObjC-method-call-colons c-lineup-ObjC-method-call +) | |
(substatement-label . 0) | |
(substatement-open . 0) | |
(knr-argdecl-intro . 5) | |
(statement-block-intro . +) | |
(objc-method-arg-min-delta-to-bracket . *) | |
(objc-method-arg-unfinished-offset . +) | |
(objc-method-parameter-offset . +))))) | |
(c-add-style "netbeans" | |
'((c-basic-offset . 2) | |
(c-comment-only-line-offset . 0) | |
(c-hanging-braces-alist . | |
((substatement-open before after))) | |
(c-offsets-alist . ((topmost-intro . 0) | |
(topmost-intro-cont . 0) | |
(substatement . +) | |
(substatement-open . 0) | |
(case-label . +) | |
(access-label . -) | |
(inclass . +) | |
(inline-open . 0) | |
)))) | |
(c-add-style "jedicf-generated" | |
'((c-basic-offset . 1) | |
(c-comment-only-line-offset . 0) | |
(c-hanging-braces-alist . | |
((substatement-open before after))) | |
(c-offsets-alist . ((topmost-intro . 0) | |
(topmost-intro-cont . 0) | |
(substatement . +) | |
(substatement-open . 0) | |
(case-label . +) | |
(access-label . -) | |
(inclass . +) | |
(inline-open . 0) | |
(func-decl-cont . +) | |
)))) | |
;; stefan schaefers programming style | |
(c-add-style "jedicf-ssch" | |
'((c-basic-offset . 2) | |
(c-comment-only-line-offset . 0) | |
(c-hanging-braces-alist . | |
((substatement-open before after))) | |
(c-offsets-alist . ((topmost-intro . 0) | |
(topmost-intro-cont . 0) | |
(substatement . +) | |
(substatement-open . 0) | |
(case-label . +) | |
(access-label . -) | |
(inclass . +) | |
(inline-open . 0) | |
(func-decl-cont . +) | |
)))) | |
;; Style used by the Jakarta/Apache projects | |
(c-add-style "jakarta-ant" | |
'((c-basic-offset . 2) | |
(c-comment-only-line-offset . 0) | |
(c-hanging-braces-alist . | |
((substatement-open before after))) | |
(c-offsets-alist . ((topmost-intro . 0) | |
(topmost-intro-cont . 0) | |
(substatement . +) | |
(substatement-open . 0) | |
(case-label . +) | |
(access-label . -) | |
(inclass . +) | |
(inline-open . 0) | |
)))) | |
;; Pear PHP Style | |
(c-add-style "php-pear" | |
'((c-basic-offset . 2) | |
(tab-width . 8) | |
(c-hanging-comment-ender-p . nil) | |
(indent-tabs-mode . nil) | |
(c-hanging-braces-alist . ((substatement-open before after))) | |
(c-offsets-alist . ((topmost-intro . 0) | |
(topmost-intro-cont . 0) | |
(substatement . +) | |
(substatement-open . 0) | |
(case-label . +) | |
(access-label . -) | |
(inclass . +) | |
(inline-open . 0) | |
(func-decl-cont . +) | |
)))) | |
;;; Before killing emacs, ask me. I've accidentally hit C-xC-c once | |
;;; too often! | |
(defun really-quit-no-arguments () | |
(yes-or-no-p "Really Quit? ")) | |
(defun redo (&optional arg) | |
"Basically the idea is to undo the last undo! Therefore this | |
can only be called directly after the last undo." | |
(interactive) | |
(if arg | |
(undo arg) | |
(undo))) | |
(defun select-all () | |
(interactive) | |
(set-mark (point-min)) | |
(goto-char (point-max))) | |
(defun mouse-stop () | |
"Stop the GPM daemon, thereby stopping the mouse" | |
(interactive) | |
(shell-command "/etc/init.d/gpm stop")) | |
(defun mouse-start () | |
"Start the GPM daemon, thereby starting the mouse" | |
(interactive) | |
(shell-command "/etc/init.d/gpm start")) | |
(add-hook 'kill-emacs-query-functions 'really-quit-no-arguments) | |
;; (require 'ecb-autoloads) | |
;; (autoload 'ruby-mode "ruby-mode" "Ruby editing mode." t) | |
;; (setq auto-mode-alist (cons '("\\.rb$" . ruby-mode) auto-mode-alist)) | |
;; (setq auto-mode-alist (cons '("\\.rhtml$" . html-mode) auto-mode-alist)) | |
;; (modify-coding-system-alist 'file "\\.rb$" 'utf-8) | |
;; (modify-coding-system-alist 'file "\\.rhtml$" 'utf-8) | |
(require 'font-lock) | |
(require 'snippet) | |
(require 'inf-ruby) | |
(require 'rails) | |
(require 'ruby-electric) | |
;(setq font-lock-support-mode 'lazy-lock-mode) | |
(setq font-lock-maximum-decoration t) | |
;; define the meta html mode i.e. mhtml-mode | |
;(load-library "mhtml") | |
;; folding mode, useful for hiding methods in classes | |
;(load-library "folding") | |
;; My very own morse code functions! | |
;(load-library "morse") | |
;; ISBN Computer! | |
;(load-library "isbn") | |
;; SixHats thinking method | |
;(load-library "sixthinkinghats") | |
;; Eye-candy while emacs is busy | |
;(load-library "working") | |
;; php-mode for emacs | |
;(load-library "php-mode") | |
;; python mode | |
;(load-library "python-mode") | |
(if window-system | |
(progn | |
;; ensure that the speedbar library is loaded. | |
(load-library "speedbar") | |
)) | |
;(if (>= emacs-major-version 20) | |
; (require 'jde)) | |
; (if (featurep 'speedbar) | |
; (progn | |
; (defun speedbar-this-file-in-vc (path name) | |
; "This is an overridden version of the function defined in | |
; `speedbar.el'. This handles RCS and CVS." | |
; (message (concat "Path: " path " File: " name)) | |
; (or | |
; ;; RCS file name | |
; (file-exists-p (concat path "RCS/" name ",v")) | |
; (file-exists-p (concat path "RCS/" name)) | |
; ;; Local SCCS file name | |
; (file-exists-p (concat path "SCCS/s." name)) | |
; ;; Remote SCCS file name | |
; (let ((proj-dir (getenv "PROJECTDIR"))) | |
; (if proj-dir | |
; (file-exists-p (concat proj-dir "/SCCS/s." name)) | |
; nil)) | |
; ;; check the CVS entries file | |
; (cond | |
; ((featurep 'vc) | |
; (not (equal (vc-status (concat path "/" name)) "-"))) | |
; ((not (featurep 'vc)) | |
; (and (file-exists-p (concat path "/CVS/Entries")) | |
; (= 1 (call-process "grep" nil nil nil "-q" "-s" | |
; (concat "^/" name "/") | |
; (concat path "/CVS/Entries")))))) | |
; ) | |
; ;; User extension ignore these as part of the or because | |
; ;; the return value of run-hook-with-args is unreliable | |
; ;;(run-hook-with-args 'speedbar-vc-in-control-hook path name) | |
; ))) | |
;; The following only works for Emacs 20.4 or greater | |
;; and is only written for a Windoze system. | |
;; It sets up my international fonts, which under Unix isn't required | |
;; strangely: 20.7 seems to support latin-1 fonts automatically! DOH! ;-) | |
(if (and (= emacs-major-version 20) | |
(>= emacs-minor-version 4) | |
(string= system-type "windows-nt")) | |
(progn | |
(setq bdf-directory-list | |
'("/usr/lib/emacs/20.7/intlfonts/Asian" | |
"/usr/lib/emacs/20.7/intlfonts/Chinese" | |
"/usr/lib/emacs/20.7/intlfonts/Chinese-X" | |
"/usr/lib/emacs/20.7/intlfonts/Ethiopic" | |
"/usr/lib/emacs/20.7/intlfonts/European" | |
"/usr/lib/emacs/20.7/intlfonts/Japanese" | |
"/usr/lib/emacs/20.7/intlfonts/Japanese-X" | |
"/usr/lib/emacs/20.7/intlfonts/Korean-X" | |
"/usr/lib/emacs/20.7/intlfonts/Misc/")) | |
(setq w32-bdf-filename-alist | |
(w32-find-bdf-fonts bdf-directory-list)) | |
(create-fontset-from-fontset-spec | |
"-*-fixed-medium-r-normal-*-16-*-*-*-c-*-fontset-bdf, | |
japanese-jisx0208:-*-*-medium-r-normal-*-16-*-*-*-c-*-jisx0208.1983-*, | |
katakana-jisx0201:-*-*-medium-r-normal-*-16-*-*-*-c-*-jisx0201*-*, | |
latin-jisx0201:-*-*-medium-r-normal-*-16-*-*-*-c-*-jisx0201*-*, | |
japanese-jisx0208-1978:-*-*-medium-r-normal-*-16-*-*-*-c-*-jisx0208.1978-*, | |
thai-tis620:-misc-fixed-medium-r-normal--16-160-72-72-m-80-tis620.2529-1, | |
lao:-misc-fixed-medium-r-normal--16-160-72-72-m-80-MuleLao-1, | |
tibetan-1-column:-TibMdXA-fixed-medium-r-normal--16-160-72-72-m-80-MuleTibetan-1, | |
ethiopic:-Admas-Ethiomx16f-Medium-R-Normal--16-150-100-100-M-160-Ethiopic-Unicode, | |
tibetan:-TibMdXA-fixed-medium-r-normal--16-160-72-72-m-160-MuleTibetan-0") | |
;; Need to add some fonts to font-encoding-alist since the bdf fonts | |
;; are type 0 not the default type 1. | |
(setq font-encoding-alist | |
(append '(("MuleTibetan-0" (tibetan . 0)) | |
("GB2312" (chinese-gb2312 . 0)) | |
("JISX0208" (japanese-jisx0208 . 0)) | |
("JISX0212" (japanese-jisx0212 . 0)) | |
("VISCII" (vietnamese-viscii-lower . 0)) | |
("KSC5601" (korean-ksc5601 . 0)) | |
("MuleArabic-0" (arabic-digit . 0)) | |
("MuleArabic-1" (arabic-1-column . 0)) | |
("MuleArabic-2" (arabic-2-column . 0))) | |
font-encoding-alist)) | |
(set-default-font "fontset-bdf"))) | |
;; this is used for the Wiki prefix command | |
(global-unset-key "\C-xw") | |
;; require igrep and agrep for wiki-mode | |
(setq grep-null-device null-device) | |
(autoload 'agrep "igrep" "*Run `agrep`..." t) | |
(setq igrep-options "-i -E") | |
(autoload 'php-mode "php-mode" "PHP editing mode" t) | |
;(require 'igrep) | |
;(require 'vc) | |
;(require 'tempo) | |
;(require 'wiki-mode) | |
;(require 'iso-oem) | |
;(standard-display-iso-oem) | |
;; follow symbolic links automatically, don't ask. | |
(setq vc-follow-symlinks 't) | |
; if the file requires debugging, then use the (print ..) command | |
;(print "some amount of output") | |
;; Do the things that are common to all versions of emacs first and then | |
;; worry about the version specific things .... | |
(require 'global-key-bindings) | |
(put 'upcase-region 'disabled nil) | |
(put 'downcase-region 'disabled nil) | |
;; (defun setup-fill-mode () | |
;; "This is the crappy little function from hell" | |
;; (interactive) | |
;; (auto-fill-mode) | |
;; (set-fill-column 78) | |
;; ) | |
;; Java functions | |
(defun java-header () | |
(interactive) | |
(tempo-template-java-header)) | |
(defun java-method-comment () | |
(interactive) | |
(tempo-template-java-method-comment)) | |
(defun java-class () | |
(interactive) | |
(tempo-template-java-class)) | |
(defun java-new-class () | |
(interactive) | |
(tempo-template-java-new-class)) | |
(defun java-new-method () | |
(interactive) | |
(tempo-template-java-method-comment) | |
(tempo-template-java-new-method)) | |
(defun java-fold-region () | |
(interactive) | |
(tempo-template-java-fold-region)) | |
(defun html-tt () | |
(interactive) | |
(tempo-template-html-tt)) | |
(defun html-bold () | |
(interactive) | |
(tempo-template-html-bold)) | |
(defun html-comment () | |
(interactive) | |
(tempo-template-html-comment)) | |
(defun html-umlaut () | |
(interactive) | |
(tempo-template-html-umlaut)) | |
(defun html-code () | |
(interactive) | |
(tempo-template-html-code)) | |
(defun html-strike () | |
(interactive) | |
(tempo-template-html-strikethru)) | |
(defun html-font-red () | |
(interactive) | |
(tempo-template-html-font-red)) | |
(defun c++-fold-region () | |
(interactive) | |
(tempo-template-c++-fold-region)) | |
(defun c-fold-region () | |
(interactive) | |
(tempo-template-c-fold-region)) | |
(defun gnu-public-license () | |
(interactive) | |
(tempo-template-gnu-public-license)) | |
(defun curly-bracket-region () | |
(interactive) | |
(tempo-template-curly-bracket-region)) | |
;; kept for historical reasons | |
(defun saga2-java-files () | |
(list | |
"i:CVS_Repository/work/java/oar/cf/core/adt/tree/binary/CFBinaryTreeNode.java,v" | |
"i:CVS_Repository/work/java/oar/cf/core/adt/tree/binary/CFBinaryTreeNodeImpl.java,v" | |
"i:CVS_Repository/work/java/oar/cf/core/persistence/query/Attic/CFQueryAttributeDescriptor.java,v" | |
)) | |
(defun close-all-buffers () | |
(interactive) | |
(mapc 'kill-buffer (buffer-list))) | |
(defun saga2-load-all-files () | |
(interactive) | |
(setq filenames (saga2-java-files)) | |
(while filenames | |
(let ((filename (car filenames))) | |
(progn | |
(find-file filename))) | |
;;(toggle-read-only))) | |
;;(vc-next-action nil))) | |
(setq filenames (cdr filenames)))) | |
; User saga2-load-all-files, followed by a query-replace-on-all-buffers | |
; (defun saga2-replace-on-files (str1 str2) | |
; (interactive "sReplace: \nsWith: ") | |
; (setq filenames (saga2-java-files)) | |
; (while filenames | |
; (let ((filename (car filenames))) | |
; (search-and-replace-in-file str1 str2 filename)) | |
; (setq filenames (cdr filenames)))) | |
;; vc-status returns a leading - (45) for files which are checked in | |
;; and a leading : (58) for files which are checked out. [errr: this comment | |
;; is a little dated: - for files that appear to match their repository | |
;; representation, : for those files that appear to differ from their | |
;; repository state]. | |
(defun checkin-all-buffers (msg) | |
"This checks all buffers of emacs and checks those buffers in that | |
are checked out" | |
(interactive "sMessage: ") | |
(setq all-buffers (buffer-list)) | |
(while all-buffers | |
(let ((current-buffer (car all-buffers))) | |
(checkin-buffer msg current-buffer)) | |
(setq all-buffers (cdr all-buffers)))) | |
(defun toggle-read-only-all-buffers () | |
"toggle all buffers read-only" | |
(interactive) | |
(setq all-buffers (buffer-list)) | |
(while all-buffers | |
(let | |
((buffer (car all-buffers))) | |
(progn | |
(set-buffer buffer) | |
(toggle-read-only))) | |
(setq all-buffers (cdr all-buffers)))) | |
(defun checkin-this-buffer (msg) | |
(interactive "sMessage: ") | |
(checkin-buffer msg (current-buffer))) | |
; (defun checkin-buffer (msg buffer) | |
; "This checks in the file with the given buffer." | |
; (interactive "sMessage: bBuffer: ") | |
; (if (or (eq (buffer-file-name buffer) nil) | |
; (eq (vc-latest-version (buffer-file-name buffer)) nil)) | |
; () | |
; (if (eq (car (string-to-list (vc-status (buffer-file-name buffer)))) 58) | |
; (vc-checkin (buffer-file-name buffer) nil msg)))) | |
;; Wrapper around vc-checkin to make check the status of a given file | |
;; before calling vc-checkin | |
(defun checkin-buffer (msg buffer) | |
"This checks in the file with the given buffer." | |
(interactive "sMessage: \nbBuffer: ") | |
(and (buffer-file-name buffer) | |
(vc-latest-version (buffer-file-name buffer)) | |
(eq (car (string-to-list (vc-status (buffer-file-name buffer)))) 58) | |
(vc-checkin (buffer-file-name buffer) nil msg))) | |
(defun does-buffer-need-to-be-checked-in (buffer) | |
"Returns true if the given buffer requires checking in. This checks | |
whether the buffer is under VC control, if not then nil is returned." | |
(interactive "bBuffer: ") | |
(if (or (eq (buffer-file-name buffer) nil) | |
(eq (vc-latest-version (buffer-file-name buffer)) nil)) | |
(nil) | |
(if (eq (car (string-to-list (vc-status (buffer-file-name buffer)))) 58) | |
(true) | |
nil))) | |
(defun search-and-replace-in-file (str1 str2 filename) | |
(interactive "sReplace: \nsWith: \nsFilename: ") | |
(setq query-replace-interactive nil) | |
(find-file filename) | |
(vc-next-action nil) | |
(beginning-of-buffer) | |
(query-replace str1 str2) | |
(save-buffer)) | |
(defun jump-to-beginning-of-block () | |
(interactive) | |
(let ((char (char-after (point)))) | |
(print char standard-output) | |
(print (matching-paren char)) | |
(print (point)) | |
(print (c-most-enclosing-brace (c-point (point)))) | |
(print (c-least-enclosing-brace (c-point (point)))))) | |
(defun query-replace-on-all-buffers (regexp string) | |
"This calls query-replace-regexp on all currently, and assciated | |
with files, open buffers." | |
(interactive "sReplace: \nsWith: ") | |
(setq all-buffers (buffer-list)) | |
(while all-buffers | |
(let | |
((buffer (car all-buffers))) | |
(progn | |
(if (not (eq (buffer-file-name buffer) nil)) | |
(progn | |
(switch-to-buffer buffer) | |
(beginning-of-buffer) | |
(query-replace-regexp regexp string)))) | |
(setq all-buffers (cdr all-buffers))))) | |
(defun indent-all-buffers () | |
"Indents all currently opened buffers. This function turns | |
font-lock-mode off on all buffers on which it acts." | |
(interactive) | |
(setq all-buffers (buffer-list)) | |
(while all-buffers | |
(let | |
((buffer (car all-buffers))) | |
(progn | |
(set-buffer buffer) | |
(font-lock-mode -1) | |
(indent-region 0 (buffer-size) nil))) | |
(setq all-buffers (cdr all-buffers)))) | |
(defun indent-this-buffer () | |
"Indent the entire buffer where the buffer is the current buffer" | |
(interactive) | |
(indent-buffer (current-buffer))) | |
(defun indent-buffer (buffer) | |
"Indent an entire buffer" | |
(interactive "bBuffer: ") | |
(set-buffer buffer) | |
(font-lock-mode nil) | |
(indent-region 0 (buffer-size) nil) | |
(font-lock-mode nil)) | |
(defun save-all-buffers () | |
"Saves all currently open buffers which are associated with a file" | |
(interactive) | |
(setq all-buffers (buffer-list)) | |
(while all-buffers | |
(let | |
((buffer (car all-buffers))) | |
(if (not (eq (buffer-file-name buffer) nil)) | |
(progn | |
(set-buffer buffer) | |
(save-buffer)))) | |
(setq all-buffers (cdr all-buffers)))) | |
(defun untabify-all-buffers () | |
"Untabify all buffers that are currently loaded. This function turns | |
font-lock-mode off on all buffers that it acts on." | |
(interactive) | |
(setq all-buffers (buffer-list)) | |
(while all-buffers | |
(let | |
((buffer (car all-buffers))) | |
(if (not (eq (buffer-file-name buffer) nil)) | |
(progn | |
(set-buffer buffer) | |
(font-lock-mode -1) | |
(untabify 0 (buffer-size))))) | |
(setq all-buffers (cdr all-buffers)))) | |
(defun untabify-this-buffer () | |
"Untabify the entire buffer where the buffer is the current buffer" | |
(interactive) | |
(untabify-buffer (current-buffer))) | |
(defun untabify-buffer (buffer) | |
"Untabify an entire buffer" | |
(interactive "bBuffer: ") | |
(font-lock-mode nil) | |
(set-buffer buffer) | |
(untabify 0 (buffer-size)) | |
(font-lock-mode t)) | |
(defun delete-file-this-buffer (answer) | |
"Remove file which corresponds to the current buffer and kill the | |
Buffer." | |
(interactive | |
(concat "sDelete " (buffer-file-name (current-buffer)) | |
"? (yes/no)")) | |
(if (equal answer "yes") | |
(progn | |
(delete-file-for-buffer (current-buffer)) | |
(kill-buffer (current-buffer))))) | |
(defun delete-file-for-buffer (buffer) | |
"Remove the file that is associated with the specific buffer" | |
(interactive "bBuffer: ") | |
(delete-file (buffer-file-name buffer))) | |
(defun html-quote-attributes (buffer) | |
"Quote all attributes of all HTML elements." | |
(interactive "bBuffer: ") | |
(switch-to-buffer buffer) | |
(beginning-of-buffer) | |
(query-replace-regexp "=\\([^ >\"\t\n\r]+\\)" "=\"\\1\"")) | |
(defun html-quote-attributes-in-this-buffer () | |
"Quote all attributes of all HTML elements." | |
(interactive) | |
(html-quote-attributes (current-buffer))) | |
(defun java-format-this-buffer () | |
"Java format this buffer. See java-format-buffer" | |
(interactive) | |
(java-format-buffer (current-buffer))) | |
(defun java-format-buffer (buffer) | |
"Convert Java code to a correct format by doing a couple of common | |
search and replaces." | |
(interactive "bBuffer: ") | |
(switch-to-buffer buffer) | |
;; replace lines that end with a { (open curly bracket) | |
;; Two replacements are done here, one in which only those lines | |
;; that contain tabs or spaces after the curly bracket, and the | |
;; other replacement of those statements that have something after | |
;; the curly bracket that is important. | |
(beginning-of-buffer) | |
(query-replace-regexp "^\\([^\n{]+[^ \n{][^\n{]+\\){[ \t]*$" "\\1\n{") | |
(beginning-of-buffer) | |
(query-replace-regexp "^\\([^\n{]+[^ \n{][^\n{]+\\){\\([^}]*\\)}[ \t]*$" | |
"\\1\n{\n\\2\n}") | |
(beginning-of-buffer) | |
(query-replace-regexp "^\\([^\n{]+[^ \n{][^\n{]+\\){\\(.*\\)$" "\\1\n{\n\\2") | |
;; replace '} catch ' | |
(beginning-of-buffer) | |
(query-replace-regexp "^[ \t]*}[ \t]*\\(catch .*\\)$" "}\n\\1") | |
;; replace '} else ' | |
(beginning-of-buffer) | |
(query-replace-regexp "^[ \t]*}[ \t]*\\(else .*\\)$" "}\n\\1") | |
;; replace '} while ' | |
(beginning-of-buffer) | |
(query-replace-regexp "^[ \t]*}[ \t]*\\(while .*\\)$" "}\n\\1") | |
;; replace '{ }' -- this might not be required...... | |
(beginning-of-buffer) | |
(query-replace-regexp "{[ \t]*}" "\n{\n}\n") | |
;; replace '{ /** some code **/ }' | |
(beginning-of-buffer) | |
(query-replace-regexp "{\\([^\n\r}]*\\)}" "\n{\n\\1\n}\n") | |
;; clean up for statements | |
(beginning-of-buffer) | |
(query-replace-regexp "for[ \t\n]*([ \t\n]*\\([^;]*\\);[ \t\n]*\\([^;]*\\);[ \t\n]*\\([^)]*\\)[ \t\n]*)[ \t]*{" "for ( \\1; \\2; \\3 )\n{") | |
;; clean up for statements | |
(beginning-of-buffer) | |
(query-replace-regexp "for[ \t\n]*([ \t\n]*\\([^;]*\\);[ \t\n]*\\([^;]*\\);[ \t\n]*\\([^)]*\\)[ \t\n]*)" "for ( \\1; \\2; \\3 )") | |
;; replace assignment operations so that they're readable | |
(beginning-of-buffer) | |
(query-replace-regexp | |
"\\([^ ]\\)[ ]*\\([+=!*-]?=\\)[ ]*\\([^ ]\\)" "\\1 \\2 \\3") | |
; ;; replace 'if (....) ....; else ' with 'if (...) { ... } else' | |
; ;; this doesn't allow nested () in the if condition | |
; (beginning-of-buffer) | |
; (query-replace-regexp "if[ \t\n]*\\(([^)]*)\\)[ \t\n]*\ | |
) | |
; From the Emacs-FAQs | |
; To bind keys on starting Emacs or on starting any given mode, you can use | |
; the following "trick." First bind the key interactively, then | |
; immediately afterwards type `C-x ESC ESC C-a C-k C-g'. Now, the command | |
; needed to bind the key is in the kill ring and can be yanked into the | |
; .emacs file. If the key binding is global, no changes to the command are | |
; required. For example, | |
;;; on a laptop is the home key right next door to the backspace | |
(global-set-key (quote [home]) (quote backward-delete-char)) | |
;;; on a laptop is the end key right next door to the up-arrow | |
(global-set-key (quote [end]) (quote recenter)) | |
;;; redefine the insert key .... | |
(global-set-key (quote [insert]) (quote recenter)) | |
;;; use spaces instead of tab-characters for indentation | |
;;;(setq indent-tabs-mode nil) | |
(setq-default indent-tabs-mode nil) | |
;(print "preparing to set fill columm") | |
(set-fill-column 78) | |
(setq c-basic-offset 2) | |
;;(setq-default case-fold-search '()) ; case sensitive search | |
;;(setq-default case-replace 1) ; when replacing - beware of case | |
(defun set-default-colors () | |
"Defines default colour scheme" | |
(interactive) | |
(set-face-foreground 'bold-italic "blue") | |
(set-cursor-color "blue") | |
(set-background-color "black") | |
(set-foreground-color "green")) | |
(set-default-colors) | |
(defun set-glare-colors () | |
"Defines colours which can be used when there is a lot of glare" | |
(interactive) | |
(set-cursor-color "blue") | |
(set-background-color "white") | |
(set-foreground-color "black")) | |
; Highlight matching parentheis | |
;; (show-paren-mode t) | |
;; (setq show-paren-style "mixed") | |
;; (setq show-paren-delay 3) | |
; Stick to the end of line | |
(setq track-eol t) | |
; highlight regions | |
(if (boundp 'transient-mark-mode) | |
(setq transient-mark-mode t)) | |
(setq mark-even-if-inactive t) | |
(setq scroll-bar-mode 'right) | |
(toggle-scroll-bar 0) | |
(toggle-scroll-bar 1) | |
;(print "toggled the scroll bars") | |
; (setq-default highlight-paren-expression nil) | |
; (setq-default overwrite-mode nil) | |
; (setq-default teach-extended-commands-p nil) | |
; (setq-default complex-buffers-menu-p t) | |
; (setq-default buffers-menu-max-size 20) | |
; (setq-default case-fold-search t) | |
; (if (featurep 'blink-paren) (blink-paren 0)) | |
; (if (featurep 'pending-del) (pending-delete 0)) | |
; (set-face-font 'default "-*-Charter-Medium-R-*-*-*-100-*-*-*-*-*-*") | |
; (set-face-font 'modeline "-*-Charter-Medium-R-*-*-*-100-*-*-*-*-*-*") | |
; (remove-hook 'c-mode-hook 'turn-on-font-lock) | |
; (remove-hook 'c++-mode-hook 'turn-on-font-lock) | |
; (remove-hook 'lisp-mode-hook 'turn-on-font-lock) | |
; (remove-hook 'emacs-lisp-mode-hook 'turn-on-font-lock) | |
; )) | |
;(require 'html-font) | |
;(setq lpr-switches '("-Plp3")) | |
(setq lpr-command "lpr") | |
; (setq font-lock-verbose 1) | |
;; (eval-after-load "font-lock" | |
;; '(add-to-list 'c-font-lock-keywords-3 | |
;; '("\\<FILE\\>" . font-lock-type-face))) | |
;;; this has been replaced by the c-add-style call above | |
; (defun set-c-basic-offset (offset-value) | |
; "This should be called to set the offset for a particular buffer without | |
; influencing existing buffers. This particular useful when editing someones | |
; elses code with a different offset." | |
; (interactive "nOffset: ") | |
; (make-variable-buffer-local 'c-basic-offset) | |
; (setq c-basic-offset offset-value)) | |
;(require 'emacs-vers) | |
;(require 'font-lock) | |
;(require 'fast-lock) | |
;(when (emacs-version>= 19 29) | |
; (require 'filladapt) | |
; (require 'fa-extras)) | |
;(require 'hilit19) | |
;(setq hilit-background-mode 'light) | |
;(global-font-lock-mode) | |
;(font-lock-make-faces) | |
(put 'narrow-to-region 'disabled nil) | |
(put 'eval-expression 'disabled nil) | |
(line-number-mode t) | |
;(defun replace-char () | |
; (interactive) | |
; (delete-char) | |
;) | |
;(add-hook 'find-file-not-found-hooks 'load-java-template t) | |
(defun myset-fill-column () | |
"Start up auto-fill-mode with a fill length of 78 characters" | |
(interactive) | |
;(turn-on-fast-lock) | |
(auto-fill-mode) | |
;(set-fill-column 78) | |
(setq c-basic-offset 2) | |
) | |
(add-hook 'font-lock-mode-hook 'myset-fill-column) | |
(defun get-comment-start () | |
comment-start) | |
;(auto-fill-mode 1) | |
;(display-time) | |
;(set-default-font "-*-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-standard") | |
(set-default-font "-apple-american typewriter condensed-bold-r-normal--12-120-72-72-m-120-mac-roman") | |
;(set-frame-font "-*-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-standard") | |
;(set-frame-font "-*-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-standard") | |
;(set-frame-font "fixed") | |
(set-frame-font "-apple-american typewriter condensed-bold-r-normal--12-120-72-72-m-120-mac-roman") | |
(setq default-frame-alist (append '((width . 80) | |
(height . 45) | |
;(font . "fixed") | |
(font . "-apple-andale mono-medium-r-normal--0-0-0-0-m-0-iso10646-1") | |
;(font "-apple-american typewriter condensed-bold-r-normal--12-120-72-72-m-120-mac-roman") | |
; (height . 45) | |
; (font . "-*-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-standard") | |
(foreground-color . "green") | |
(background-color . "black") | |
(cursor-color . "blue") | |
(case-fold-search . nil) | |
(indent-tabs-mode . nil)) | |
default-frame-alist)) | |
; require html font locking only if we know that font lock is available | |
;; (cond ((or (and (= emacs-major-version 19) | |
;; (>= emacs-minor-version 31)) (>= emacs-major-version 20)) | |
;; (require 'html-font) | |
;; ;; this ensures that global-font-lock-mode is only started once | |
;; (global-font-lock-mode t) | |
; (cond (window-system | |
; (cond ((and (= emacs-major-version 19) (>= emacs-minor-version 31)) | |
; (font-lock-make-faces))) | |
; (set-my-default-colors) | |
; )) | |
;; )) | |
(add-hook 'ada-mode-hook 'turn-on-font-lock) | |
(add-hook 'awk-mode-hook 'restart-font-lock-mode) | |
(add-hook 'c++-mode-hook 'turn-on-font-lock) | |
(add-hook 'c-mode-hook 'turn-on-font-lock) | |
(add-hook 'dired-mode-hook 'turn-on-font-lock) | |
(add-hook 'emacs-lisp-mode-hook 'turn-on-font-lock) | |
(add-hook 'java-mode-hook 'restart-font-lock-mode) | |
(add-hook 'latex-mode-hook 'turn-on-font-lock) | |
(add-hook 'lisp-mode-hook 'turn-on-font-lock) | |
(add-hook 'perl-mode-hook 'turn-on-font-lock) | |
(add-hook 'php-mode-hook 'restart-font-lock-mode) | |
(add-hook 'postscript-mode-hook 'turn-on-font-lock) | |
(add-hook 'sh-mode-hook '(lambda () (auto-fill-mode 'nil))) | |
(add-hook 'tex-mode-hook 'turn-on-font-lock) | |
(add-hook 'texinfo-mode-hook 'turn-on-font-lock) | |
(add-hook 'text-mode-hook 'turn-on-auto-fill) | |
;; (add-hook 'php-mode-hook '(lambda () (visit-tags-table | |
;; "/www/development/BerliOS/sourceagency/tests" 't))) | |
; (add-hook 'find-file-not-found-hooks | |
; '(lambda () (if (= mode-name "Java") | |
; (tempo-template-java-header) nil)) | |
; t) | |
(defun my-new-java-class () | |
(tempo-template-java-header) | |
(newline 3) | |
(tempo-template-java-new-class)) | |
(defun my-new-java-test-class () | |
(tempo-template-java-header) | |
(tempo-template-java-new-test-class)) | |
(defun my-java-mode-hook () | |
(cond (window-system | |
;(require 'andersl-java-font-lock) | |
(turn-on-font-lock))) | |
(if (= buffer-saved-size 0) | |
(if (or (string-match "/Test[^/]+[.]java$" (buffer-file-name)) | |
(string-match "^Test[^/]+[.]java$" (buffer-file-name))) | |
(my-new-java-test-class) | |
(my-new-java-class)))) | |
(add-hook 'java-mode-hook '(lambda () (font-lock-mode 1))) | |
(add-hook 'java-mode-hook '(lambda () (abbrev-mode 1))) | |
(add-hook 'java-mode-hook 'my-java-mode-hook) | |
(defun my-mhtml-mode-hook () | |
(cond (window-system | |
(turn-on-font-lock)))) | |
(add-hook 'mhtml-mode-hook '(lambda () (font-lock-mode 1))) | |
(add-hook 'mhtml-mode-hook '(lambda () (abbrev-mode 1))) | |
(add-hook 'mhtml-mode-hook 'my-mhtml-mode-hook) | |
;; some modes have problems (or don't seem to) update font-lock-mode | |
;; so this function restarts font-lock for those modes. | |
(defun restart-font-lock-mode () | |
(cond (window-system | |
(font-lock-mode -1) | |
(font-lock-mode 1)))) | |
(defun my-awk-mode-hook () | |
(if (and (= buffer-saved-size 0) (= (buffer-size) 0)) | |
(tempo-template-awk-new-file))) | |
(add-hook 'awk-mode-hook 'my-awk-mode-hook) | |
(defun my-sh-mode-hook () | |
(if (and (= buffer-saved-size 0) (= (buffer-size) 0)) | |
(tempo-template-sh-new-file))) | |
(add-hook 'sh-mode-hook 'my-sh-mode-hook) | |
(defun my-php-mode-hook () | |
(c-set-style "php-pear") | |
(if (and (= buffer-saved-size 0) (= (buffer-size) 0)) | |
(if (or (string-match "/Test[^/]+[.]\\(php.?\\|inc\\)$" | |
(buffer-file-name)) | |
(string-match "^Test[^/]+[.]\\(php.?\\|inc\\)$" | |
(buffer-file-name))) | |
(tempo-template-php-unit-test-new-file) | |
(tempo-template-php-new-file)))) | |
(add-hook 'php-mode-hook 'my-php-mode-hook) | |
(defun my-python-mode-hook () | |
(if (and (= buffer-saved-size 0) (= (buffer-size) 0)) | |
(tempo-template-python-file))) | |
(add-hook 'python-mode-hook 'my-python-mode-hook) | |
(defun my-ruby-mode-hook () | |
(if (and (= buffer-saved-size 0) (= (buffer-size) 0) | |
(string-match "[.]rb$" (buffer-file-name))) | |
(tempo-template-ruby-file)) | |
(if (and (= buffer-saved-size 0) (= (buffer-size) 0) | |
(string-match "[.]rake$" (buffer-file-name))) | |
(tempo-template-rake-file))) | |
(add-hook 'ruby-mode-hook 'my-ruby-mode-hook) | |
;;(global-set-key "\C-h" 'backward-delete-char) | |
;;(global-set-key "\C-\?" 'help-for-help) | |
;(cond ((eq window-system 'x) | |
; (setq x-mode-pointer-shape "leftbutton") | |
; (if (featurep 'xpm) | |
; (let ((file (expand-file-name "recycle.xpm" data-directory))) | |
; (if (condition-case error | |
; (make-cursor file) ; returns a cursor if successful. | |
; (error nil)) ; returns nil if an error occurred. | |
; (setq x-gc-pointer-shape file)))))) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Customization of Specific Packages ;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; ******************** | |
;;; Load ange-ftp, which uses the FTP protocol as a pseudo-filesystem. | |
;;; When this is loaded, the pathname syntax /user@host:/remote/path | |
;;; refers to files accessible through ftp. | |
;;; | |
(require 'dired) | |
(require 'ange-ftp) | |
(setq ange-ftp-default-user "anonymous" ; id to use for /host:/remote/path | |
ange-ftp-generate-anonymous-password t ; use $USER@`hostname` | |
ange-ftp-binary-file-name-regexp "." ; always transfer in binary mode | |
) | |
;;; ******************** | |
;;; Load the auto-save.el package, which lets you put all of your autosave | |
;;; files in one place, instead of scattering them around the file system. | |
;;; | |
;(require 'auto-save "$HOME/lib-old/emacs/auto-save.el") | |
;(require 'auto-save) | |
;(setq auto-save-directory (expand-file-name "~/autosaves/") | |
; auto-save-directory-fallback auto-save-directory | |
; auto-save-hash-directory (expand-file-name "~/autosaves/") | |
; auto-save-hash-p t | |
; ange-ftp-auto-save t | |
; ange-ftp-auto-save-remotely nil | |
; ;; now that we have auto-save-timeout, let's crank this up | |
; ;; for better interactive response. | |
; auto-save-interval 500 | |
; ) | |
;(require 'auto-save) | |
;; This adds additional extensions which indicate files normally | |
;; handled by cc-mode. | |
;;; Property mode is used for Java .properties files. These have | |
;;; a similiar syntax to makefiles, however, no tabs please. | |
(defun property-mode () | |
(makefile-mode) | |
(setq indent-tabs-mode nil)) | |
(setq auto-mode-alist | |
(append '(("\\.C$" . c++-mode) | |
("\\.cc$" . c++-mode) | |
("\\.hh$" . c++-mode) | |
("\\.th$" . c++-mode) | |
("\\.cpp$" . c++-mode) | |
("\\.h$" . c++-mode) | |
("\\.html?$" . html-mode) | |
("\\.c$" . c-mode) | |
("\\.j$" . objj-mode) | |
("\\.java$" . java-mode) | |
("\\.js$" . js2-mode) | |
("\\.json$" . js2-mode) | |
("\\.jsp$" . html-mode) | |
("\\.jad$" . java-mode) ;; .jad --> Java Decompiler | |
("\\.gemspec$" . ruby-mode) | |
("\\.g?awk$" . awk-mode) | |
("\\.inc$" . php-mode) ;; .inc --> include files in PHP | |
("\\.mhtml$" . mhtml-mode) | |
("\\.md$" . markdown-mode) | |
("\\.php3?$" . php-mode) | |
("\\.pkg$" . sql-mode) | |
("\\.pkb$" . sql-mode) | |
("\\.pp$" . puppet-mode) | |
("\\.properties$" . property-mode) | |
("\\.pic$" . picture-mode) | |
("\\.py$" . python-mode) | |
("\\.rdfs?$" . nxml-mode) | |
("\\.xml$" . nxml-mode) | |
("\\.ya?ml$" . yaml-mode) | |
("Jakefile" . js2-mode) | |
("\\.hulk$" . mustache-mode) | |
("\\.mustache$" . mustache-mode) | |
) | |
auto-mode-alist)) | |
(setq auto-mode-alist | |
(cons | |
(cons (concat "^" wiki-directory "/") 'wiki-mode) | |
auto-mode-alist)) | |
(defun my-current-year () | |
(format-time-string "%C%y")) | |
;;; Define a Java Template | |
(if (condition-case nil | |
(progn (require 'tempo) nil) | |
(error t)) | |
() ;; Nope, no tempo. | |
;; Run interactively | |
(setq tempo-interactive t) | |
;; In XEmacs `user-mail-address' returns "[email protected] (Foo Bar)" ARGH! | |
(defvar my-java-tempo-mail-address | |
(symbol-value 'user-mail-address) | |
; (concat (user-login-name) "@" | |
; (or (and (boundp 'mail-host-address) | |
; (symbol-value 'mail-host-address)) | |
; (system-name))) | |
"Mail address of the user.") | |
(defun my-java-tempo-dd-mmm-yyyy () | |
"Return the current date as a string in \"DD Mon YYYY\" form. | |
The first character of DD is space if the value is less than 10." | |
(let ((date (current-time-string))) | |
(format "%2d %s %s" | |
(string-to-int (substring date 8 10)) | |
(substring date 4 7) | |
(substring date -4)))) | |
(defun my-java-tempo-dd-mm-yyyy () | |
"Return the current date as a string in \"DD Mon YYYY\" form. | |
The first character of DD is space if the value is less than 10." | |
(format-time-string "%d.%m.%C%y")) | |
(defun my-java-tempo-right-header-column () | |
(indent-to-column 77) | |
nil) | |
(defvar my-java-tempo-header | |
'((beginning-of-buffer) | |
"/* -*- java -*-" n | |
" *" n | |
" * $" "Id$" n | |
" *" n | |
" * $" "Source" "$" n | |
" *" n | |
" * $Revision" "$" n | |
" * $Author" "$" n | |
" * $Date" "$" n | |
" *" n | |
" * $" "Log" "$" n | |
" *" n | |
" *" n | |
" */" n | |
)) | |
; (defvar my-java-tempo-header | |
; '((beginning-of-buffer) | |
; "/*" n | |
; " " (file-name-nondirectory (buffer-file-name)) n | |
; " " n | |
; " $" "Id" "$ " n | |
; " vom " (my-java-tempo-dd-mm-yyyy) " " n n | |
; " Copyright (C) " (my-current-year) " " my-company-name n n | |
; " All Rights Reserved." n n | |
; " Autor: " (user-full-name) ", " my-java-tempo-mail-address " " n | |
; "*/" n n | |
; )) | |
(tempo-define-template "java-header" my-java-tempo-header) | |
(defvar my-java-tempo-method-comment | |
'("/**"> n | |
"<b>Description Missing</b>"> n | |
"@param "> n | |
"@param "> n | |
"@return "> n | |
"@exception "> n | |
"?deprecated "> n | |
"?since "> n | |
"@see "> n | |
"*/"> n | |
) | |
) | |
(tempo-define-template "java-method-comment" my-java-tempo-method-comment) | |
(defvar my-java-tempo-new-method | |
'((p "Method Name: " method-name 'noinsert) | |
"public/private/protected void " (s method-name) "() {"> n | |
"// {{{ Method Declaration" > n | |
"// }}}" > n | |
"}"> n | |
) | |
) | |
(tempo-define-template "java-new-method" my-java-tempo-new-method) | |
(defvar my-java-tempo-class | |
'((p "Version: " version 'noinsert) | |
"/**"> n | |
"<b>Description Missing</b>"> n n | |
"@see "> n | |
"@see "> n | |
"?deprecated "> n | |
"?since "> n | |
"@version " (s version) ", " (my-java-tempo-dd-mm-yyyy) > n | |
"@author <a href=\"mailto:" my-java-tempo-mail-address "\">" | |
(user-full-name) "</a>, " my-company-name > n | |
>"*/" > n)) | |
(tempo-define-template "java-class" my-java-tempo-class) | |
(defvar my-java-javadoc-comment | |
'(>"/**"> n | |
"*" (push-mark) > n | |
"*/"> n | |
(set-mark (pop-mark)))) | |
(tempo-define-template "java-javadoc-comment" my-java-javadoc-comment) | |
(defvar my-java-tempo-new-class | |
'((p "Class Version: " version 'noinsert "0.1") | |
(p "Package: " package 'noinsert | |
(subst-char-in-string ?/ ?. (file-name-directory (buffer-file-name)))) | |
"package " (s package) ";" > n n | |
"import java.lang.*;" > n | |
"import java.io.*;" > n | |
"import java.util.*;" > n n | |
"/**" > n | |
" <b>Description Missing</b> " > n n | |
"@see " > n | |
"@see " > n | |
"?deprecated " > n | |
"?since " > n | |
"@version " (s version) ", " (my-java-tempo-dd-mm-yyyy) > n | |
"@author <a href=\"mailto:" my-java-tempo-mail-address "\">" | |
(user-full-name) "</a>, " my-company-name > n | |
"*/"> n | |
"public class " (substring (file-name-nondirectory (buffer-file-name)) 0 | |
(string-match "[.]" (file-name-nondirectory | |
(buffer-file-name)))) | |
" extends Object " > n | |
"{" > n | |
"// {{{ Class Declaration " > n n | |
"// **** public/private Constants/Class Variables " > n n | |
"// **** public Constructors " > n n | |
"/**"> n | |
"<b>Default Constructor</b>"> n n | |
"@param "> n | |
"@param "> n | |
"@return "> n | |
"@exception "> n | |
"?deprecated "> n | |
"@since " (s version) > n | |
"@see "> n | |
"*/"> n | |
"public " (substring (file-name-nondirectory (buffer-file-name)) 0 | |
(string-match "[.]" (file-name-nondirectory | |
(buffer-file-name)))) | |
"()"> n | |
"{" > n | |
"}" > n n | |
"// **** public Methods " > n n | |
"/**" > n | |
"Method called when this class is started with <tt>java</tt>." > n n | |
"@param args Arguments passed to the on the command line." > n | |
"@exception " > n | |
"?deprecated " > n | |
"@since " (s version) > n | |
"@see " > n | |
"*/" > n | |
"public static void main( String args[] )" > n | |
"{" > n | |
"}" > n n | |
"// **** protected Construtors " > n n | |
"// **** protected Methods " > n n | |
"/**" > n | |
" * Method called before a object is garbage collected." > n | |
"*/" > n | |
"protected void finalize()" > n | |
"throws Throwable" > n | |
"{" > n | |
"}" > n n | |
"// **** package Methods " > n n | |
"// **** private Constructors " > n n | |
"// **** private Methods " > n n | |
"// **** public Instance Variables " > n n | |
"// **** protected Instance Variables " > n n | |
"// **** private Instance Variables " > n n | |
"// }}} " > n | |
"}"> n | |
) | |
) | |
(tempo-define-template "java-new-class" my-java-tempo-new-class) | |
(defvar my-java-tempo-new-test-class | |
'((p "Test Class Version: " version 'noinsert "0.1") | |
(p "Package Name: " package 'noinsert | |
(subst-char-in-string ?/ ?. (file-name-directory (buffer-file-name)))) | |
"package " (s package) ";" > n n | |
"import java.lang.*;" > n | |
"import java.io.*;" > n | |
"import java.util.*;" > n | |
"import junit.framework.*;" > n n | |
"/**" > n | |
" * JUnit Test class for " (s package) "." | |
(substring (file-name-nondirectory (buffer-file-name)) 4 | |
(string-match "[.]" (file-name-nondirectory | |
(buffer-file-name)))) > n n | |
"@see " > n | |
"@see " > n | |
"?deprecated " > n | |
"?since " > n | |
"@version " (s version) ", " (my-java-tempo-dd-mm-yyyy) > n | |
"@author <a href=\"mailto:" my-java-tempo-mail-address "\">" | |
(user-full-name) "</a>, " my-company-name > n | |
"*/"> n | |
"public class " (substring (file-name-nondirectory (buffer-file-name)) 0 | |
(string-match "[.]" (file-name-nondirectory | |
(buffer-file-name)))) | |
" extends TestCase {" > n | |
"// {{{ Class Declaration " > n n | |
"// **** public Constants/Class Variables " > n n | |
"// **** public Methods " > n n | |
"/**"> n | |
"Method called when this class is started with <tt>java</tt>."> n n | |
"@param args Arguments passed to the on the command line."> n | |
"@exception "> n | |
"?deprecated "> n | |
"@since " (s version) > n | |
"@see "> n | |
"*/"> n | |
"public static void main( String args[] )"> n | |
"{"> n | |
"junit.textui.TestRunner.run( suite() );" > n | |
"}"> n n | |
"/**"> n | |
"* collect all the tests together" > n | |
"*/" > n | |
"public static junit.framework.Test suite()" > n | |
"{" > n | |
"return new TestSuite( " (s package) "." | |
(substring (file-name-nondirectory (buffer-file-name)) 0 | |
(string-match "[.]" (file-name-nondirectory | |
(buffer-file-name)))) | |
".class );" > n "}" > n n | |
"// **** public Constructors " > n n | |
"/**"> n | |
"<b>Default Constructor</b>"> n n | |
"@param "> n | |
"@param "> n | |
"@return "> n | |
"@exception "> n | |
"?deprecated "> n | |
"@since " (s version) > n | |
"@see "> n | |
"*/"> n | |
"public " (substring (file-name-nondirectory (buffer-file-name)) 0 | |
(string-match "[.]" (file-name-nondirectory | |
(buffer-file-name)))) | |
"()"> n | |
"{" > n | |
"super( \"" (s package) "." | |
(substring (file-name-nondirectory (buffer-file-name)) 0 | |
(string-match "[.]" (file-name-nondirectory | |
(buffer-file-name)))) | |
"\");" > n | |
"}" > n n | |
"/**"> n | |
"<b>Single Argument Constructor</b>"> n n | |
"@param "> n | |
"@param "> n | |
"@return "> n | |
"@exception "> n | |
"?deprecated "> n | |
"@since " (s version) > n | |
"@see "> n | |
"*/"> n | |
"public " (substring (file-name-nondirectory (buffer-file-name)) 0 | |
(string-match "[.]" (file-name-nondirectory | |
(buffer-file-name)))) | |
"( String name )"> n | |
"{" > n | |
"super( name );" > n | |
"}" > n n | |
"// **** public Methods " > n n | |
"/**" > n | |
"* Called before each test method." > n | |
"*/" > n | |
"public void setUp()" > n | |
"{" > n | |
"}" > n n | |
"/**" > n | |
"* Called after each test method." > n | |
"*/" > n | |
"public void tearDown()" > n | |
"{" > n | |
"}" > n n | |
"/**" > n | |
"* Define the First Test here. <<Short Description>>" > n | |
"*/" > n | |
"public void test01()" > n | |
"{" > n | |
"assertTrue( true );" > n | |
"}" > n n | |
"/**" > n | |
"* Define the Second Test here. <<Short Description>>" > n | |
"*/" > n | |
"public void test02()" > n | |
"{" > n | |
"assertTrue( true );" > n | |
"}" > n n | |
"// **** protected Construtors " > n n | |
"// **** protected Methods " > n n | |
"/**" > n | |
" * Method called before a object is garbage collected." > n | |
"*/" > n | |
"protected void finalize()" > n | |
"throws Throwable" > n | |
"{" > n | |
"}" > n n | |
"// **** package Methods " > n n | |
"// **** private Constructors " > n n | |
"// **** private Methods " > n n | |
"// **** public Instance Variables " > n n | |
"// **** protected Instance Variables " > n n | |
"// **** private Instance Variables " > n n | |
"// }}} " > n | |
"}"> n | |
) | |
) | |
(tempo-define-template "java-new-test-class" my-java-tempo-new-test-class) | |
(defvar my-java-fold-region-tempo | |
'((p "Region Name: " region-name 'noinsert) | |
"// {{{ " (s region-name) > n | |
r | |
"// }}}" > n | |
) | |
) | |
(tempo-define-template "java-fold-region" my-java-fold-region-tempo) | |
;; because the comment characters as the same in c++ and java, this is safe. | |
(tempo-define-template "c++-fold-region" my-java-fold-region-tempo) | |
(defvar my-c-fold-region-tempo | |
'((p "Region Name: " region-name 'noinsert) | |
"/* {{{ " (s region-name) " */" > n | |
r | |
"/* }}} */"> n | |
) | |
) | |
(tempo-define-template "c-fold-region" my-c-fold-region-tempo) | |
(defvar gnu-pl | |
'((p "Description: " desc 'noinsert "<NO DESCRIPTION>") | |
(p "Comment start: " comment 'noinsert (get-comment-start)) | |
(s comment)" " > n | |
(s comment)" "(s desc) > n | |
(s comment)" Copyright (C) " (my-current-year) " " (user-full-name) > n | |
(s comment)" " > n | |
(s comment)" This program is free software; you can redistribute it " | |
"and/or modify" > n | |
(s comment)" it under the terms of the GNU General Public License as " | |
"published by" > n | |
(s comment)" the Free Software Foundation; either version 2 of the " | |
"License, or" > n | |
(s comment)" (at your option) any later version." > n | |
(s comment)" " > n | |
(s comment)" This program is distributed in the hope that it will be " | |
"useful," > n | |
(s comment)" but WITHOUT ANY WARRANTY; without even the implied " | |
"warranty of" > n | |
(s comment)" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. " | |
"See the" > n | |
(s comment)" GNU General Public License for more details." > n | |
(s comment)" " > n | |
(s comment)" You should have received a copy of the GNU General " | |
"Public License" > n | |
(s comment)" along with this program; if not, write to the Free " | |
"Software" > n | |
(s comment)" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA" | |
" 02111-1307 USA" > n | |
(s comment)" " > n)) | |
(tempo-define-template "gnu-public-license" gnu-pl) | |
(defvar my-html-tt | |
'("<tt>" r "</tt>")) | |
(tempo-define-template "html-tt" my-html-tt) | |
(defvar my-html-font-red | |
'("<font color=\"red\">" r "</font>")) | |
(tempo-define-template "html-font-red" my-html-font-red) | |
(defvar my-html-bold | |
'("<b>" r "</b>")) | |
(tempo-define-template "html-bold" my-html-bold) | |
(defvar my-html-code | |
'("<code>" r "</code>")) | |
(tempo-define-template "html-code" my-html-code) | |
(defvar my-html-comment | |
'("<!--" > n | |
r > "-->" > n)) | |
(tempo-define-template "html-comment" my-html-comment) | |
(defvar my-html-umlaut | |
'("&" r "uml;")) | |
(tempo-define-template "html-umlaut" my-html-umlaut) | |
(defvar my-curly-bracket-region | |
'("\n{\n" r "\n}\n")) | |
(tempo-define-template "curly-bracket-region" my-curly-bracket-region) | |
(defvar my-php-unit-test-new-file | |
'("<?php" > n | |
"// -*- php -*-" > n | |
"// " (file-name-nondirectory (buffer-file-name)) > n | |
"// " > n | |
"// Author: " (user-full-name) ", " my-java-tempo-mail-address > n | |
"// Copyright (C) " (my-current-year) " " (user-full-name) > n | |
"// This code is licensed under the GNU Public License." > n | |
"// " > n | |
"// $" "Id" "$" > n > n | |
"include_once( '../constants.php' );" > n > n | |
"if ( !defined(\"BEING_INCLUDED\" ) ) {" > n | |
"}" > n > n | |
"include_once( '" | |
(downcase (substring (file-name-nondirectory (buffer-file-name)) 4 | |
(string-match "[.]" (file-name-nondirectory | |
(buffer-file-name))))) | |
".inc' );" > n > n | |
"class UnitTest" | |
(substring (file-name-nondirectory (buffer-file-name)) 4 | |
(string-match "[.]" (file-name-nondirectory | |
(buffer-file-name)))) > n | |
"extends UnitTest" > n | |
"{" > n | |
"function UnitTest" | |
(substring (file-name-nondirectory (buffer-file-name)) 4 | |
(string-match "[.]" (file-name-nondirectory | |
(buffer-file-name)))) | |
"( $name ) {" > n | |
"$this->UnitTest( $name );" > n | |
"}" > n > n | |
"function setup() {" > n "}" > n | |
"function tearDown() {" > n "}" > n | |
"}" > n > n | |
"define_test_suite( __FILE__ );" > n | |
"?>" > n | |
)) | |
(tempo-define-template "php-unit-test-new-file" my-php-unit-test-new-file) | |
(defvar my-php-new-file | |
'("<?php" > n | |
"// -*- php -*-" > n | |
"// " (file-name-nondirectory (buffer-file-name)) > n | |
"// " > n | |
"// Author: " (user-full-name) ", " my-java-tempo-mail-address > n | |
"// Copyright (C) " (my-current-year) " " (user-full-name) > n | |
"// This code is licensed under the GNU Public License." > n | |
"// " > n | |
"// $" "Id" "$" > n | |
> n | |
> n | |
"?>" > n | |
)) | |
(tempo-define-template "php-new-file" my-php-new-file) | |
(defvar my-awk-new-file | |
'("# -*- awk -*-\n# " (file-name-nondirectory (buffer-file-name)) n | |
"#\n# Author: " (user-full-name) ", " my-java-tempo-mail-address " " n | |
"# Copyright (C) " (my-current-year) " " (user-full-name) n | |
"# This code is licensed under the GNU Public License." n | |
"# $" "Id" "$ " n | |
"#\nBEGIN {\n}\n\n// {\n}\n\nEND {\n}\n" n | |
)) | |
(tempo-define-template "awk-new-file" my-awk-new-file) | |
(defvar my-sh-new-file | |
'("#!/bin/bash\n#\n# " (file-name-nondirectory (buffer-file-name)) n | |
"#\n# Author: " (user-full-name) ", " my-java-tempo-mail-address n | |
"# Copyright (C) " (my-current-year) " " (user-full-name) n | |
"# This code is licensed under the GNU Public License." n | |
"#\n# $" "Id" "$\n#\n" n | |
)) | |
(tempo-define-template "sh-new-file" my-sh-new-file) | |
(defvar my-author-line | |
'("Author: " (user-full-name) ", " my-java-tempo-mail-address)) | |
(tempo-define-template "author-line" my-author-line) | |
(defvar my-python-file | |
'("# -*- mode: python -*-" n> | |
"#\n# Author: " (user-full-name) ", " my-java-tempo-mail-address n> | |
"# Copyright (C) " (my-current-year) " " (user-full-name) n> | |
"# This code is licensed under the GNU Public License." n> | |
"#\n# $" "Id" "$\n#\n" n> | |
"\"\"\"" n> | |
"Documentation" n> | |
"\"\"\"" n> | |
"" n> | |
"import types, math, sys, re" n> n> | |
"# __all__ defines what should be accessible outside of this file" n> | |
"__all__ = []" n> n> | |
"class " | |
(substring (file-name-nondirectory (buffer-file-name)) 0 | |
(string-match "[.]" (file-name-nondirectory | |
(buffer-file-name)))) | |
":" n> n> | |
"# insert any class variables here" n> n> | |
"# constructor method" n> | |
"def __init__(self):" n> | |
"# define instance variables here" n> | |
"pass" n> n> | |
"# destructor method" n> | |
"def __del__(self):" n> | |
"pass" n> n> | |
"# representation method for debugging, return string" n> | |
"def __repr__(self):" n> | |
"raise NotImplementedError" n> n> | |
"# string method returns an informal representation of the object" n> | |
"def __str__(self):" n> | |
"raise NotImplementedError" n> n> | |
"# this the method used for handle class[key] calls" n> | |
"def __getitem__( self, key ):" n> | |
"raise NotImplementedError" n> n> | |
"# this the method used for handle class[key] = value calls" n> | |
"def __setitem__( self, key, value ):" n> | |
"raise NotImplementedError" n> n> | |
"# truth checker: called when object is used in an if,while,... stmt" n> | |
"def __nonzero__(self):" n> | |
"raise NotImplementedError" n> n> | |
"# method called when comparing with ==" n> | |
"def __eq__(self, other):" n> | |
"raise NotImplementedError" n> n> | |
"# method used to comparsion if __eq__ is not defined" n> | |
"def __cmp__(self, other):" n> | |
"raise NotImplementedError" n> n> | |
n> n | |
"# define a main function" n | |
"def main():" n> | |
"# create an instance of the class" n> | |
"t = " | |
(substring (file-name-nondirectory (buffer-file-name)) 0 | |
(string-match "[.]" (file-name-nondirectory | |
(buffer-file-name)))) | |
"()" n> | |
"print \"argc: \" + str( len( sys.argv ) )" n> | |
"print sys.argv" n> n | |
"if __name__ == '__main__':" n> | |
"main()" n> | |
)) | |
(tempo-define-template "python-file" my-python-file) | |
(defvar my-rake-file | |
'("#" > n | |
"# Author: " (user-full-name) ", " my-java-tempo-mail-address > n | |
"# Copyright (C) " (my-current-year) " " (user-full-name) > n | |
"# This code is licensed under the GNU Public License." > n | |
"# " > n | |
"" > n | |
"directory \"tmp\"" > n | |
"" > n | |
"file \"tmp/hello.tmp\" => \"tmp\" do" > n | |
" sh \"echo 'Hello' > 'tmp/hello.tmp'\"" > n | |
"end" > n | |
"" > n | |
"task :default => 'morning:turn_off_alarm'" > n | |
"" > n | |
"namespace :fubar do" > n | |
" namespace :snafu do" > n | |
" task :common => :environment do" > n | |
" end" > n | |
"" > n | |
" desc <<-EOF" > n | |
" Defines the task fubar:snafu:doit" > n | |
" EOF" > n | |
" task :doit => :common do" > n | |
" end" > n | |
"" > n | |
" desc <<-EOF" > n | |
" Two arguments and depbut be careful: " > n | |
" rake ..test[ClassName,FieldOne,FieldTwo]" > n | |
" will be come args[:class_name] == ClassName" > n | |
" and args[:field_names] == FieldOne (FieldTwo will be ignored)" > n | |
" and using quotes does not improve the situation. ==> ENV['field_names'] will" > n | |
" EOF" > n | |
" task :test, :class_name, :field_names, :needs => [:environment] do |t, args|" > n | |
" end" > n | |
" end" > n | |
"end" > n | |
)) | |
(tempo-define-template "rake-file" my-rake-file) | |
(defvar my-ruby-file-preamble | |
'("#!/usr/bin/ruby" > n | |
"#" > n | |
"# Author: " (user-full-name) ", " my-java-tempo-mail-address > n | |
"# Copyright (C) " (my-current-year) " " (user-full-name) > n | |
"# This code is licensed under the GNU Public License." > n | |
"# " > n | |
"use 'M-x tempo-template-ruby-file-content' to insert ruby template" > n | |
)) | |
(tempo-define-template "ruby-file" my-ruby-file-preamble) | |
(defvar my-ruby-file | |
'("#!/usr/bin/ruby" > n | |
"#" > n | |
"# Author: " (user-full-name) ", " my-java-tempo-mail-address > n | |
"# Copyright (C) " (my-current-year) " " (user-full-name) > n | |
"# This code is licensed under the GNU Public License." > n | |
"# " > n | |
"# $" "Id" "$" > n > n | |
"require 'rubygems'" > n | |
"require 'fileutils'" > n | |
"require 'active_record'" > n | |
"require 'sqlite3'" > n | |
"require 'readline'" > n | |
"require 'ostruct'" > n | |
"require 'ruby-prof'" > n | |
"require 'optparse'" > n > n | |
"# getopt like behaviour" > n | |
"@filename = 'unknown'" > n | |
"opts = OptionParser.new do |o|" > n | |
" o.program_name = 'ruby " (file-name-nondirectory (buffer-file-name)) "'" > n | |
" o.separator 'Options:'" > n | |
" o.on('--src-file FILENAME', '-s', 'Source file name') { |@filename| }" > n | |
" o.on('--sleep FILENAME', '-s', 'Source file name') { |@sleep| }" > n | |
" o.on('--count FILENAME', '-c', 'Source file name') { |@count| }" > n | |
" o.on_tail('--help', '-h', 'Show this message') do" > n | |
" puts opts" > n | |
" exit" > n | |
" end" > n | |
"end" > n | |
"opts.parse!(ARGV)" > n | |
"" > n | |
"# awk-like behaviour" > n | |
"STDIN.read.each do |line|" > n | |
" next if line.match(/^Thread/) or line.match(/^Total Time/)" > n | |
" line = line.split(/\s+/)" > n | |
" next if line[1].nil? or line[1] == '%total'" > n | |
"" > n | |
" selfval, waitval, callval = if line[1].match(/[%]/)" > n | |
" [ line[4], line[5], line[7] ]" > n | |
" else" > n | |
" [nil,nil,nil]" > n | |
" end" > n | |
"end" > n | |
"" > n | |
"# swapping two values" > n | |
"x,y = [4,5]" > n | |
"x,y = y,x # done!" > n | |
"" > n | |
"# different range operators" > n | |
"0..10.to_a # -> 0,1,2,...10" > n | |
"0...10.to_a # -> 0,1,2,...9 --> good (fucker to debug!) for 0...ary.length { |val| .... }" > n | |
"('ant'..'bad').to_a # (.size=>323) this can also be incredibly useful" > n | |
"" > n | |
"# for matching lines between to markers, use the following:" > n | |
"while line = gets" > n | |
" puts 'Match: ' + line if line =~ /start/ .. line =~ /end/" > n | |
"end" > n | |
"# => one\\ntwo\\nstart\\nthree\\nfour\\nend\\nfive would match start,three,four,end" > n | |
"" > n | |
"# use inject to sum, mul, ... over an array and get a single result" > n | |
"[1,2,3,4].inject { |sum,val| sum += val } # => 10, here array.first is the start value" > n | |
"[1,2,3,4].inject(-10) { |sum,val| sum += val } # => 0 , -10 is the start value" > n | |
"" > n | |
"# overriding elements in an array with a new array" > n | |
"a = [1,2,3,4] # equivalent: a = (1..4).to_a or a = (1...5).to_a" > n | |
"a[1,2] = ('a'..'d').to_a # replace the two elments from index 1 with array values" > n | |
"# ==> [1,'a','b','c','d',4]" > n | |
"" > n | |
"# close all io objects" > n | |
" def close_io_handles" > n | |
" ObjectSpace.each_object(IO) do |io|" > n | |
" unless [STDIN, STDOUT, STDERR].include?(io)" > n | |
" begin" > n | |
" io.close unless io.closed?" > n | |
" rescue Exception" > n | |
" end" > n | |
" end" > n | |
" end" > n | |
" end" > n | |
"" > n | |
"# threads and forking in ruby" > n | |
"Timeout.timeout(@count.to_i) do" > n | |
" Thread.new do" > n | |
" sleep @sleep.to_i" > n | |
" end" > n | |
"end" > n | |
"" > n | |
"# fork creates separate ruby processes, while" > n | |
"# threads are 'green', i.e. managed by the ruby VM" > n | |
"puts @count" > n | |
"@count.to_i.times do" > n | |
" if fork" > n | |
" puts 'sleep for ten seconds'" > n | |
" sleep @sleep.to_i" > n | |
" exit" > n | |
" else" > n | |
" puts 'continuing'" > n | |
" end" > n | |
"end" > n | |
"sleep @sleep.to_i" > n | |
"exit" > n | |
"" > n | |
"# ruby performance measurements" > n | |
"def make_hash(szi)" > n | |
" hsh = { }" > n | |
" (1..szi).each do |idx|" > n | |
" hsh[rand(idx).to_s] = 'asdasdasdasdasdasdkjnlnmlkwqlknklasdlkamdklamdklmaslkdma'" > n | |
" end" > n | |
" hsh" > n | |
"end" > n | |
"" > n | |
"def uuid1(hsh )" > n | |
" newhsh = hsh.clone" > n | |
"end" > n | |
"" > n | |
"def uuid2(hsh )" > n | |
" #newhsh = {}.merge(hsh)" > n | |
" newhsh = { }" > n | |
" hsh.each { |k,v| newhsh[k] = v }" > n | |
"end" > n | |
"" > n | |
"(1..10).each do |idx2|" > n | |
" r1 = RubyProf.profile do" > n | |
" (1..100000).each do |idx|" > n | |
" uuid1(make_hash((idx % 10)+1))" > n | |
" end" > n | |
" end" > n | |
"" > n | |
" r2 = RubyProf.profile do" > n | |
" (1..100000).each do |idx|" > n | |
" uuid2(make_hash((idx % 10)+1))" > n | |
" end" > n | |
" end" > n | |
"" > n | |
" RubyProf::FlatPrinter.new(r1).print(f=File.open(%Q(tmp1-#{idx2}.prof), 'wb'))" > n | |
" RubyProf::FlatPrinter.new(r2).print(f=File.open(%Q(tmp2-#{idx2}.prof), 'wb'))" > n | |
" puts idx2" > n | |
"end" > n | |
"" > n | |
"# difference between proc and lambda" > n | |
"def foo" > n | |
" f = Proc.new { return 'return from foo from inside proc' }" > n | |
" f.call # control leaves foo here" > n | |
" return 'return from foo' " > n | |
"end" > n | |
"" > n | |
"def bar" > n | |
" f = lambda { return 'return from lambda' }" > n | |
" f.call # control does not leave bar here" > n | |
" return 'return from bar' " > n | |
"end" > n | |
"" > n | |
"# also remember that scope of variables inside a proc: they can override local variables" > n | |
"# outside of the proc. although this problem has been addressed in 1.9 by making all" > n | |
"# parameters to a proc local to the proc and allowing explicit definition of local variables." > n | |
"" > n | |
"puts foo # prints 'return from foo from inside proc' " > n | |
"puts bar # prints 'return from bar' " > n | |
"" > n | |
"# Class for defining a range. need to defined succ and <=>" > n | |
"class PowerOfTwo " > n | |
" attr_reader :value # defines the method value but not the instance variable" > n | |
" def initialize(value) " > n | |
" @value = value " > n | |
" end " > n | |
" def <=>(other) " > n | |
" @value <=> other.value " > n | |
" end " > n | |
" def succ " > n | |
" PowerOfTwo.new(@value + @value) " > n | |
" end " > n | |
" def to_s " > n | |
" @value.to_s " > n | |
" end " > n | |
"end " > n | |
"" > n | |
"(PowerOfTwo.new(2)..PowerOfTwo.new(32)).to_a" > n | |
"" > n | |
"# Struct and OpenStruct are very useful for create classes on the fly" > n | |
"Song = Struct.new(:artist, :title)" > n | |
"s = Song.new('fubar', 'happiness is where the home is')" > n | |
"s2 = Song.new('snafu', 'roses are red')" > n | |
"" > n | |
"something = OpenStruct.new( { :name => 'fubar', :street => 'main 1'})" > n | |
"something.name" > n | |
"something.name = 'snafu'" > n | |
"something.steet" > n | |
"" > n | |
"# after that it's possible to include modules into the struct" > n | |
"module Snafu" > n | |
" def get_artist_and_title" > n | |
" [self.artist, self.title].join(' - ')" > n | |
" end" > n | |
"end" > n | |
"" > n | |
"Song.class_eval do" > n | |
" include Snafu" > n | |
"end" > n | |
"" > n | |
"s.get_artist_and_title" > n | |
"" > n | |
"class PowerOfTwo " > n | |
" # all attr_XXX methods only define the methosd not the instance variables!!!" > n | |
" attr_writer :write_only" > n | |
" attr_reader :read_only" > n | |
" attr_accessor :read_write" > n | |
"" > n | |
" def initialize " > n | |
" @write_only = :one " > n | |
" @read_write = :two " > n | |
" @read_only = :three " > n | |
" end " > n | |
"end " > n | |
"" > n | |
"class BasicObject #:nodoc:" > n | |
" instance_methods.each { |m| undef_method m unless m =~ /^__|instance_eval/ }" > n | |
"end unless defined?(BasicObject)" > n | |
"class Proxy < BlankSlate" > n | |
" def initialize(subject)" > n | |
" @subject = subject" > n | |
" end" > n | |
"" > n | |
" private" > n | |
" def method_missing(method, *args, &block)" > n | |
" @subject.send(method, *args, &block)" > n | |
" end" > n | |
"end" > n | |
"" > n | |
"def method_missing(name, *args, &block)" > n | |
" raise NameError.new(\"Unknown Method: #{name}\")" > n | |
"end" > n | |
"" > n | |
"def gsub_file(path, regexp, *args, &block)" > n | |
" content = File.read(path).gsub(regexp, *args, &block)" > n | |
" File.open(path, 'wb') { |file| file.write(content) }" > n | |
"end" > n | |
"" > n | |
"Dir.glob('*.rb').each do |f|" > n | |
" gsub_file(f, /[<] AbstractGrabber/) do" > n | |
" '< AffiliateNetworkGrabber::Base'" > n | |
" end" > n | |
"end" > n | |
"" > n | |
"# provide a module with it's own instance methods" > n | |
"module Fubar" > n | |
" extend self" > n | |
" def hello" > n | |
" 'dasdad'" > n | |
" end" > n | |
"end" > n | |
"Fubar.hello" > n | |
"# retruns 'dasdad'" > n | |
"" > n | |
"# instance_eval do this:" > n | |
"Server.run do " > n | |
" handle(/hello/i) { \"Hello from server at #{Time.now}\" } " > n | |
" handle(/goodbye/i) { \"Goodbye from server at #{Time.now}\" } " > n | |
" handle(/name is (\w+)/) { |m| \"Nice to meet you #{m[1]}!\" } " > n | |
"end " > n | |
"" > n | |
"class Server " > n | |
" # other methods same as before " > n | |
" def self.run(port=3333,&block) " > n | |
" server = Server.new(port) " > n | |
" server.instance_eval(&block) " > n | |
" server.run " > n | |
" end " > n | |
"end " > n | |
"" > n | |
"# remember:" > n | |
"def fubar(opts)" > n | |
" # define default values" > n | |
" opts = {:fubar => :snafu}.merge(opts)" > n | |
"end" > n | |
"# can be called" > n | |
"fubar({:fubar => :a, :s => :b})" > n | |
"fubar(fubar: \"a\", s: \"b\") # didn't work for me --> 1.9 ?" > n | |
"fubar(:fubar => :a, :s => :b)" > n | |
"" > n | |
"" > n | |
"# Anonymous Class:" > n | |
"def format(name, options={}, &block) " > n | |
" formats[name] = Class.new(options[:base] || Fatty::Format, &block) " > n | |
"end " > n | |
"def helpers(helper_module=nil, &block) " > n | |
" @helpers = helper_module || Module.new(&block) " > n | |
"end " > n | |
"# helpers can also be used like this:" > n | |
"#class MyReport < Fatty::Formatter " > n | |
"# helpers MyHelperModule " > n | |
"# #... " > n | |
"#end " > n | |
"" > n | |
"class MyReport < Fatty::Formatter " > n | |
" required_params :first_name, :last_name " > n | |
"" > n | |
" helpers do " > n | |
" def full_name " > n | |
" \"#{params[:first_name]} #{params[:last_name]}\" " > n | |
" end " > n | |
" end " > n | |
"" > n | |
" format :txt do " > n | |
" def render " > n | |
" \"Hello #{full_name} from plain text\" " > n | |
" end " > n | |
" end " > n | |
" " > n | |
" format :pdf, :base => Prawn::FattyFormat do " > n | |
" def render " > n | |
" doc.text \"Hello #{full_name} from PDF\" " > n | |
" doc.render " > n | |
" end " > n | |
" end " > n | |
"end " > n | |
"" > n | |
"## here is where all the work is done" > n | |
"def render(format, params={}) " > n | |
" validate(format, params) " > n | |
" format_obj = formats[format].new " > n | |
" format_obj.extend(@helpers) if @helpers " > n | |
" format_obj.params = params " > n | |
" format_obj.validate " > n | |
" format_obj.render " > n | |
"end " > n | |
"" > n | |
"def _f(txt)" > n | |
" STDOUT << txt" > n | |
" STDOUT.flush" > n | |
"end" > n | |
"_f(\"\\r %06d \" % (counter+=1))" > n | |
"" > n | |
"CounterFormat = \"\r O %06d OT %06d P %06d S %07d : %07d %07d %07d %07d\"" > n | |
"cnt = [0]*8" > n | |
"_f(CounterFormat,cnt)" > n | |
"" > n | |
)) | |
(tempo-define-template "ruby-file-content" my-ruby-file) | |
) | |
(defun insert-author-line () | |
"Insert a line containing author details" | |
(interactive) | |
(tempo-template-author-line)) | |
;;; ******************** | |
;;; Load crypt, which is a package for automatically decoding and reencoding | |
;;; files by various methods - for example, you can visit a .Z or .gz file, | |
;;; edit it, and have it automatically re-compressed when you save it again. | |
;;; | |
;;(setq crypt-encryption-type 'pgp ; default encryption mechanism | |
;; crypt-confirm-password t ; make sure new passwords are correct | |
;; ;crypt-never-ever-decrypt t; if you don't encrypt anything, set this to | |
;; ; tell it not to assume that "binary" files | |
;; ; are encrypted and require a password. | |
;; ) | |
;;(require 'crypt++ "/users/sdss/gjw/home/lib/emacs/crypt++") | |
;;; ******************** | |
;;; Edebug is a source-level debugger for emacs-lisp programs. | |
;;; | |
(define-key emacs-lisp-mode-map "\C-xx" 'edebug-defun) | |
;;; ******************** | |
;;; Font-Lock is a syntax-highlighting package. When it is enabled and you | |
;;; are editing a program, different parts of your program will appear in | |
;;; different fonts or colors. For example, with the code below, comments | |
;;; appear in red italics, function names in function definitions appear in | |
;;; blue bold, etc. The code below will cause font-lock to automatically be | |
;;; enabled when you edit C, C++, Emacs-Lisp, and many other kinds of | |
;;; programs. | |
;;; | |
;;; The "Options" menu has some commands for controlling this as well. | |
;;; | |
;(cond ((string-match "XEmacs\\|Lucid" emacs-version) | |
; (require 'font-lock) | |
; (set-face-foreground 'font-lock-function-name-face "blue") | |
; (set-face-foreground 'font-lock-comment-face "orange") | |
; (set-face-foreground 'font-lock-string-face "forest green") | |
; (set-face-underline-p 'font-lock-string-face nil) | |
; (make-face-unitalic 'font-lock-string-face) | |
; (make-face-unitalic 'font-lock-function-name-face) | |
; )) | |
;;; fast-lock is a package which speeds up the highlighting of files | |
;;; by saving information about a font-locked buffer to a file and | |
;;; loading that information when the file is loaded again. This | |
;;; requires a little extra disk space be used. | |
;;; | |
;;; Normally fast-lock puts the cache file (the filename appended with | |
;;; .flc) in the same directory as the file it caches. You can | |
;;; specify an alternate directory to use by setting the variable | |
;;; fast-lock-cache-directories. | |
;(setq fast-lock-cache-directories '("/foo/bar/baz")) | |
;;; ******************** | |
;;; func-menu is a package that scans your source file for function definitions | |
;;; and makes a menubar entry that lets you jump to any particular function | |
;;; definition by selecting it from the menu. The following code turns this on | |
;;; for all of the recognized languages. Scanning the buffer takes some time, | |
;;; but not much. | |
;;; | |
;(cond ((string-match "XEmacs\\|Lucid" emacs-version) | |
; (require 'func-menu) | |
; (define-key global-map 'f8 'function-menu) | |
; (add-hook 'find-file-hooks 'fume-add-menubar-entry) | |
; (define-key global-map "\C-cg" 'fume-prompt-function-goto) | |
; (define-key global-map '(shift button3) 'mouse-function-menu) | |
; )) | |
;;; ******************** | |
;;; MH is a mail-reading system from the Rand Corporation that relies on a | |
;;; number of external filter programs (which do not come with emacs.) | |
;;; Emacs provides a nice front-end onto MH, called "mh-e". | |
;;; | |
;; Bindings that let you send or read mail using MH | |
;(global-set-key "\C-xm" 'mh-smail) | |
;(global-set-key "\C-x4m" 'mh-smail-other-window) | |
;(global-set-key "\C-cr" 'mh-rmail) | |
;; Customization of MH behavior. | |
;(setq mh-delete-yanked-msg-window t) | |
;(setq mh-yank-from-start-of-msg 'body) | |
;(setq mh-summary-height 11) | |
;; Use lines like the following if your version of MH | |
;; is in a special place. | |
;(setq mh-progs "/usr/dist/pkgs/mh/bin.svr4/") | |
;(setq mh-lib "/usr/dist/pkgs/mh/lib.svr4/") | |
;;; ******************** | |
;;; W3 is a browser for the World Wide Web, and takes advantage of the very | |
;;; latest redisplay features in XEmacs. You can access it simply by typing | |
;;; 'M-x w3'; however, if you're unlucky enough to be on a machine that is | |
;;; behind a firewall, you will have to do something like this first: | |
;(setq w3-use-telnet t | |
; ;; | |
; ;; If the Telnet program you use to access the outside world is | |
; ;; not called "telnet", specify its name like this. | |
; w3-telnet-prog "itelnet" | |
; ;; | |
; ;; If your Telnet program adds lines of junk at the beginning | |
; ;; of the session, specify the number of lines here. | |
; w3-telnet-header-length 4 | |
; ) | |
(setq mmm-global-mode 'maybe) | |
(setq mmm-submode-decoration-level 2) | |
(set-face-background 'mmm-output-submode-face "#333") | |
(set-face-background 'mmm-code-submode-face "#333") | |
(set-face-background 'mmm-comment-submode-face "lightgrey") | |
(mmm-add-classes | |
'((erb-code | |
:submode ruby-mode | |
:match-face (("<%#" . mmm-comment-submode-face) | |
("<%=" . mmm-output-submode-face) | |
("<%" . mmm-code-submode-face)) | |
:front "<%[#=]?" | |
:back "-?%>" | |
:insert ((?% erb-code nil @ "<%" @ " " _ " " @ "%>" @) | |
(?# erb-comment nil @ "<%#" @ " " _ " " @ "%>" @) | |
(?= erb-expression nil @ "<%=" @ " " _ " " @ "%>" @)) | |
))) | |
(add-hook 'html-mode-hook | |
(lambda () | |
(setq mmm-classes '(erb-code)) | |
(mmm-mode-on))) | |
(add-to-list 'auto-mode-alist '("\.rhtml$" . html-mode)) | |
;; shortcut to reparse the buffer | |
(global-set-key [f8] 'mmm-parse-buffer) | |
;; i hate whitespace that does nothing | |
(add-hook 'before-save-hook 'delete-trailing-whitespace) | |
;; move flymake temp files to somewhere else. | |
(defun flymake-create-temp-intemp (file-name prefix) | |
"Return file name in temporary directory for checking FILE-NAME. | |
This is a replacement for `flymake-create-temp-inplace'. The | |
difference is that it gives a file name in | |
`temporary-file-directory' instead of the same directory as | |
FILE-NAME. | |
For the use of PREFIX see that function. | |
Note that not making the temporary file in another directory | |
\(like here) will not if the file you are checking depends on | |
relative paths to other files \(for the type of checks flymake | |
makes)." | |
(unless (stringp file-name) | |
(error "Invalid file-name")) | |
(or prefix | |
(setq prefix "flymake")) | |
(let* ((name (concat | |
(file-name-nondirectory | |
(file-name-sans-extension file-name)) | |
"_" prefix)) | |
(ext (concat "." (file-name-extension file-name))) | |
(temp-name (make-temp-file name nil ext)) | |
) | |
(flymake-log 3 "create-temp-intemp: file=%s temp=%s" file-name temp-name) | |
temp-name)) | |
;; flymake mode for erb files | |
(defun flymake-erb-init () | |
(let* ((check-buffer (current-buffer)) | |
(temp-file (flymake-create-temp-inplace (buffer-file-name) "flymake")) | |
(local-file (file-relative-name | |
temp-file | |
(file-name-directory buffer-file-name)))) | |
(save-excursion | |
(save-restriction | |
(widen) | |
(with-temp-file temp-file | |
(let ((temp-buffer (current-buffer))) | |
(set-buffer check-buffer) | |
(call-process-region (point-min) (point-max) "erb" nil temp-buffer nil "-x")))) | |
(setq flymake-temp-source-file-name temp-file) | |
(list "ruby" (list "-c" local-file))))) | |
(eval-after-load "flymake" | |
'(progn | |
(push '(".+\\.\\(rhtml\\|erb\\)$" flymake-erb-init) flymake-allowed-file-name-masks) | |
(push '("^\\(.*\\):\\([0-9]+\\): \\(.*\\)$" 1 2 nil 3) flymake-err-line-patterns))) | |
(defun turn-on-flymake-for-erb-files () | |
(when (string-match "\.erb$" (buffer-file-name)) | |
(flymake-mode 1))) | |
(add-hook 'find-file-hook 'turn-on-flymake-for-erb-files) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment