;; 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") ;;; ;;; 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) ;; 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))) (setq compilation-ask-about-save nil) (setq compilation-scroll-output t) (setq compilation-window-height 8) ;; 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 . 45) (top . 24) (left . 100) (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))) (set-frame-position fr (cdr (assq 'left default-frame-alist)) (cdr (assq 'top default-frame-alist)))) ;; Printing (setq ps-printer-name "lj10") ;; Web browsers (setq browse-url-browser-function 'browse-url-w3m) ;;(setq browse-url-browser-function 'browse-url-firefox) (setq browse-url-firefox-new-window-is-tab t) ;; Look up words in multitran (defconst multitran-en-url-prefix "http://www.multitran.ru/c/m.exe?l1=1&l2=2&HL=2&EXT=0&s=") (defun multitran-en () (interactive) (let ((word (current-word))) (browse-url-epiphany (concat multitran-en-url-prefix word) t))) (defconst multitran-fr-url-prefix "http://www.multitran.ru/c/m.exe?l1=4&l2=2&HL=2&EXT=0&s=") (defun multitran-fr () (interactive) (let ((word (current-word))) (browse-url-epiphany (concat multitran-fr-url-prefix word) t))) (let ((map (make-sparse-keymap "Text Mode"))) (define-key text-mode-map [menu-bar] (make-sparse-keymap)) (define-key text-mode-map [menu-bar text-mode] (cons "Text Mode" map)) (define-key map [separator-format] '("--")) (define-key map [multitran-fr] '("Multitran Fr" . multitran-fr)) (define-key map [multitran-en] '("Multitran En" . multitran-en))) (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-home] 'beginning-of-buffer) (global-set-key [C-end] 'end-of-buffer) (global-set-key [C-tab] 'other-window) ;; Make control+pageup/down scroll the other buffer (global-set-key [C-next] 'scroll-other-window) (global-set-key [C-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) ;;; ;;; 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 '(("Cyrillic-CP1251" (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))))) (setq language-info-alist (append language-info-alist language-info)) (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 'Latin-1) ;; (set-keyboard-coding-system 'iso-latin-1) ;; (set-selection-coding-system 'iso-latin-1) ;; (set-language-environment 'Cyrillic-CP1251) ;; (set-keyboard-coding-system 'cp1251) ;; (set-selection-coding-system 'cp1251) ;; (set-input-method 'cyrillic-translit) ;;; ;;; Extra packages ;;; ;; Wanderlust (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)) ;; Tramp (setq tramp-default-method "ssh") ;; Iswitchb (iswitchb-mode 1) (iswitchb-default-keybindings) ;; 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) (add-hook 'LaTeX-mode-hook 'flyspell-mode) (setq tex-dvi-view-command "xdvi") ;; i/aspell (setq ispell-program-name "ispell") ;; ruby mode (autoload 'ruby-mode "ruby-mode" "Mode for editing ruby source files" t) (setq auto-mode-alist (cons '("\\.rb$" . ruby-mode) auto-mode-alist)) (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) ;; Wikipedia (autoload 'wikipedia-mode "wikipedia-mode.el" "Major mode for editing documents in Wikipedia markup." t) (autoload 'longlines-mode "longlines.el" "Minor mode for editing long lines." t) ;; Lojban (autoload 'lojban-parse-region "lojban" nil t) (autoload 'lojban-mode "lojban-mode" nil t) ;;; Haskell (autoload 'run-haskell "inf-haskell" "" t) (setq haskell-program-name "ghci") ;;; SLIME ;; (autoload 'slime "slime" ;; "The Superior Lisp Interaction Mode for Emacs" t) ;; (autoload 'slime-mode "slime" ;; "The Superior Lisp Interaction Mode for Emacs" t) (setq common-lisp-hyperspec-root "file:///usr/share/doc/HyperSpec/") (setq inferior-lisp-program "sbcl") (global-set-key [f9] 'slime-selector) (setq inferior-lisp-program "/usr/bin/sbcl") ;;(slime-setup) ;;; Scheme (mit-scheme) (setq scheme-mit-dialect t) ;;; OCaml (autoload 'tuareg-mode "tuareg" "Major mode for editing Caml code" t) (setq auto-mode-alist (cons '("\\.ml\\w?" . tuareg-mode) auto-mode-alist)) (setq tuareg-library-path "/usr/lib/ocaml/3.08.3/") (setq tuareg-manual-url "file:///usr/share/doc/ocaml/docs/ocaml.html/index.html") (setq tuareg-browser 'browse-url-w3m) ;; C (autoload 'cc-mode "cc-mode") (setq c-default-style "k&r") (defun my-c-mode-common-hook () (c-setup-filladapt) (filladapt-mode 1) (c-toggle-auto-hungry-state 1)) (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) (setq auto-mode-alist (append '( ("\\.txt$" . text-mode) ("\\.y$" . bison-mode) ("\\.l$" . flex-mode) ;; ("\\.[sj]?html?\\'" . nxhtml-mode) ("\\.xml$" . xml-mode) ("\\.css\\'" . css-mode) ;; ("\\.php[34]?$" . nxhtml-mode) ("\\.wiki\\'" . wikipedia-mode) ("\\.pl$" . prolog-mode)) auto-mode-alist ))