jeudi 3 novembre 2011

emacs

Fichier ~/.emacs



(require 'color-theme)
(load-file "~/.emacs.d/themes/color-theme-blackboard.el")
(color-theme-blackboard) 

(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)

(setq column-number-mode t)
(setq line-number-mode t)
(setq inhibit-startup-message t)

;; ==================== KEYS ====================
;; already bind via simple.el
;; (global-set-key [home] 'beginning-of-line)
;; (global-set-key [end] 'end-of-line) 
;; (global-set-key [backspace] 'backward-delete-char-untabify)
;; (global-set-key [(control space)] 'set-mark-command)
;; (global-set-key [(control insert)] 'kill-ring-save)
;; (global-set-key [(shift insert)] 'yank)
;; (global-set-key [(control home)] 'beginning-of-buffer)
;; (global-set-key [(control end)] 'end-of-buffer)
;; (global-set-key [(control left)] 'backward-word)
;; (global-set-key [(control right)] 'forward-word)
;; (global-set-key [(control o)] 'open-line)

;; already bind via paragraphs.el
;; (global-set-key [(control down)] 'forward-paragraph)
;; (global-set-key [(control up)] 'backward-paragraph)

(defun beginning-of-page () (interactive) (move-to-window-line 0))
(defun end-of-page () (interactive) (move-to-window-line -1))
(global-set-key [(control kp-begin)] 'move-to-window-line)
(global-set-key [(control kp-down)] 'end-of-page)
(global-set-key [(control kp-up)] 'beginning-of-page)

(defun delete-char-or-region() (interactive) (if mark-active (delete-region (point) (mark)) (delete-char 1)))
(global-set-key [delete] 'delete-char-or-region)

(global-set-key [(control return)] 'newline-and-indent)
(global-set-key [(control delete)] 'kill-region)


(global-set-key [?\e ?s] 'point-to-register)  ;; M-s
(global-set-key [?\e ?r] 'jump-to-register) ;;  M-r


(global-set-key [?\e backspace] 'backward-kill-word)
(global-set-key [?\e delete] 'kill-word)

(global-set-key [?\e ?g] 'goto-line)

(global-set-key [M-return] 'kill-this-buffer)
(global-set-key [(control >)]    'bs-cycle-next)
(global-set-key [(control <)]   'bs-cycle-previous)
(global-set-key [f5]     'linum-mode)
(global-set-key [f6]     'menu-bar-mode)
(global-set-key [f8]     'next-error)
(global-set-key [f9]     'compile) ;;my-compile-or-tramp-compile)


(defun move-region (start end n)
  "Move the current region up or down by N lines."
  (interactive "r\np")
  (let ((line-text (delete-and-extract-region start end)))
    (forward-line n)
    (let ((start (point)))
      (insert line-text)
      (setq deactivate-mark nil)
      (set-mark start))))

(defun move-region-up (start end n)
  "Move the current line up by N lines."
  (interactive "r\np")
  (move-region start end (if (null n) -1 (- n))))

(defun move-region-down (start end n)
  "Move the current line down by N lines."
  (interactive "r\np")
  (move-region start end (if (null n) 1 n)))

(defun move-line (n)
  "Move the current line up or down by N lines."
  (interactive "p")
  (setq col (current-column))
  (beginning-of-line) (setq start (point))
  (end-of-line) (forward-char) (setq end (point))
  (let ((line-text (delete-and-extract-region start end)))
    (forward-line n)
    (insert line-text)
    ;; restore point to original column in moved line
    (forward-line -1)
    (forward-char col)))

(defun move-line-up (n)
  "Move the current line up by N lines."
  (interactive "p")
  (move-line (if (null n) -1 (- n))))

(defun move-line-down (n)
  "Move the current line down by N lines."
  (interactive "p")
  (move-line (if (null n) 1 n)))

(defun move-line-region-up (start end n)
  (interactive "r\np")
  (if (region-active-p) (move-region-up start end n) (move-line-up n)))

(defun move-line-region-down (start end n)
  (interactive "r\np")
  (if (region-active-p) (move-region-down start end n) (move-line-down n)))

(global-set-key [(meta up)] 'move-line-region-up)
(global-set-key [(meta down)] 'move-line-region-down)


;;; Déplacements entre buffers ************************************************
;;; Affichage du nom du fichier dans minibuffer *******************************

(global-set-key [(meta left)]    'goto-previous-buffer)
(global-set-key [(meta right)]   'goto-next-buffer)

(defun goto-next-buffer ()
  ""
  (interactive)
  (let ((l (reverse (buffer-list)))
        (buf (current-buffer))
        (regexp "^ ?\\*.*\\*$")
        )
    (while (progn
             (if l nil
               (switch-to-buffer buf)
               (error "No buffer to show"))
             (switch-to-buffer (car l))
             (message (buffer-file-name))
             (setq l (cdr l))
             (string-match regexp (buffer-name (current-buffer)))))))

(defun goto-previous-buffer ()
  ""
  (interactive)
  (let ((n (length (buffer-list)))
        (k 0)
        (buf (current-buffer))
        (regexp "^ ?\\*.*\\*$")
        )
    (while (progn
             (setq k (1+ k))
             (if (<= k n) nil
               (switch-to-buffer buf)
               (error "No buffer to show"))
             (bury-buffer)
             (message (buffer-file-name))
             (string-match regexp (buffer-name (current-buffer)))))))

;;; deplacement entre frames **************************************************

(global-set-key (kbd "")
  '(lambda () (interactive)
     (message (buffer-file-name)) (other-window -1)))
(global-set-key [(control tab)]
  '(lambda () (interactive)
     (message (buffer-file-name)) (other-window 1)))

;;; Acces par REGEXP dans C-x b ***********************************************

(iswitchb-mode t)
(iswitchb-default-keybindings)

(defun iswitchb-system-buffers-to-end ()
  ""
  (let ((files (delq nil (mapcar 
                          (lambda (x) 
                            (if (or 
                                 (string-match "Summary" x)
                                 (string-match "^ ?\\*.*\\*$" x))
                                x))
                          iswitchb-temp-buflist))))
    (iswitchb-to-end files)))

(add-hook 'iswitchb-make-buflist-hook 'iswitchb-system-buffers-to-end)

(message "main is loaded")


Fichier ~/.emacs.d/themes/color-theme-blackboard.el



(defun color-theme-blackboard ()
  "Color theme"
  (interactive)
  (color-theme-install
   '(color-theme-blackboard
     ((background-color . "black")
      (background-mode . dark)
      (border-color . "black")
      (cursor-color . "#A7A7A7")
      (foreground-color . "#F8F8F8")
      (mouse-color . "sienna1"))
     (default ((t (:background "#000000" :foreground "#F8F8F8"))))
     (font-lock-builtin-face ((t (:foreground "#F8F8F8"))))
     (font-lock-comment-face ((t (:italic t :foreground "#AEAEAE"))))
     (font-lock-constant-face ((t (:foreground "#D8FA3C"))))
     (font-lock-doc-string-face ((t (:foreground "DarkOrange"))))
     (font-lock-function-name-face ((t (:foreground "#FF6400"))))
     (font-lock-keyword-face ((t (:foreground "#FBDE2D"))))
     (font-lock-preprocessor-face ((t (:foreground "Aquamarine"))))
     (font-lock-reference-face ((t (:foreground "SlateBlue"))))

     (font-lock-regexp-grouping-backslash ((t (:foreground "#E9C062"))))
     (font-lock-regexp-grouping-construct ((t (:foreground "red"))))

     (font-lock-string-face ((t (:foreground "#61CE3C"))))
     (font-lock-type-face ((t (:foreground "#8DA6CE"))))
     (font-lock-variable-name-face ((t (:foreground "#FF6400"))))
     (font-lock-warning-face ((t (:bold t :foreground "Pink"))))
     (gui-element ((t (:background "#D4D0C8" :foreground "black"))))
     (region ((t (:background "#253B76"))))
     (mode-line ((t (:background "grey75" :foreground "black"))))
     (highlight ((t (:background "#222222"))))
     (highline-face ((t (:background "SeaGreen"))))
     (italic ((t (nil))))
     (left-margin ((t (nil))))
     (text-cursor ((t (:background "yellow" :foreground "black"))))
     (toolbar ((t (nil))))
     (underline ((nil (:underline nil))))
     (zmacs-region ((t (:background "snow" :foreground "ble")))))))

Cette configuration requiert  

le paquet suivant : emacs-goodies-el