Defindit Docs and Howto Home
This page last modified: Dec 02 2009
;; Tom Laudeman's .emacs file.
;; Enable EasyPG
; (require 'epa-setup)
; (epa-file-enable)
;; Skip the startup "message", which looks like a "screen" or
;; "splash". Whatever. This makes it not appear.
(setq inhibit-startup-message t)
;; Not sure what these skip, but I doubt I want to see the splash or
;; startup screen.
(setq inhibit-startup-screen t)
(setq inhibit-splash-screen t)
;; http://www.emacswiki.org/emacs/CuaMode
(cua-mode t)
;; Don't tabify after rectangle commands
(setq cua-auto-tabify-rectangles nil)
;; No region when it is not highlighted
(transient-mark-mode 1)
;; Standard Windows behaviour is t, but since I usually use a C-x
;; command immediately after copy, I have it set to nil
(setq cua-keep-region-after-copy nil)
;; makes killing/yanking interact with clipboard X11 selection
(setq x-select-enable-clipboard t)
;; Enable ido-mode for fancy completion on buffer switch and file
;; open. We don't seem to need the require 'ido in recent versions of
;; Emacs. http://www.emacswiki.org/cgi-bin/wiki/InteractivelyDoThings
(ido-mode t)
;; Tell emacs that read-only files whether write protected on disk or
;; set to read-only via toggle-read-only are *not* editable. The
;; normal "can't edit" was broken somewhere around version 22.1.1 and
;; now it insists on using the version control system (which doesn't
;; work either).
(setq view-mode-only t)
;; Disable the damnable hard to read colorized source code, aka syntax
;; highlighting. Automatically becomes buffer-local when set in any
;; fashion, so you have to use the global version of the function.
;; (Font Lock is also known as "syntax highlighting".) For more info
;; do describe-function on font-lock-mode (Yes, there is a variable
;; and a function with the same name, apparently.) This does not
;; work: (setq font-lock-mode nil) Emacs gets upset when calling the
;; function global-font-lock-mode with an arg nil, so I call it with
;; zero and that's fine. All this time I thought nil was a value.
;; (global-font-lock-mode nil)
;; (global-font-lock-mode 0)
;; This works.
(setq font-lock-global-modes '(not perl-mode))
;; This works now that the defun is correct. Don't need it, but I've
;; left it here for historical purposes.
;; (defun turn-off-font-lock ()
;; "Disable font-lock-mode"
;; (interactive)
;; (font-lock-mode nil))
;; (add-hook 'perl-mode-hook 'turn-off-font-lock)
;; Non-nil inhibits the startup screen.
;; It also inhibits display of the initial message in the `*scratch*' buffer.
(setq inhibit-splash-screen t)
;; Paste (yank) at the text cursor location, not at the
;; location of the mouse pointer. This only applies to graphical (X)
;; emacs sessions.
(setq mouse-yank-at-point t)
;; Disable the nasty zmacs region highlighting in xemacs. Having it on
;; breaks mark-search-cut behavior.
(setq zmacs-regions nil)
;; Uncomment to automatically load ispell at startup.
;(load "ispell")
;; Uncomment for hexl
;(autoload 'hexl-find-file "hexl" "Edit file FILENAME in hexl-mode." t)
;(define-key global-map "\C-c\C-h" 'hexl-find-file)
;; Uncomment if you like lots of backup versions
;(setq version-control t)
;; Stop emacs from automatically converting end of line characters.
;; Auto converting Windows or Mac eol to Linux eol can be really, really
;; confusing.
(setq inhibit-eol-conversion t)
;; Prevent loading default.el.
(setq inhibit-default-init 1)
;; valid values for require-final-newline
;; nil
;; t
;; (quote query)
(setq require-final-newline nil)
;; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs
(defvar user-minor-mode-map (make-sparse-keymap) "user-minor-mode keymap.")
(define-minor-mode user-minor-mode
"A minor mode so that my key settings override annoying major modes."
t
" user-keys"
'user-minor-mode-map)
;; Turn user-minor-mode on/off 1/0 in the mini-buffer.
;; Oct 5 2009 Was 1 which was clearly a mistake.
(defun user-minibuffer-setup-hook ()
(user-minor-mode 0))
(add-hook 'minibuffer-setup-hook 'user-minibuffer-setup-hook)
(user-minor-mode 1)
;; No need to do the uppercase and lowercase versions of keystrokes since
;; that is the default. C-xf also matches C-xF
;; (defun noop ()
;; "Noop for disabled keys"
;; (interactive)
;; ;; print a useful message in the mini-buffer
;; nil
;; )
;; Unset certain undo bindings because I hit \C-? which turns out to be
;; identical to \C-_
;; Even though \C-/ won't (apparently) do anything in -nw mode,
;; unset it anyway so I don't hit it in windowing mode.
;; (define-key user-minor-mode-map "\C-_" 'noop)
;; (define-key user-minor-mode-map (kbd "C-/") 'noop)
;; Default is to center text. Too close to M-C-s and I never use
;; it. Disable. In a lisp eval window, it didn't like the usual
;; shortcuts for Meta, so I just inserted an escape char.
;; (define-key user-minor-mode-map "s" 'noop)
(define-key user-minor-mode-map "\C-xt" 'font-lock-mode)
(define-key user-minor-mode-map "\C-[#" 'comment-region)
(define-key user-minor-mode-map "\C-x#" 'comment-region)
(define-key user-minor-mode-map "\C-s" 'search-forward)
(define-key user-minor-mode-map "\C-r" 'search-backward)
(define-key user-minor-mode-map "\C-x\C-n" 'next-error)
(define-key user-minor-mode-map "\C-x\C-p" 'previous-error)
(define-key user-minor-mode-map "\C-xc" 'compile)
(define-key user-minor-mode-map "\C-h" 'backward-delete-char)
(define-key user-minor-mode-map "\C-[g" 'goto-line)
(define-key user-minor-mode-map "\C-xn" 'other-window)
(define-key user-minor-mode-map "\C-[q" 'query-replace)
(define-key user-minor-mode-map "\C-xf" 'find-file)
(define-key user-minor-mode-map "\C-[\C-[" 'repeat-complex-command)
(define-key user-minor-mode-map "\C-[r" 'replace-string)
(define-key user-minor-mode-map "\C-[f" 'fill-paragraph)
(define-key user-minor-mode-map "\C-z" 'advertised-undo)
(define-key user-minor-mode-map [C-S-backspace] nil) ;; control-shift-backspace
(define-key user-minor-mode-map [C-backspace] nil)
(define-key user-minor-mode-map [M-backspace] nil)
(define-key user-minor-mode-map [insert] nil)
(define-key user-minor-mode-map [insertchar] nil)
;; Standard bind is to recenter-top-bottom.
(define-key user-minor-mode-map "\C-l" 'recenter)
;; Stupid xemacs can't grok "\C-[\C-[" so re-purpose C-x[ It
;; normally means page up, but I always use ESC-v for page up.
;; (define-key user-minor-mode-map "\C-x\["
;; 'repeat-complex-command) (global-set-key "\C-x\["
;; 'repeat-complex-command)
;; Use a new function for page up and page down.
;; This one will place the cursor on the line where you started if
;; you do the opposite. The default Emacs scroll-up and scroll-down
;; don't return the cursor to the same line. That's bad.
;; This still doesn't work quite right if you hit the top or bottom of the buffer.
;; That could be fixed by remembering how far the last scroll was, and
;; reversing when necessary.
(define-key user-minor-mode-map "\C-[a" 'backward-screen)
(define-key user-minor-mode-map "\C-[z" 'forward-screen)
(define-key user-minor-mode-map [(prior)] 'backward-screen)
(define-key user-minor-mode-map [(next)] 'forward-screen)
(define-key user-minor-mode-map "\C-[p" 'down-one)
(define-key user-minor-mode-map "\C-[n" 'up-one)
;; Remap the danged downcase-region keys
;; because I'm always hitting these instead of C-l
;; C-xl might be ok. Consider commenting it out, even
;; though l is for "lower" which isn't the command. It should
;; be d for "downcase".
(define-key user-minor-mode-map "\C-[l" 'recenter)
(define-key user-minor-mode-map "\C-x\C-l" 'recenter)
;; Use new kdb syntax available as of 19.30
;; http://tiny-tools.sourceforge.net/emacs-keys.html
;; None of these work in -nw
;; ;(define-key user-minor-mode-map (kbd "C-S-N") 'up-one)
;; ;(define-key user-minor-mode-map (kbd "C-S-P") 'down-one)
;; ;(global-set-key [(control shift n)] 'up-one)
;; (list ?C-S-n (type-of ?C-S-n))
;; (list ?C-n (type-of ?C-n))
;; ;;(define-key user-minor-mode-map (kbd "C-N") 'up-one)
;; ;;(define-key user-minor-mode-map (kbd "C-P") 'down-one)
(defun forward-screen ()
"scroll down one screen in display."
(interactive)
(forward-line (- (window-height) 2)))
(defun backward-screen ()
"scroll down one screen in display."
(interactive)
(forward-line (- (- (window-height) 2))))
;; sep 19 2008 Could bind unindent and force-indent to keys, or just
;; create a keyboard macro everytime I need one of them.
(defun unindent ()
;; remove whitespace from the beginning of a line
(interactive)
(beginning-of-line)
(re-search-forward "^[ ]*")
(replace-match "")
)
(defun force-indent ()
"remove leading whitespace and insert a tab"
(interactive)
(unindent)
(insert " ")
)
;; man page mode uses one of my favorite key bindings.
;; over load it's function with mine.
(defun Man-next-manpage ()
"overload"
(interactive)
(up-one))
(defun Man-previous-manpage ()
"overload"
(interactive)
(down-one))
(defun up-one ()
"scroll up one line in display."
(interactive)
(scroll-up 1)
(forward-line 1))
(defun down-one ()
"scroll down one line in display."
(interactive)
(scroll-down 1)
(forward-line -1))
(setq auto-mode-alist (cons (cons "\\.java$" 'c-mode) auto-mode-alist))
(setq auto-mode-alist (cons (cons "\\.cgi$" 'perl-mode) auto-mode-alist))
; This is an example of keyboard rebinding on the Macintosh.
; I've preserved this for historical interest only.
; It makes these assignments:
; F5 splits the display vertically
; F6 enlarges the window containing the cursor
; F7 shrinks the window containing the cursor
; F8 eliminates all split windows
; See the file ~/lisp/mac/Macintosh-win.el for the codes to define other keys.
;; (setq mac-raw-map-hooks
;; (list
;; '(define-key mac-raw-map "\040" 'split-window-vertically)
;; '(define-key mac-raw-map "\041" 'enlarge-window)
;; '(define-key mac-raw-map "\042" 'shrink-window)
;; '(define-key mac-raw-map "\044" 'delete-other-windows)))
;; No idea what this was supposed to do.
;; (put 'downcase-region 'disabled nil)
;; (put 'upcase-region 'disabled nil)
(assq-delete-all 'font default-frame-alist)
(add-to-list
'default-frame-alist
'(font . "-Adobe-Courier-Medium-R-Normal--17-120-100-100-M-100-ISO8859-1"))
;; The font below was present in Fedora 6, but not in Fedora 8
;; Why did the available fonts change?
;; '(font . "-Adobe-Courier-Medium-R-Normal--14-140-75-75-M-90-ISO8859-1"))
;; In customization group Editing Basics, Line Move Visual controls
;; whether or not the cursor moves to logical lines or visual
;; lines. The difference is for continuation lines, the visual line is
;; the next line on the screen. The logical line is the next actual
;; line in the file, and not necessarily what is "visual" on the
;; screen. This should not be confused with visual line mode.
;; http://www.gnu.org/software/emacs/manual/html_node/emacs/Continuation-Lines.html
;; http://www.gnu.org/software/emacs/manual/html_node/emacs/Visual-Line-Mode.html#Visual-Line-Mode
;; Keywords: line wrap, wrapping, continuation, visual, logical,
;; cursor, cursor jump, cursor skip, skip line, skip continuation,
;; wrapped lines, continuation lines, line continuation, line
;; continuation mode, cursor movement mode, cursor mode, next line,
;; next logical line, skip to logical line, cursor move, line visual
;; move, line-move-visual, move logical, logical lines
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ess-S-assign "_")
'(ido-everywhere t)
'(ido-show-dot-for-dired t)
'(line-move-visual nil))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)