GNU Emacs Snippets

GNU Emacs will read it's configuration settings from ~/.emacs. The following settings are used globally upon my hosts:

My complete .emacs file is available.

;; ~/.emacs
;;
;;  Customizations for GNU Emacs
;;
;; Steve
;; --
;; http://www.steve.org.uk
;;
;; $Id: _emacs,v 1.10 2005/11/21 18:59:44 steve Exp $
;;;

;;
;;  Avoid the annoying startup message.
(setq inhibit-startup-message t)


;;
;;  Start GNUClient with each loaded file appearing in the already
;; present Emacs frame.
;;
(if (require 'gnuserv-compat nil t)
    (if (require 'gnuserv nil t)
	(progn
	  (gnuserv-start)
	  (setq gnuserv-frame (car (frame-list))))))


;; Setup a nice theme if we have the color-theme package loaded.
(if (require 'color-theme nil t)
     (if window-system
     	(color-theme-arjen)
     	      (color-theme-arjen)))

;; Enable colour support
(if (fboundp 'global-font-lock-mode)
    (global-font-lock-mode 1)        ; GNU Emacs
  (setq font-lock-auto-fontify t))   ; XEmacs


;;  We always prefer CPerl mode to Perl mode.
(fset 'perl-mode 'cperl-mode)

;;  When starting load my hooks
(add-hook 'cperl-mode-hook 'my-cperl-mode-hook t)

;;  BSD Style brace placement, with tab=4 spaces.
(defun my-cperl-mode-hook ()
  (setq cperl-indent-level 4)
  (setq cperl-brace-offset -2)
  (setq cperl-label-offset 0))


;; Add the given path to the load-path variable.
(defun add-to-load-path (path-string)
  (message (format "Passed %S..." path-string))
  (if (stringp path-string)
      (when (file-exists-p path-string)
	(message (format "Adding %S to load-path..." path-string))
	(add-to-list 'load-path (expand-file-name path-string)))
    (crs-add-to-load-path (car path-string))
    (if (cdr path-string)
	(crs-add-to-load-path (cdr path-string)))))


;; Add ~/.dotfiles/emacs.d/ to the load-path if the directory exists
(if (file-exists-p (expand-file-name "~/.dotfiles/emacs.d"))
    (add-to-load-path (expand-file-name "~/.dotfiles/emacs.d")))

;; Load if available.
(require 'save-history nil t)
(setq save-history-file (expand-file-name "~/.dotfiles/emacs.d/tmp/histories" ))

;; Load our align-equals function
(require 'align-equals nil t)


;; Load the clock and column number
(unless (featurep 'xemacs)
  (display-time) ; put the current time in the modeline
  (column-number-mode t)
)

;; Show the time on the status bar.
(setq display-time-24hr-format t)
(display-time)


;;; Set the % key to goto matched parenthesis.
;;; Posted to the NTEmacs mailing list by
;;; Chris McMahan
(show-paren-mode t)
(global-set-key "%" 'match-paren)
(defun match-paren (arg)
  "Go to the matching parenthesis if on parenthesis otherwise insert %."
  (interactive "p")
  (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
          ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
          (t (self-insert-command (or arg 1)))))




;;
;;  Allow me to load files that are named in the current buffer
;;
(autoload 'find-file-at-point "ffap" nil t)
(define-key global-map [(control x) (control f)] 'find-file-at-point)


;; DON'T ADD LINES at the end of buffer when trying to scroll past end
(setq next-line-add-newlines nil)

;;
;; When running in a windowed mode the mouse pointer shouldn't intefere
;; with the cursor.
;;
(if window-system
    (mouse-avoidance-mode 'cat-and-mouse))

;;
;; Make all "yes or no" prompts show "y or n" instead
;;
(fset 'yes-or-no-p 'y-or-n-p)

;;
;; hide GPL header in C, C++, Perl, and Emacs Lisp code.
;;
(autoload 'hide-copyleft-region   "hide-copyleft" nil t)
(autoload 'unhide-copyleft-region "hide-copyleft" nil t)
(add-hook 'c-mode-hook 'hide-copyleft-region)
(add-hook 'emacs-lisp-mode-hook 'hide-copyleft-region)
(add-hook 'c++-mode-hook 'hide-copyleft-region)
(add-hook 'cperl-mode-hook 'hide-copyleft-region)

;;
;; M-g = goto-line
;;
(global-set-key "\M-g" 'goto-line)


[ Back To Snippets Index ]