;; Add my personal directory to the path ;(setq load-path (cons "~/.emacs.d/lisp/" load-path)) (add-to-list 'load-path "/usr/share/emacs/site-lisp/emacs-goodies-el/") ; ... in case I am running my own compiled version of emacs (add-to-list 'load-path "~/.emacs.d/lisp/") ;; enables TEMPLATES if possible (if (locate-library "template") (progn (require 'template) (template-initialize))) ;; Show line numbers at the left side ;; (if (locate-library "linum") ;; (progn ;; (require 'linum) ;; (add-hook 'find-file-hook (lambda () (linum-mode 1))))) ;; Open special buffers in new window ;(setq special-display-buffer-names ; '("*compilation*" "*Inferior Octave*")) ;; Nice shell within emacs (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on) ;; Keeps the cursor in the same relative row during pgups and dwns (setq scroll-preserve-screen-position t) ;; Change pasting behavior. Normally, it pastes where the mouse is at, ;; which is not necessarily where the cursor is. This changes things ;; so all pastes, whether they be middle-click or C-y or menu, all ;; paste at the cursor. Very useful for me. (setq mouse-yank-at-point t) ;; Window takes the name of the file being edited ;(setq frame-title-format "%f") ;; When opening a file, go to the last point I was visiting (setq-default save-place t) (require 'saveplace) ;; Inhibit annoying splash screen (setq inhibit-startup-message t) ;; Tab width of 4 (setq default-tab-width 4) (setq-default indent-tabs-mode nil) ;; Scroll by one step (setq scroll-conservatively 1) ;; Nicer cut and paste ;(cua-mode t) ;; Highlight current line ;(if window-system (highlight-current-line-on t)) (if window-system (global-hl-line-mode 1)) (if window-system (set-face-background 'hl-line "#fff")) ;; if it doesn't work, try using this: (global-hl-line-mode 1) ;; Don't show the menu bar if in console (if (not window-system) (menu-bar-mode 0)) ;; Shift-tab completes (global-set-key [backtab] 'hippie-expand) ;; Jaime's trick to have fullscreen (defun switch-full-screen () (interactive) (shell-command "wmctrl -r :ACTIVE: -btoggle,fullscreen") (menu-bar-mode 0)) (global-set-key [f11] 'switch-full-screen) ;; Column & line numbers in mode bar (column-number-mode t) (line-number-mode t) ;; Recognise cmake files as such (add-to-list 'auto-mode-alist '("CMakeLists\\s\\s.txt$" . cmake-mode)) (add-to-list 'auto-mode-alist '("\\.dag$" . sh-mode)) (add-to-list 'auto-mode-alist '("\\.sub$" . sh-mode)) ;; Enable backup files. (setq make-backup-files t backup-directory-alist '((".*" . "~/.emacs_backups/")) ; put backups here version-control t ; enable versioning vc-make-backup-files nil ; don't make backups for cvs projects vc-follow-symlinks t delete-old-versions t kept-new-versions 6 kept-old-versions 2) ;; Maybe I would like to use this too: ;(setq tramp-backup-directory-alist backup-directory-alist) ;(setq auto-save-file-name-transforms nil) ;; Goto line. (global-set-key (kbd "C-c g") 'goto-line) (global-set-key (kbd "M-g") 'goto-line) ;; Display current word's manpage. (global-set-key (kbd "C-c m") (lambda () (interactive) (manual-entry (current-word)))) ;; Highlight a word. (global-set-key (kbd "C-c h") 'highlight-regexp) ;; Start compile command. (global-set-key (kbd "C-c c") 'compile) ;; Use a better buffer list than the default (global-set-key (kbd "C-x C-b") 'electric-buffer-list) ;; Turn on font-lock mode (global-font-lock-mode t) ;; Enable visual feedback on selections (setq transient-mark-mode t) ;; Don't show the scrollbar (scroll-bar-mode nil) ;; Don't show the toolbar either (tool-bar-mode nil) ;; Start without menubar ;(menu-bar-mode nil) ;; But do mark parenthesis (show-paren-mode t) (setq show-paren-delay 0) (if window-system (setq show-paren-style 'expression)) (set-face-background 'show-paren-match-face "#ffff50") ;; Unified diff (setq vc-diff-switches "-u") ;; Use fixed font ;(set-default-font "fixed") ;(add-to-list 'default-frame-alist '(font . "6x10")) (setq default-frame-alist '((vertical-scroll-bars) (tool-bar-lines . 0) (menu-bar-lines . 1) (top . 50) (left . 800) (width . 80) (height . 105) (right-fringe) (left-fringe) (font . "6x10"))) ;; Change the colors that diff uses. (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. '(diff-added ((t (:foreground "Green4"))) t) '(diff-changed ((t (:foreground "MediumBlue"))) t) '(diff-context ((t (:foreground "Black"))) t) '(diff-file-header ((t (:foreground "Black" :weight bold))) t) '(diff-header ((t (:foreground "Blue3"))) t) '(diff-hunk-header ((t (:foreground "Blue3" :background "White"))) t) '(diff-index ((t (:foreground "Green"))) t) '(diff-nonexistent ((t (:foreground "DarkBlue"))) t) '(diff-removed ((t (:foreground "Red3"))) t)) ;; **** For development in LIGO **** (setq c-default-style "stroustrup") (set-default-font "6x10") (if window-system (set-frame-height (selected-frame) 110)) (defun pcdev1 () (interactive) (find-file "/caltech:/archive/home/jordi/public/active/")) (defun hoftmon-caltech () (interactive) (find-file "/caltech:/archive/home/jordi/public/active/gds-development/gds/cvs/head/gds/Monitors/hoftMon/hoftMon.cc")) (defun grb () (interactive) (find-file "/pcdev1:/scratch4/jordi/s5GRBs/GRB060121/Plothipe/check_missed.py")) (add-to-list 'auto-mode-alist '("\\.m$" . octave-mode)) (global-set-key (kbd "C-c C-c") 'comment-region) ;; Nice frdump output. When I press RET in dired-mode, I want to ;; frdump the file, not visit it! (add-hook 'dired-mode-hook (lambda () (local-set-key "\r" (lambda () (interactive) (let ((fname (dired-get-filename t t))) (if (and (> (length fname) 3) (string= (substring fname -4) ".gwf")) (frdump) (dired-find-file))))))) ;; When editing octave code. (add-hook 'octave-mode-hook (lambda () (setq octave-comment-char 37) ; use % for comments (local-set-key (kbd "C-c C-c") 'octave-comment-region) (local-set-key [f5] ; make it behave as in matlab (lambda () (interactive) (save-buffer) (let ((n (buffer-name))) (run-octave) (switch-to-buffer "*Inferior Octave*") (goto-char (point-max)) (insert "run " (substring n 0 (- (length n) 2))) (comint-send-input) (switch-to-buffer n)) (delete-other-windows) )))) (add-hook 'inferior-octave-mode-hook (lambda () (local-set-key [M-up] 'comint-previous-input) (local-set-key [M-down] 'comint-next-input))) ; Don't mess with Kipps horrible :) tabs style (add-hook 'python-mode-hook (lambda () (save-excursion (if (search-forward "kipp cannon" nil t) (setq indent-tabs-mode t))))) (defun frdump () (interactive) (let ((frdumpexe "/home/jordi/public/active/libframe-v8r04/Linux-x86_64/FrDump") ; use just "FrDump" for the one in /opt/lscsoft/ (bufname (concat "*frdump-" (current-word) "*"))) (shell-command (concat frdumpexe " -d 5 -i " (dired-get-filename)) bufname) ;(switch-to-buffer-other-window bufname) ; we could do this (delete-window) ; or this, whatever pisses me off less often! (highlight-regexp "Vector:[a-zA-Z0-9-\.\:_]+" "hi-yellow"))) ;; --- For testing Clojure --- ;; (setq slime-lisp-implementations nil) ;;;;; ;; (setq clojure-path "/home/jordi/public/active/fun/clojure/") ;; ;; Clojure mode ;; (add-to-list 'load-path (concat clojure-path "clojure-mode")) ;; (require 'clojure-mode) ;; (add-to-list 'auto-mode-alist '("\\.clj$" . clojure-mode)) ;; ;; Swank (for SLIME) ;; (add-to-list 'load-path (concat clojure-path "swank-clojure")) ;; (require 'swank-clojure-autoload) ;; (swank-clojure-config ;; (setq swank-clojure-jar-path (concat clojure-path "clojure/clojure.jar"))) ;; ;; SLIME ;; (eval-after-load "slime" ;; '(progn (slime-setup '(slime-repl)))) ;; (clojure-slime-config) ;; --- Trying stuff --- ;; (require 'color-theme) ;; (defun color-theme-vim () ;; "Color theme based on vim default." ;; (interactive) ;; (color-theme-install ;; '(color-theme-vim ;; () ;; ;; ((foreground-color . "#cfbfad") ;; ;; ; (background-color . "#1e1e27") ;; ;; (background-color . "#ffffff") ;; ;; (border-color . "#3e3e5e") ;; ;; (cursor-color . "#404040") ;; ;; ; (background-mode . dark) ;; ;; ) ;; ;; (region ((t (:background "#ffffcf")))) ;; ;; (highlight ((t (:background "#efefef")))) ;; ;; (fringe ((t (:background "#16161b")))) ;; ;; (show-paren-match-face ((t (:background "#00ffaf")))) ;; ;; (isearch ((t (:foreground "#303030" :background "#cd8b60")))) ;; ;; (modeline ((t (:foreground "#b9b9b9" :background "#3e3e5e")))) ;; ;; (modeline-inactive ((t (:foreground "#708090" :background "#3e3e5e")))) ;; ;; (modeline-buffer-id ((t (:foreground "#b9b9b9" :background "#3e3e5e")))) ;; ;; (minibuffer-prompt ((t (:foreground "#708090")))) ;; ;; (font-lock-builtin-face ((t (:foreground "#c080d0")))) ;; (font-lock-comment-face ((t (:foreground "#0000ff")))) ;; (font-lock-comment-delimiter-face ((t (:foreground "#0000ff")))) ;; ;; (font-lock-constant-face ((t (:foreground "#00ffff")))) ;; ;; (font-lock-doc-face ((t (:foreground "#cd8b00")))) ;; (font-lock-function-name-face ((t (:foreground "#10af10")))) ;; (font-lock-keyword-face ((t (:foreground "#afaf00")))) ;; ;; (font-lock-preprocessor-face ((t (:foreground "309090")))) ;; ;; (font-lock-reference-face ((t (:bold t :foreground "#808bed")))) ;; ;;;; (font-lock-string-face ((t (:foreground "#cf0000")))) ;; (font-lock-string-face ((t (:foreground "#008fbf")))) ;; ;; (font-lock-type-face ((t (:foreground "#ff8bff")))) ;; ;; (font-lock-variable-name-face ((t nil))) ;; ;; (font-lock-warning-face ((t (:foreground "#000000" :background "#ff0000")))) ;; ))) ;; (color-theme-vim) ;; ;(add-to-list 'load-path "/home/jordi/downloads/") ;; ;; Emacs server ;; (server-start) ;;;; Crazy tests ;(add-to-list 'load-path "/home/jordi/downloads") ;; (require 'auto-complete) ;; (global-auto-complete-mode t) ;; (require 'auto-complete-etags) ;(add-to-list 'load-path (expand-file-name "~/.emacs.d")) (autoload 'vala-mode "vala-mode" "Major mode for editing Vala code." t) (add-to-list 'auto-mode-alist '("\\.vala$" . vala-mode)) (add-to-list 'auto-mode-alist '("\\.vapi$" . vala-mode)) (add-to-list 'file-coding-system-alist '("\\.vala$" . utf-8)) (add-to-list 'file-coding-system-alist '("\\.vapi$" . utf-8)) (defun cute-comment-box (arg) "Stupid function to put a nice box surrounding comments. Just to try to do things in emacs lisp." (interactive "P") (let* ((text (if arg (read-input "Comment: ") "")) (c comment-start) (e comment-end) (n 70)) (beginning-of-line) (insert c " *" (make-string n ?*) "*" e "\n" c " *" (make-string n ? ) "*" e "\n") (insert text) (center-line) (beginning-of-line) (insert c " *") (end-of-line) (indent-to (+ n (length c))) (insert " *" e "\n") (insert c " *" (make-string n ? ) "*" e "\n" c " *" (make-string n ?*) "*" e "\n"))) (defun kill-whole-word (&optional really-word) "Kill the symbol or word that point is on (or a nearby one). The function, belying its name, normally finds a symbol. If optional arg REALLY-WORD is non-nil, it finds just a word." (interactive) (progn (let* ((oldpoint (point)) (start (point)) (end (point)) (syntaxes (if really-word "w" "w_")) (not-syntaxes (concat "^" syntaxes))) (skip-syntax-backward syntaxes) (setq start (point)) (goto-char oldpoint) (skip-syntax-forward syntaxes) (setq end (point)) ;; If we found something nonempty, delete it. (unless (= start end) (kill-region start end))))) (global-set-key (kbd "S-") 'kill-whole-word) (global-set-key (kbd "C-x ") 'previous-multiframe-window) (global-set-key (kbd "C-x ") 'next-multiframe-window) (defun beautify () "Make the code look nice. Remove tabs, put parenthesis nicely, etc." (interactive) (save-excursion (defmacro separate-parent (kw) "Like (replace-string 'kw(' 'kw (' nil (point-min) (point-max)) -ish..." `(progn (goto-char (point-min)) (while (search-forward (concat ,kw "(") nil t) (replace-match (concat ,kw " (") nil t)))) (defmacro separate-parent-many (&rest kws) `(progn ,@(mapcar (lambda (kw) `(separate-parent ,kw)) kws))) (defmacro repl (regexp to-string) "Like (replace-string 'kw(' 'kw (' nil (point-min) (point-max)) -ish..." `(progn (goto-char (point-min)) (while (re-search-forward ,regexp nil t) (replace-match ,to-string nil nil)))) (set-variable 'tab-width 4) (untabify (point-min) (point-max)) (repl "\\(\\w\\) (" "\\1(") ; f ( -> f( (repl "( \\(\\w\\)" "(\\1") ; ( x -> (x (repl ",\\(\\w\\)" ", \\1") ; ,y -> , y (repl "\\(\\w\\) )" "\\1)") ; y ) -> y) ; (replace-regexp "\\(\\w\\) (" "\\1(" nil (point-min) (point-max)) ; (replace-regexp "( \\(\\w\\)" "(\\1" nil (point-min) (point-max)) ; (replace-regexp ",\\(\\w\\)" ", \\1" nil (point-min) (point-max)) (separate-parent-many "if" "while" "switch") ;; Same as the following, but done it the hard-and-flexible way with macros! ;; (replace-string "if(" "if (" nil (point-min) (point-max)) ;; (replace-string "while(" "while (" nil (point-min) (point-max)) ;; (replace-string "switch(" "switch (") nil (point-min) (point-max)) (indent-region (point-min) (point-max)))) ;;;;;;;; (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. '(parens-require-spaces nil))