我的emacs简易配置

;;------------语言环境字符集设置(utf-8)-------------

(set-language-environment 'Chinese-GB)
(set-keyboard-coding-system 'utf-8)
(set-clipboard-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-buffer-file-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-selection-coding-system 'utf-8)
(modify-coding-system-alist 'process "*" 'utf-8)
(setq default-process-coding-system '(utf-8 . utf-8))
(setq-default pathname-coding-system 'utf-8)
(set-file-name-coding-system 'utf-8)
(setq ansi-color-for-comint-mode t)
;;处理shell-mode乱码,好像没作用

;;------语言环境字符集设置结束------------

;;--------------窗口界面设置------------------

(set-foreground-color "grey")
(set-background-color "black")
(set-cursor-color "gold1")
(set-mouse-color "gold1")

(set-scroll-bar-mode nil)
;;取消滚动栏

;;(customize-set-variable 'scroll-bar-mode 'right))
;;设置滚动栏在窗口右侧,而默认是在左侧

(tool-bar-mode nil)
;;取消工具栏

;;启动设置
(setq default-frame-alist
             '((vertical-scroll-bars)
               (top . 25)
               (left . 45)
               (width . 120)
               (height . 40)
               (background-color . "black")
               (foreground-color . "grey")
               (cursor-color . "gold1")
               (mouse-color . "gold1")
               (tool-bar-lines . 0)
               (menu-bar-lines . 1)
               (right-fringe)
               (left-fringe)))

;;启动自动最大化(数据自己调整,注意格式,如(top . 0),圆点前后都要留有空格)
;;(setq initial-frame-alist '((top . 0) (left . 0) (width . 142) (height . 49)))


;; 设置另外一些颜色:语法高亮显示的背景和主题,区域选择的背景和主题,二次选择的背景和选择
(set-face-foreground 'highlight "white")
(set-face-background 'highlight "blue")
(set-face-foreground 'region "cyan")
(set-face-background 'region "blue")
(set-face-foreground 'secondary-selection "skyblue")
(set-face-background 'secondary-selection "darkblue")

;;------------窗口界面设置结束-----------------


;;-------------方便编程操作设置----------------


;;把c语言风格设置为k&r风格
(add-hook 'c-mode-hook
'(lambda ()
(c-set-style "k&r")))

(autoload 'css-mode "css-mode" "CSS editing mode" t)
;;css-mode.el编辑css文件

(autoload 'htmlize-buffer "htmlize" "HTMLize mode" t)
;;把buffer的内容连同颜色转为html格式


(setq auto-mode-alist
      ;; 将文件模式和文件后缀关联起来
      (append '(("\\.py\\'" . python-mode)
                ("\\.s?html?\\'" . html-helper-mode)
                ("\\.asp\\'" . html-helper-mode)
                ("\\.phtml\\'" . html-helper-mode)
                ("\\.css\\'" . css-mode))
              auto-mode-alist))

(defun my-compile()
    (interactive)
    (save-some-buffers t)
    (let((file(file-name-nondirectory buffer-file-name)))
      (compile(format "g++ %s -g -o %s" file(file-name-sans-extension file))))
)


(global-linum-mode t)
(global-set-key [f9] 'my-compile)


(set-frame-parameter (selected-frame) 'alpha '(85  50))
 (add-to-list 'default-frame-alist '(alpha  (85  50)))

 (defun toggle-transparency ()
   (interactive)
   (let ((alpha (frame-parameter nil 'alpha)))
     (set-frame-parameter
      nil 'alpha
      (if (eql (cond ((numberp alpha) alpha)
                     ((numberp (cdr alpha)) (cdr alpha))
                     ;; Also handle undocumented ( ) form.
                     ((numberp (cadr alpha)) (cadr alpha)))
               100)
          '(85  50) '(100  100)))))
 (global-set-key (kbd "C-c t") 'toggle-transparency)
 
 
 (setq c-default-style
      '((java-mode . "java")(other . "awk")))
      
;;------------方便编程操作设置结束--------------------
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(cua-mode t nil (cua-base)))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

;;在标题栏显示buffer的名字(默认不显示)
(setq frame-title-format "%b@emacs")

;;显示匹配括号
(show-paren-mode t)
(setq show-paren-style 'parentheses)

;;全选
(global-set-key (kbd "C-a") 'mark-whole-buffer)

;滚动页面时比较舒服,不要整页的滚动
(setq     scroll-step 1
scroll-margin 3
scroll-conservatively 10000)


;;4格缩进
(setq-default indent-tabs-mode nil) ; tab 改为插入空格
(setq c-basic-offset 4) ; c c++ 缩进4个空格
(setq c-default-style "linux"); 没有这个 { } 就会瞎搞
(setq default-tab-width 4)

;;其中最重要的一段:[F9]编译
(defun my-compile()
    (interactive)
    (save-some-buffers t)
    (let((file(file-name-nondirectory buffer-file-name)))
      (compile(format "g++ %s -g -o %s" file(file-name-sans-extension file))))
)


(global-linum-mode t)
(global-set-key [f9] 'my-compile)
posted @ 2018-10-05 08:09  real_l  阅读(587)  评论(0编辑  收藏  举报