.emacs configuration notes

Below are some configuration notes for your .emacs file.
By default .emacs is found in your "c:/documents and settings/<your-login-id>/Application Data" folder.
If you set a HOME system variable, .emacs will be found in the HOME directory.

Below are setting I have used over the years, not necessarily all at the same time. Pick and choose what you need.


Global settings

; For all buffers
(global-font-lock-mode 1) 
(show-paren-mode t);show matching parentheses
(cua-enable-cua-keys t);allows me to use Windows shortcut keys. Must install cua-mode.el
(cua-mode t nil (cua-base))
(tool-bar-mode nil);I don't like tool bars
(transient-mark-mode t);highlight marked regions when selecting code
(global-set-key (kbd "<f12>") 'other-window)
(global-set-key (kbd "<f2>") 'switch-to-buffer)
(global-set-key (kbd "<f1>") 'find-file)

;Define a key to load and run your current project of interest file
(defun load-and-run-fave-file()
  (interactive)
  (load "my-favorite-file.el"))

(global-set-key (kbd "<f6>") 'load-and-run-fave-file)

EMACS Lisp

;;;;    Programming - Elisp

(add-hook 'emacs-lisp-mode-hook
	  '(lambda ()
	     (interactive)
	     (require 'eldoc)
	     (turn-on-eldoc-mode)
	     (define-key emacs-lisp-mode-map [f5] 'eval-region)
	     (define-key emacs-lisp-mode-map [f4] 'eval-buffer)))
Note that below I use F5 in R mode to evaluate a region. Whichever mode I am in, R or Lisp, F5 evaluates a region.


R

;;;; R  Setup
 (require 'ess-site)

(defun my-ess-mode ()
  (interactive)
  (cond ((string= "R" ess-dialect)
	 (message "my-r-mode")
	 ;; customization for ESS[R] here
	 (define-key ess-mode-map '[f5] 'ess-eval-region-and-go))))

;and then hook this into the appropriate place:

(add-hook 'ess-mode-hook 'my-ess-mode)    

SLIME

;; 1. Start the CL first with "M-x clisp-start" (or equivalent) from Emacs 
;; 2. Start the SLIME connection with "M-x slime-connect RET RET RET" from Emacs

;for Common Lisp
;(defun clisp-start ()
;  (interactive)
; (shell-command (concat "c:/clisp-2.43/full/lisp.exe" ;
;			 "-B c:/clisp-2.43/full/ "
;			 "-M c:/clisp-2.43/full/lispinit.mem "
;			 "-i c:/emacs-22.1/site-lisp/.slime.lisp "
;			 "-ansi -q&")))

;(defun sbcl-start ()
;	 (interactive) 
;	(shell-command (concat "c:/sbcl-1.0.13/sbcl.exe" 
					" --dynamic-space-size 64" 
					" --noinform"))) 
(defun sbcl-start () 
	(interactive) 
	(shell-command "c:/sbcl-1.0.13/sbcl.exe --core c:/sbcl-1.0.13/sbcl.core --load c:/emacs-22.1/site-lisp/.slime.lisp &")) 

(setq load-path (append (list "c:/emacs-22.1/site/slime-2.0")
                        load-path))

(require 'slime)
(add-hook 'lisp-mode-hook (lambda () (slime-mode t)))
(add-hook 'inferior-lisp-mode-hook (lambda () (inferior-slime-mode t)))
;; If you don't want eldoc-like behavior, comment out the following line
(slime-autodoc-mode)

;M-x run-lisp;  M-x slime

(setq inferior-lisp-program "c:/sbcl-1.0.13/sbcl.exe --core c:/sbcl-1.0.13/sbcl.core --userinit c:/sbcl-1.0.13/sbcl-init2.lisp")
(require 'slime)
(slime-setup) 

Clojure

(setq load-path (append (list "c:/emacs-22.3/site-lisp/slime-2009-06-28")
                        load-path))
(require 'slime)
(slime-setup) 

(setq inferior-lisp-program
                                        ; Path to java implementation
      (let* ((java-path "java")
                                        ; Extra command-line options
                                        ; to java.
             (java-options "")
                                        ; Base directory to Clojure.
                                        ; Change this accordingly.
             (clojure-path "c:/mortimer/classes/clojure/")
                                        ; The character between
                                        ; elements of your classpath.
             (class-path-delimiter ";")
             (class-path (mapconcat (lambda (s) s)
                                        ; Add other paths to this list
                                        ; if you want to have other
                                        ; things in your classpath.
                                    (list (concat clojure-path "clojure.jar"))
                                    class-path-delimiter)))
        (concat java-path
                " " java-options
                " -cp " class-path
                " clojure.lang.Repl")))

(require 'clojure-mode)

(setq auto-mode-alist
      (cons '("\\.clj$" . clojure-mode)
            auto-mode-alist))

JDEE

(setq defer-loading-jde t) 
;; 

(if defer-loading-jde 
    (progn 
      (autoload 'jde-mode "jde" "JDE mode." t) 
      (setq auto-mode-alist 
	    (append 
	     '(("\\.java\\'" . jde-mode)) 
	     auto-mode-alist))) 
  (require 'jde)
  (load "jde-ant")) 

;; Sets the basic indentation for Java source files 
;; to two spaces. 

(defun my-jde-mode-hook () 
	(setq c-basic-offset 2)
        ( define-key jde-mode-map '[f5] 'jde-build) ) 

(add-hook 'jde-mode-hook 'my-jde-mode-hook) 

(cond ((fboundp 'global-font-lock-mode)
       ;;Turn on font-lock in all modes that support it
      (global-font-lock-mode t)
       ;;Maximum colors
      (setq font-lock-maximum-decoration t)))

(jde-ant-args "-emacs")
(jde-ant-buildfile "c:\\classes\\prs500mngr\\bin\\build.xml")
(jde-ant-complete-target t)
(jde-ant-enable-find nil)
(jde-ant-home "c:\\classes\\org\\apache-ant-1.7.1")
(jde-ant-program "c:\\classes\\prs500mngr\\bin\\ant")
(jde-ant-read-buildfile t)
(jde-ant-read-target nil)
(jde-ant-working-directory "c:\\classes\\prs500mngr\\bin\\")
(setenv "ANT_HOME" "c:\\classes\\org\\apache-ant-1.7.1")

ORG mode

(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
     (global-set-key "\C-cl" 'org-store-link)
     (global-set-key "\C-ca" 'org-agenda)

(require 'org)

(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))

(define-key mode-specific-map [?a] 'org-agenda)

(eval-after-load "org"
  '(progn
     (define-prefix-command 'org-todo-state-map)

     (define-key org-mode-map "\C-cx" 'org-todo-state-map)

     (define-key org-todo-state-map "x"
       #'(lambda nil (interactive) (org-todo "CANCELLED")))
     (define-key org-todo-state-map "d"
       #'(lambda nil (interactive) (org-todo "DONE")))
     (define-key org-todo-state-map "f"
       #'(lambda nil (interactive) (org-todo "DEFERRED")))
     (define-key org-todo-state-map "l"
       #'(lambda nil (interactive) (org-todo "DELEGATED")))
     (define-key org-todo-state-map "s"
       #'(lambda nil (interactive) (org-todo "STARTED")))
     (define-key org-todo-state-map "w"
       #'(lambda nil (interactive) (org-todo "WAITING")))

     (define-key org-agenda-mode-map "\C-n" 'next-line)
     (define-key org-agenda-keymap "\C-n" 'next-line)
     (define-key org-agenda-mode-map "\C-p" 'previous-line)
     (define-key org-agenda-keymap "\C-p" 'previous-line)))

(require 'remember)

(add-hook 'remember-mode-hook 'org-remember-apply-template)

(define-key global-map [(control meta ?r)] 'remember)
'(org-agenda-custom-commands (quote (("d" todo #("DELEGATED" 0 9 (face org-warning)) nil) ("c" todo #("DONE|DEFERRED|CANCELLED" 0 23 (face org-warning)) nil) ("w" todo #("WAITING" 0 7 (face org-warning)) nil) ("W" agenda "" ((org-agenda-ndays 21))) ("A" agenda "" ((org-agenda-skip-function (lambda nil (org-agenda-skip-entry-if (quote notregexp) "\\=.*\\[#A\\]"))) (org-agenda-ndays 1) (org-agenda-overriding-header "Today's Priority #A tasks: "))) ("u" alltodo "" ((org-agenda-skip-function (lambda nil (org-agenda-skip-entry-if (quote scheduled) (quote deadline) (quote regexp) "<[^>
]+>"))) (org-agenda-overriding-header "Unscheduled TODO entries: "))))))
(org-agenda-files (quote ("~/todo.org" "b:/private/2008/recur.org")))
(org-agenda-ndays 7)
(org-agenda-show-all-dates t)
(org-agenda-skip-deadline-if-done t)
(org-agenda-skip-scheduled-if-done t)
(org-agenda-start-on-weekday nil)
(org-deadline-warning-days 14)
(org-default-notes-file "~/notes.org")
(org-fast-tag-selection-single-key (quote expert))
(org-remember-store-without-prompt t)
(org-remember-templates (quote ((116 "* TODO %?
  %u" "~/todo.org" "Tasks") (110 "* %u %?" "~/notes.org" "Notes"))))
(org-reverse-note-order t)
(remember-annotation-functions (quote (org-remember-annotation)))
(remember-handler-functions (quote (org-remember-handler)))


Last modified: 10 October 2010