Startpage >> Site >> UsefulFiles

Everything you could ever want to know about me
Useful Files

Emacs configuration file

; ==============================================================================
;                          Olaf.Steinkamp@nikhef.nl
;                          Marcel.Merk@nikhef.nl
;                          ribalba@gmail.com
; ==============================================================================

;; Insertion of Dates.
(defun insert-date-string ()
  "Insert a nicely formated date string."
  (interactive)
  (insert (format-time-string "%Y-%m-%d")))

;; C-c i calls insert-date-string
(global-set-key (kbd "C-c i") 'insert-date-string)


;; so sytax is higloigtes
(global-font-lock-mode 1) 


;; line bu line scra.ll
(setq scroll-step 1)

;; display the current time
; (display-time)

;; alias y to yes and n to no
(defalias 'yes-or-no-p 'y-or-n-p)

;; highlight matches from searches
(setq isearch-highlight t)
(setq search-highlight t)
(setq-default transient-mark-mode t)

;;(when (fboundp 'blink-cursor-mode)
;;  (blink-cursor-mode -1))

;; format the title-bar to always include the buffer name
(setq frame-title-format "emacs - %b")

;; highlight during searching
(setq query-replace-highlight t)

;; highlight incremental search
(setq search-highlight t)

;; Try this
(setq compilation-scroll-output "1")
(custom-set-variables
 '(load-home-init-file t t))
(custom-set-faces)



; ====================
;  no startup message
; ====================

(setq inhibit-startup-message t)

; ===================
; set load directory
; ===================

(setq load-path (append '( "~/.emacs.d/mods/" ) load-path))


; ===============================
;  show time/date in status line
; ===============================

(load-library "time")
(setq display-time-day-and-date t)
(setq display-24hr-format t)
(display-time)

; =====================================
;  show cursor position in status line
; =====================================

(setq line-number-mode t)              

; ===============================
;  indicate matching parentheses
; ===============================

(setq blink-matching-paren t)

; ==========================================================
;  enable up/downcase region (CTRL-x CTRL-u, CTRL-x CTRL-l)
; ==========================================================

(put 'downcase-region 'disabled nil)
(put 'upcase-region   'disabled nil)

; =================
;  version control
; =================

 (setq version-control t)
 (setq trim-versions-without-asking t)
 (setq delete-old-versions t)
 (setq kept-old-versions 1)

; ===================
; cvs version control
; ====================
 (setq vc-handle-cvs nil)

; ==============
;  Miscellaneous
; ===============

(setq default-tab-width 4)
(setq-default indent-tabs-mode nil)
(setq blink-matching-paren t)
(setq dired-listing-switches "-alL")
(load-library "time")
(setq display-time-day-and-date nil)
(setq display-24hr-format t)
(setq dired-listing-switches "-alL")
 ; CJAN(setq lpr-switches '("-Psla")) ; CJAN
(setq ps-lpr-command "xprint")
;  Font-lock buffer size can be changed with the following:
(setq font-lock-maximum-size (* 300 1024))
;  Note that default is:
;(defcustom font-lock-maximum-size 256000

;; For erin twiki editing mode
(require 'erin)


;;rst edit mode
(require 'rst)
(add-hook 'rst-adjust-hook 'rst-toc-update)


;;
;; For use with the PS-print utility (see
;; /usr/local/share/emacs/20.2/lisp/ps-print.el)
;;

(setq ps-paper-type 'a4)
(setq ps-landscape-mode t)
(setq ps-number-of-columns 2)
(setq ps-inter-column 48)
(setq ps-left-margin 48)
(setq ps-right-margin 10)
(setq ps-bottom-margin 42)
(setq ps-font-size 7)

(setq interpreter-mode-alist 
      (append'(
              ("perl"  . cperl-mode)
              ("perl5" . cperl-mode)
              )
      )
)

; =============================================
;  load major-mode depending on file-extension 
; =============================================

(setq default-major-mode 'text-mode)

(setq auto-mode-alist 
      (append '(
               ("\\.el$"        . emacs-lisp-mode)
               ("\\.emacs$"     . emacs-lisp-mode)
               ("\\.tex$"       . latex-mode)
               ("\\.sty$"       . latex-mode) ; JvE
               ("\\.bib$"       . bibtex-mode)
               ("\\.txi$"       . texinfo-mode)
               ("\\.html$"      . html-mode)
               ("\\.kumac$"     . kumac-mode)
               ("\\.csh$"       . sh-mode)
               ("\\.zsh$"       . sh-mode)
               ("\\.sh$"        . sh-mode)
               ("\\.tcsh$"      . sh-mode)
               ("\\.C$"         . c-mode)
               ("\\.c$"         . c-mode)
               ("\\.h$"         . c-mode)
               ("\\.a$"         . c-mode)
               ("\\.ctl$"       . c-mode) ; JvE for PVSS control script "language"
               ("\\.frm$"       . fortran-mode)
               ("\\.f$"         . fortran-mode)
               ("\\.f77$"       . fortran-mode)
               ("\\.inc"        . fortran-mode)
               ("\\.F$"         . fortran-mode)
               ("\\.ftn$"       . fortran-mode)
               ("\\.f_[0-9]$"   . fortran-mode)
               ("\\.edt_[0-9]$" . fortran-mode)
               ("\\.edt$"       . fortran-mode)
               ("\\.car$"       . fortran-mode)
               ("\\.cards$"     . fortran-mode) ; JvE
               ("\\.py$"        . python-mode) ; JvE
               ("\\.pl$"        . cperl-mode) ; JvE
               ("\\.pm$"        . cperl-mode) ; JvE
               ("\\.pm.cin$"    . cperl-mode) ; JvE
               ("\\.java$"      . java-mode) ; JvE
               ("\\.cxx$"       . c++-mode)
               ("\\.hxx$"       . c++-mode)
               ("\\.spec$"      . rpm-spec-mode)
               ("\\.txt$"       . rst-mode)
               ("\\.rst$"       . rst-mode)
               ("\\.rest$"      . rst-mode)
               )
            )
    )

(global-font-lock-mode t)

; ===============================
;  Add some hooks for keypad etc
; ===============================

;(setq fortran-mode-hook 'Fortran-Setup-IS)

;(setq term-setup-hook 'Setup-Term-IS)
;(add-hook 'term-setup-hook 'Setup-Keypad-ICB)
;(add-hook 'term-setup-hook 'edt-emulation-on)

; ================
;  load libraries
; ================

;(autoload 'Fortran-Setup-IS "fortran-ib")
;(require 'crypt)
;(load-library "misc-ib")
;(load-library "setup-ib")

; =============================
;  A few handy key definitions
; =============================

(global-set-key "\M-o"     'occur)
(global-set-key "\C-cg"    'goto-line)
(global-set-key "\M-p"     'pr-region)
;(global-set-key "\C-x="    'what-cursor-position-and-line)


; =====================
; Parenthesis matching
; =====================
;; stig-paren.el, a parentheses mathing much better than the default paren.el
;*************** (for better view of matched parentheses)
(load "paren")
(cond (window-system
  (require 'paren)
 ;; XEmacs
  (global-set-key [(control leftparen)] 'stig-paren-toggle-dingaling-mode)
  (global-set-key [(control rightparen)] 'stig-paren-toggle-sexp-mode))
  (t
  (setq blink-matching-paren t)))


; ======================
;  Load the emacsclient
; ======================

(server-start)
(emacs-version)

; ===========
;  Time stamp
; ===========

(require 'time-stamp)
(if (not (memq 'time-stamp write-file-hooks))
    (setq write-file-hooks (cons 'time-stamp write-file-hooks)))
;
; I want to change the "Last update : " "" field
; [Nota : I insert <A HREF=...>...</A> so the use of <> in delimiters is forbidden...]
; [       That's why I redefine time-stamp-start and time-stamp-end without <>       ]
;
(setq time-stamp-start "Last Update:[ \t]+\\\\?\"+")
(setq time-stamp-end "\\\\?\"")
;
; In the last 30 lines of the file
;
(setq time-stamp-line-limit -30)
;
; With <DayName DayNumberIntheMonth Month, Year at HH:MM:SS TZ by MyFullName (MyEmail)>
;
; [Nota : unfortunately %u@%h will expand to username@localhost ...]
;
(setq time-stamp-format "%:a %02d %:b, %:y at %02H:%02M:%02S %Z by %U (<A 
HREF=mailto:geerd-dietger.hoffmann@cern.ch>geerd-dietger.hoffmann@cern.ch</A>)")

(put 'narrow-to-region 'disabled nil)



; ===========
;  Some functions I copied from extraedit.el
; ===========
(defmacro get-current-line()
  "Current line string"
  (buffer-substring (save-excursion (beginning-of-line) (point))
            (save-excursion (end-of-line) (point))))

(defmacro line-length()
  "Length of a line in number of characters"
  (length (buffer-substring (save-excursion (beginning-of-line) (point))
                (save-excursion (end-of-line) (point)))))


(global-set-key "\C-c\C-f" 'duplicate)
(global-set-key "\C-c\C-o" 'comment-duplicate)

;; Duplicate it
(defun duplicate()
  "Duplicate it."
  (interactive)
  (let (
        (beg (line-beginning-position))
        (end (line-end-position)))
    (copy-region-as-kill beg end)
    (beginning-of-line)
    (forward-line 1)
    (yank)
    (newline)
    (forward-line -1)))

;; Duplicate it
(defun comment-duplicate()
  "Comment and Duplicate it."
  (interactive)
  (let (
        (beg (line-beginning-position))
        (end (line-end-position)))
    (copy-region-as-kill beg end)
    (comment-region beg end)
    (beginning-of-line)
    (forward-line 1)
    (yank)
    (newline)
    (forward-line -1)))

;; Insert comment

(defun insert-dcomment()
  "Insert a comment in the line above"
  (interactive)
  (insert-string "==============>")
  (insert-string "   ")
  (insert-string "<==============")
  (newline)
  (forward-line -1)
  (let (
        (beg (line-beginning-position))
        (end (line-end-position)))
  (comment-region beg end)
    (beginning-of-line)
    (forward-char 19)
;    (forward-line 1)
))
Page last modified on February 05, 2009, at 05:12 PM