SITM Emacs

I've got so many Stick In The Mud emacs customizations, they need their very own web page:

I'm a seven bit ASCII kind of guy. If a file I'm looking at has unicode or DOS CR-LF line ends or other such nonsense, I damn well want to know about it, I don't want it “helpfully” hidden from me. I don't even want DOS line endings when I'm on Windows Emacs because the only program on Windows that actually cares about CR-LF is the stoopid notepad.exe program I never use. Here's my lisp solution:

; guess we are running on windows if the window system says so or if the
; default directory looks like it starts with a drive letter spec.
;
(setq this-is-w32 (or (eq window-system 'w32)
         (equal (string-match "^[A-Za-z]:[/\\]" default-directory) 0)))

; This .emacs file is for a reactionary DOS/Unicode hating stick in the mud
; seven bit ascii old time programmer who damn well wants to see files that
; are filled with crap instead of being lulled into the belief that the file
; he is looking at is perfectly normal when, in fact, it has been corrupted
; by all those new fangled modern character set ideas...
;
(setq default-enable-multibyte-characters nil)  ; NO Unicode!!!!
(setq inhibit-iso-escape-detection t)           ; NO Unicode Again!!!
(set-language-environment "ASCII")              ; NO 8-bit characters!!
(setq inhibit-eol-conversion t)                 ; NO CR-LF!
(if this-is-w32
   (progn

      ; Stamp out the obnoxious setting of new files to CR-LF mode by
      ; default on w32 systems. Beacuse the dos-w32 function sets up these
      ; hooks when it is loaded, I need to load it merely so I can stamp out
      ; the hooks (never figured out how to keep it from being loaded in the
      ; first place - sigh...).

      (require 'dos-w32)
      (remove-hook 'find-file-not-found-hooks 
                   'find-file-not-found-set-buffer-file-coding-system) ) )

The emacs windows have acquired a lot of space wasting frills over the years (menu bars, toolbars, scrollbars, fringes, etc). Fortunately they can all be squashed like bugs, leaving the entire window for the text God intended to be there.

; Functions for diddling the frame alist data which will be used in just
; a bit to setup the frames the way I like 'em.

(defun modify-alist (alist key val)
"Modify the alist ALIST to contain (KEY . VAL) replacing any existing
KEY or adding new one if KEY not already in alist"
   (let ( (elt (assoc key (symbol-value alist))) )
      (if elt
         (setcdr elt val)
         (set alist (cons (cons key val) (symbol-value alist))) )
      alist ) )

(defun modify-initial-frame-alist (key val)
"Modify initial-frame-alist to contain (KEY . VAL)"
   (modify-alist 'initial-frame-alist key val) )

(defun modify-default-frame-alist (key val)
"Modify default-frame-alist to contain (KEY . VAL)"
   (modify-alist 'default-frame-alist key val) )

(defun modify-both-frame-alists (key val)
"Modify both initial-frame-alist and default-frame-alist to contain (KEY . VAL)"
   (modify-initial-frame-alist key val)
   (modify-default-frame-alist key val) )

; Note: i-want-background and i-want-foreground need to be set to the
; desired background and foreground colors before you get here.
;
(if (or (eq window-system 'x) (eq window-system 'w32))
   (progn
      (modify-both-frame-alists      'wait-for-wm          nil)
      (modify-both-frame-alists      'cursor-color         "brown4")
      (modify-both-frame-alists      'mouse-color          "green")
      (modify-both-frame-alists      'background-color     i-want-background)
      (modify-both-frame-alists      'foreground-color     i-want-foreground)
      (modify-both-frame-alists      'vertical-scroll-bars nil)
      (modify-both-frame-alists      'menu-bar-lines       0)
      (modify-both-frame-alists      'left-fringe          0)
      (modify-both-frame-alists      'tool-bar-lines       0)
      (set-face-background           'fringe               i-want-background)
      (if (fboundp 'blink-cursor-mode)
         (blink-cursor-mode 0) )
      (if (fboundp 'menu-bar-mode)
         (menu-bar-mode -1) ) ) )

Next a whole slew of little individual irritants I've squashed over the years...

; No shell history files cluttering up the disk

(setq comint-input-ring-file-name "")

; Just feed what I type to the shell, don't help me by magically
; transmogrifying some random "special" characters into something I not only
; didn't type, but didn't want to type (sheesh!).

(setq comint-input-autoexpand nil)

; I get font-lock squashed everywhere and comint goes and implements
; its own highlighting junk. Squash it too.

(setq comint-highlight-input nil)
(setq comint-highlight-prompt nil)

; If they work hard, they can make emacs shell mode as stupid and
; annoying as a real terminal, but I can make it stop too...

(setq comint-scroll-show-maximum-output nil)

; Get the insanely annoying mouse-face stuff squashed in comint-mode

(defun toms-comint-mode-hook ()
"Disable mouse face in shells"
   (set (make-local-variable 'mouse-highlight) nil)
)
(add-hook 'comint-mode-hook 'toms-comint-mode-hook)

; I don't need thousands of saved emacs session files in my home directory,
; and I don't even want to save the sessions. I like starting with a nice
; clean emacs and not restoring the massive clutter from the previous
; session. I'm probably working on something different today anyway.

(setq auto-save-list-file-prefix nil)

; There is only one sure fire way to make emacs shut its damn piehole and
; keep it shut, and this is it. Tell it to use an audible bell, then tell it
; to ring that bell by doing absolutely nothing.

(defun really-no-bell ()
"Do nothing so the bell won't ring even when emacs tries..."
   (interactive) )
(setq visible-bell nil)
(setq ring-bell-function 'really-no-bell)

; Emacs has this strange idea that when I go to all the trouble to run
; certain sets of functions, it should ask if I meant that.  This
; permanently records the answer "YES DAMMIT, I MEANT THAT!!!"

(put 'upcase-region 'disabled nil)
(put 'erase-buffer 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'eval-expression 'disabled nil)

; Emacs has long implemented a security hole far bigger than any Microsoft
; ever accidentally created, and these are *deliberate* no less.  Let's turn
; this "feature" off.

(setq enable-local-variables nil)
(setq enable-local-eval nil)

; I've seen this once, I don't need to see it every damn time I start emacs.

(setq inhibit-startup-message t)

; People who put TAB characters in files should be shot. Either that or
; people who write editors which display TABs on anything other than an 8
; character boundaries should be shot. Come to think of it, shooting them is
; too merciful - they should be skinned alive and dropped into a vat of salt
; and alchohol! In any case, the combination of the two means no one can
; ever figure out what the file is supposed to look like, but at least I can
; have mercy on the people trying to read my source by never using TABs
; even if the rest of the universe is filled with tab-happy morons.

(setq-default indent-tabs-mode nil)

; The iDEa thAt EmacS can CorRecTlY guess THE case you "waNt" things
; exPandeD as is ludicrous. Disabuse it of this fantasy.

(setq dabbrev-case-replace nil)

; I need "helpful" messages distracting me in the minibuffer about as much
; as I need an animated paper clip tapping on the inside of my screen
; and screaming "Hey Guys! Look at me!!!"

(setq suggest-key-bindings nil)

; Another amazing innovation from emacs21 - hiding most of the results
; of an eval, let's not do that...

(setq eval-expression-print-length nil)

; GAAAAH! Emacs 22 invents yet more new ways to foist modes on me.
(setq magic-mode-alist nil)
(setq interpreter-mode-alist nil)
(setq auto-mode-interpreter-regexp "[^\000-\377]")

; Stop the annoying emacs 22 cursor shape changes in text windows
(setq void-text-area-pointer 'text)

; Wipe out yet more font-lock paint factory explosions in emacs 22
(if (fboundp 'global-font-lock-mode)
         (global-font-lock-mode nil)
(if (fboundp 'jit-lock-mode)
         (jit-lock-mode nil)

; My GOD! Emacs22 compile and grep buffers look like an explosion in a
; combined paint and fireworks store! I can barely see any actual
; information through the glare. Install a bunch of hooks to remove the face
; and mouse-face text properties as fast as they are added in.
;
(defun squash-font-lock-end (dummy1 dummy2)
"Cleanup any font lock nonsense that may have been missed by filter."
   (setq squash-font-lock-last-pos (point-min))
   (squash-font-lock))

(defun squash-font-lock-begin ()
"At start of compilation mode make variable we can use to track how
much text we have fixed so far."
   (make-variable-buffer-local 'squash-font-lock-last-pos)
   (setq squash-font-lock-last-pos (point-min))
   (add-hook 'compilation-finish-functions 'squash-font-lock-end))

(defun squash-font-lock ()
"Ratchin satchel matta fratchin...
Emacs has bound itself hand and foot with font-lock mode
for things like compilation and grep buffers. So, use this hook
to turn off all the glaring face and mouse-face properties while
leaving the other properties emacs uses for things like grep
hits intact."
   (let
      ((orig-buffer-read-only buffer-read-only)
       (last-pos (save-excursion
                    (goto-char squash-font-lock-last-pos)
                    (forward-line -4)
                    (point)))
       (this-pos (point-max)))
      (setq buffer-read-only nil)
      (remove-text-properties last-pos this-pos '(face nil))
      (remove-text-properties last-pos this-pos '(mouse-face nil))
      (setq squash-font-lock-last-pos this-pos)
      (setq buffer-read-only orig-buffer-read-only)))

(add-hook 'compilation-mode-hook 'squash-font-lock-begin)
(add-hook 'compilation-filter-hook 'squash-font-lock 'append)
(setq grep-highlight-matches nil)

; Tooltips are another annoying new emacs21 innovation. Not sure how to
; eradicate them entirely, but I can make sure they are highly unlikely to
; appear by setting the delay time high enough.

(setq tooltip-delay 5000)

; Like tooltips, the hourglass cursor change emacs21 has is annoying. Do the
; same trick to set the delay time so high I'll never see it.

(setq hourglass-delay 5000)

I've probably got even more of these scattered around, but these were the major ones I've fixed.

Page last modified Sat Aug 9 20:24:20 2008