u
[emacs-helper.git] / eh-misc.el
blob5f459e046feae75086ae25a83790f4bcf46518bf
1 ;;; eh-misc.el --- Tumashu's emacs configuation -*- lexical-binding: t; -*-
3 ;; * Header
4 ;; Copyright (c) 2011-2019, Feng Shu
6 ;; Author: Feng Shu <tumashu@163.com>
7 ;; URL: https://github.com/tumashu/emacs-helper
8 ;; Version: 0.0.1
10 ;; This file is not part of GNU Emacs.
12 ;;; License:
14 ;; This program is free software; you can redistribute it and/or
15 ;; modify it under the terms of the GNU General Public License
16 ;; as published by the Free Software Foundation; either version 3
17 ;; of the License, or (at your option) any later version.
19 ;; This program is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;; GNU General Public License for more details.
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
26 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27 ;; Boston, MA 02110-1301, USA.
29 ;;; Commentary:
31 ;; * 简介 :README:
32 ;; 这个文件是tumashu个人专用的emacs配置文件,emacs中文用户可以参考。
34 ;;; Code:
36 ;; * 代码 :code:
38 ;; ** emacs-eat
39 (require 'eat)
40 (eat-eshell-mode 1)
42 (defun eh-eat--set-cmd (_ cmd)
43 (when (cl-some (lambda (x)
44 (string-search x cmd))
45 '("htop" "nmtui" "mutt" "aptitude"))
46 ;; * Color number:
47 ;; 0. black 1. red 2. green 3. yellow
48 ;; 4. blue 5. magenta 6. cyan 7. white
49 (dolist (x '((1 . 124)
50 (4 . 20)))
51 (eh-eat--change-color (car x) (cdr x)))))
53 (defun eh-eat--change-color (old-color-number new-color-number)
54 (let ((old-face (intern (format "color-%s-face" old-color-number)))
55 (new-face (intern (format "eat-term-color-%s" new-color-number))))
56 (setf (eat-term-parameter eat--terminal old-face) new-face)))
58 (defun eh-eat--eshell-adjust-make-process-args (_ command _args)
59 (when eat--terminal
60 (eh-eat--set-cmd nil command)))
62 (defun eh-eat--set-cmd-status (&rest _)
63 (dotimes (i 8)
64 (eh-eat--change-color i i)))
66 (advice-add 'eat--set-cmd :after #'eh-eat--set-cmd)
67 (advice-add 'eat--set-cmd-status :after #'eh-eat--set-cmd-status)
68 (advice-add 'eat--eshell-adjust-make-process-args :after #'eh-eat--eshell-adjust-make-process-args)
70 ;; ** projectile
71 (require 'projectile)
72 (global-set-key (kbd "C-x F") 'projectile-find-file)
73 (global-set-key (kbd "C-S-s") 'projectile-grep)
74 (setq projectile-enable-caching nil)
75 (projectile-mode 1)
77 ;; ** citre
78 (require 'citre-config)
79 (global-set-key (kbd "C-x c j") 'citre-jump)
80 (global-set-key (kbd "C-x c J") 'citre-jump-back)
81 (global-set-key (kbd "C-x c p") 'citre-ace-peek)
82 (global-set-key (kbd "C-x c u") 'citre-update-this-tags-file)
83 (setq citre-project-root-function #'projectile-project-root
84 citre-default-create-tags-file-location 'global-cache
85 citre-use-project-root-when-creating-tags t
86 citre-prompt-language-for-ctags-command t
87 citre-auto-enable-citre-mode-modes '(prog-mode))
89 ;; ** tempel
90 (require 'tempel)
91 (setq tempel-path (list (format "%s/*" (expand-file-name "tempel" (eh-directory)))))
92 (global-set-key (kbd "<f4>") 'tempel-insert)
93 (define-key tempel-map (kbd "<tab>") #'tempel-next)
94 (define-key tempel-map (kbd "C-<tab>") #'tempel-previous)
95 (add-hook 'write-file-functions #'tempel-done)
97 ;; ** syncthing
98 (defvar eh-org-syncthing-dir "~/syncthing")
99 (defun eh-org-open-syncthing-dir ()
100 (interactive)
101 (let ((dir (file-name-as-directory
102 (expand-file-name eh-org-syncthing-dir))))
103 (when (file-directory-p dir)
104 (if (or (derived-mode-p 'org-mode)
105 (derived-mode-p 'org-agenda-mode))
106 (eh-org-attach-reveal)
107 (eh-system-open dir)))))
109 (global-set-key (kbd "<f1>") 'eh-org-open-syncthing-dir)
111 ;; ** cnfonts
112 (require 'cnfonts)
113 (setq-default line-spacing 2)
114 (setq cnfonts-use-face-font-rescale
115 (eq system-type 'gnu/linux))
116 (cnfonts-mode 1)
117 (define-key cnfonts-mode-map (kbd "C--") 'cnfonts-decrease-fontsize)
118 (define-key cnfonts-mode-map (kbd "C-=") 'cnfonts-increase-fontsize)
120 ;; ** el2org
121 (require 'el2org)
123 ;; ** EPG
124 (require 'epg)
125 ;; 1. Put the below to your ~/.gnupg/gpg-agent.conf:
126 ;; allow-emacs-pinentry
127 ;; allow-loopback-pinentry
128 ;; 2. gpgconf --reload gpg-agent
129 ;; 3. (setq epa-pinentry-mode 'loopback)
130 ;; 4. (pinentry-start)
131 (setq epg-pinentry-mode 'loopback)
133 ;; ** emms
134 (require 'eh-emms)
136 ;; ** aggressive-indent
137 (require 'aggressive-indent)
139 (defun eh-elisp-setup ()
140 ;; 跟踪行尾空格
141 (setq show-trailing-whitespace t)
142 ;; 高亮TAB
143 (setq highlight-tabs t)
144 ;; 自动缩进
145 (aggressive-indent-mode))
147 (add-hook 'emacs-lisp-mode-hook
148 #'eh-elisp-setup)
150 ;; ** magit
151 (require 'magit)
152 (global-set-key (kbd "C-c g") 'magit-status)
153 (define-key magit-status-mode-map (kbd "C-c f") 'magit-format-patch)
155 ;; ** vundo
156 (require 'vundo)
158 ;; * Footer
159 (provide 'eh-misc)
161 ;; Local Variables:
162 ;; coding: utf-8-unix
163 ;; End:
165 ;;; eh-misc.el ends here