User:Kungi/GNU Emacs Config: Difference between revisions

From NoName e.V.
Jump to navigation Jump to search
(New page: ; General Configuration should be independent of Emacs ; ---------------------------------------------------- ;; I should use psvn mode from http://www.xsteve.at/prg/emacs/psvn.el ;;...)
(No difference)

Revision as of 13:47, 21 January 2008

; General Configuration should be independent of Emacs
; ----------------------------------------------------

;; I should use psvn mode from http://www.xsteve.at/prg/emacs/psvn.el
;; XXX: Does not work for some reason
;; (require 'psvn)

;; highlight the line the cursor is in ( in aquamacs it's green )
(global-hl-line-mode 1)

;; Elisp directory
(add-to-list 'load-path "~/.elisp/")

;; Get some nice line numberg
(require 'setnu)

;; No any emcas backup files
(setq make-backup-files nil
      backup-inhxibited t)

;; Completion
(load-library "completion")
(initialize-completions)

;; Highlight 80th character (by Kai Großjohann)
(font-lock-add-keywords 'c-mode
			'(("................................................................................\\(.\\)"
			   1 font-lock-warning-face prepend)))

;; yes/no = y/n
(fset 'yes-or-no-p 'y-or-n-p)

;; Replace highlighted/marked areas
(delete-selection-mode t)

; Aquamacs Option optimized for my macbook
(when (or (featurep 'aquaemacs) (boundp 'aquamacs-version))
  ;; I really hate the Aquaemacs toolbar
  (tool-bar-mode 0)
  (line-number-mode 1)
  (column-number-mode 1)

  ;; Let the Apple Key be the Meta key
  (setq mac-command-modifier 'meta)

  ;; Let the option key be no special key
  (setq mac-option-modifier nil)

  ;; Set position of emacs
  (setq initial-frame-alist '((background-color . "white") (left . 230) (width . 145) (height . 47)))

  ;; Do exacly as defined above -- don't try to be intelligent
  (smart-frame-positioning-mode nil)

  ;; let aquamacs open a new buffer in one the same frame
  (one-buffer-one-frame-mode 0)
)

; TEX Editing
; -----------
;; Stuff that AUCTeX needs
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)

;; Activate REFTeX
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)   ; with AUCTeX LaTeX mode
(add-hook 'latex-mode-hook 'turn-on-reftex)   ; with Emacs latex mode

(global-set-key [(control .)] 'TeX-complete-symbol)

; Lisp Editing
; ------------
;; Stuff required for slime
(setq inferior-lisp-program "sbcl")
(add-to-list 'load-path "~/.elisp/slime/")
(require 'slime)
(slime-setup)

;; Some neaty tricks :-)
;;; ibuffer mode which make all operations on buffers possible
(setq ibuffer-shrink-to-minimum-size t)
(setq ibuffer-always-show-last-buffer nil)
(setq ibuffer-sorting-mode 'recency)
(setq ibuffer-use-header-line t)
(global-set-key [(f12)] 'ibuffer)

;; Functions taken from http://www.xsteve.at/prg/emacs/xsteve-functions.el
;; All occurances of kungi were made by replacing xsteve with kungi :-)
;;; taken from vhdl-mode
(defun kungi-remove-trailing-spaces ()
  "Remove trailing spaces in the whole buffer."
  (interactive)
  (save-match-data
    (save-excursion
      (let ((remove-count 0))
        (goto-char (point-min))
        (while (re-search-forward "[ \t]+$" (point-max) t)
          (setq remove-count (+ remove-count 1))
          (replace-match "" nil nil))
        (message (format "%d Trailing spaces removed from buffer." remove-count))))))

(defun kungi-remove-control-M ()
  "Remove ^M at end of line in the whole buffer."
  (interactive)
  (save-match-data
    (save-excursion
      (let ((remove-count 0))
	(goto-char (point-min))
	(while (re-search-forward " $" (point-max) t)
	  (setq remove-count (+ remove-count 1))
	  (replace-match "" nil nil))
	(message (format "%d ^M removed from buffer." remove-count))))))