csdn初学

http://blog.youkuaiyun.com/myarrow/article/details/27049673






;; 关闭工具栏,tool-bar-mode 即为一个 Minor Mode


;; Added by Package.el.  This must come before configurations of
;; installed packages.  Don't delete this line.  If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
;;(package-initialize)
;(add-to-list 'load-path "/Users/tinyult/.emacs.d/elpa")
;(add-to-list 'load-path "/Users/tinyult/Documents/Go/gocodea")




(when (>= emacs-major-version 24)
  (require 'package)
  (package-initialize)
  (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
  )


(require 'cl)


(defvar TinyUlt/packages '(
 company
 monokai-theme
 go
 go-mode
         go-autocomplete
 go-eldoc
 hungry-delete
 smex
 swiper
 counsel
 exec-path-from-shell
 smartparens
 ) "Default packages")
(setq package-selected-packages TinyUlt/packages)
(defun TinyUlt/packages-installed-p ()
  (loop for pkg in TinyUlt/packages
when(not (package-installed-p pkg)) do (return nil)
finally (return t)))
(unless (TinyUlt/packages-installed-p)
  (message "%s" "Refreshing package database...")
  (package-refresh-contents)
  (dolist (pkg TinyUlt/packages)
    (when (not (package-installed-p pkg))
      (package-install pkg))))








(tool-bar-mode -1)


;; 关闭文件滑动控件
(scroll-bar-mode -1)


;; 显示行号
(global-linum-mode 1)


;; 更改光标的样式(不能生效,解决方案见第二集)
(setq cursor-type 'bar)


;; 关闭启动帮助画面
(setq inhibit-splash-screen 1)


;; 关闭缩进 (第二天中被去除)
;; (electric-indent-mode -1)


;; 更改显示字体大小 16pt
;; http://stackoverflow.com/questions/294664/how-to-set-the-font-size-in-emacs
(set-face-attribute 'default nil :height 160)


;; 快速打开配置文件
(defun open-init-file()
  (interactive)
  (find-file "~/.emacs.d/init.el"))


(defun open-go-file()
     (interactive)
     (find-file "/Users/tinyult/Documents/Go/hello.go")
     )


;; 这一行代码,将函数 open-init-file 绑定到 <f1> 键上
     (global-set-key (kbd "<f2>") 'open-init-file)
     (global-set-key (kbd "<f3>") 'open-go-file)


(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.
 '(ansi-color-faces-vector
   [default default default italic underline success warning error])
 '(ansi-color-names-vector
   ["black" "#d55e00" "#009e73" "#f8ec59" "#0072b2" "#cc79a7" "#56b4e9" "white"])
 '(company-idle-delay 0.08)
 '(company-minimum-prefix-length 1)
 '(custom-enabled-themes (quote (deeper-blue)))
 '(package-selected-packages (quote (monokai-theme company)))
 '(show-paren-mode t)
 '(tool-bar-mode nil))
(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.
 )
; 开启全局 Company 补全
(global-company-mode 1)






(setq make-backup-files nil)


(require 'recentf)
(recentf-mode 1)
(setq recentf-max-menu-item 25)
(global-set-key "\C-x\ \C-r" 'recentf-open-files)


(delete-selection-mode t)
(setq initial-frame-alist (quote ((fullscreen . maximized))))


(add-hook 'emacs-lisp-mode-hook 'show-paren-mode)


(global-hl-line-mode t)


(setq-default cursor-type 'bar)




(load-theme 'monokai t)


(require 'hungry-delete)
(global-hungry-delete-mode)








(require 'smex) ; Not needed if you use package.el
(smex-initialize) ; Can be omitted. This might cause a (minimal) delay
                  ; when Smex is auto-initialized on its first run.
(global-set-key (kbd "M-x") 'smex)


(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(global-set-key "\C-s" 'swiper)
(global-set-key (kbd "C-c C-r") 'ivy-resume)
(global-set-key (kbd "<f6>") 'ivy-resume)
(global-set-key (kbd "M-x") 'counsel-M-x)
(global-set-key (kbd "C-x C-f") 'counsel-find-file)
(global-set-key (kbd "<f1> f") 'counsel-describe-function)
(global-set-key (kbd "<f1> v") 'counsel-describe-variable)


(require 'smartparens-config)
(smartparens-global-mode t)






(defun set-exec-path-from-shell-PATH ()
  (let ((path-from-shell (replace-regexp-in-string
                          "[ \t\n]*$"
                          ""
                          (shell-command-to-string "$SHELL --login -i -c 'echo $PATH'"))))
    (setenv "PATH" path-from-shell)
    (setq eshell-path-env path-from-shell) ; for eshell users
    (setq exec-path (split-string path-from-shell path-separator))))


(when window-system (set-exec-path-from-shell-PATH))
(setenv "GOPATH" "/Users/tinyult/Development/gocode")


(setq exec-path (cons "/usr/local/go/bin" exec-path))
(add-to-list 'exec-path "/Users/tinyult/Development/gocode/bin")
(add-hook 'before-save-hook 'gofmt-before-save)










(defun auto-complete-for-go ()
  (auto-complete-mode 1))


 (add-hook 'go-mode-hook 'auto-complete-for-go)
(with-eval-after-load 'go-mode
  (require 'go-autocomplete))










(defun my-go-mode-hook ()
  ; Use goimports instead of go-fmt
  (setq gofmt-command "goimports")
  ; Call Gofmt before saving
  (add-hook 'before-save-hook 'gofmt-before-save)
  ; Customize compile command to run go build
  (if (not (string-match "go" compile-command))
      (set (make-local-variable 'compile-command)
           "go run"))
  ; Go oracle
  (load-file "$GOPATH/src/golang.org/x/tools/cmd/oracle/oracle.el")
  ; Godef jump key binding
  (local-set-key (kbd "M-.") 'godef-jump))
(add-hook 'go-mode-hook 'my-go-mode-hook)




(setq org-agenda-file '("/Users/tinyult/org"))
(global-set-key (kbd "C-c a") 'org-agenda)


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值