The very unofficial .emacs home JayakrishnanNair.emacs
emacs
Sections
home
what is this all about ?
customization basics
special topics
local dotfiles
dotfiles on the web
new and updated pages
useful sites and pages
search locally
EMacro
OS/2 Emacs
Latest Additions
local files:
John J. Glynn
David Jolley

linked files:


articles:


links:
The Emacs wiki
ODP search for Emacs


dmoz.org
;;{{{  Notes
;;; Started on : Nov 3, 1995
;;; Adapted for Work Dec 7, 1998
;;; Adapted for my IBM ThinkPad Mar 1, 1999
;;; More things added on March 30, 2000
;;
;;  FILE
;;      ~/.emacs
;;
;;  AUTHOR
;;      Jayakrishnan Nair jayakrishnan@netscape.net
;;
;;  DESCRIPTION
;;      My personal emacs startup-file. 
;;
;;      Note: There are references to my personal environment so please
;;      take care when borrowing pieces of code.
;;
;;}}}
(setq debug-on-error t)
(message "Loading Jayakrishnan's .emacs file")

frame;;{{{ Initial Setting of the display
(setq default-frame-alist
      '((top . 5) (left . 350)
        (width . 80) (height . 43)
        (cursor-color . "red")
        (cursor-type . box)
        (foreground-color . "black")
        (background-color . "white")
        (vertical-scroll-bars . right)))
;;}}}

(setq load-path 
      (cons "d:/Applications/emacs-20.6/site-lisp/jde-2.1.5" load-path))
(setq load-path
          (cons "d:/jk-personal/Emacs/lisp" load-path))
(setq load-path
          (cons "d:/jk-personal/Emacs/lisp/w3-4.0pre.46" load-path))

;;{{{ Display Time
;; I like to know what time it is. These lines show the clock in
;; the status bar. Comment out first line if you prefer to show
;; time in 12 hour format
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(display-time)
;;}}}


;;{{{ Buffer Switching
;; Easy switching to buffers
(require 'iswitchb)
(iswitchb-default-keybindings)

;;}}}

;;{{{ Show Absolute Path on the Title Frame
(setq frame-title-format "%f")
;;}}}
;;{{{ Match Parenthesis, vi style

                                        ; By an unknown contributor
(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)))))

;;}}}
;;{{{ Ispell
;;
;; ispell4:
;;
(autoload 'ispell-word "ispell" 
  "Check spelling of word at or before point" t)
(autoload 'ispell-complete-word "ispell" 
  "Complete word at or before point" t)
(autoload 'ispell-region "ispell" 
  "Check spelling of every word in the region" t)
(autoload 'ispell-buffer "ispell" 
  "Check spelling of every word in the buffer" t)
(autoload 'ispell "ispell" "Run ispell over buffer" t)
(autoload 'ispell-region "ispell" "Run ispell over region" t)
(autoload 'ispell-word "ispell" "Check word under cursor" t)
(define-key esc-map "$" 'ispell-word)
(setq ispell-command "c:/usr/local/bin/ispell.exe")
(setq ispell-look-dictionary "c:/Applications/Ispell/ispell.words")
(setq ispell-look-command "c:/usr/local/bin/look.exe")
(setenv "ISPELL_DICTIONARY" "c:/Applications/Ispell/ispell.dict")
(setenv "ISPELL_WORDS" "c:/Applications/Ispell/ispell.words")
(setq ispell-command-options (list "-d" "c:/Applications/Ispell/ispell.dict"))
;;}}}
;;{{{ Folding Mode
 (autoload 'folding-mode "folding" "Folding mode" t) 
;;}}}

(custom-set-variables
 '(paren-mode (quote paren) nil (paren))
 '(browse-url-browser-function (quote browse-url-netscape))
 '(toolbar-visible-p nil)
 '(w3-package t)
 '(gnus-package t))
(custom-set-faces)
;;{{{ Font Lock
(defcustom font-lock-mode-string ""
  "The string that will appear in the modeline when font-lock-mode is on."
  :type 'string
  :group 'font-lock)
;;}}}

;;{{{ Which Function
(defun which-function ()
  "Return current function name based on point.
If `imenu--index-alist' does no exist, or is empty  or if point
is located before first function, returns nil."
  (and
   (boundp 'imenu--index-alist)
   imenu--index-alist
   (let ((pair (car-safe imenu--index-alist))
         (rest (cdr-safe imenu--index-alist))
         (name nil))
     ;; Fix suggested by Roman Belenov <roman@nstl.nnov.ru> and
     ;; accepted by Richard Stallman <rms@santafe.edu> (<rms@gnu.org>).
     ;;(while (and pair (or (not (number-or-marker-p (cdr pair)))
     (while (and (or rest pair)
                 (or (not (number-or-marker-p (cdr pair)))
                     ;; Fix made by Cristian Ionescu-Idbohrn <cii@axis.com>
                     ;; show function name when point is on 1st char of
                     ;; function name.
                     ;;(> (point) (cdr pair))))
                     (>= (point) (cdr pair))))
       (setq name (car pair))
       (setq pair (car-safe rest))
       (setq rest (cdr-safe rest)))
     name)))

(defun cii-which-func-mode-on ()
  "Turn `which-func-modes' on, full scale."
  (setq which-func-maxout         0         ;; enabled, regardless buffer size
        which-func-format         '(" [" which-func-current "]")
        which-func-mode-global    t)
  (require 'which-func)
  (add-to-list 'which-func-modes 'cperl-mode)
  (add-to-list 'which-func-modes 'java-mode)
  (add-to-list 'which-func-modes 'jde-mode)
  (which-func-mode 0)
  (which-func-mode 1))
(cii-which-func-mode-on)
;;}}}
;;{{{ Emacs Internal variables

(setq gc-cons-threshold 750000)         ; Default 100000 in Emacs 19.27
(setq truncate-partial-width-windows nil)
(setq window-min-height 3)
(setq completion-auto-help t)   ; I want as much help as I can get
(setq completion-auto-exit t)            ; Dont want to always hit return
;;(setq require-final-newline 'ask)     ; Ask if final newline is needed
(setq track-eol t)
(setq mouse-yank-at-point t)
(setq print-escape-newlines t)
(setq visible-bell t)
(setq inhibit-startup-message t)
(setq default-major-mode 'text-mode)
(setq garbage-collection-messages t)    ;; Traditional
;;; Mark handling.  The following two lines makes the highlighted
;;; region visible, but I'm still able to use all region-commands even
;;; if the region has been turned off (just like in the good ol'
;;; days!)
;;;

(if (boundp 'transient-mark-mode)
    (setq transient-mark-mode t))
(setq mark-even-if-inactive t)
(setq-default search-highlight t)
(copy-face 'highlight 'isearch)
; highlight during query
(setq query-replace-highlight t)        
; highlight incremental search
(setq search-highlight t)    

; Show matching parens
(require 'paren)



; Display the column number of the point in the mode line
(column-number-mode t)

;;;;;; Enabling disabled commands
(put 'narrow-to-region 'disabled nil)
(put 'eval-expression 'disabled nil)

; Tab length
(setq default-tab-width 4)

;;}}}
;;{{{ Java, JDE etc.
;(require 'jpack) ;; Download this package
(message "jpack loaded")
(require 'jde)
(require 'jdok)
(message "jdok loaded")
(load "javahelp")
;;; Java Help: Who needs Visual Cafe
(setq javahelp-directories '("d:/Reference/Java/jdk1.1.8/docs/api" "//d/Reference/Java/swing-1.1.1fcs/doc/api")) 
(setq javahelp-database-file "c:/.javahelp")
(setq max-specpdl-size 50000)
(setq max-lisp-eval-depth 50000)

; parse funky Jikes error strings
(setq compilation-error-regexp-alist
      (cons (list "\\([^:\n]+\\):\\([0-9]+\\):\\([0-9]+\\):\\([0-9]+\\):\\([0-9]+\\)" 1 2 3)
            compilation-error-regexp-alist))

;; Complicated regexp to match method declarations in interfaces or classes
;; A nasty test case is:
;;    else if(foo instanceof bar) {
;; To avoid matching this as a method named "if" must check that within
;; a parameter list there are an even number of symbols, i.e., one type name
;; paired with one variable name.  The trick there is to use the regexp
;; patterns \< and \> to match beginning and end of words.
(defvar java-function-regexp
  (concat
   "^[ \t]*"                                   ; leading white space
   "\\(public\\|private\\|protected\\|"        ; some of these 8 keywords
   "abstract\\|final\\|static\\|"
   "synchronized\\|native"
   "\\|[ \t\n\r]\\)*"                          ; or whitespace
   "[a-zA-Z0-9_$]+"                            ; return type
   "[ \t\n\r]*[[]?[]]?"                        ; (could be array)
   "[ \t\n\r]+"                                ; whitespace
   "\\([a-zA-Z0-9_$]+\\)"                      ; the name we want!
   "[ \t\n\r]*"                                ; optional whitespace
   "("                                         ; open the param list
   "\\([ \t\n\r]*"                             ; optional whitespace
   "\\<[a-zA-Z0-9_$]+\\>"                      ; typename
   "[ \t\n\r]*[[]?[]]?"                        ; (could be array)
   "[ \t\n\r]+"                                ; whitespace
   "\\<[a-zA-Z0-9_$]+\\>"                      ; variable name
   "[ \t\n\r]*[[]?[]]?"                        ; (could be array)
   "[ \t\n\r]*,?\\)*"                          ; opt whitespace and comma
   "[ \t\n\r]*"                                ; optional whitespace
   ")"                                         ; end the param list
   "[ \t\n\r]*"                                ; whitespace
;   "\\(throws\\([, \t\n\r]\\|[a-zA-Z0-9_$]\\)+\\)?{"
   "\\(throws[^{;]+\\)?"                       ; optional exceptions
   "[;{]"                                      ; ending ';' (interfaces) or '{'
   )
  "Matches method names in java code, select match 2")

(defvar java-class-regexp
  "^[ \t\n\r]*\\(final\\|abstract\\|public\\|[ \t\n\r]\\)*class[ \t\n\r]+\\([a-zA-Z0-9_$]+\\)[^;{]*{"
  "Matches class names in java code, select match 2")

(defvar java-interface-regexp
  "^[ \t\n\r]*\\(abstract\\|public\\|[ \t\n\r]\\)*interface[ \t\n\r]+\\([a-zA-Z0-9_$]+\\)[^;]*;"
  "Matches interface names in java code, select match 2")

(defvar java-imenu-regexp
  (list (list nil java-function-regexp 2)
        (list ".CLASSES." java-class-regexp 2)
        (list ".INTERFACES." java-interface-regexp 2))
  "Imenu expression for Java")

;; install it
(add-hook 'java-mode-hook
          (function (lambda ()
                      (setq imenu-generic-expression java-imenu-regexp))))




;;}}}
;;{{{ Keys
(global-set-key "\C-cf" 'imenu)
(global-set-key "\C-cg" 'goto-line)
(global-set-key "\C-cr" 'revert-buffer)
(global-set-key '[f1] 'javahelp-search-emacs-flavour)
(global-set-key '[f2] 'browse-url)
;;}}}

;;{{{ Set Jasmin Mode
(load "jasmin")
(setq auto-mode-alist
          (append
           '(("\\.C$"    . c++-mode)
                 ("\\.j$" . jasmin-mode)
                 ) auto-mode-alist))

;;}}}
;;{{{ Auto Revert
(autoload 'auto-revert-mode "autorevert" nil t)
(autoload 'turn-on-auto-revert-mode "autorevert" nil nil)
(autoload 'global-auto-revert-mode "autorevert" nil t)
(global-auto-revert-mode 1)

;;}}}
;;{{{ Browse URL
(setq browse-url-netscape-program  "c:/Program Files/Netscape/Communicator/Program/netscape.exe")
(defvar shell-execute-helper "d:/jk-personal/Emacs/bin/shelex.exe")
(defun shell-execute-url (url &optional new-window)
"Invoke the shell-execute-helper program to call ShellExecute and launch or
re-direct a web browser on the specified url."
   (interactive "sURL: ")
   (call-process shell-execute-helper nil nil nil url))

(setq browse-url-browser-function 'shell-execute-url)
(setq gnus-button-url 'shell-execute-url)       ; GNUS
(setq vm-url-browser 'shell-execute-url)        ; VM



;;}}}
;;{{{
(autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
;;   To invoke html-helper-mode automatically on .html files, do this:
(setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist))


;;
;;}}}
;;{{{ Yes or No ?
;make the y or n suffice for a yes or no question
(fset 'yes-or-no-p 'y-or-n-p)
;;}}}
All content copyright by the contributors. Website maintained with Emacs , wsmake and html-helper-mode
Emacs community logo by Daniel Lundin Last updated on Sat Jan 22 14:49:24 2005 by Ingo Koch