;; additional files
(require 'mmm-mode)
(require 'generic-x)
(require 'css-mode)
(require 'vm)
;; mail stuff
(setq sendmail-program "/usr/bin/sendmail")
;; file mappings
(mmm-add-find-file-hook)
(add-to-list 'auto-mode-alist '("\\.asp\\'" . html-mode))
(add-to-list 'auto-mode-alist '("\\.inc\\'" . html-mode))
(mmm-add-mode-ext-class 'html-mode "\\.asp\\'" 'perlscript)
(mmm-add-mode-ext-class 'html-mode "\\.inc\\'" 'perlscript)
;; key mappings
(global-set-key [M-f1] 'my-switch-0)
(global-set-key [M-f2] 'my-switch-1)
(global-set-key [M-f3] 'my-switch-2)
(global-set-key [M-f4] 'my-switch-3)
(global-set-key [M-f5] 'my-switch-4)
(global-set-key [M-f6] 'my-switch-5)
(global-set-key [M-f7] 'my-switch-6)
(global-set-key [M-f8] 'my-switch-7)
(global-set-key [C-home] 'beginning-of-buffer)
(global-set-key [C-end] 'end-of-buffer)
(global-set-key [home] 'my-beginning-of-line)
(global-set-key [end] 'end-of-line)
(global-set-key [C-f1] 'my-save-and-kill)
(global-set-key [C-f2] 'delete-window)
(global-set-key [C-f3] 'revert-buffer)
(global-set-key [C-f4] 'my-kill-and-close)
(global-set-key [f5] 'delete-other-windows)
(global-set-key [C-f5] 'my-kill-and-close-other)
(global-set-key [f6] 'bury-buffer)
(global-set-key [f7] 'my-show-next-window)
(global-set-key [M-up] 'bury-buffer)
(global-set-key [M-down] 'my-show-next-window)
(global-set-key "\C-a" 'mark-whole-buffer)
(global-set-key "\C-m" 'my-newline)
(global-set-key "\C-r" 'query-replace)
(global-set-key "\M-n" 'my-new-buffer)
(global-set-key "\C-z" 'undo)
(global-set-key "\M-s" 'toggle-truncate-lines)
(global-set-key [?\C-\-] 'shrink-window)
(global-set-key [?\C-\=] 'enlarge-window)
(global-set-key "\C-xt" 'capitalize-region)
(global-set-key [C-kp-add] 'my-indent)
(global-set-key [C-kp-subtract] 'my-outdent)
(global-set-key [M-kp-add] 'my-increase-left-margin)
(global-set-key [M-kp-subtract] 'my-decrease-left-margin)
(global-set-key [backspace] 'my-backspace)
(global-set-key [C-backspace] 'my-kill-whitespace-backward)
(global-set-key [C-delete] 'my-kill-whitespace-forward)
(global-set-key [C-tab] 'my-toggle-tab-mode)
(global-set-key [S-delete] 'kill-region)
(global-set-key [S-insert] 'yank)
(global-set-key [C-insert] 'kill-ring-save)
(global-set-key "\e\e\C-r" 'my-mark-buffer-rw)
(global-unset-key "\C-v")
(define-key isearch-mode-map [backspace] 'isearch-delete-char)
(define-key vm-mode-map "\C-f\C-n" 'my-train-nonspam)
(define-key vm-mode-map "\C-f\C-s" 'my-train-spam)
(define-key vm-mode-map "\C-fn" 'my-retrain-nonspam)
(define-key vm-mode-map "\C-fs" 'my-retrain-spam)
(define-key vm-mode-map "g" 'my-get-new-mail)
;; options (variables and modes)
(global-font-lock-mode t)
(transient-mark-mode t)
(column-number-mode t)
(mouse-wheel-mode t)
(delete-selection-mode t)
(setq next-line-add-newlines nil)
(setq kill-whole-line t)
(setq tab-always-indent nil)
(setq indent-line-function 'my-indent-relative)
(setq fill-column 76)
(setq indent-tabs-mode t)
(setq scroll-step 1)
(setq visible-bell t)
(setq tab-width 4)
(setq backup-directory-alist '(("." . "~/.emacs.d/backup" )))
(setq auto-mode-alist (cons '("\\.xsl\\'\\|\\.xsd\\'" . sgml-mode) auto-mode-alist))
(setq my-buf-arr (make-vector 8 nil))
(setq my-mark nil)
(setq bogofilter-program "/usr/bin/bogofilter")
(setq fetchmail-program "/usr/bin/fetchmail")
(setq my-move-list
'((right)
(left)
(down)
(up)
(control right)
(control left)
(end)
(home)
(control end)
(control home)
(next)
(prior)
(control down)
(control up)))
;; functions
(defun my-setup-console-keys()
(interactive)
(global-set-key "\C-h" 'my-backspace)
(global-set-key "\e\eOA" 'bury-buffer)
(global-set-key "\e\eOB" 'my-show-next-window)
(global-set-key "\e[1~" 'beginning-of-line)
(global-set-key "\e[4~" 'end-of-line))
(defun my-setup-mmm()
(setq mmm-submode-decoration-level 2)
(defface mmm-plain-face '((t ()))
"A plain old face."
:group 'mmm-faces)
(mmm-add-group
'perlscript
'((css-block
:submode css-mode
:face mmm-plain-face
:front "")
(css-inline
:submode css-mode
:face mmm-declaration-submode-face
:front "\[ \\t\\n\]?style=\\(\"\\|\"\\)"
:back "~1"
:save-matches 1)
(js-block
:submode javascript-generic-mode
:face mmm-plain-face
:front "")
(js-inline
:submode javascript-generic-mode
:face mmm-code-submode-face
:front "\[ \\t\\n\]?on\\w+=\\(\"\\|\'\\)"
:back "~1"
:save-matches 1)
(short-tag
:submode perl-mode
:face mmm-plain-face
:front "<%"
:back "%>")
(long-tag
:submode perl-mode
:face mmm-plain-face
:front ""))))
(defun my-get-new-mail()
(interactive)
(if fetchmail-program
(call-process (or shell-file-name "sh") nil nil nil
shell-command-switch fetchmail-program))
(vm-get-new-mail))
(defsubst my-sort-mail()
(interactive)
(vm-sort-messages "reversed-date")
(vm-goto-message 1))
(defun my-spam-report()
(interactive)
(vm-follow-summary-cursor)
(vm-select-folder-buffer)
(vm-check-for-killed-summary)
(vm-error-if-folder-empty)
(let ((m (car vm-message-pointer))
(buffer (get-buffer-create "*Spam Report*")))
(set-buffer buffer)
(erase-buffer)
(set-buffer (vm-buffer-of m))
(save-restriction
(widen)
(goto-char (vm-headers-of m))
(narrow-to-region (point) (vm-end-of m))
(call-process-region (point-min) (point-max)
(or shell-file-name "sh") nil buffer nil
shell-command-switch
(concat bogofilter-program " -vv"))
(call-process-region (point-min) (point-max)
(or shell-file-name "sh") nil buffer nil
shell-command-switch
(concat bogofilter-program " -vvv"))
(switch-to-buffer buffer)
(goto-char (point-min)))))
(defun my-train(prefix args del)
(vm-follow-summary-cursor)
(vm-select-folder-buffer)
(vm-check-for-killed-summary)
(vm-error-if-folder-empty)
(let* ((next nil) (m nil)
(command (concat bogofilter-program " " args))
(mlist
(if (eq last-command 'vm-next-command-uses-marks)
(vm-select-marked-or-prefixed-messages 0)
(setq next t)
(list (car vm-message-pointer)))))
(save-excursion
(while mlist
(setq m (vm-real-message-of (car mlist)))
(if (not (and next (vm-mark-of m)))
(progn
(set-buffer (vm-buffer-of m))
(save-restriction
(widen)
(goto-char (vm-headers-of m))
(narrow-to-region (point) (vm-end-of m))
(call-process-region (point-min) (point-max)
(or shell-file-name "sh") nil nil nil
shell-command-switch command))))
(if del (vm-set-deleted-flag m t))
(setq mlist (cdr mlist))))
(if next
(progn
(vm-follow-summary-cursor)
(vm-select-folder-buffer)
(vm-mark-message prefix)
(vm-next-message))
(vm-update-summary-and-mode-line))))
(defun my-train-nonspam(arg)
(interactive "p")
(my-train arg "-n" nil))
(defun my-train-spam(arg)
(interactive "p")
(my-train arg "-s" t))
(defun my-retrain-nonspam(arg)
(interactive "p")
(my-train arg "-Sn" nil))
(defun my-retrain-spam(arg)
(interactive "p")
(my-train arg "-Ns" t))
;; this function has side effects! doesn't save excursion!
(defun my-get-depth()
"this function has side effects! doesn't save excursion!"
(beginning-of-line)
(if (looking-at "^[ \t]+")
(progn
(forward-char (- (match-end 0) (match-beginning 0)))
(current-column))
0))
(defun my-multi-bind(key)
(if (vectorp key)
(setq key (aref key 0)))
(if (not (listp key))
(setq key (list key)))
(let ((command (lookup-key global-map (vector key))))
(global-set-key (vector key) command)
(global-set-key (vector (cons 'shift key)) command)))
(defun my-multi-binds()
"Operate on each element of `my-move-list' and call `my-multi-bind'."
(let ((e nil) (lst my-move-list))
(while (setq e (pop lst))
(my-multi-bind e))))
(defun my-make-tab-stops(&optional end start step)
"Make tab stops from 'start' to 'end', inclusive, stepping by 'step'.
'start' defaults to tab-width, 'end' defaults to 120, and 'step'
defaults to whatever 'start' is."
(interactive)
(if (not end) (setq end 120))
(if (not start) (setq start tab-width))
(if (not step) (setq step start))
(let ((lst (list start)))
(while (<= (setq start (+ start step)) end)
(push start lst))
(setq tab-stop-list (reverse lst))))
(defun my-show-next-window()
"Move the focus to the next window. This also works on the
minibuffer if it is active."
(interactive)
(other-window 1 t))
(defun my-show-prev-window()
"Move the focus to the previous window. This also works on the minibuffer if it is active."
(interactive)
(other-window -1 t))
(defun my-columns-flk(N)
"Return a keyword for a warning highlight after N columns."
(list
(concat "^.\\{" (int-to-string N) "\\}\\(.*\\)$")
1 'font-lock-warning-face 'prepend))
(defun my-columns(&optional N)
"Add a warning highlight after N (default 76) columns. Only useful if
font-lock-mode is turned on."
(interactive)
(font-lock-add-keywords nil (list (my-columns-flk (or N 76)))))
(defun my-setup-column-highlights()
"Set up default column highlighting."
(let ((cols (list (my-columns-flk 100))))
(font-lock-add-keywords 'text-mode (list (my-columns-flk 74)))
(font-lock-add-keywords 'emacs-lisp-mode cols)
(font-lock-add-keywords 'html-mode cols)
(font-lock-add-keywords 'sgml-mode cols)
(font-lock-add-keywords 'perl-mode cols)
(font-lock-add-keywords 'c-mode cols)
(font-lock-add-keywords 'c++-mode cols)))
(defun my-mark-buffer-rw()
(interactive)
(setq buffer-read-only nil))
(defsubst my-new-buffer()
"Add a new buffer called 'NEW'. If a buffer with this name
exists, it will switch to that buffer instead."
(interactive)
(switch-to-buffer (generate-new-buffer "NEW"))
(my-text-setup))
(defun my-save-for-kill(&optional buf)
"If the buffer (use current if nil is passed) is not a system
buffer, is modified, and is not saved, ask whether it's okay
to save it. A system buffer begins with a '*' or
' pp-to-string'."
(if (not buf) (setq buf (current-buffer)))
(let* ((n (buffer-name buf)) (go 1) (c 1))
(if (and
(buffer-modified-p buf)
(not (string-match "\*" n))
(or
(string= n "NEW")
(buffer-file-name)))
(progn
(setq cursor-in-echo-area 1)
(if minibuffer-auto-raise
(raise-frame (window-frame (minibuffer-window))))
(while (progn
(setq c (read-event (format "Save buffer '%s' (y, n, c)? " n) 1))
(if (/= c -1)
(progn
(setq c (downcase c))
(if (= c ?y) (progn (save-buffer buf) (setq c 1 go nil))
(if (= c ?c) (progn (setq cursor-in-echo-area nil) (keyboard-quit))
(if (= c ?n)
(progn
(save-excursion
(set-buffer buf)
(set-buffer-modified-p nil))
(setq c 1 go nil)))))
go)
1)))
(message nil)
(setq cursor-in-echo-area nil)))
c))
(defun my-save-and-kill(&optional buf)
"Kill the buffer (uses current if nil is passed), possibly
asking whether to save it first."
(interactive)
(if (not buf) (setq buf (current-buffer)))
(if (my-save-for-kill buf) (kill-buffer buf)))
(defun my-kill-and-close()
"Kill the buffer (uses current if nil is passed), possibly asking
whether to save it first. Then close the window if the buffer
was closed."
(interactive)
(if (my-save-for-kill (current-buffer))
(progn
(kill-this-buffer)
(delete-window))))
(defun my-kill-and-close-other(&optional N)
"Kill the buffer in the N'th window away (N defaults to 1) in
the current frame, possibly asking whether to save it first.
Then close the window if the buffer was closed. If there is
only one window in this frame, the function does nothing."
(interactive)
(if (> (count-windows) 1)
(progn
(other-window (or N 1))
(if (my-save-for-kill (current-buffer))
(progn
(kill-this-buffer)
(delete-window))
(other-window (- N))))))
(defun my-indent (from to &optional wid)
"Indent the region by `tab-width' or 'wid', if it's passed."
(interactive "r")
(indent-rigidly from to (or wid tab-width))
(set deactivate-mark nil))
(defun my-outdent (from to &optional wid)
"Outdent the region by `tab-width' or 'wid', if it's passed."
(interactive "r")
(indent-rigidly from to (- (or wid tab-width)))
(set deactivate-mark nil))
(defun my-increase-left-margin()
"Add `standard-indent' to `left-margin'. Useful in conjunction
with `tab-to-left-margin'."
(interactive)
(setq left-margin (+ left-margin standard-indent))
(message "left-margin is now %d" left-margin))
(defun my-decrease-left-margin()
"Decrease `left-margin' by `standard-indent'. Useful in
conjunction with `tab-to-left-margin'."
(interactive)
(if (< left-margin standard-indent)
(setq left-margin 0)
(setq left-margin (- left-margin standard-indent)))
(message "left-margin is now %d" left-margin))
(defun my-toggle-tab-mode()
"Toggle `indent-line-function' between `my-indent-relative' and
`my-tab-to-tab-stop'. If it's not set to either of those, just
output a message and do nothing."
(interactive)
(if (eq indent-line-function 'my-indent-relative)
(message "indent-line-function now %s" (setq indent-line-function 'my-tab-to-tab-stop))
(if (eq indent-line-function 'my-tab-to-tab-stop)
(message "indent-line-function now %s" (setq indent-line-function 'my-indent-relative))
(message "Not in one of the two recognized tab modes!"))))
(defun my-tab-to-tab-stop()
(interactive)
(and abbrev-mode (= (char-syntax (preceding-char)) ?w)
(expand-abbrev))
(let ((col (* (/ (+ (current-column) tab-width) tab-width) tab-width)))
(delete-horizontal-space t)
(indent-to col)))
(defun my-indent-relative (&optional unindented-ok)
"My replacement for `indent-relative' that calls `my-tab-to-tab-stop'.
Basically ripped from indent.el"
(interactive "P")
(if (and abbrev-mode
(eq (char-syntax (preceding-char)) ?w))
(expand-abbrev))
(let ((start-column (current-column))
indent)
(save-excursion
(beginning-of-line)
(if (re-search-backward "^[^\n]" nil t)
(let ((end (save-excursion (forward-line 1) (point))))
(move-to-column start-column)
(if (> (current-column) start-column)
(backward-char 1))
(or (looking-at "[ \t]")
unindented-ok
(skip-chars-forward "^ \t" end))
(skip-chars-forward " \t" end)
(or (= (point) end) (setq indent (current-column))))))
(if indent
(let ((opoint (point-marker)))
(delete-region (point) (progn (skip-chars-backward " \t") (point)))
(indent-to indent 0)
(if (> opoint (point))
(goto-char opoint))
(move-marker opoint nil))
(my-tab-to-tab-stop))))
(defun my-beginning-of-line(&optional N)
"Only move back to the first non-whitespace character, unless already
at or before that point."
(interactive)
(if (and N (> N 1)) (next-line N))
(let ((depth 0) (cur (point)))
(beginning-of-line)
(setq cur (- cur (point)))
(if (looking-at "^[ \t]+")
(setq depth (- (match-end 0) (match-beginning 0))))
(if (> cur depth) (forward-char depth))))
(defun my-newline (&optional arg)
"If before the first non-whitespace of the current line, lower
the entire line. Otherwise, add a newline and indent so it lines
up with the previous line."
(interactive)
(if arg
(newline arg)
(let ((dep -1) (pdep -1) (cur (point)) (col (current-column)))
(save-excursion
(beginning-of-line)
(setq cur (- cur (point)))
(setq dep (my-get-depth))
(if (= (forward-line -1) 0)
(setq pdep (my-get-depth))))
(if (< col dep)
(progn
(beginning-of-line)
(newline)
(forward-char cur))
(newline)
(indent-to dep)))))
(defun my-backspace (&optional arg)
"If backspacing onto a line containing only whitespace, clear the
whitespace."
(interactive)
(if arg
(delete-backward-char arg)
(if (/= (current-column) 0)
(delete-backward-char 1)
(let ((from (point)))
(backward-char 1)
(skip-chars-backward " \t")
(if (and (/= from (point)) (= (current-column) 0))
(delete-region from (point))
(goto-char from)
(delete-backward-char 1))))))
(defun my-calc-point(N)
"Calculate the point close to N columns away on this line."
(let ((to (+ (current-column) N)) (line (line-beginning-position)))
(save-excursion
(if (< N 0)
(progn
(if (< to 0) (setq to 0))
(while (> (current-column) to) (backward-char 1)))
(while
(and
(< (current-column) to)
(= (line-beginning-position) line))
(forward-char 1)))
(point))))
(defun my-kill-whitespace-backward (&optional arg)
"Backspace over whitespace until a non-whitespace is found."
(interactive)
(if arg
; FIXME: with arg, doesn't check if it's deleting only whitespace!
(let* ((to (point)) (from (my-calc-point (- arg))))
(delete-region from to))
(delete-horizontal-space t)))
(defun my-kill-whitespace-forward (&optional arg)
"Delete whitespace until a non-whitespace is found."
(interactive)
(if arg
; FIXME: with arg, doesn't check if it's deleting only whitespace!
(let* ((from (point)) (to (my-calc-point arg)))
(delete-region from to))
(let ((from (point)))
(skip-chars-forward " \t")
(if (/= from (point))
(delete-region from (point))))))
(defun my-add-to-barr(buf)
(let ((p nil) (i 0) (len (length my-buf-arr)))
(while (< i len)
(if (eq (aref my-buf-arr i) nil)
(progn
(aset my-buf-arr i buf)
(setq i len p 1))
(setq i (1+ i))))
(if (not p)
(aset my-buf-arr (- len 1) buf))))
(defun my-rem-from-barr(buf)
(let ((i 0) (len (length my-buf-arr)))
(while (< i len)
(if (eq (aref my-buf-arr i) buf)
(progn
(aset my-buf-arr i nil)
(setq i len))
(setq i (1+ i))))))
(defun my-find-in-barr(buf)
(let ((i 0) (p -1) (len (length my-buf-arr)))
(while (< i len)
(if (eq (aref my-buf-arr i) buf)
(setq p i i len)
(setq i (1+ i))))
p))
(defun my-c-newline(&optional arg)
(interactive)
(if arg
(newline arg)
(my-newline)
(let ((cur 0) (col (current-column)) (doit nil))
(save-excursion
(setq doit (and
(= (forward-line -1) 0)
(move-to-column col t)
(looking-at "{[ \t]"))))
(if doit (indent-to (+ col tab-width))))))
(defun my-c-backspace (&optional arg)
"If there is no nonwhitespace between the cursor and the beginning of the
line, and the previous line ends in '}', call `my-kill-whitespace-backward'
to kill up to `tab-width' columns (moving the cursor back to the previous
tab stop) otherwise call `my-backspace'."
(interactive)
(let ((depth 0) (cur (current-column)))
(save-excursion (setq depth (my-get-depth)))
(if (and (> cur 0) (<= cur depth))
(my-kill-whitespace-backward (- cur (* (/ (1- cur) 2) 2)))
(my-backspace arg))))
(defun my-c-open-brace(arg)
"Auto indents when a brace is typed."
(interactive "P")
(if (not (c-in-literal))
(let ((depth 0) (cur (point)) (col (current-column)) (linelen 0) (isb nil))
(save-excursion
(beginning-of-line)
(setq cur (- cur (point)))
(setq depth (my-get-depth))
(if (= (forward-line -1) 0)
(progn
(setq linelen (- (line-end-position) (line-beginning-position)))
(if (<= cur linelen)
(progn
(move-to-column col)
(setq isb (looking-at "{")))))))
(if (and isb (= col depth)) (my-tab-to-tab-stop))
(self-insert-command (prefix-numeric-value arg))
(if (= col depth) (my-tab-to-tab-stop)))
(self-insert-command (prefix-numeric-value arg))))
(defun my-c-close-brace(arg)
"Moves brace back to matching brace under certain circumstances."
(interactive "P")
(if (not (c-in-literal))
(let ((cdepth -1) (depth -1) (cur (point)) (col (current-column)) (linelen 0) (isb nil) (isbb nil))
(save-excursion
(beginning-of-line)
(setq cur (- cur (point)))
(setq cdepth (my-get-depth))
(if (= (forward-line -1) 0)
(progn
(setq linelen (- (line-end-position) (line-beginning-position)))
(setq depth (my-get-depth))
(if (<= cur linelen)
(progn
(move-to-column col t)
(if (or
(setq isb (looking-at "{"))
(>= col tab-width))
(progn
(move-to-column (- col tab-width) t)
(setq isbb (looking-at "{")))))))))
(if (and (not isb) (or (and isbb (= cdepth col)) (= col depth)))
(my-kill-whitespace-backward (min cur tab-width)))))
(self-insert-command (prefix-numeric-value arg)))
(defsubst my-switch-0() (interactive) (my-switch-to 0))
(defsubst my-switch-1() (interactive) (my-switch-to 1))
(defsubst my-switch-2() (interactive) (my-switch-to 2))
(defsubst my-switch-3() (interactive) (my-switch-to 3))
(defsubst my-switch-4() (interactive) (my-switch-to 4))
(defsubst my-switch-5() (interactive) (my-switch-to 5))
(defsubst my-switch-6() (interactive) (my-switch-to 6))
(defsubst my-switch-7() (interactive) (my-switch-to 7))
(defun my-switch-to(n)
"Switch to the nth buffer. This does not count buffers in
exact order, but the order shouldn't change, once set. n
must be in the range from 0 to 7, currently."
(interactive)
(if (aref my-buf-arr n)
(switch-to-buffer (aref my-buf-arr n))
(let ((b (current-buffer)) (e (my-find-in-barr nil)) (lst (buffer-list)))
(while
(progn
(if (and
(not (string-match "\*" (buffer-name b)))
(= (my-find-in-barr b) -1))
(progn
(message "Slot %d is %s" n (buffer-name b))
(aset my-buf-arr n b)
(switch-to-buffer b)
(setq lst nil)))
(and lst (setq b (pop lst))))))))
;; hooks
(add-hook 'vm-arrived-messages-hook 'my-sort-mail)
(add-hook 'vm-summary-mode-hook 'my-sort-mail)
(add-hook 'fundamental-mode-hook 'my-text-setup)
(add-hook 'c-mode-hook 'my-c-setup)
(add-hook 'c++-mode-hook 'my-c-setup)
(add-hook 'emacs-lisp-mode-hook 'my-el-setup)
(add-hook 'perl-mode-hook 'my-perl-setup)
(add-hook 'kill-buffer-hook 'my-on-kill)
(add-hook 'kill-buffer-query-functions 'my-save-for-kill)
(add-hook 'html-mode-hook 'my-ml-setup)
(add-hook 'sgml-mode-hook 'my-ml-setup)
(add-hook 'text-mode-hook 'my-text-setup)
(add-hook 'pre-command-hook 'my-pre-hook)
(add-hook 'post-command-hook 'my-post-hook)
;; hook code
(defun my-lcmp(l1 l2)
"Compares two lists and returns t if they contain the same elements."
(and
(= (length l1) (length l2))
(let ((ret t))
(while l1
(if (member (car l1) l2) (setq l1 (cdr l1)) (setq l1 nil ret nil)))
ret)))
(defun my-is-move(key)
(let ((e nil) (ret nil) (lst my-move-list) (mods nil) (mkey nil))
(setq mods (copy-sequence (event-modifiers key)) mkey (nconc mods (list (event-basic-type key))))
(while (and lst (setq e (pop lst)))
(if (or (my-lcmp e mkey) (my-lcmp (nconc (list 'shift) e) mkey))
(setq lst nil ret t)))
ret))
(defun my-char(&optional N)
"Switch to character indentation N (default 2) chars wide."
(interactive)
(setq tab-width (or N 2))
(setq standard-indent (or N 2))
(setq indent-tabs-mode nil))
(defun my-tab(&optional N)
"Switch to tab indentation N (default 2) chars wide."
(interactive)
(setq tab-width (or N 2))
(setq standard-indent (or N 2))
(setq indent-tabs-mode t))
(defun my-pre-hook()
(interactive)
(condition-case nil
(if (and (eq my-mark nil) (not mark-active))
(let* ((keys (this-single-command-raw-keys)) (fk (aref keys 0)))
(if (and
(= (length keys) 1)
(memq 'shift (event-modifiers fk))
(my-is-move fk))
(progn
(set-mark-command nil)
(setq my-mark (mark t))))))))
(defun my-post-hook()
(interactive)
(condition-case nil
(if (not (eq my-mark nil))
(let* ((keys (this-single-command-raw-keys)) (fk (aref keys 0)))
(if (or
deactivate-mark
(not mark-active)
(and
transient-mark-mode
(= (length keys) 1)
(not (memq 'shift (event-modifiers fk)))
(my-is-move fk)))
(setq deactivate-mark t mark-active nil my-mark nil))))))
(defun my-c-setup()
(interactive)
(setq c-set-style "user")
(setq c-offsets-alist nil)
(setq c-basic-offset 2)
(setq c-syntactic-indentation nil)
(setq indent-line-function 'my-tab-to-tab-stop)
(local-set-key "{" 'my-c-open-brace)
(local-set-key "}" 'my-c-close-brace)
(local-set-key "\C-m" 'my-c-newline)
(local-set-key [tab] 'indent-for-tab-command)
(local-set-key [backspace] 'my-c-backspace)
(my-char 2))
(defun my-el-setup()
(interactive)
(my-char 2)
(eldoc-mode 1))
(defun my-perl-setup()
(interactive)
(my-char 2))
(defun my-ml-setup()
(interactive)
(setq indent-line-function 'my-tab-to-tab-stop)
(my-char 2))
(defsubst my-on-kill()
(my-rem-from-barr (current-buffer)))
(defun my-text-setup()
(interactive)
(local-set-key [tab] 'indent-for-tab-command)
(setq indent-line-function 'my-tab-to-tab-stop)
(my-tab 4)
(font-lock-mode t))
(defun my-shell-setup()
(ansi-color-for-comint-mode-on)
(funcall comint-input-sender (get-buffer-process (current-buffer)) ". /etc/profile")
(funcall comint-input-sender (get-buffer-process (current-buffer)) ". ~/.bashrc &>/dev/null")
(funcall comint-input-sender (get-buffer-process (current-buffer)) ". ~/.bash_profile"))
;; executed code
(my-make-tab-stops)
(my-multi-binds)
(my-setup-column-highlights)
(my-setup-mmm)