The very unofficial .emacs home EugeneMorozov.emacs
emacs
Sections
home
what is this all about ?
customization basics
special topics
local dotfiles
dotfiles on the web
new and updated pages
useful sites and pages
search locally
EMacro
OS/2 Emacs
Eugene Morozov
EugeneMorozov.emacs
.custom.xemacs.nomule
.custom.xemacs.nomule
.gnus.el
.vm.el

EugeneMorozov.zip
Latest Additions
local files:
John J. Glynn
David Jolley

linked files:


articles:


links:
The Emacs wiki
;; Eugene Morozov's .emacs
;; $Id: EugeneMorozov.emacs.html,v 1.1.1.1 2003/10/25 21:10:52 ingo Exp $

;; I don't wrap this in `eval-when-compile' because I don't always 
;; byte-compile this file
(require 'cl)

;;{{{ Variables describing environment Emacs is running in

(defvar running-xemacs (string-match "XEmacs\\|Lucid" emacs-version))
(defvar running-on-windows (eq 'windows-nt system-type))
(defvar running-on-unix (not running-on-windows))
(defvar mule-present (featurep 'mule))
(defvar running-on-x (cond (running-xemacs 
                            (eq (console-type) 'x))
                           (t
                            (eq window-system 'x)))
  "Whether emacs is running on X display.")
(defvar emacs-flavor 
  (concat (if running-xemacs "xemacs" "gnuemacs") "."
          (if mule-present "mule" "nomule") "-"
          (int-to-string emacs-major-version) "."
          (int-to-string emacs-minor-version)))
(defvar default-mail-user-agent 'mutt
  "Default MUA to use. Can be mutt or vm.")

;;}}}

;;{{{ Funtions

(defun read-mail-with-mutt ()
  "Run mutt in gnome-terminal."
  (interactive)
  (call-process "gnome-terminal" nil 0 nil "-e" "mutt"))

;;}}}

;;{{{ Customization

;; Store customization information in file specific for emacs version
(setq custom-file (concat (expand-file-name "~/emacs/custom.") emacs-flavor ".el"))

;; I like to keep all emacs-related configs in one directory
(if (eq default-mail-user-agent 'vm)
    (setq vm-init-file "~/emacs/vm.el"))

;; Load customization information if it exists
(if (file-exists-p custom-file)
    (load custom-file))

;;}}}                                                                              

;;{{{ load-path setup

;; Add to load-path directory "~/elisp" and all its subdirectories
(let* ((my-lisp-directory (expand-file-name "~/elisp"))
       (my-load-path (list my-lisp-directory)))
  (setq my-load-path 
        (append (directory-files my-lisp-directory t nil t)
                my-load-path))
  (setq my-load-path (delete (concat my-lisp-directory "/.") my-load-path))
  (setq my-load-path (delete (concat my-lisp-directory "/..") my-load-path))
  (delete-if-not 'file-directory-p my-load-path)
  (setq load-path (append my-load-path load-path)))

;;}}}

;;{{{ Load packages required during initialization

(require 'cc-langs)
(require 'cc-mode)
(require 'vc-hooks)
(require 'gnus)
(require 'message)

;; This packages are needed only under XEmacs
(cond ((featurep 'xemacs)
       (require 'auto-save)
       (require 'big-menubar)
       (require 'filladapt)
       ;; Otherwise it won't highlight syntax automatically even if 
       ;; font-lock-auto-fontify is t
       (require 'font-lock)))

;;}}}

;;{{{ Load local packages

(require 'psgml)

(require 'greedy-delete)
(require 'wiki)
(require 'table)

;; Load vm personal crisis if it exists and I switched to VM for reading mail
(if (and (eq default-mail-user-agent 'vm) (file-exists-p "~/elisp/vm-pcrisis.el"))
    (load "vm-pcrisis"))

;;}}}

;;{{{ auto-mode-alist setup

;; Open every file ending in .sql with sql mode
(setq auto-mode-alist (cons '("\\.sql$" . sql-mode) auto-mode-alist))

;; Edit html files in sgml-mode
(setq auto-mode-alist (cons '("\\.s?html$" . sgml-mode) auto-mode-alist))

;;}}}

;;{{{ c-mode setup

(modify-syntax-entry ?_ "w" c-mode-syntax-table)

(defun my-c-mode-common-hook ()
  (turn-on-auto-fill)
  (imenu-add-menubar-index)
  )
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

;;}}}

;;{{{ Settings specific to GNU Emacs

;; FIXME: do that via customize if possible
(cond ((not running-xemacs)
       (transient-mark-mode 1)
       ;; Turn on font-lock in all modes that support it
       (global-font-lock-mode t)
       ))

;;}}}

;;{{{ Fast file finder setup

;; Undefine C-c C-f binding -- fff needs it and I don't use it anyway
(define-key global-map [(control c) (control f)] nil)

(require 'fff)
(fff-install-map)

;;}}}

;;{{{ Folding mode setup

(load "folding" 'nomessage 'noerror)
(folding-mode-add-find-file-hook)
(folding-add-to-marks-list 'python-mode "# {{{ " "# }}}" nil t)

;;}}}

;;{{{ Mousewheel install

;; We need mouse wheel support only under X (and mwhell
;; package probably won't work under Windows anyway)
(cond ((featurep 'x)
       (autoload 'mwheel-install "mwheel" "Enable mouse wheel support.")
       (mwheel-install)))

;;}}}

;;{{{ Mailcrypt settings

;; It is very unlikely that I'll ever compose or read mail in Emacs
;; under Windows
(cond ((not running-on-windows)
       (load-library "mailcrypt")
       (mc-setversion "gpg")
       (setq mc-passwd-timeout 600
             mc-gpg-user-id "Eugene Morozov")
       (autoload 'mc-install-write-mode "mailcrypt" nil t)
       (autoload 'mc-install-read-mode "mailcrypt" nil t)
       (add-hook 'mail-mode-hook 'mc-install-write-mode)))

;;}}}

;;{{{ Load browse-kill-ring

(require 'browse-kill-ring)
(define-key global-map [(control c) k] 'browse-kill-ring)

;;}}}

;;{{{ Load resize-minibuffer

;; Resize-minibuffer files called differently in XEmacs and GNU Emacs
;; distributions
(if running-xemacs
    (setq resize-minibuffer-file "rsz-minibuf")
  (setq resize-minibuffer-file "rsz-mini"))
(autoload 'resize-minibuffer-mode resize-minibuffer-file nil t)
(resize-minibuffer-mode)

;;}}}

;;{{{ Savehist install

(cond (running-xemacs
       ;; Sometimes bad troubles occurs with history saved in one Emacs flavor
       ;; and loaded in another
       (custom-set-variables 
        '(savehist-file (concat "~/.emacs-history." emacs-flavor)))
       (require 'savehist)
       (savehist-load)))

;;}}}
       
;;{{{ Cyrillic settings

;; XEmacs w/o MULE under X doesn't understand cyrillic keysyms
(cond ((and running-xemacs (not mule-present) (eq (console-type) 'x))
       (global-set-key [(iso-next-group)] [])
       (global-set-key [Cyrillic_a] [])
       (global-set-key [Cyrillic_A] [])
       (global-set-key [Cyrillic_be] [])
       (global-set-key [Cyrillic_BE] [])
       (global-set-key [Cyrillic_che] [])
       (global-set-key [Cyrillic_CHE] [])
       (global-set-key [Cyrillic_de] [])
       (global-set-key [Cyrillic_DE] [])
       (global-set-key [Cyrillic_dzhe] [])
       (global-set-key [Cyrillic_DZHE] [])
       (global-set-key [Cyrillic_e] [])
       (global-set-key [Cyrillic_E] [])
       (global-set-key [Cyrillic_ef] [])
       (global-set-key [Cyrillic_EF] [])
       (global-set-key [Cyrillic_el] [])
       (global-set-key [Cyrillic_EL] [])
       (global-set-key [Cyrillic_em] [])
       (global-set-key [Cyrillic_EM] [])
       (global-set-key [Cyrillic_en] [])
       (global-set-key [Cyrillic_EN] [H])
       (global-set-key [Cyrillic_er] [])
       (global-set-key [Cyrillic_ER] [])
       (global-set-key [Cyrillic_es] [])
       (global-set-key [Cyrillic_ES] [])
       (global-set-key [Cyrillic_ghe] [])
       (global-set-key [Cyrillic_GHE] [])
       (global-set-key [Cyrillic_ha] [])
       (global-set-key [Cyrillic_HA] [])
       (global-set-key [Cyrillic_hardsign] [])
       (global-set-key [Cyrillic_HARDSIGN] [])
       (global-set-key [Cyrillic_i] [])
       (global-set-key [Cyrillic_I] [])
       (global-set-key [Cyrillic_ie] [])
       (global-set-key [Cyrillic_IE] [])
       (global-set-key [Cyrillic_io] [])
       (global-set-key [Cyrillic_IO] [])
       (global-set-key [Cyrillic_ka] [])
       (global-set-key [Cyrillic_KA] [])
       (global-set-key [Cyrillic_o] [])
       (global-set-key [Cyrillic_O] [])
       (global-set-key [Cyrillic_pe] [])
       (global-set-key [Cyrillic_PE] [])
       (global-set-key [Cyrillic_sha] [])
       (global-set-key [Cyrillic_SHA] [])
       (global-set-key [Cyrillic_shcha] [])
       (global-set-key [Cyrillic_SHCHA] [])
       (global-set-key [Cyrillic_shorti] [])
       (global-set-key [Cyrillic_SHORTI] [])
       (global-set-key [Cyrillic_softsign] [])
       (global-set-key [Cyrillic_SOFTSIGN] [])
       (global-set-key [Cyrillic_te] [])
       (global-set-key [Cyrillic_TE] [])
       (global-set-key [Cyrillic_tse] [])
       (global-set-key [Cyrillic_TSE] [])
       (global-set-key [Cyrillic_u] [])
       (global-set-key [Cyrillic_U] [])
       (global-set-key [Cyrillic_ve] [])
       (global-set-key [Cyrillic_VE] [])
       (global-set-key [Cyrillic_ya] [])
       (global-set-key [Cyrillic_YA] [])
       (global-set-key [Cyrillic_yeru] [])
       (global-set-key [Cyrillic_YERU] [])
       (global-set-key [Cyrillic_yu] [])
       (global-set-key [Cyrillic_YU] [])
       (global-set-key [Cyrillic_ze] [])
       (global-set-key [Cyrillic_ZE] [])
       (global-set-key [Cyrillic_zhe] [])
       (global-set-key [Cyrillic_ZHE] [])

       ;; Adjust syntax table of the current so that russian letters are
       ;; correctly recognized
       (modify-syntax-entry ?\ "w" (standard-syntax-table))
       (modify-syntax-entry ?\ "w" (standard-syntax-table))
       (modify-syntax-entry ?\ "w" (standard-syntax-table))
       (modify-syntax-entry ?\ "w" (standard-syntax-table))))

;; Russian ispell setup
(setq ispell-dictionary-alist
      (append ispell-dictionary-alist
              (list
               (list
                "russian"
                "[
]"
                "[^
]"
                "[\0]"
                nil
                nil
                nil)))
      ispell-dictionary "russian")

;; Mail-utils modified by XEmacs team are a little bit braindamaged -- they 
;; think that unencoded 8 bit messages are incorrect. That's not true, I think.
(cond ((and running-xemacs mule-present)
       (require 'mail-utils)
       (fset 'mail-check-safe-charset '(lambda () nil))))

;; MULE settings common to both emacsen
(cond (mule-present
       ;; Make Gnus send letters in koi8-r encoding
       (put-charset-property 'cyrillic-iso8859-5 
                             'preferred-coding-system 'koi8-r)
       ;; I'd like to see cyrillic in ZenIRC buffers
       (modify-coding-system-alist 'network 6666 'koi8-r)
       ;; And in dictionary buffers, too
       (modify-coding-system-alist 'network 2628 'koi8-r)
       ))

;; Make isearch tolerable to iso-next-group/iso-prev-group keys
(cond (running-xemacs
       (defun isearch-foo-command ()
         (interactive)
         (isearch-update))
       (put 'isearch-foo-command 'isearch-command t)
       (define-key isearch-mode-map [(iso-next-group)] 'isearch-foo-command)
       (define-key isearch-mode-map [(iso-prev-group)] 'isearch-foo-command)))

;; MULE on Unix setup
(cond ((and running-on-unix mule-present)
       (set-language-environment "Cyrillic-KOI8")
       (prefer-coding-system 'koi8-r)

       (if running-on-x
           (set-face-font
            'default
            '("-monotype-courier new-medium-r-*-*-17-*-*-*-*-*-iso8859-1"
              "-monotype-courier new-medium-r-*-*-17-*-*-*-*-*-iso8859-2"
              "-monotype-courier new-medium-r-*-*-17-*-*-*-*-*-iso8859-3"
              "-monotype-courier new-medium-r-*-*-17-*-*-*-*-*-iso8859-4"
              "-monotype-courier new-medium-r-*-*-17-*-*-*-*-*-iso8859-5"
              "-monotype-courier new-medium-r-*-*-17-*-*-*-*-*-iso8859-7"
              "-monotype-courier new-medium-r-*-*-17-*-*-*-*-*-iso8859-8"
              "-monotype-courier new-medium-r-*-*-17-*-*-*-*-*-iso8859-9")
            'global '(mule-fonts) 'prepend))))

;; Fix case table (this code works on latest XEmacs version)
(if (and running-xemacs (>= emacs-major-version 21) (>= emacs-minor-version 4))
    (let ((uc "")
          (dc "ţ")
          (ct (standard-case-table)))
      (mapc (lambda (x y)
              (put-case-table-pair x y ct))
            uc dc)
      (set-standard-case-table ct)))

;; NT Emacs settings
(cond (running-on-windows       
       (codepage-setup 1251)       
       (prefer-coding-system 'cp1251-dos)       
       (set-w32-system-coding-system 'cp1251-dos)       
       (set-clipboard-coding-system 'cp1251-dos)       
       (set-default-coding-systems 'cp1251-dos)       
       (setq w32-standard-fontset-spec	     
             "-*-Courier New-normal-r-*-*-*-120-*-*-c-*-fontset-courier,   
              ascii:-*-Courier New-normal-r-*-*-*-120-*-*-c-*-iso8859-1,   
              latin-iso8859-1:-*-Courier New-normal-r-*-*-*-120-*-*-c-*-iso8859-1,   
              latin-iso8859-2:-*-Courier New-normal-r-*-*-*-120-*-*-c-*-iso8859-2,   
              latin-iso8859-3:-*-Courier New-normal-r-*-*-*-120-*-*-c-*-iso8859-3,   
              latin-iso8859-4:-*-Courier New-normal-r-*-*-*-120-*-*-c-*-iso8859-4,   
              latin-iso8859-9:-*-Courier New-normal-r-*-*-*-120-*-*-c-*-iso8859-9,   
              cyrillic-iso8859-5:-*-Courier New-normal-r-*-*-*-120-*-*-c-*-iso8859-5,   
              greek-iso8859-7:-*-Courier New-normal-r-*-*-*-120-*-*-c-*-iso8859-7")       
       (setq w32-enable-italics t)       
       (create-fontset-from-fontset-spec w32-standard-fontset-spec t)       
       (setq default-frame-alist '((font . "fontset-courier")))))

;;}}}

;;{{{ Remember settings

(autoload 'remember "remember" nil t)
(autoload 'remember-region "remember" nil t)

(define-key global-map [(control c) (meta r)] 'remember)
(define-key global-map [(control c) (control r)] 'remember-region)

;;}}}

;;{{{ BBDB Settings

(cond ((not running-on-windows)
       (require 'bbdb)
       (bbdb-initialize 'gnus 'message 'vm 'w3)
       (add-hook 'gnus-startup-hook 'bbdb-insinuate-gnus)
       (add-hook 'mail-setup-hook 'bbdb-insinuate-sendmail)
       (bbdb-insinuate-message)
       (bbdb-insinuate-w3)
       (add-hook 'message-setup-hook 'bbdb-define-all-aliases)))

;;}}}

;;{{{ Miscelanneous settings

(put 'narrow-to-region 'disabled nil)
(setq gd-indicator-string " G")
(setq-default filladapt-mode t)
;; Don't let Gnus eat my mail
(setq mail-sources nil)
(setq nnmail-spool-file nil)
;; Make text mode default major mode
(setq default-major-mode 'text-mode)
;; My shell prompt ends on ")"
(setq shell-prompt-pattern "^[^#$%>\n]*[#$%>\)] *")

(standard-display-8bit 128 255)

;;}}}

;;{{{ Keys

;; Keybindings for C-derived modes
(define-key c-mode-base-map "\C-cc" 'compile)
(define-key c-mode-base-map "\C-m" 'newline-and-indent)

;; C-x m should call vm-mail if I want to use vm
(if (eq default-mail-user-agent 'vm)
    (define-key global-map [(control x) m] 'vm-mail))

(define-key global-map [(f1)] 'manual-entry)
(define-key global-map [(f2)] 'gnus)
(if (eq default-mail-user-agent 'vm)
    (define-key global-map [(f3)] 'vm))
(if (eq default-mail-user-agent 'mutt)
    (define-key global-map [(f3)] 'read-mail-with-mutt))
(define-key global-map [(f4)] 'zenirc)

;; Let C-c v be view-file
(define-key global-map [(control c) v] 'view-file)

;; Rebind C-x C-b for buffer-menu
(define-key global-map [(control c) (control b)] 'buffer-menu)

;; Never iconify
(define-key global-map [(control z)] nil)
(define-key global-map [(control x) (control z)] nil)

;; Never quit by mistake...
(define-key global-map [(control x) (control c)]
  '(lambda () (interactive)
     (cond ((y-or-n-p "Quit editor? ")
            (save-buffers-kill-emacs)))))

;;}}}

;;{{{ Hooks

;; Useful defaults for text and programming modes
(defun my-text-modes-common-hook ()
  (turn-on-auto-fill))

;; For composing messages: long lines in mail messages annoys me
(defun small-fill-column-hook ()
  (setq fill-column 70))

(add-hook 'sgml-mode-common-hook 'my-text-modes-common-hook)
(add-hook 'text-mode-hook 'my-text-modes-common-hook)
(add-hook 'shell-mode-hook 'my-text-modes-common-hook)
(add-hook 'mail-mode-hook 'my-text-modes-common-hook)
(add-hook 'py-mode-hook 'my-text-modes-common-hook)

(add-hook 'mail-mode-hook 'small-fill-column-hook)
(add-hook 'mail-mode-hook 'font-lock-mode)
(add-hook 'shell-mode-hook 'install-shell-fonts)
(add-hook 'find-file-hook 'auto-insert)

(add-hook 'emacs-lisp-mode-hook 'imenu-add-menubar-index)

;;}}}

;;{{{ ZenIRC settings

;; this is a list of IRC servers you use
;; it consists of servername, portnumber, password, nickname, username
(setq zenirc-server-alist 
      '(
        ("irc.ru" 6666 nil "sad" "Eugene")
        ("irc.funet.fi" 6666 nil "sad" "Eugene")
        ))

(setq zenirc-user-full-name-default "Eugene Morozov"
      zenirc-userinfo "Oink."
      zenirc-beep-on-signal 'always)

;; with zenirc-beep-on-signal turned on, this will make zenirc beep when you
;; recieve a private PRIVMSG
(setq zenirc-signal-list '("^\\([^ ]\\)* PRIVMSG [^#&+]\\([^ ]\\)* :"))

(setq zenirc-send-confirmation 'message
      zenirc-timestamp t
      zenirc-timestamp-prefix "["
      zenirc-timestamp-suffix "]"
      zenirc-delete-preceding-whitespaces t)


;; in ircII, the channelname isn't shown in PRIVMSGs if you're currently
;; talking to the channel, setting zenirc-always-show-channelname to nil
;; gives you the same effect.
(setq zenirc-always-show-channelname t)

;; if WHOIS returns no-such-nick, setting this variable to t will make 
;; the client automaticall issue an WHOWAS command
(setq zenirc-whowas-on-401 t)

;; if you want ZenIRC to send out ERRMSG on bogus CTCP queries
(setq zenirc-send-ctcp-errmsg-on-unknown t)

;; if you awnt ZenIRC to send out ERRMSG on unbalanced CTCP queries
(setq zenirc-send-ctcp-errmsg-on-unbalanced t)

;; if you want ZenIRC to tell you when send out CTCP replies
(setq zenirc-verbose-ctcp t)

;; what ZenIRC replies on CTCP FINGER
(setq zenirc-fingerdata "Why do you want to know that")

(load-library "zenirc-complete")
(load-library "zenirc-history")
(load-library "zenirc-netsplit")

;;; use the following to make ZenIRC format things like no-other-client 
;;; is able to. the first time a nick is seen, it's shown as 
;;; `nick!user@host'... after the first time it's just shown as `nick'
;;; until the `user@host' part changes.
(load-library "zenirc-format")

;;; use the following to get an ircII like /ignore command
;(load-library "zenirc-ignore")

;;}}}

;;{{{ Dictionary setup

;; Load support for dictionary lookups
(autoload 'dictionary-search "dictionary"
  "Ask for a word and search it in all dictionaries" t)
(autoload 'dictionary-match-words "dictionary"
  "Ask for a word and search all matching words in the dictionaries" t)
(autoload 'dictionary "dictionary"
  "Create a new dictionary buffer" t)

(global-set-key [(control c) ?s] 'dictionary-search)
(global-set-key [(control c) ?m] 'dictionary-match-words)

;;}}}

(cond (running-xemacs
       (gnuserv-start)))

;;{{{ Local variables

;; Local variables:
;; folded-file: t
;; coding: koi8-r-unix
;; End:

;;}}}
All content copyright by the contributors. Website maintained with Emacs , wsmake and html-helper-mode
Emacs community logo by Daniel Lundin Last updated on Sat Jan 22 14:57:07 2005 by Ingo Koch