The very unofficial .emacs home IngoKoch.emacs-gnu-all
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
Ingo Koch
IngoKoch.emacs
.emacs-gnu-all
.emacs-gnu-win
.mycustom
.vm
javadecomp.el
wsmake.el

IngoKoch.zip
Latest Additions
local files:
John J. Glynn
David Jolley

linked files:


articles:


links:
The Emacs wiki
;; -*- lisp -*- 
;; ***************************************************************************
;;       Ingos GNU Emacs configuration common for all platforms
;; 
;; This file holds the GNU Emacs configuration common to all platforms.
;; Most of it might also be ok for XEmacs, but not using it, I didn't test it.
;;        
;; Date        Version  Author  Reason
;; 2000/04/23  1.1.0    ko      Oops, a major rewrite !
;;                              
;; ---------------------------------------------------------------------------
;; switch debugging on or off ( hopefully off 8-)) )
;; ---------------------------------------------------------------------------
(setq debug-on-error t)
;(setq debug-on-quit t)
;(setq nntp-record-commands t)

;; ---------------------------------------------------------------------------
;; for jcvs, jacob, and far (the best norton commander clone on NT) user menu
;; or any program which would like to call emacs
;; This is loaded in front of all packages, because Jason Rumney states that
;; loading it to late could lead to problems due to gnuclient timing out.
;; I've had this in the middle of my .emacs and I've never encountered any 
;; problems, but to be on the sunny side, I've put it here 8-))) 
;; Well, with the new loading scheme it will load quite late, I'll see
;; wether this is a problem.
;; ---------------------------------------------------------------------------
 (require 'gnuserv)
 (gnuserv-start)
 (setq gnuserv-frame (selected-frame))

;; ***************************************************************************
;;                              preface
;; 
;; One of the really nice features of emacs is the possibility to customize
;; almost everything to your own special needs.
;; A lot of this customization can be done by setting simple variables
;; (the only problem here is to know all of them 8-))
;; The following section contains a few of them.
;;
;; ***************************************************************************
;; ---------------------------------------------------------------------------
;; some user vars
;; ---------------------------------------------------------------------------
(setq my-author-name (getenv "USER"))
(setq user-full-name (getenv "USER"))

;; ---------------------------------------------------------------------------
;; Beside the row I'd also like to see the column in the mode line
;; ---------------------------------------------------------------------------
(setq column-number-mode t)

;; ---------------------------------------------------------------------------
;; Do only one line scrolling, not more ! This scrolling half a screen drives
;; me crazy 8-)
;; But be careful: if you keep the cursor keys pressed, updating of the 
;; screen becomes ugly. Because I've a nervous finger, pressing the key 
;; once for every line, this doesn't bother me.
;; ---------------------------------------------------------------------------
(setq scroll-step 1)

;; ---------------------------------------------------------------------------
;; Don't wrap long lines, I can't recognize anything if this is the case
;; ---------------------------------------------------------------------------
(set-default 'truncate-lines t)

;; ---------------------------------------------------------------------------
;; Nevertheless I'd like to have the possibility to see what is out of my
;; view.
;; Ok, that's no var, but because of belonging to the nowrap, I've placed it 
;; here (long live structure !)
;; ---------------------------------------------------------------------------
(require 'auto-show)
(auto-show-mode 1)
(setq-default auto-show-mode t)

;; ---------------------------------------------------------------------------
;; Make the region visible (but only up to the next operation on it)
;; ---------------------------------------------------------------------------
(setq transient-mark-mode t)

;; ---------------------------------------------------------------------------
;; handle abbreviations
;; ---------------------------------------------------------------------------
(setq abbrev-mode t)
(quietly-read-abbrev-file)

;; ***************************************************************************
;;                     emacs look and feel
;;
;; ***************************************************************************
;; ---------------------------------------------------------------------------
;; Set the foreground and background colors of the mode line.
(cond (window-system
      (set-face-background 'modeline "yellow")
      (set-face-foreground 'modeline "blue")
      ))

;; ---------------------------------------------------------------------------
;; to get emacs a bit more consistent, replace all yes or no questions with
;; simple y or n. 
;; ---------------------------------------------------------------------------
(fset 'yes-or-no-p 'y-or-n-p)

;; ***************************************************************************
;;                     useful packages
;;
;; This section loads or configures some packages I use.
;;
;; ***************************************************************************

;; ---------------------------------------------------------------------------
;; imenu (beeing bound to a mouse button later on) gives you a context menu
;; with entries for all functions, variables, classes and so on (if the mode
;; for the programming language supports imenu).
;; Selecting an entry makes you jump to the right place in the source.
;; Supported by a number of different programming modes.
;; Nice to have !
;; ---------------------------------------------------------------------------
(require 'imenu)
(setq imenu-sort-function (quote imenu--sort-by-name))

;; ---------------------------------------------------------------------------
;; Give me colors, please.
;; But give me the colors I prefer !
;; ---------------------------------------------------------------------------
(require 'font-lock)
(global-font-lock-mode t)

;; as much colours as possible for c and c++
(setq font-lock-maximum-decoration
  '((c-mode    . 3) 
    (c++-mode  . 3)
    (java-mode . 3)
    (jde-mode  . 3)
    (t         . 3))
)

;; ---------------------------------------------------------------------------
;; Buffer-menu in a cleaned up manner (this is great !)
;; It will be bound to one of the mouse buttons later on.
;; ---------------------------------------------------------------------------
(require 'msb)

;; ---------------------------------------------------------------------------
;; view man pages from within emacs. This is nice, but can't handle all
;; of the man pages I've seen. 
;; To be called with M-x woman
;; Author: Francis Wright  <F.J.Wright@QMW.ac.uk>
;; available at: http://centaur.maths.qmw.ac.uk/Emacs/
;; ---------------------------------------------------------------------------
(autoload 'woman "woman"
             "Decode and browse a UN*X man page." t)
(autoload 'woman-find-file "woman"
             "Find, decode and browse a specific UN*X man-page file." t)

(autoload 'woman-dired-find-file "woman"
   "In dired, run the WoMan man-page browser on this file." t)
(add-hook 'dired-mode-hook
  (function
    (lambda ()
      (define-key dired-mode-map "W" 'woman-dired-find-file))))

;; ---------------------------------------------------------------------------
;; give me my last working environment (if  I have saved it 8-) )
;; ---------------------------------------------------------------------------
(load "desktop")
(desktop-load-default)
(desktop-read)

;; ***************************************************************************
;;                            Mail-Support
;;
;; ***************************************************************************
(setq user-full-name "Ingo Koch")
(setq mail-default-reply-to "ingo.koch@ikoch.de")
(setq user-mail-address "Ingo Koch <ingo.koch@ikoch.de>")

(setq smtpmail-default-smtp-server "komserver.ikoch.de")
(setq smtpmail-local-domain nil)
(setq send-mail-function 'smtpmail-send-it)

(load-library "smtpmail")

(setenv "MAILHOST" "komserver.ikoch.de")

(load-library "vm")

(put 'rmail 'disabled t)

(define-key menu-bar-tools-menu [rmail] '("Read Mail" . vm))
(define-key-after menu-bar-tools-menu [smail] '("Send Mail" . vm-mail) 'rmail)


;; ***************************************************************************
;;                         programming languages
;;
;; Here are the customizations of C, C++ and java-mode and loading 
;; of python and rexx modes.
;; ***************************************************************************
;; ---------------------------------------------------------------------------
;; emacs is (not only) an editor from software developers for software 
;; developers. But different people have different opinions about the way
;; sourcecode should be formatted (that's the point where tools like indent
;; get their right to exist 8-)) ).
;; I have an idea of well formatted, readable sourcecode too 8-)
;; And here is my way of formatting:
;; ---------------------------------------------------------------------------
(defconst ingos-c-style
  '((c-tab-always-indent        . t)
    (c-basic-offset             . 2)
    (c-comment-only-line-offset . (0 . 0))
    (c-hanging-braces-alist     . ((defun-open          before after)
                                   (defun-close         before after)  
                                   (class-open          before after)  
                                   (class-close         before after)  
                                   (brace-list-open     before after)  
                                   (brace-list-close    before after)  
                                   (block-open          before after)  
                                   (block-close         before after)  
                                   (substatement-open   before after)  
                                   (statement-case-open before after)  
                                   )) 
    (c-offsets-alist            . ((statement-block-intro . +)
				   (knr-argdecl-intro     . +)
				   (substatement-open     . 0)
				   (inline-open           . 0)
				   (label                 . 0)
				   (statement-case-open   . +)
				   (case-label            . +)
				   (statement-cont        . +)
				   (arglist-intro         . c-lineup-arglist-intro-after-paren)
				   (arglist-close         . c-lineup-arglist)
				   ))
    (c-echo-syntactic-information-p . t)
    ) 
  "Ingos C Programming Style")


;; ---------------------------------------------------------------------------
;; define my hooks and add them
;; ---------------------------------------------------------------------------
(defun ingos-c-mode-common-hook ()
  (c-add-style "PERSONAL" ingos-c-style t)
  ;; some more customization 
  (setq tab-width 2
	;; I don't like tabs, give me spaces instead
	indent-tabs-mode nil)
  ;; auto-newline and hungry-delete
  (c-toggle-auto-hungry-state 1)
  (define-key c-mode-map "\C-m" 'newline-and-indent)
  ) 
(add-hook 'c-mode-common-hook 'ingos-c-mode-common-hook)


;; please handle .hpp as cc-mode files
(setq auto-mode-alist (cons '("\\.hpp$" . c++-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.yac$" . c++-mode) auto-mode-alist))
;;(setq auto-mode-alist (cons '("\\.lex$" . c++-mode) auto-mode-alist))

;; ---------------------------------------------------------------------------
;; activate Python mode 
;; available at: http://www.python.org/emacs/python-mode/
;; ---------------------------------------------------------------------------
(setq auto-mode-alist
      (cons '("\\.py$" . python-mode) auto-mode-alist))
(setq interpreter-mode-alist
      (cons '("python" . python-mode)
            interpreter-mode-alist))
(autoload 'python-mode "python-mode" "Python editing mode." t)

;; ---------------------------------------------------------------------------
;; REXX mode (Do I still need this one ? It's some years ago that I've 
;; developed for OS/2)
;; I don't need it anymore, but I'll leave it here. Maybe somebody is
;; interested in this.
;; ---------------------------------------------------------------------------
;; (setq auto-mode-alist (cons '("\\.cmd$" . rexx-mode) auto-mode-alist))
;; (autoload 'rexx-mode "rexx-mode")
;; (setq rexx-command-auto-upper t)
;; (setq rexx-external-function-auto-capitilize t)
;; (setq rexx-auto-build-procedure-table t)
;; If you want to enable very high level completion, add:
;;   (setq rexx-super-completion-mode)

;; ---------------------------------------------------------------------------
;; add some extensions to be handled as pascal files 
;; ---------------------------------------------------------------------------
(setq auto-mode-alist
      (append '(("\\.inc$"  . pascal-mode)
		("\\.pc$"   . pascal-mode)
		("\\.mde$"  . pascal-mode)
		("\\.rx1$"  . pascal-mode)
               )
	      auto-mode-alist))

;; ---------------------------------------------------------------------------
;; Load a better perl
;; ---------------------------------------------------------------------------
(autoload 'perl-mode "cperl-mode" "better mode for editing Perl programs" t)

;; ---------------------------------------------------------------------------
;; Do an autoinsert of the top of programming language files (currently C/C++)
;; ---------------------------------------------------------------------------
(add-hook 'find-file-hooks 'auto-insert)
(setq c-companion-file "Headder.c")

;; ***************************************************************************
;;                  useful things for programing
;;
;; ***************************************************************************
;; ---------------------------------------------------------------------------
;; hilight the matching paren
;; ---------------------------------------------------------------------------
(show-paren-mode 1)
;; ---------------------------------------------------------------------------
;; I'd like to have tmake -f instead of make -k for building  
;; ---------------------------------------------------------------------------
(setq compile-command "tmake ")
(setq compilation-read-command nil)

;; ---------------------------------------------------------------------------
;; load this lovely jde package
;; developed by Paul Kinnucan 
;; available at http://sunsite.auc.dk/jde/
;; ---------------------------------------------------------------------------
(require 'jde) 
;; The rest is done by the java mode hook, so I don't have to do any more
;; here
;; ---------------------------------------------------------------------------
;; the next two belong to the jde contributions
;; ---------------------------------------------------------------------------
(require 'jdok)
(require 'jmaker)

;; ---------------------------------------------------------------------------
;; Browse the javadoc for the word under the cursor. Helpful !
;; ---------------------------------------------------------------------------
(setq max-specpdl-size 50000)
(setq max-lisp-eval-depth 50000)
(load "javahelp")

(global-set-key '[f1] 'javahelp-search)

;; ---------------------------------------------------------------------------
;; Install the support to decompile java class files.
;; I've modified Jake Donhams mocha support to use jad for decompiling.
;; This is available as javadecomp.el in the IngoKoch.zip file
;; ---------------------------------------------------------------------------
(require 'javadecomp)

;; ---------------------------------------------------------------------------
;; Browse the javadoc for the word under the cursor. Helpful !
;; Well, after some difficulties and workarounds, it works 8-))
;; available at: http://www.kclee.com/clemens/java/browsejavadoc/index.html
;; ---------------------------------------------------------------------------
;; commented out because I'm currently using javahelp (see above)
;(autoload 'browse-javadoc "browse-javadoc"
;          "Read the java-api documentation of the keyword your cursor is over in a web browser." t)
;;; help
;(defun my-help ()
;  (interactive)
;  (if (string= major-mode "jde-mode")
;      (browse-javadoc)
;  ;; Well, this is Clemens path, I don't have a help.info, so 
;  ;; I'll leave it untouched 8-))
;  (info "h:\\eigen\\edit\\emacs\\info\\help.info")
;   )
;)
;(global-set-key [f1] 'my-help)

;; ---------------------------------------------------------------------------
;; This one is taken from an answer to the ntemacs-users mailing list
;; posted by David Gallucci. This is really helpfull. Thanks a lot.
;; It is available in his .emacs on my .emacs site 
;; www.ikoch.de/dotfiles/DaveGallucci.emacs.html
;; (or here 8-) ):
;; ---------------------------------------------------------------------------
;; This allows you to keep a tags stack and push and pop your
;; way around the source code. This feature is present in both
;; XEmacs and VI. Pop tag is mapped to M-*.
(global-set-key (read-kbd-macro "M-*") 'tags-return)

(defvar tags-stack nil)

(defun tags-stack-push (el)
  (setq tags-stack (cons el tags-stack)))

(defun tags-stack-pop ()
  (let ((el (car tags-stack)))    
    (setq tags-stack (cdr tags-stack))
    el))

(defadvice find-tag (before push-tag activate)  
  (or (ad-get-arg 1)
      (tags-stack-push (cons (current-buffer) (point)))))

(defadvice tags-search (before push-tag activate)
  (tags-stack-push (cons (current-buffer) (point))))

(defun tags-return ()
  (interactive) 
  (let* ((el (tags-stack-pop))  
         (buffer (car el))
         (point  (cdr el)))
    (if buffer (switch-to-buffer buffer))
    (if point (goto-char point))))


;; ---------------------------------------------------------------------------
;; Author: Hrvoje Niksic <hniksic@srce.hr>
;; available at http://jagor.srce.hr/~hniksic/htmlize.el
;; This is the package I've htmlized the files on the site with !
;; It works fine for all font-locked buffers.
;; ---------------------------------------------------------------------------
(require 'htmlize)

;; ---------------------------------------------------------------------------
;; Html helper mode is an Emacs Lisp major mode for editing HTML files witten 
;; by Nelson Minar and now mantained by Gian Uberto Lauri lauri@mail.eng.it 
;; available at: http://www.gest.unipd.it/~saint/hth.html
;; Very helpful !
;; ---------------------------------------------------------------------------
(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))

;; ---------------------------------------------------------------------------
;; Let's see wether gnus works:
;; It works.
;; ---------------------------------------------------------------------------
(setq gnus-select-method '(nntp "192.168.146.140"))


;; ***************************************************************************
;;                        The dark side of the moon
;;
;; Everything up to the next (final) section are my personal test entries.
;; I try them, I play with them and I'll use them if they fit to my personal 
;; needs. 
;; 
;; Thanks to everybody who contributes her/his work to this wonderful editor !
;;
;; ***************************************************************************

;; ---------------------------------------------------------------------------
;; modified dired 
;; does anybody remember, what it was good for ?
;; I'd take a look at it's documentation again !
;; ---------------------------------------------------------------------------
(add-hook 'dired-load-hook
   (function (lambda ()
      (load "dired-x")
      ;; Set dired-x global variables here.  For example:
      ;; (setq dired-guess-shell-gnutar "gtar")
      ;; (setq dired-x-hands-off-my-keys nil)
      ;;; Files or directories I don't want to see in dired mode:
      ;;; directory RCS, anything ending with ,v  or obj or rim
      (setq dired-omit-files
      (concat dired-omit-files "\\|^RCS$\\|^CVS$\\|,v$\\|.*\\.obj$\\|rim$\\|bin$"))
      (setq  dired-omit-files-p t)
       )))
(add-hook 'dired-mode-hook
   (function (lambda ()
      ;; Set dired-x buffer-local variables here.  For example:
      ;; (setq dired-omit-files-p t)
      )))

;; ---------------------------------------------------------------------------
;; eshell
;; ---------------------------------------------------------------------------
(load "eshell-auto")
(load "pcmpl-auto")
(add-hook 'shell-mode-hook 'pcomplete-shell-setup)

(require 'bbdb)          
(bbdb-initialize)

(setq bbdb-use-pop-up nil
      bbdb-completion-display-record nil)
;; ---------------------------------------------------------------------------
;; w3 - emacs as a html Browser !!
;; available at: http://www.cs.indiana.edu/l/www/elisp/w3/docs.html
;; I'll give it a try
;; Giving it a try, I see there are better possibilities available.
;; ---------------------------------------------------------------------------
;;(require 'w3-auto)

;; ---------------------------------------------------------------------------
;; German umlauts 
;; This cuts Mule out of the menue, but as I didn't get the expeceted results
;; while having mule active, this doesn't bother me
;; ---------------------------------------------------------------------------
;;(standard-display-european t) (require 'iso-syntax) 
;;(standard-display-european t) (require 'latin-1)
;;(set-language-environment "Latin-1")
;;(standard-display-european 1)

;; ---------------------------------------------------------------------------
;; after some TeX-free and Word-full-of-errors years I'll try TeX again.
;; This way I'll need AucTeX 8-))
;; available at: http://sunsite.auc.dk/auctex/
;; ---------------------------------------------------------------------------
(load "tex-site")

;; ---------------------------------------------------------------------------
;; OO-Browser has made his way in here 8-))
;; available at http://www.beopen.com
;; ---------------------------------------------------------------------------
;; (load "br-start")

;; ***************************************************************************
;;  useful defuns stolen from other dotfiles or written on my own
;; ***************************************************************************

(defun sum-column (start end arg)
  "Add up (presumed) numbers in the column defined by START and END.
Insert if ARG."
  (interactive "r\nP")
  (if (< end start) (let (tmp)
		      (setq tmp start)
		      (setq start end)
		      (setq end tmp)))
  (save-excursion
    (goto-char start)
    (let ((numcol (current-column))
	  (numend (save-excursion (goto-char end) (current-column)))
	  (sum 0))
      (while (< (point) end)
	(setq sum (+ sum (string-to-number
			  (buffer-substring (point)
					    (progn
					      (move-to-column numend t)
					      (point))))))
	(beginning-of-line 2)
	(move-to-column numcol t))
      (if arg (insert (number-to-string sum)))
      (message "Total: %.2f" sum))))


;; ***************************************************************************
;;                       This is the end, my friend
;; ***************************************************************************

;; ---------------------------------------------------------------------------
;; If not in text-mode, I'd like to have some nice features bound to the
;; right (third one on my M$-mouse, see above 8-))) ) mouse button.
;; By the way, I hate this kill and yank stuff beeing bound to a mouse click !
;; ---------------------------------------------------------------------------
(cond (window-system
       ;; imenu works great, is part of the standard distribution
       ;; and is used by a lot of packages. This way, it is a better choice
       ;; than func-menu.
       (define-key global-map [mouse-3] 'imenu)
       ;; SHIFT-right mouse button: give me a list of bookmarks
       (define-key global-map [S-mouse-3] 'bookmark-menu-jump)
       ;; CTRL-right mouse button: set a bookmark
       (define-key global-map [C-down-mouse-3] 'bookmark-set)
       ))

;; ---------------------------------------------------------------------------
;; redefine some keys to my own preferences
;; I have moved this one near to the end, because there are a lot of packages
;; which try to redefine keys. I'd like to have these:
;; ---------------------------------------------------------------------------
(define-key global-map [f2]  'save-buffer)
(global-set-key [f3]         'kill-this-buffer)
(global-set-key [f4]         'find-file)
(global-set-key [f5]         'indent-region)

(global-set-key [S-f5]       'indent-rigidly)
(global-set-key [f6]         'increase-left-margin)
(global-set-key [S-f6]       'decrease-left-margin)
(global-set-key [f7]         'tags-return)
(global-set-key [f8]         'find-tag)
(global-set-key [S-f8]       'find-tag-other-window)

(global-set-key [f10]        'expand-abbrev)
(global-set-key [S-f10]      'write-abbrev-file)
(global-set-key [C-f10]      'read-abbrev-file)

(global-set-key [C-f10]      'ediff-revision)
(global-set-key [C-f11]      'desktop-save)
(global-set-key [C-f12]      'desktop-read)
(global-set-key [home]       'beginning-of-line)
(global-set-key [end]        'end-of-line)
(global-set-key [C-home]     'beginning-of-buffer)
(global-set-key [C-end]      'end-of-buffer)
(global-set-key [C-pageup]   'beginning-of-defun)
(global-set-key [C-pagedown] 'end-of-defun)
(global-set-key [f9 ?c]      'compile)
(global-set-key [S-f9]       'jde-compile)

;; ---------------------------------------------------------------------------
;; Date and time are a nice option for the mode line, that way you'll always
;; see if it's lunch or closing time and you know what you are missing because
;; you can't go to lunch or go home (your project is late, isn't it ?).
;; But seriously, this is the last entry because emacs stops to read the 
;; .emacs if an error occurs. This way (taking only a quick look at the mode 
;; line) I can see wether .emacs was fully loaded or not. 
;; If I don't see date and time, my .emacs has to be debugged again 8-((
;; I think this idea is stolen from Shane Steele's .emacs
;; ---------------------------------------------------------------------------
(setq display-time-day-and-date t
      display-time-24hr-format t)
(display-time)

;; ---------------------------------------------------------------------------
;; Tell custom to use a separate file for the custom-set-variables and
;; load them from there. This throws the custom-set stuff out of my .emacs
;; into its own file. 
;; Be careful: any customizations via Customize will override the settings
;; in your dotfile. You won't be warned by customize !
;; ---------------------------------------------------------------------------
(setq custom-file "~/.mycustom")
(load custom-file)

(message ".emacs-gnu-all successfully loaded")

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:57:05 2005 by Ingo Koch