;; initialize (set 'inhibit-startup-message 1) ;; Functions (defun tabs (n) (interactive (progn (let ((nn (read-string "tab stops: "))) (list (string-to-int nn))))) (set 'tab-width n) ) (defun cols () (interactive) (column-number-mode) ) (defun save-modified-buffers () (interactive) (save-some-buffers 2)) (defun capitalize-previous-word () (interactive) (capitalize-word -1)) (defun unix () "Set coding system to Unix" (interactive) (set-buffer-file-coding-system 'big5-unix) ) (defun dos () "Set coding system to DOS" (interactive) (set-buffer-file-coding-system 'big5-dos) ) (defun undos () "remove control-M's from entire file." (interactive) (beginning-of-buffer) (replace-string "\^M" "" nil) (beginning-of-buffer)) (defun beginning-of-next-line () "Move to the beginning of the next line." (interactive) (end-of-line) (if (looking-at "\\'") (insert-string "\n") (forward-line 1)) (beginning-of-line)) (defun beginning-of-previous-line () "Move to the beginning of the previous line." (interactive) (forward-line -1)) (defun zap-line () "Delete one line. Does not leave null line" (interactive) (beginning-of-next-line) (let ((nextl (point))) (forward-line -1) (kill-region (point) nextl))) (defun scroll-down-1 () "Scroll down one line." (interactive) (scroll-up 1)) (defun scroll-up-1 () "Scroll up one line." (interactive) (scroll-down 1)) (defun plain-newline () "Insert a newline character at point" (interactive) (insert-char 10 1) ) (defun use-plain-newline () "Make RET just insert a newline character" (interactive) (if (null (current-local-map)) (use-local-map global-map)) (define-key (current-local-map) "\^M" 'plain-newline) ) ;; New global key bindings (define-key global-map "\^B" 'scroll-up-1) (define-key global-map "\^F" 'scroll-down-1) (define-key global-map "\^V" 'call-last-kbd-macro) (define-key global-map "\^Z" 'zap-line) (define-key global-map "\eC" 'capitalize-previous-word) (define-key global-map "\eG" 'goto-line) (define-key global-map "\eb" 'buffer-menu) (define-key global-map "\eg" 'fill-individual-paragraphs) (define-key global-map "\eR" 'rs) (define-key global-map "\es" 'spread-par) (set 'tab-always-indent nil) ;; C stuff (defun c-mode-hook () (modify-syntax-entry 95 "w" c-mode-syntax-table) ) (defvar c-mode-hook 'c-mode-hook) ;;(setq auto-mode-alist (cons (cons "\\.c$" 'fundamental-mode) ;; auto-mode-alist)) ;;(setq auto-mode-alist (cons (cons "\\.h$" 'fundamental-mode) ;; auto-mode-alist)) ;;(setq auto-mode-alist (cons (cons "\\.y$" 'fundamental-mode) ;; auto-mode-alist)) ;; options ;; Add a newline when writing a text file, if there isn't one at the end. (set 'require-final-newline t) ;; Allow narrow-to-region and Lisp evaluation (put 'narrow-to-region 'disabled nil) (put 'eval-expression 'disabled nil) ;; Display the time and line number in the status line. (display-time) (set 'line-number-mode t)