Emacs
~/.emacs
(setq user-full-name "Adam Flott")
(setq user-mail-address "adam@npjh.com")
(add-to-list 'load-path "~/emacs/")
; GUI
; No toolbar, scrollbar and startup screen
(if window-system (setq inhibit-splash-screen t))
(if window-system (scroll-bar-mode 1))
(if window-system (tool-bar-mode 0))
(menu-bar-mode 0)
(if window-system (menu-bar-mode 1))
; Time and date in status bar
(setq display-time-day-and-date t display-time-24hr-format t)
(display-time)
; Turn line/column numbers on
(line-number-mode t)
(column-number-mode t)
; Syntax highlighting
;(require 'color-theme)
;(setq color-theme-is-global t)
;(color-theme-hober)
; Add a new line to the end of files
(setq require-final-newline t)
; Lines shouldn't be longer than 79 chars
(setq fill-column 79)
; Superboosts C-x b
(iswitchb-mode t)
; General Programming
(global-set-key [(f9)] 'compile)
(global-set-key "\C-ck" 'mode-compile-kill)
(show-paren-mode t)
;;; find file at point
(require 'ffap)
;; rebind C-x C-f and others to the ffap bindings (see variable ffap-bindings)
(ffap-bindings)
;; C-u C-x C-f finds the file at point
(setq ffap-require-prefix t)
;; browse urls at point via w3m
(setq ffap-url-fetcher 'w3m-browse-url)
;;recentf
(require 'recentf)
(recentf-mode 1)
(setq recentf-max-saved-items 500)
(setq recentf-max-menu-items 60)
(global-set-key [(meta f12)] 'recentf-open-files)
;; save a list of open files in ~/.emacs.desktop
;; save the desktop file automatically if it already exists
(setq desktop-save 'if-exists)
(desktop-save-mode 1)
;; save a bunch of variables to the desktop file
;; for lists specify the len of the maximal saved data also
(setq desktop-globals-to-save
(append '((extended-command-history . 30)
(file-name-history . 100)
(grep-history . 30)
(compile-history . 30)
(minibuffer-history . 50)
(query-replace-history . 60)
(read-expression-history . 60)
(regexp-history . 60)
(regexp-search-ring . 20)
(search-ring . 20)
(shell-command-history . 50)
tags-file-name
register-alist)))
; C
(setq-default indent-tabs-mode nil)
(setq-default c-indent-level 4)
(setq-default c-basic-offset 4)
(setq compilation-window-height 8)
; (add-hook 'c-mode-common-hook '(lambda () (flyspell-prog-mode)))
; Perl
(defalias 'perl-mode 'cperl-mode)
(add-to-list 'auto-mode-alist '("\\.t$" . cperl-mode))
;; Use 4 space indents via cperl mode
(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-close-paren-offset -4)
'(cperl-continued-statement-offset 4)
'(cperl-indent-level 4)
'(cperl-indent-parens-as-block t)
'(cperl-tab-always-indent t)
'(ecb-options-version "2.40"))
(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 ((t (:foreground "dark goldenrod"))))
;'(cperl-hash-face ((t (:foreground "dark goldenrod"))))
'(cperl-invalid ((t (:background "red" :foreground "white")))) )
;'(cperl-nonoverridable-face ((t (:foreground "purple"))))
;'(font-lock-string-face ((t (:foreground "dark green")))))
; XML
(setq sgml-basic-offset 4)
; Disable search highlighting
(setq search-highlight nil)
(setq isearch-lazy-highlight nil)
; Key mapping
(setq x-super-keysym 'meta)
(global-set-key "\C-xg" 'goto-line)
(global-set-key [(control backspace)] 'join-line)
; Diary
(when (file-exists-p "~/diary") (diary-mode))
(setq mark-diary-entries-in-calendar t)
(add-hook 'diary-display-hook 'fancy-diary-display)
(add-hook 'list-diary-entries-hook 'sort-diary-entries t)
; org-mode
(when (string= (system-name) "an.sumeria")
(when (file-exists-p "~/emacs/org.an") (load "org.an"))
)
; Occurrences in color
; http://www.bookshelf.jp/elc/color-moccur.el
(require 'color-moccur)
; Read only buffers that are over 1048576 bytes in size
(defun tj-find-file-check-make-large-file-read-only-hook ()
"If a file is over a given size, make the buffer read only."
(when (> (buffer-size) (* 1024 1024))
(setq buffer-read-only t)
(buffer-disable-undo)
(message "Buffer is set to read-only because it is large. Undo also disabled.")))
(add-hook 'find-file-hooks 'tj-find-file-check-make-large-file-read-only-hook)
; Killing text in read only buffers is allowed
(setq kill-read-only-ok 1)
; Show unfinished keystrokes early.
(setq echo-keystrokes 0.1)
; Selecting text copies it into the X clipboard
(setq x-select-enable-clipboard t)
; Unique buffer names
; It allows to have for instance "Makefile|proj" and
; "Makefile|otherProj" as buffer name instead of "Makefile" and
; "Makefile<2>", and it is activated only if there are multiple
; files with the same name!
; http://curiousprogrammer.wordpress.com/2009/04/28/emacs-hacks/
(require 'uniquify)
(setq uniquify-buffer-name-style 'reverse)
(setq uniquify-separator "|")
(setq uniquify-after-kill-buffer-p t)
(setq uniquify-ignore-buffers-re "^\\*")
; Show approx buffer size in modeline
(if (fboundp 'size-indication-mode)
(size-indication-mode))
; Make URLs in comments/strings clickable
(if (fboundp 'goto-address-prog-mode)
(add-hook 'find-file-hooks 'goto-address-prog-mode))
; Remember position in files between sessions
(when (require 'saveplace)
(setq save-place-file "~/.emacs.d/saveplace")
(setq-default save-place t))
; Perforce integration
(when (file-exists-p "~/bin/p4") (load "p4"))
; Escreen
(load "escreen")
(escreen-install)
;; add C-\ l to list screens with emphase for current one
;; http://blog.tapoueh.org/news.dim.html#%20Escreen%20integration
(defun escreen-get-active-screen-numbers-with-emphasis ()
"what the name says"
(interactive)
(let ((escreens (escreen-get-active-screen-numbers))
(emphased ""))
(dolist (s escreens)
(setq emphased
(concat emphased (if (= escreen-current-screen-number s)
(propertize (number-to-string s)
;;'face 'custom-variable-tag) " ")
'face 'info-title-3)
;;'face 'font-lock-warning-face)
;;'face 'secondary-selection)
(number-to-string s))
" ")))
(message "escreen: active screens: %s" emphased)))
(global-set-key (kbd "C-\\ l") 'escreen-get-active-screen-numbers-with-emphasis)
(autoload 'comment-out-region "comment" nil t)
(global-set-key "\C-cq" 'comment-out-region)
; Set the text copiestitlebar and icons, %f=filename, %b=buffername
(setq frame-title-formatat (list "GNU Emacs " emacs-version "@" system-name " - " '(buffer-file-name "%f" "%b")))
(setq icon-title-format frame-title-format)
(setq make-backup-files nil)
;diff-mode
(require 'diff-mode "diff-mode" t)
(setq diff-switches "-u") ; Use -u for plain diff also
(setq diff-default-read-only t)
; disable bold
;; (set-face-bold-p 'bold nil)
;; (mapc
;; (lambda (face)
;; (set-face-attribute face nil :weight 'normal))
;; (face-list))
;;
;; (defun clean-up-buffer-or-region ()
;; "Untabifies, indents and deletes trailing whitespace from buffer or region."
;; (interactive)
;; (save-excursion
;; (unless (region-active-p)
;; (mark-whole-buffer))
;; (untabify (region-beginning) (region-end))
;; (indent-region (region-beginning) (region-end))
;; (save-restriction
;; (narrow-to-region (region-beginning) (region-end))
;; (delete-trailing-whitespace))))
(add-to-list 'load-path
"~/emacs/yasnippet-current")
(require 'yasnippet) ;; not yasnippet-bundle
(yas/initialize)
(yas/load-directory "~/emacs/yasnippet-current/snippets")
(defun timestamp ()
(interactive)
(insert (format-time-string "%A, %B %d, %Y %Z %H:%M:%S")))
(dolist (hook '(text-mode-hook))
(add-hook hook (lambda () (flyspell-mode))))
(dolist (hook '(cperl-mode-hook))
(add-hook hook (lambda () (flyspell-prog-mode))))
;;(setq show-trailing-whitespace t)
(load-file "~/emacs/cedet/common/cedet.el")
(global-ede-mode 1) ; Enable the Project management system
(semantic-load-enable-code-helpers) ; Enable prototype help and smart completion
(global-srecode-minor-mode 1) ; Enable template insertion menu
(add-to-list 'load-path "~/emacs/ecb")
(require 'ecb)
;(require 'color-theme)
;(color-theme-initialize)
;(color-theme-adam)
(setq tab-width 4)
(add-to-list 'load-path "~/emacs/color-theme-current")
(require 'color-theme)
(defun color-theme-adam ()
"Emacs default colors.
If you are missing standard faces in this theme, please notify the maintainer."
(interactive)
;; Note that some of the things that make up a color theme are
;; actually variable settings!
(color-theme-install
'(color-theme-adam
((foreground-color . "black")
(background-color . "white")
(mouse-color . "black")
(cursor-color . "black")
(border-color . "black")
(background-mode . light))
((Man-overstrike-face . bold)
(Man-underline-face . underline)
(apropos-keybinding-face . underline)
(apropos-label-face . italic)
(apropos-match-face . secondary-selection)
(apropos-property-face . bold-italic)
(apropos-symbol-face . bold)
(goto-address-mail-face . italic)
(goto-address-mail-mouse-face . secondary-selection)
(goto-address-url-face . bold)
(goto-address-url-mouse-face . highlight)
(help-highlight-face . underline)
(list-matching-lines-face . bold)
(view-highlight-face . highlight))
(default ((t (nil))))
(bold ((t (:bold t))))
(bold-italic ((t (:bold t :italic t))))
(calendar-today-face ((t (:underline t))))
(cperl-array-face ((t (:foreground "Black" :background "White"))))
(cperl-hash-face ((t (:foreground "Black" :background "White"))))
(cperl-pod-face ((t (:foreground "DarkGreen"))))
(cperl-nonoverridable-face ((t (:foreground "firebrick"))))
(custom-button-face ((t (nil))))
(custom-changed-face ((t (:foreground "white" :background "blue"))))
(custom-documentation-face ((t (nil))))
(custom-face-tag-face ((t (:underline t))))
(custom-group-tag-face ((t (:foreground "blue" :underline t))))
(custom-group-tag-face-1 ((t (:foreground "red" :underline t))))
(custom-invalid-face ((t (:foreground "yellow" :background "red"))))
(custom-modified-face ((t (:foreground "white" :background "blue"))))
(custom-rogue-face ((t (:foreground "pink" :background "black"))))
(custom-saved-face ((t (:underline t))))
(custom-set-face ((t (:foreground "blue" :background "white"))))
(custom-state-face ((t (:foreground "dark green"))))
(custom-variable-button-face ((t (:bold t :underline t))))
(custom-variable-tag-face ((t (:foreground "blue" :underline t))))
(diary-face ((t (:foreground "red"))))
(excerpt ((t (:italic t))))
(fixed ((t (:bold t))))
(flyspell-duplicate-face ((t (:foreground "Gold3" :bold t :underline t))))
(flyspell-incorrect-face ((t (:foreground "OrangeRed" :bold t :underline t))))
(font-lock-builtin-face ((t (:foreground "MidnightBlue"))))
(font-lock-comment-face ((t (:foreground "ForestGreen"))))
(font-lock-constant-face ((t (:foreground "CadetBlue"))))
(font-lock-function-name-face ((t (:foreground "MidnightBlue"))))
(font-lock-keyword-face ((t (:foreground "SteelBlue"))))
; (font-lock-string-face ((t (:foreground "DarkGoldenrod"))))
(font-lock-string-face ((t (:foreground "black" :background "MistyRose1"))))
(font-lock-type-face ((t (:foreground "SteelBlue"))))
(font-lock-variable-name-face ((t (:foreground "Black"))))
(font-lock-warning-face ((t (:foreground "Red" :bold t))))
(fringe ((t (:background "grey95"))))
(highlight ((t (:background "darkseagreen2"))))
(highlight-changes-delete-face ((t (:foreground "red" :underline t))))
(highlight-changes-face ((t (:foreground "red"))))
(highline-face ((t (:background "paleturquoise"))))
(holiday-face ((t (:background "pink"))))
(info-menu-5 ((t (:underline t))))
(info-node ((t (:bold t :italic t))))
(info-xref ((t (:bold t))))
(italic ((t (:italic t))))
(makefile-space-face ((t (:background "hotpink"))))
(message-cited-text-face ((t (:foreground "red"))))
(message-header-cc-face ((t (:foreground "MidnightBlue"))))
(message-header-name-face ((t (:foreground "cornflower blue"))))
(message-header-newsgroups-face ((t (:foreground "blue4" :bold t :italic t))))
(message-header-other-face ((t (:foreground "steel blue"))))
(message-header-subject-face ((t (:foreground "navy blue" :bold t))))
(message-header-to-face ((t (:foreground "MidnightBlue" :bold t))))
(message-header-xheader-face ((t (:foreground "blue"))))
(message-separator-face ((t (:foreground "brown"))))
(modeline ((t (:foreground "white" :background "black"))))
(modeline-buffer-id ((t (:foreground "white" :background "black"))))
(modeline-mousable ((t (:foreground "white" :background "black"))))
(modeline-mousable-minor-mode ((t (:foreground "white" :background "black"))))
(region ((t (:background "light goldenrod yellow"))))
(secondary-selection ((t (:background "paleturquoise"))))
(show-paren-match-face ((t (:background "turquoise"))))
(show-paren-mismatch-face ((t (:foreground "white" :background "purple"))))
(speedbar-button-face ((t (:foreground "green4"))))
(speedbar-directory-face ((t (:foreground "blue4"))))
(speedbar-file-face ((t (:foreground "cyan4"))))
(speedbar-highlight-face ((t (:background "green"))))
(speedbar-selected-face ((t (:foreground "red" :underline t))))
(speedbar-tag-face ((t (:foreground "brown"))))
(underline ((t (:underline t))))
(vcursor ((t (:foreground "blue" :background "cyan" :underline t))))
(widget-button-face ((t (:bold t))))
(widget-button-pressed-face ((t (:foreground "red"))))
(widget-documentation-face ((t (:foreground "dark green"))))
(widget-field-face ((t (:background "gray85"))))
(widget-inactive-face ((t (:foreground "dim gray"))))
(widget-single-line-field-face ((t (:background "gray85")))))))
(eval-after-load "color-theme"
'(progn
(color-theme-initialize)
(color-theme-adam)))
(defun shift-text (distance)
(if (use-region-p)
(let ((mark (mark)))
(save-excursion
(indent-rigidly (region-beginning)
(region-end)
distance)
(push-mark mark t t)
(setq deactivate-mark nil)))
(indent-rigidly (line-beginning-position)
(line-end-position)
distance)))
(defun shift-right (count)
(interactive "p")
(shift-text count))
(defun shift-left (count)
(interactive "p")
(shift-text (- count)))
(autoload 'vkill "vkill" nil t)
(autoload 'list-unix-processes "vkill" nil t)