Created
January 14, 2013 10:33
-
-
Save markcameron/4529174 to your computer and use it in GitHub Desktop.
.emacs for mac
This file contains 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
;;(add-to-list 'load-path "D:/Program Files/emacs-23.3/emacs-related/") | |
;; Mac specific | |
;(setq mac-option-modifier 'command) | |
;(setq mac-option-modifier nil) | |
;(setq mac-command-modifier 'meta) | |
;; No Blinking Cursor | |
(blink-cursor-mode 0) | |
;; No Toolbar | |
(tool-bar-mode 0) | |
;; No Menu Bar | |
(menu-bar-mode 0) | |
;; pas d'auto-save | |
(auto-save-mode 0) | |
;; No Scrollbars | |
(set-scroll-bar-mode nil) | |
(defadvice new-frame (after scroll-bar-mode activate) | |
(set-scroll-bar-mode nil)) | |
;; Put all ~ files in this folder: | |
(setq backup-directory-alist '((".*" . "~/emacstrash"))) | |
;;(set-frame-parameter (selected-frame) 'alpha '(<active> [<inactive>])) | |
(set-frame-parameter (selected-frame) 'alpha '(84 84)) | |
(add-to-list 'default-frame-alist '(alpha 84 84)) | |
;; YASnippet | |
(add-to-list 'load-path | |
"~/.emacs.d/yasnippet") | |
(require 'yasnippet) ;; not yasnippet-bundle | |
(yas/initialize) | |
(yas/load-directory "~/.emacs.d/yasnippet") | |
;; Default Folders [HOME] | |
(setq homepath "/www/") | |
(setq default-directory "/www/") | |
;; Mercurial | |
(require 'vc-hg) | |
;; way better buffer-switching ... | |
;(ido-mode t) | |
;; c mode customizations | |
;(cwarn-mode t) | |
;(setq c-default-style "linux") | |
;(which-func-mode t) | |
;;(hide-ifdefs t) | |
;; Default Encoding | |
(set-terminal-coding-system 'utf-8) | |
;; Replace 'yes' by 'y' | |
(fset 'yes-or-no-p 'y-or-n-p) | |
;; pending delete | |
(pending-delete-mode) | |
;; Set Colors | |
(set-background-color "black") | |
(set-border-color "white") | |
(set-border-color "green") | |
(set-cursor-color "white") | |
(set-foreground-color "white") | |
(set-mouse-color "red") | |
(setq default-frame-alist | |
(append default-frame-alist | |
'((foreground-color . "white") | |
(background-color . "Black") | |
(set-border-color "white") | |
(cursor-color . "white") | |
))) | |
(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. | |
'(cperl-array-face ((((class color) (background dark)) (:foreground "LimeGreen" :weight bold)))) | |
'(cperl-hash-face ((((class color) (background dark)) (:foreground "LimeGreen" :slant italic :weight bold)))) | |
'(font-lock-comment-face ((t (:bold nil :foreground "DeepPink"))))) | |
(set-face-attribute 'default nil :height 140) | |
;; Tab indent with spaces | |
;(setq indent-tabs-mode nil) | |
(setq tab-width 6) | |
;; Switch between visible buffers using Alt+Right and Alt+Left | |
(global-set-key [(meta right)] 'other-window) | |
(global-set-key [(meta left)] '(lambda() | |
(interactive) | |
(other-window -1) | |
)) | |
; C-x k Kills the buffer without confirmation | |
(global-set-key (read-kbd-macro "C-x k") (quote kill-this-buffer)) | |
;; Auto-Complete with Ctrl+Tab | |
(abbrev-mode t) | |
(global-set-key (quote [C-tab]) (quote dabbrev-expand)) | |
;; C-a C-k removes whole line, not just text [includes carriage return] | |
(setq kill-whole-line t) | |
;; Remove splash screen | |
(setq inhibit-splash-screen t) | |
; Show column number | |
(column-number-mode 1) | |
; Highlight matching {} () | |
(show-paren-mode 1) | |
(setq blink-matching-paren-on-screen t) | |
; Add a final newline to files that don't have one without asking. | |
(setq require-final-newline t) | |
;; Notepad++ comment/uncomment system | |
(defun toggle-comment() | |
"Toggle the // style comments at the beginning of a line" | |
(interactive) | |
; Save cursor position for later. | |
(setq cursor (point)) | |
; Setup comment string | |
(setq comment-str "#") | |
(setq comment-size (length comment-str)) | |
(move-beginning-of-line nil) | |
; Get current line from buffer and check if it is commented or not | |
; and apply or remove comment accordingly | |
(setq line-of-code (buffer-substring (line-beginning-position) (line-end-position))) | |
(if (not (equal (substring line-of-code 0 comment-size) comment-str)) | |
(progn | |
(setq line-of-code (concat comment-str line-of-code)) | |
(setq cursor (+ cursor comment-size)) | |
) | |
(if (string= (substring line-of-code 0 comment-size) comment-str) | |
(progn | |
(setq line-of-code (substring line-of-code comment-size nil)) | |
(setq cursor (- cursor comment-size)) | |
) | |
) | |
) | |
; Overwrite old line with the newly commented one. | |
(kill-line) | |
(insert line-of-code) | |
(newline) | |
(goto-char cursor) | |
) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; MODES ;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; PHP | |
(add-to-list 'load-path "~/.emacs.d/php-mode") | |
(require 'php-mode) | |
(defconst my-php-style | |
'((c-offsets-alist . ( | |
(arglist-close . c-lineup-close-paren) ; correct arglist closing parenthesis | |
))) | |
"My PHP Programming style" | |
) | |
(c-add-style "my-php-style" my-php-style) | |
(defun my-php-mode () | |
"My personal php-mode customizations." | |
(c-set-style "my-php-style") | |
; More generic PHP customizations here | |
) | |
(defun drupal-mode () | |
"Drupal php-mode." | |
(interactive) | |
(php-mode) | |
(message "Drupal mode activated.") | |
(set 'tab-width 2) | |
(set 'c-basic-offset 2) | |
(set 'indent-tabs-mode nil) | |
(c-set-offset 'case-label '+) | |
(c-set-offset 'arglist-intro '+) ; for FAPI arrays and DBTNG | |
(c-set-offset 'arglist-cont-nonempty 'c-lineup-math) ; for DBTNG fields and values | |
; More Drupal-specific customizations here | |
) | |
(defun setup-php () | |
; PHP | |
(add-hook 'php-mode-hook 'my-php-mode) | |
; Drupal | |
(add-to-list 'auto-mode-alist '("\\.\\(module\\|test\\|install\\|theme\\)$" . drupal-mode)) | |
(add-to-list 'auto-mode-alist '("/drupal.*\\.\\(php\\|inc\\)$" . drupal-mode)) | |
(add-to-list 'auto-mode-alist '("\\.info" . conf-windows-mode)) | |
; More startup-setup for PHP customizations to work here | |
) | |
(setup-php) | |
(provide 'setup-php) | |
;; PERL | |
; Override perl-mode by cperl-mode | |
(fset 'perl-mode 'cperl-mode) | |
(add-hook 'cperl-mode-hook | |
(lambda () | |
(message "CPerl mode activated.") | |
(set 'tab-width 4) | |
(set 'indent-tabs-mode t))) | |
(setq | |
cperl-close-paren-offset -4 | |
cperl-continued-statement-offset 4 | |
cperl-indent-level 4 | |
cperl-indent-parens-as-block t | |
cperl-tabs-always-indent t) | |
;; CSS | |
(setq cssm-indent-level 4) | |
(setq cssm-newline-before-closing-bracket t) | |
(setq cssm-indent-function #'cssm-c-style-indenter) | |
(setq cssm-mirror-mode nil) | |
;;MACROS | |
(fset 'macro-breakstring | |
"|. .qq|") | |
(fset 'macro-translate | |
"|. t('') .qq|") | |
(fset 'macro-html | |
"\C-a$html .= qq|\C-e|;\C-n\C-a") | |
(fset 'macro-out | |
"\C-a$out .= '\C-e';\C-n\C-a") | |
(fset 'macro-echo | |
"\C-aecho '\C-e';\C-n\C-a") | |
(fset 'dpr | |
[?d ?p ?r ?\( ?\) ?\; left left ?$ C-tab]) | |
(fset 'devnetz-tramp | |
"\C-x\C-f\C-a\C-k/plink:mark@devnetz.ch:/home/mark/www/") | |
(fset 'daikon-tramp | |
"\C-x\C-f\C-a\C-k/plink:mca@daikon.edipresse.com:/var/www/") | |
(fset 'brace-left | |
"{") | |
(fset 'brace-right | |
"}") | |
(defun indent-buffer () | |
(interactive) | |
(save-excursion (indent-region (point-min) (point-max) nil)) | |
) | |
;; scroll one line at a time (less "jumpy" than defaults) | |
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ;; one line at a time | |
;;e-speed nil) ;; don't accelerate scrolling | |
(setq mouse-wheel-follow-mouse 't) ;; scroll window under mouse | |
(setq scroll-step 1) ;; keyboard scroll one line at a time | |
; Custom KBD SHortcuts | |
(global-set-key [f5] 'indent-buffer) | |
(global-set-key [f11] 'devnetz-tramp) | |
(global-set-key [f12] 'daikon-tramp) | |
(global-set-key "\C-x\C-a" 'macro-breakstring) | |
(global-set-key "\C-x\C-t" 'macro-translate) | |
(global-set-key "\C-x\C-h" 'macro-html) | |
(global-set-key "\C-x\M-o" 'macro-out) | |
(global-set-key "\C-x\M-e" 'macro-echo) | |
(global-set-key "\C-x\p" 'dpr) | |
(global-set-key "\M-g" 'goto-line) | |
(global-set-key "\C-q" 'toggle-comment) | |
(global-set-key (kbd "<C-M-f8>") 'brace-left) | |
(define-key global-map (kbd "<C-M-f9>") 'brace-right) | |
;(global-set-key "\C-M-8" 'brace-left) | |
(global-set-key [(home)] 'beginning-of-line) | |
(global-set-key [(C-home)] 'beginning-of-buffer) | |
(global-set-key [(end)] 'end-of-line) | |
(global-set-key [(C-end)] 'end-of-buffer) | |
(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. | |
'(cperl-invalid-face (quote none))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment