u
[emacs-helper.git] / eh-misc.el
blob077f0d748917b05a3d054a4d1d2224a27134fcd3
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 ;; ** tempel
78 (require 'tempel)
79 (setq tempel-path (list (format "%s/*" (expand-file-name "tempel" (eh-directory)))))
80 (global-set-key (kbd "<f4>") 'tempel-insert)
81 (define-key tempel-map (kbd "<tab>") #'tempel-next)
82 (define-key tempel-map (kbd "C-<tab>") #'tempel-previous)
83 (add-hook 'write-file-functions #'tempel-done)
85 ;; ** syncthing
86 (require 'eh-basic)
87 (require 'eh-org)
88 (defvar eh-org-syncthing-dir "~/syncthing")
89 (defun eh-org-open-syncthing-dir ()
90 (interactive)
91 (let ((dir (file-name-as-directory
92 (expand-file-name eh-org-syncthing-dir))))
93 (when (file-directory-p dir)
94 (if (or (derived-mode-p 'org-mode)
95 (derived-mode-p 'org-agenda-mode))
96 (eh-org-attach-reveal)
97 (eh-system-open dir)))))
99 (global-set-key (kbd "<f1>") 'eh-org-open-syncthing-dir)
101 ;; ** cnfonts
102 (require 'cnfonts)
103 (setq-default line-spacing 2)
104 (setq cnfonts-use-face-font-rescale
105 (eq system-type 'gnu/linux))
106 (setq cnfonts-personal-fontnames
107 '(("PragmataPro Mono")))
108 (cnfonts-mode 1)
109 (define-key cnfonts-mode-map (kbd "C--") 'cnfonts-decrease-fontsize)
110 (define-key cnfonts-mode-map (kbd "C-=") 'cnfonts-increase-fontsize)
112 ;; ** el2org
113 (require 'el2org)
115 ;; ** EPG
116 (require 'epg)
117 ;; 1. Put the below to your ~/.gnupg/gpg-agent.conf:
118 ;; allow-emacs-pinentry
119 ;; allow-loopback-pinentry
120 ;; 2. gpgconf --reload gpg-agent
121 ;; 3. (setq epa-pinentry-mode 'loopback)
122 ;; 4. (pinentry-start)
123 (setq epg-pinentry-mode 'loopback)
125 ;; ** emms
126 (require 'eh-emms)
128 ;; ** aggressive-indent
129 (require 'aggressive-indent)
131 (defun eh-elisp-setup ()
132 ;; 跟踪行尾空格
133 (setq show-trailing-whitespace t)
134 ;; 自动缩进
135 (aggressive-indent-mode))
137 (add-hook 'emacs-lisp-mode-hook
138 #'eh-elisp-setup)
140 ;; ** magit
141 (require 'magit)
142 (global-set-key (kbd "C-c g") 'magit-status)
143 (define-key magit-status-mode-map (kbd "C-c f") 'magit-format-patch)
145 ;; ** vundo
146 (require 'vundo)
148 ;; * Footer
149 (provide 'eh-misc)
151 ;; Local Variables:
152 ;; coding: utf-8-unix
153 ;; End:
155 ;;; eh-misc.el ends here