美文网首页
我的Emacs配置

我的Emacs配置

作者: alango | 来源:发表于2018-09-12 14:05 被阅读0次

我采用了模块化的配置方式。

init.el文件的内容为:

;; 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(expand-file-name "~/.emacs.d/lisp"))

;; Require Other Files
(require 'init-better-default)
(require 'init-modeline)
(require 'init-org)
(require 'init-package)
(require 'init-shortKey)
(require 'init-dired)
(require 'init-markdown)

;; Recent File Configurations
(require 'recentf)
(recentf-mode t)
(global-set-key "\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.
 '(company-idle-delay 0.05)
 '(company-minimum-prefix-length 2)
 '(package-selected-packages (quote (swiper)))
 '(word-wrap t))

init-better-default.el的内容为:

;; Initialize default
(setq-default indent-tabs-mode nil);; Tab to spaces.
(setq auto-save-default nil)
(setq make-backup-files nil)
(setq default-tab-width 4)
(setq c-basic-offset 4) ;; Insert 4 spaces in c/cpp mode.
(delete-selection-mode t)
(global-auto-revert-mode t)
(global-linum-mode t)
(show-paren-mode 1)

;; Change C-SPC to M-SPC. And using M-SPC to mark set.
;; And ensure I can use Chinese input method to input Chinese in Ubuntu.
;; Because in Ubuntu, "C-SPC" is the shortkey to change input method.
(global-set-key (kbd "C-SPC") nil)
(global-set-key (kbd "M-SPC") 'set-mark-command)

;; Auto-pair Brackets(Emacs Build-in Setting)
(electric-pair-mode t)

;; "M-x customize-option" to open "word-wrap". And set it to on.

;; Initialize UI
(setq inhibit-startup-screen t)
(tool-bar-mode -1)
(set-scroll-bar-mode nil)
(menu-bar-mode -1)
(global-hl-line-mode t)
(setq initial-frame-alist (quote ((fullscreen . maximized))))

;; Initialize Font
;; English font configuration
;; (set-default-font "Ubuntu Mono-13")
;; Chinese font configuration
(dolist (charset '(kana han cjk-misc bopomofo))
  (set-fontset-font "fontset-default" charset
                    (font-spec :family "微软雅黑" :size 16)))

;; Initialize Org-mode
;; line wrap
(add-hook 'org-mode-hook (lambda () (setq truncate-lines nil)))


(provide 'init-better-default)

init-dired.el内容为:

(setq dired-recursive-copies 'always)
(setq dired-recursive-deletes 'always)

(put 'dired-find-alternate-file 'disabled nil)
;; 主动加载 Dired Mode
;; (require 'dired)
;; (efined-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))
;; 使用延迟加载可以使编辑器加载速度有所提升

(require 'dired-x)  ;; 使得 C-x C-j 就可以进入当前文件夹的所在路径
(provide 'init-dired)

init-markdown.el的内容为:

(setq markdown-command "/usr/bin/pandoc")
;; Reference: https://jblevins.org/projects/markdown-mode/

(provide 'init-markdown)

init-modeline.el的内容为:

(setq-default mode-line-format
  (list
    '(:eval (propertize "%b " 'face nil
        'help-echo (buffer-file-name)))
    " ["
    '(:eval (propertize "%m" 'face nil
              'help-echo buffer-file-coding-system))
    '(:eval (when (buffer-modified-p)
              (concat ", "  (propertize "Modify"
                             'face nil
                             'help-echo "Buffer has been modified"))))
    ;; is this buffer read-only?
    '(:eval (when buffer-read-only
              (concat ","  (propertize "Read-Only"
                             'face nil
                             'help-echo "Buffer is read-only"))))
    "]"
    (propertize "%M" 'face nil)
    ))
(provide 'init-modeline)

init-org.el的内容为:

(defcustom org-structure-template-alist
    '(("s" "#+BEGIN_SRC ?\n\n#+END_SRC" "<src lang=\"?\">\n\n</src>")
         ("e" "#+BEGIN_EXAMPLE\n?\n#+END_EXAMPLE" "<example>\n?\n</example>")
         ("q" "#+BEGIN_QUOTE\n?\n#+END_QUOTE" "<quote>\n?\n</quote>")
         ("v" "#+BEGIN_VERSE\n?\n#+END_VERSE" "<verse>\n?\n</verse>")
         ("V" "#+BEGIN_VERBATIM\n?\n#+END_VERBATIM" "<verbatim>\n?\n</verbatim>")
         ("c" "#+BEGIN_CENTER\n?\n#+END_CENTER" "<center>\n?\n</center>")
         ("l" "#+BEGIN_LaTeX\n?\n#+END_LaTeX"
             "<literal style=\"latex\">\n?\n</literal>")
         ("L" "#+LaTeX: " "<literal style=\"latex\">?</literal>")
         ("h" "#+BEGIN_HTML\n?\n#+END_HTML"
             "<literal style=\"html\">\n?\n</literal>")
         ("H" "#+HTML: " "<literal style=\"html\">?</literal>")
         ("a" "#+BEGIN_ASCII\n?\n#+END_ASCII" "")
         ("A" "#+ASCII: " "")
         ("i" "#+INDEX: ?" "#+INDEX: ?")
         ("I" "#+INCLUDE: %file ?"
             "<include file=%file markup=\"?\">"))
    "Structure completion elements.
This is a list of abbreviation keys and values.  The value gets inserted
if you type `<' followed by the key and then press the completion key,
usually `M-TAB'.  %file will be replaced by a file name after prompting
for the file using completion.  The cursor will be placed at the position
of the `?` in the template.
There are two templates for each key, the first uses the original Org syntax,
the second uses Emacs Muse-like syntax tags.  These Muse-like tags become
the default when the /org-mtags.el/ module has been loaded.  See also the
variable `org-mtags-prefer-muse-templates'."
    :group 'org-completion
    :type '(repeat
               (list
                   (string :tag "Key")
                   (string :tag "Template")
                   (string :tag "Muse Template"))))

(require 'org)
(setq org-src-fontify-natively t)

(provide 'init-org)

init-package.el的内容为:

;; Package configuration
(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/"))))

(require 'cl)
;; Add Packages
(defvar melpa-include-packages
  '(
    swiper
    counsel
    material-theme
    atom-one-dark-theme
    zenburn-theme
    company
    markdown-mode
    edit-indirect
    window-numbering
    ) "Default packages")
(setq package-selected-packages melpa-include-packages)

(defun melpa-installed-packages ()
  (loop for pkg in melpa-include-packages
        when (not (package-installed-p pkg)) do (return nil)
        finally (return t)))

(unless (melpa-installed-packages)
  (message "%s" "Refreshing package database...")
  (package-refresh-contents)
  (dolist (pkg melpa-include-packages)
    (when (not (package-installed-p pkg))
      (package-install pkg))))

;; Smartparens configuration
;; (require 'smartparens-config)
;; (smartparens-global-mode t)

;; Swiper Configuration
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)

;; Theme Configuration
;; (load-theme 'material 1)
(load-theme 'zenburn 1)

;; Company configuration
(add-hook 'after-init-hook 'global-company-mode)

;; Window-numbering Configuration
(window-numbering-mode t)


(provide 'init-package)

init-shortkey.el的内容为:

(defun open-init-file()
  (interactive)
  (find-file "~/.emacs.d/init.el"))
(global-set-key (kbd "<f2>") 'open-init-file)

;; Ivy short key
(global-set-key "\C-s" 'swiper)
(global-set-key (kbd "C-c C-r") '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 "C-h f") 'counsel-describe-function)
(global-set-key (kbd "C-h v") 'counsel-describe-variable)


(provide 'init-shortKey)

相关文章

网友评论

      本文标题:我的Emacs配置

      本文链接:https://www.haomeiwen.com/subject/qgyvgftx.html