Skip to content

Instantly share code, notes, and snippets.

@jzztf
Created December 30, 2018 13:51
Show Gist options
  • Save jzztf/3ce9dbd8fbd2c23783a5be8f4bccc3cc to your computer and use it in GitHub Desktop.
Save jzztf/3ce9dbd8fbd2c23783a5be8f4bccc3cc to your computer and use it in GitHub Desktop.
emacs
;; 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.
(when (>= emacs-major-version 24)
(require 'package)
(package-initialize)
(setq package-archives '(("gnu" . "http://elpa.emacs-china.org/gnu/")
("melpa" . "http://elpa.emacs-china.org/melpa/"))))
;; cl - Common Lisp Extension
(require 'cl)
;; Add Packages
(defvar jzztf/packages '(
;; --- Auto-completion ---
company
;; --- Better Editor ---
popwin
hungry-delete
swiper
counsel
smartparens
;; --- Major Mode ---
js2-mode
markdown-mode+
;; --- Minor Mode ---
nodejs-repl
exec-path-from-shell
;; --- Themes ---
monokai-theme
;; solarized-theme
) "Default packages")
(setq package-selected-packages jzztf/packages)
(defun jzztf/packages-installed-p ()
(loop for pkg in jzztf/packages
when (not (package-installed-p pkg)) do (return nil)
finally (return t)))
(unless (jzztf/packages-installed-p)
(message "%s" "Refreshing package database...")
(package-refresh-contents)
(dolist (pkg jzztf/packages)
(when (not (package-installed-p pkg))
(package-install pkg))))
(global-linum-mode t)
;;install company-mode first: "M-x" -> "package-install" -> "company"
(global-company-mode 1)
;; close help screen
(setq inhibit-splash-screen 1)
;;delete-selection-mode
(delete-selection-mode 1)
;; load-theme
(load-theme 'monokai t)
;; add-to-list
;; (add-to-list 'jzztf/packages 'monokai-theme)
;; hungry-delete
(require 'hungry-delete)
(global-hungry-delete-mode)
;; swiper
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers 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)
;;"How emacs Choose a Major Mode"
;;[[https://www.gnu.org/software/emacs/manual/html_node/elisp/Auto-Major-Mode.html]]
(setq auto-mode-alist
(append
'(("\\.js\\'" . js2-mode)
("\\.md\\'" . markdown-mode))
auto-mode-alist))
;; hightlight in org source block
(require 'org)
(setq org-src-fontify-natively t)
;; set default agenda file directory
(setq org-agenda-files '("~/org"))
;; set short key for agenda
(global-set-key (kbd "C-c a") 'org-agenda)
;; autoload writted file
(global-auto-revert-mode t)
;; auto close autosave
(setq auto-save-default nil)
;; auto close backup
(setq make-backup-files nil)
;; auto move cursor to new window
(require 'popwin)
(popwin-mode 1)
;; close bi-bi-bi
(setq ring-bell-function 'ignore)
;; set y or n
(fset 'yes-or-no-p 'y-or-n-p)
;; indent
(defun indent-buffer()
(interactive)
(indent-region (point-min) (point-max)))
(defun indent-region-or-buffer()
(interactive)
(save-excursion
(if (region-active-p)
(progn
(indent-region (region-beginning) (region-end))
(message "Indent selected region."))
(progn
(indent-buffer)
(message "Indent buffer.")))))
(global-set-key (kbd "C-M-\\") 'indent-region-or-buffer)
;; 缩写补全,当填写缩写字符,并以“空格”结束,就会自动补全
(setq-default abbrev-mode t)
(define-abbrev-table 'global-abbrev-table '(
;; Shifu
("8zl" "zilongshanren")
;; Tudi
("8lxy" "lixinyang")
))
;; hippie自动补全,强化company
(setq hippie-expand-try-function-list '(try-expand-debbrev
try-expand-debbrev-all-buffers
try-expand-debbrev-from-kill
try-complete-file-name-partially
try-complete-file-name
try-expand-all-abbrevs
try-expand-list
try-expand-line
try-complete-lisp-symbol-partially
try-complete-lisp-symbol))
;; 绑定快捷键
(global-set-key (kbd "s-/") 'hippie-expand)
;;dired-mode
(setq dired-recursive-deletes 'always)
(setq dired-recursive-copies 'always)
(put 'dired-find-alternate-file 'disabled nil)
;; 主动加载 Dired Mode
;; (require 'dired)
;; (defined-key dired-mode-map (kbd "RET") 'dired-find-alternate-file)
;; 延迟加载
(with-eval-after-load 'dired
(define-key dired-mode-map (kbd "RET") 'dired-find-alternate-file))
;;C-x C-j 快速进入当前路径
(require 'dired-x)
;; setting for windows client
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(set-face-attribute 'default nil :height 130)
(setq initial-frame-alist (quote ((fullscreen . maximized))))
(global-hl-line-mode 1)
(add-hook 'emacs-lisp-mode-hook 'show-paren-mode)
;; open-init-file
(defun open-init-file()
(interactive)
(find-file "~/.emacs.d/init.el"))
(global-set-key (kbd "<f2>") 'open-init-file)
;; recentf
(require 'recentf)
(recentf-mode 1)
(setq recenf-max-menu-item 25)
(global-set-key (kbd "C-x C-r") 'recentf-open-files)
(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.
'(package-selected-packages (quote (markdown-mode+ company))))
(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.
)
;;20181230
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment