LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 653|回复: 1

My dotEmacs献给sir的处女作

[复制链接]
发表于 2005-3-23 22:22:17 | 显示全部楼层 |阅读模式
献给想模一模emacs的初学者,下面的.emacs内容可选其中部分,或全拿,如果起动emacs时,发现缺少某个扩展包的(肯定会碰到^_^),到下面这个网址去找扩展包http://www.linuxpcug.org/lessons/el-list-all.html#m
,将其保存到emacs目录下的site-lisp目录。我的是rh9:
/usr/share/emacs/site-lisp.当然
更好的作法是将它们单独放在一个目录下,然后在.emacs中
添加loadpath路径--我可懒得这么做。

想起用emacs自己的汉字输入法:C-\\(Ctrl+\\)。我想这应该需要mule-gbk包,这是我乱敲键盘发现的


;;*****************************Emacs setting configure***********************
;;
;;Copyright by amii .2:30 Sat, Mar 19,2005
;;
;;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>rivate Infomation<<<<<<<<<<<<<<<<<<<<<<<<<<<<
(setq user-full-name "AMII")
(setq user-mail-address "mh_su@163.com")

;;====================================Window Mode==============================

;;{{{{{--
(set-frame-height (selected-frame) 43)
(set-frame-width (selected-frame) 122)
(and window-system
     (setq screen-width (x-display-pixel-width)
       screen-height (x-display-pixel-height)))

;;Coding system--- Load mule-gbk
(require 'chinese-gbk)
(require 'characters-gbk)
;; Do not load fontset definitions when Emacs is in terminal mode.
(if window-system
   (require 'fontset-gbk))
;; Setup GBK environment
   (set-terminal-coding-system 'chinese-gbk)
   (set-keyboard-coding-system 'chinese-gbk)
   (set-language-environment 'chinese-gbk)
   (setq locale-coding-system 'chinese-gbk)
   (setq current-language-environment "Chinese-GBK")
   (set-selection-coding-system 'chinese-iso-8bit-with-esc)

;;font change
(set-default-font "-misc-fixed-medium-r-normal--20-200-75-75-c-100-iso8859-9")
             ;       -misc-fixed-medium-r-normal--18-120-100-100-c-90-iso8859-1")

;recognize chinese marker
;(setq sentence-end-double-space nil)
;;End--}}}}}

;;=======================================Microsoft Stype================================
;;{{{{{--
(pc-selection-mode)
;;starup message
(setq inhibit-startup-message t)

;;select all
(global-set-key "\C-a" 'mark-whole-buffer)

;;mouse wheel configure
(mouse-wheel-mode t)

;ut scroll bars on the right
(set-scroll-bar-mode 'right)

;;shutdown sound
(setq visible-bell t)

;;color theme
(require 'color-theme)
;; set default color theme
    (color-theme-dark-blue)
; (load-file "~/.emacs-color-theme")
;    (my-color-theme)

;;change yes/no to y/n
(fset 'yes-or-no-p 'y-or-n-p)

;;display time
;(display-time)

;;tool bar hide
(tool-bar-mode -1)

;; tabbar.el --- Display a tab bar in the header line
  (require 'tabbar)
        (tabbar-mode)
        (define-prefix-command 'lwindow-map)
        (setq tabbar-buffer-groups-function 'tabbar-buffer-ignore-groups)
     (global-set-key [(control up)] 'tabbar-backward-group)
     (global-set-key [(control down)] 'tabbar-forward-group)
     (global-set-key [(control left)] 'tabbar-backward)
     (global-set-key [(control right)]  'tabbar-forward)
     (global-set-key [(control tab)]  'tabbar-forward)


    (defun tabbar-buffer-ignore-groups (buffer)  "Return the list of group names BUFFER \
             belongs to.Return only one group for each buffer."
    (with-current-buffer (get-buffer buffer)
    (cond
     ((or (get-buffer-process (current-buffer))
          (memq major-mode
                '(comint-mode compilation-mode)))
      '("rocess")
      )
     ((member (buffer-name)
              '("*scratch*")); "*Messages*"))
      '("Common")
      )
     ((eq major-mode 'dired-mode)
      '("Dired")
      )
     ((memq major-mode
            '(help-mode apropos-mode Info-mode Man-mode))
      '("Help")
      )
     ((memq major-mode
            '(rmail-mode
              rmail-edit-mode vm-summary-mode vm-mode mail-mode
              mh-letter-mode mh-show-mode mh-folder-mode
              gnus-summary-mode message-mode gnus-group-mode
              gnus-article-mode score-mode gnus-browse-killed-mode))
      '("Mail")
      )
     (t
      (list
       "default"  ;; no-grouping
       (if (and (stringp mode-name) (string-match "[^ ]" mode-name))
           mode-name
         (symbol-name major-mode)))
      )
     )))


(custom-set-faces
  ;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
'(border ((t (:background "darkslategray"))))
'(menu ((t (:inherit default :background "wheat" :foreground "darkslategray" :family "misc-fixed"))))
'(tabbar-default-face ((t (:inherit variable-pitch :background "gray80" :foreground "gray35" :height 0.8))))
'(tabbar-selected-face ((t (:inherit tabbar-default-face :background "#102e4e" :foreground "green" \
:box (:line-width 2 :color "#102e4e" :style pressed-button)))))
'(tabbar-unselected-face ((t (:inherit tabbar-default-face :foreground "#0505F8" \
:box (:line-width 2 :color "gray95" :style released-button nil))))))
;;}}}
;;Don't echo passwords when communicating with interactive programs
(add-hook 'comint-output-filter-functions 'comint-watch-for-password-prompt)
;;End--}}}}}

;;===============================Edit Setting Conf===============================

;;{{{{{
;;scroll end-sreen before three lines
(setq scroll-margin 3
      scroll-conservatively 10000)

;;major mode text
(setq default-major-mode 'text-mode)

;;tab fashion
(require 'cl)
(setq-default indent-tabs-mode nil)
(setq default-tab-width 4)
(setq tab-stop-list ())
(loop for x downfrom 40 to 1 do
     (setq tab-stop-list (cons (* x 4) tab-stop-list)))

;;show line number
(setq column-number-mode t)
(require 'setnu)

;;show hightlight text
(global-font-lock-mode t)
(setq lazy-lock-defer-on-scrolling t)
(setq font-lock-support-mode 'lazy-lock-mode)
(setq font-lock-maximum-decoration t)

;;match another ")"
(show-paren-mode t)
(setq show-paren-style 'parentheses)

;; auto complete function
     (global-set-key [f3] 'hippie-expand)
       (setq hippie-expand-try-functions-list
        '(try-complete-file-name-partially
          try-complete-file-name
          try-expand-all-abbrevs
          try-expand-list
          try-expand-line
          try-expand-dabbrev
          try-expand-dabbrev-all-buffers
          try-expand-dabbrev-from-kill
          try-complete-lisp-symbol-partially
          try-complete-lisp-symbol))

;;paste text from/to firefox
(setq x-select-enable-clipboard t)

;;show picture/image directly
;(require 'thumbs)
(auto-image-file-mode)

;;let out cussur
(mouse-avoidance-mode 'animate)

;;directly delete directory
(setq dired-recursive-copies 'top)
(setq dired-recursive-deletes 'top)

;;dont create temp file
(setq-default make-backup-files nil)

;;default open directory
(setq default-directory "/home/examples/")

;;backup files directory
;delete auto-save files
(setq delete-auto-save-files t)
;; backup policies
(setq version-control t)
(setq kept-old-versions 2)
(setq kept-new-versions 5)
(setq delete-old-versions t)
(setq backup-directory-alist '(("" . "~/tmp")))

;;keymap bindings
(global-set-key [f2] 'setnu-mode)
;(global-set-key [f2] 'undo)
;(global-set-key [f3] 'redo)
(global-set-key [f4] 'kill-this-buffer)
(global-set-key [f5] 'shell-command)
(global-set-key [f7] 'gnus)
(global-set-key [f8] 'compile)
(global-set-key [f9] 'gdb)
(global-set-key [f11] 'next-error)
(global-set-key [(control v)] 'yank)
(global-set-key [(control z)] 'undo)

;;help and kill buffer
(global-set-key [(f1)] 'help)
(global-set-key [(control w)] 'kill-buffer)

;;auto-mode-alist
(mapcar
(function (lambda (setting)
             (setq auto-mode-alist
                   (cons setting auto-mode-alist))))
'(("\\.\\(xml\\|xsl\\)\\'".  sgml-mode)
   ("\\\.bash" . sh-mode)
   ("\\.rdf$".  sgml-mode)
   ("\\.session" . emacs-lisp-mode)
   ("\\.l$" . c-mode)
   ("\\.css$" . css-mode)
   ("\\.cfm$" . html-mode)
   ("gnus" . emacs-lisp-mode)
   ("\\.idl$" . idl-mode)
   ("\\.el$" . lisp-mode)
   ("\\.cgi$" . perl-mode)))       

;;;End--}}}}}

;;==========================================Orgnize Buffer===========================

;;{{{{{
;;show buffer name in title
(setq frame-title-format "emacs@%b")

(require 'ibuffer)
(global-set-key (kbd "C-x C-b") 'ibuffer)
;;
(require 'ido)
(ido-mode t)
;;Remember last opened & modified files
(require 'session)
  (add-hook 'after-init-hook 'session-initialize)
;;End--}}}}}
(add-hook 'c-mode-hook
       (lambda ()
         (unless (or (file-exists-p "makefile")
                     (file-exists-p "Makefile"))
           (set (make-local-variable 'compile-command)
                (concat "make -k "
                        (file-name-sans-extension buffer-file-name))))))

;;=============================Show Holiday & Birthday in Calender====================

;;{{{{{{
(setq mark-holidays-in-calendar t)
;;calender color configure
(setq calendar-load-hook
'(lambda ()
(set-face-foreground 'diary-face "skyblue")
(set-face-background 'holiday-face "slate blue")
(set-face-foreground 'holiday-face "white")))
;;End--}}}}}

;;=============================Programming Language Mode==============================

;;{{{{{-----------------------------------------c++ mode
(autoload 'c-mode "cc-mode")
(autoload 'c++-mode "cc-mode")

;;Java specializations
(c-add-style "java-pure-block-aligned"
             (list '(c-basic-offset . 4)
                   '(c-comment-only-line-offset 0 . 0)
                   '(c-hanging-comment-starter-p . t)
                   (list 'c-offsets-alist
                         '(access-label . 0)
                         '(arglist-close . c-lineup-arglist)
                         '(arglist-intro . c-lineup-arglist-intro-after-paren)
                         '(block-close . 0)
                         '(class-open . +)
                         '(class-close . +)
                         '(defun-block-intro . 0)
                         '(func-decl-cont . c-lineup-java-throws)
                         '(inher-cont . c-lineup-java-inher)
                         '(inline-open . +)
                         '(knr-argdecl-intro . 4)
                         '(label . 0)
                         '(statement-block-intro . 0)
                         '(statement-case-open . +)
                         '(statement-cont . +)
                         '(substatement-open . +)
                         '(topmost-intro . -)
                         '(topmost-intro-cont . +)
                         )))

(defun my-c++-mode-hook()
(c-set-style "stroustrup")
(setq tab-width 4
       ;; this will make sure spaces are used instead of tabs
       indent-tabs-mode nil)
;; we like auto-newline and hungry-delete
(c-toggle-auto-hungry-state 1))
;(local-set-key [return] 'newline-and-indent)
; (define-key c-mode-base-map "\C-m" 'c-context-line-break)
(add-hook 'c++-mode-hook 'my-c++-mode-hook)
(add-hook 'c-mode-hook 'my-c++-mode-hook)   
;;End c++ mode--}}}}}

(setq auto-insert t)
(setq auto-insert-query nil)
(add-hook 'find-file-hooks 'auto-insert)
(setq auto-insert-directory "~/.autoinsert/")
(load-library "autoinsert")
(setq auto-insert-alist
       (quote ((("\\.\\([Hh]\\|hh\\|hpp\\)\\'" . "My C / C++ header") nil
                (let* ((buf-name (file-name-nondirectory buffer-file-name)))
                  (let* ((num (- (length buf-name) 2)))
                    (let* ((str (substring buf-name 0 num)))
                      (concat "#ifndef " (upcase str)"_H\n"
                         "#define " (upcase str)  "_H\n"
                          "/*" (make-string 69 ?*) "\n"
                          " *\n"
                          " * Copyright (C) by " (user-full-name) " <" user-mail-address ">\n"
                          " * Time-stamp: <"(format-time-string "%h %d,%Y")">\n"
                          " *" (make-string 69 ?*) "*/\n"
                          "#include <iostream>\n"
                          "using std::cout;\nusing std::cin;\nusing std::err;\n\n"
                          "//namespace"(upcase str)"{\n"
                          "class foo\n"
                          "{\npublic:"
                          "\n\tfoo();"
                          "\n\t~foo();"
                          "\n\tvirtual vfoo();"
                          "\n\nprotect:"
                          "\nprivate:\n\n};\n//}"
                          "\n\n#endif /* " (upcase str) "_H */\n" )))))

                (("\\.\\([Cc]\\|cc\\|cpp\\)\\'" . "C / C++ program") nil
                  (concat "/*" (make-string 69 ?*) "\n"
                          " *"(file-name-nondirectory buffer-file-name)"\n"
                          " * Copyright (C) by " (user-full-name) " <" user-mail-address ">\n"
                          " * Time-stamp: <"(format-time-string "%h %d,%Y")">\n"
                          " *" (make-string 69 ?*) "*/\n"
                          "#include <iostream>\n"
                          "//#include ""\n"
                          "using std::cout;\nusing std::cin;\nusing std::err;\n\n"
                          "int main()\n{\n\n\treturn 0;\n}"))

               (perl-mode . (concat
                               "#! /usr/bin/perl -W\n"
                               "#\n#    " "^@^" "\n"
                               "#\n# Copyright (C) " (format-time-string "%h %d,%Y") " by "
                               (user-full-name) " <" (progn user-mail-address) ">\n"
                               "#\n\n")))))
;(define-auto-insert "\\.html\\'" "autoinsert.html")
;(define-auto-insert "\\.hh\\'" "hh")

;;{{{{{------------------------------------------------------Html mode
;;what you see is what you get text edit stype
(autoload 'table-insert "table" "WYGIWYS table editor")

;;html helper
(autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
(setq html-helper-do-write-file-hooks t)
(setq html-helper-build-new-buffer t)
(setq html-helper-address-string
  "<a href=\"http://202.117.217.121/\">AMII &lt;MH_SU@163.COM&gt;</a>")
(setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.asp$" . html-helper-mode)  auto-mode-alist))
(setq auto-mode-alist (cons '("\\.phtml$" . html-helper-mode) auto-mode-alist))

;;generate html file in buffer
(require 'htmlize)
;;End Html mode--}}}}}

;;{{{{{-------------------------------------------------------SQL mode
(add-to-list 'same-window-buffer-names "*SQL*")
(require 'sql)
(custom-set-variables
  ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
'(align-region-separate (quote entire))
'(case-fold-search t)
'(change-log-default-name "LOG")
'(compile-auto-highlight t)
'(current-language-environment "Chinese-GBK")
'(default-input-method "chinese-py")
'(global-font-lock-mode t nil (font-lock))
'(next-line-add-newlines t)
'(show-paren-mode t nil (paren))
'(sql-server "localhost")
'(tabbar-separator (quote ("")))
'(transient-mark-mode t))
    ;(defalias 'sql-get-login 'ignore)
;;End SQL mode--}}}}}
(add-hook 'perl-mode-hook
          (lambda ()
            (message "Setting up my perl hooks")
            ;;(setq tab-width 4)
            ;;(auto-fill-mode t)
            (local-set-key [return] 'newline-and-indent)
            ;;(auto-load-tags-file)
            (hs-minor-mode t)
            ))
(add-hook 'lisp-mode-hook
          (lambda ()
            (message "Setting up my lisp hooks")
            ;;(setq tab-width 4)
            (auto-fill-mode t)
            (local-set-key [return] 'newline-and-indent)
            ;;(auto-load-tags-file)
            (hs-minor-mode t)
            ))
;;===================================misc=====================================
(add-to-list 'load-path "/usr/share/emacs/site-lisp/emms/")

(require 'emms)
(require 'emms-default)
         (emms-setup 'tiny "~/mp3/");"directory-1" "directory 2" ...)
(require 'emms-player-simple)
(require 'emms-source-file)
(setq emms-player-list '(emms-player-mplayer
                        ; emms-player-ogg123
                        ; emms-player-mpg321
                                                 )
      emms-source-list '((emms-directory-tree "~/mp3/")))
;; Show the current track each time EMMS
;; starts to play a track with "NP : "
(add-hook 'emms-player-started-hook 'emms-show)
(setq emms-show-format "Now Play: %s")
(setq emms-repeat-playlist t)
;; When asked for emms-play-directory,
;; always start from this one
(setq emms-source-file-default-directory "~/mp3/")



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;Never byte-compile your .emacs file by hand again
(defun autocompile nil
  "compile itself if ~/.emacs"
  (interactive)
  (require 'bytecomp)
  (if (string= (buffer-file-name) (expand-file-name (concat default-directory ".emacs")))
      (byte-compile-file (buffer-file-name))))

(add-hook 'after-save-hook 'autocompile)

(message "Initialization...done")
发表于 2005-3-23 23:41:18 | 显示全部楼层
不错不错哦
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表