;; Start gnuserv (server-start) ;; (add-hook 'server-switch-hook ;; (lambda () ;; (local-set-key (kbd "C-x k") 'server-edit))) ;;(setq frame-title-format ;; '(multiple-frames "%b" ;; ("" invocation-name "@laowai"))) (add-to-list 'load-path "~/elisp") (load-library "subdirs.el") ;;; ;;; Beautifiers & commodities ;;; (global-font-lock-mode t) (transient-mark-mode t) (column-number-mode t) (mouse-wheel-mode t) (show-paren-mode t) (auto-compression-mode t) (savehist-mode 1) (tool-bar-mode 0) (require 'highlight-current-line) (highlight-current-line-on t) ;; Open unidentified files in text mode (setq default-major-mode 'text-mode) ;; Display clock (display-time) ;; NO sound (setq visible-bell t) ;; show the GNU splash screen (setq inhibit-startup-message nil) ;; Make all "yes or no" prompts show "y or n" instead (fset 'yes-or-no-p 'y-or-n-p) (setq fill-column 70) (setq text-mode-hook (quote (turn-on-auto-fill text-mode-hook-identify))) (defun unfill-paragraph () "Takes a multi-line paragraph and makes it into a single line of text." (interactive) (let ((fill-column (point-max))) (fill-paragraph nil))) ;; New frame starts in home directory (add-hook 'after-make-frame-functions (lambda (frame) (cd "~") )) (cd "~") ;; Set default frame size (let ((frame '((width . 85) (height . 55) (menu-bar-lines . 1)))) (setq default-frame-alist frame) (setq initial-frame-alist frame)) ;; Resize the initial frame (let ((fr (selected-frame))) (set-frame-size fr (cdr (assq 'width default-frame-alist)) (cdr (assq 'height default-frame-alist)))) ;;; ;;; Russian language support ;;; (defvar cp866-decode-table [ 255 240 nil nil 242 nil nil 244 nil nil nil nil nil nil 246 nil 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 252 241 nil nil 243 nil nil 245 nil nil nil nil nil nil 247 nil] "Table for converting ISO-8859-5 characters into codepage 866 glyphs.") (setplist 'cp866-decode-table '(charset cyrillic-iso8859-5 language "Cyrillic-ISO" offset 160)) (codepage-setup 866) (codepage-setup 1251) (defun setup-cyrillic-cp1251-environment () "Setup multilingual environment (MULE) for Cyrillic CP1251 users." (interactive) (set-default-coding-systems 'cp1251)) (let ((language-info '((documentation . "Support for Cyrillic CP1251.") (sample-text . "Russian (Ðóññêèé) Çäðàâñòâóéòå!") (features cyril-util) (unibyte-display . cyrillic-iso-8bit) (nonascii-translation . cyrillic-iso8859-5) (input-method . "cyrillic-jcuken") (coding-priority cp1251) (coding-system cp1251) (setup-function . setup-cyrillic-cp1251-environment) (charset cyrillic-iso8859-5)))) (set-language-info-alist "Cyrillic-CP1251" language-info '("Cyrillic")) ) (set-language-environment 'UTF-8) (load-library "cyrillic-dvorak") (set-input-method 'cyrillic-dvorak) (inactivate-input-method) ;; (set-language-environment 'Cyrillic-CP1251) ;; (set-keyboard-coding-system 'cp1251) ;; (set-selection-coding-system 'cp1251) ;; (set-input-method 'cyrillic-translit) ;; Full screen (require 'fullscreen) (global-set-key [f11] 'fullscreen-toggle) (global-set-key [f12] 'delete-other-windows) (global-set-key [C-f4] 'kill-this-buffer) (defvar iresize-mode-map (let ((m (make-sparse-keymap))) (define-key m (kbd "C-p") 'shrink-window) (define-key m (kbd "p") 'shrink-window) (define-key m (kbd "") 'shrink-window) (define-key m (kbd "C-n") 'enlarge-window) (define-key m (kbd "n") 'enlarge-window) (define-key m (kbd "") 'enlarge-window) (define-key m (kbd "C-c C-c") 'iresize-mode) m)) (define-minor-mode iresize-mode :initial-value nil :lighter " IResize" :keymap iresize-mode-map :group 'iresize) (global-set-key [?\C-c ?+] 'iresize-mode) (defun write-room () "Make a frame without any bling." (interactive) ;; to restore: ;; (setq mode-line-format (default-value 'mode-line-format)) (let ((frame (make-frame '((minibuffer . t) (vertical-scroll-bars . nil) (left-fringe . 0); no fringe (right-fringe . 0) (background-mode . light) (background-color . "white") (foreground-color . "black") (cursor-color . "black") (border-width . 0) (border-color . "black"); should be unnecessary (internal-border-width . 64); whitespace! (cursor-type . box) (menu-bar-lines . 0) (tool-bar-lines . 0) (mode-line-format . nil) ; dream on... has no effect (fullscreen . fullboth) ; this should work (unsplittable . t))))) (select-frame frame) (find-file "~/sketches/sketches.tex"))) ;; Window splitting (defun my-window-hsplit () (interactive) (let ((w (+ fill-column 5))) (if (> (window-width (selected-window)) 70) (split-window-horizontally w)))) (global-set-key [?\C-x ?3] 'my-window-hsplit) (defun insert-date () "Insert the current date in the ISO 8601 format" (interactive "*") (insert (format-time-string "%Y-%m-%d %T %z" (current-time)))) ;;; ;;; Key bindings ;;; (global-set-key [C-prior] 'beginning-of-buffer) (global-set-key [C-next] 'end-of-buffer) (global-set-key [C-tab] 'other-window) ;; Make control+pageup/down scroll the other buffer (global-set-key [C-S-next] 'scroll-other-window) (global-set-key [C-S-prior] 'scroll-other-window-down) ;; Cool home key (defun my-home-key () (interactive) (let ((f (current-column))) (beginning-of-line) (skip-chars-forward " \t") (if (= (current-column) f) (beginning-of-line)))) (global-set-key [home] 'my-home-key) (global-set-key "\C-a" 'my-home-key) (global-set-key [end] 'end-of-line) (global-set-key "\M-[" 'TeX-previous-error) (global-set-key "\M-]" 'TeX-next-error) (setq compilation-ask-about-save nil) (setq compilation-scroll-output t) (setq compilation-window-height 8) ;;; ;;; Extra packages ;;; ;; Wanderlust (setq smtp-end-of-line "\n") (autoload 'wl "wl" nil t) (autoload 'wl-other-frame "wl" nil t) (autoload 'wl-user-agent-compose "wl-draft" nil t) (if (boundp 'mail-user-agent) (setq mail-user-agent 'wl-user-agent)) (if (fboundp 'define-mail-user-agent) (define-mail-user-agent 'wl-user-agent 'wl-user-agent-compose 'wl-draft-send 'wl-draft-kill 'mail-send-hook)) (if (boundp 'read-mail-command) (setq read-mail-command 'wl)) ;; TeX (load-library "auctex") (autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t) (autoload 'flyspell-delay-command "flyspell" "Delay on command." t) (autoload 'tex-mode-flyspell-verify "flyspell" "" t) (setq tex-dvi-view-command "xdvi -s 8") (add-hook 'LaTeX-mode-hook (lambda () (TeX-source-specials-mode 1) (setq TeX-source-specials-view-start-server t) (turn-on-reftex) (flyspell-mode) (reftex-isearch-minor-mode t) (setq reftex-section-levels (append reftex-section-levels '(("todo" . -7) ("note" . -7)))) (setq reftex-plug-into-AUCTeX t) (setq reftex-cite-format 'natbib))) (when window-system (define-key global-map [C-M-mouse-1] 'imenu)) ;; Tramp (setq tramp-default-method "ssh") ;; tabbar (require 'tabbar) (tabbar-mode) ;; Printing (setq ps-printer-name "lpz2d") ;; Web browsers ;; (setq browse-url-browser-function 'w3m-browse-url) (setq browse-url-browser-function 'browse-url-firefox) (setq browse-url-firefox-new-window-is-tab t) ;; Iswitchb (iswitchb-mode 1) (iswitchb-default-keybindings) (setq iswitchb-default-method 'samewindow) (autoload 'longlines-mode "longlines.el" "Minor mode for editing long lines." t) ;; i/aspell (setq ispell-program-name "aspell") ;; ruby mode (autoload 'ruby-mode "ruby-mode" "Mode for editing ruby source files" t) (add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode)) (setq interpreter-mode-alist (cons '("ruby" . ruby-mode) interpreter-mode-alist)) (autoload 'run-ruby "inf-ruby" "Run an inferior Ruby process") (autoload 'inf-ruby-keys "inf-ruby" "Set local key defs for inf-ruby in ruby-mode") (setq ruby-program-name "irb1.8 --inf-ruby-mode") (add-hook 'ruby-mode-hook '(lambda () (inf-ruby-keys))) ;; CSS (autoload 'css-mode "css-mode") (setq cssm-indent-function #'cssm-c-style-indenter) (setq cssm-indent-level '2) ;;; Haskell (autoload 'run-haskell "inf-haskell" "" t) (setq haskell-program-name "ghci") ;; CSS (autoload 'css-mode "css-mode" nil t) (add-to-list 'auto-mode-alist '("\\.css$" . css-mode)) (setq safe-local-variable-values '((ispell-local-dictionary . "british") (ispell-local-dictionary . "american") (ispell-local-dictionary . "francais") ))