├── .editorconfig ├── .gitignore ├── .gitmodules ├── README.org ├── bin ├── delete_elc_file.py ├── ec ├── es ├── et └── install-spacemacs.sh ├── init.el ├── layers ├── appleshan-appearance │ ├── README.org │ ├── config.el │ ├── funcs.el │ └── packages.el ├── appleshan-chinese │ ├── README.org │ ├── config.el │ ├── funcs.el │ ├── local │ │ └── unicad │ │ │ ├── FAQ.md │ │ │ ├── FAQ_Chinese.md │ │ │ ├── FAQ_Chinese.org │ │ │ ├── ProjectHome.md │ │ │ ├── README │ │ │ └── unicad.el │ └── packages.el ├── appleshan-complete │ ├── README.org │ ├── config.el │ ├── funcs.el │ └── packages.el ├── appleshan-core │ ├── README.org │ ├── config.el │ ├── funcs.el │ └── packages.el ├── appleshan-database │ ├── config.el │ ├── funcs.el │ ├── img │ │ └── my-ejc-sql.png │ ├── local │ │ └── database-client │ │ │ ├── database-client.el │ │ │ └── database-password.el.gpg │ └── packages.el ├── appleshan-dired │ ├── README.org │ ├── funcs.el │ └── packages.el ├── appleshan-java │ ├── README.org │ ├── funcs.el │ └── packages.el ├── appleshan-javascript │ ├── funcs.el │ └── packages.el ├── appleshan-lisp │ ├── funcs.el │ └── packages.el ├── appleshan-misc │ ├── config.el │ ├── funcs.el │ └── packages.el ├── appleshan-navigation │ ├── README.org │ ├── funcs.el │ └── packages.el ├── appleshan-notify │ ├── README.org │ └── packages.el ├── appleshan-org │ ├── README.org │ ├── config.el │ ├── funcs.el │ └── packages.el ├── appleshan-programming │ ├── README.org │ ├── config.el │ ├── funcs.el │ ├── layers.el │ └── packages.el ├── appleshan-python │ ├── README.org │ ├── config.el │ ├── funcs.el │ └── packages.el ├── appleshan-remote │ └── packages.el ├── appleshan-shell │ ├── README.org │ ├── config.el │ └── packages.el ├── appleshan-web │ ├── funcs.el │ └── packages.el └── appleshan │ ├── keybindings.el │ └── layers.el └── local ├── banner ├── 001-banner-kban.txt ├── 002-banner-varsity.txt ├── 003-banner-epic.txt ├── 004-banner-alpha.txt ├── 005-banner-Isometric1.txt ├── 006-banner-keyboard.txt └── 007-banner-emacs.png ├── custom.el ├── custom.src.el ├── icons ├── book.png ├── email.png ├── gnus.png ├── holidays.png ├── important.png ├── irc.png ├── medical.png ├── music.png ├── org.png ├── train.png └── trip.png ├── img ├── spacemacs-demo-1.png ├── spacemacs-demo-2.png └── title2.png └── prodigy-services.el /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | indent_style = space 3 | indent_size = 2 4 | end_of_line = lf 5 | charset = utf-8 6 | trim_trailing_whitespace = true 7 | insert_final_newline = true -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io/api/elisp 2 | 3 | ### Elisp ### 4 | # Compiled 5 | *.elc 6 | 7 | # Packaging 8 | .cask 9 | 10 | .cache/ 11 | eclipse.jdt.ls/ 12 | 13 | local/dired-k/ 14 | local/terminal-here/ 15 | local/pyim-basedict/ 16 | local/pyim-greatdict/ 17 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "snippets"] 2 | path = snippets 3 | url = https://github.com/appleshan/emacs-snippets.git 4 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | #+TITLE:Apple Shan 的 Emacs 配置 :sparkles: 2 | #+begin_src :tangle no 3 | '||''''| '|| ||' | ..|'''.| .|'''.| 4 | || . ||| ||| ||| .|' ' ||.. ' 5 | ||''| |'|..'|| | || || ''|||. 6 | || | '|' || .''''|. '|. . . '|| 7 | .||.....| .|. | .||. .|. .||. ''|....' |'....|' 8 | #+end_src 9 | 10 | Hacking 始于 2012 年。2015 年爱上 Spacemacs :smile: :sparkling_heart: 11 | 12 | 我的 Spacemacs 配置一共有两部分: 13 | 一个 .emacs.d 目录,是 Spacemacs 的原始代码,未做任何修改; 14 | 一个 .spacemacs.d 目录,存放私有 layer。 15 | 16 | * Emacs version 17 | Tested on versions: 18 | - GNU Emacs 25.1 for Arch Linux (x86_64-pc-linux-gnu, GTK+ Version 3.4.2) of 2017-11-06 19 | Linux 大法好 20 | - [[https://github.com/zklhp/emacs-w64/releases][64-bit GNU Emacs for MS Windows with optimization]] (x86_64-pc-windows-10) of 2017-05-02 21 | 不要在 MS Windows 上折腾 emacs。建议先阅读 [[https://emacs-china.org/t/topic/3980][Windows 上面重度使用 Emacs 一个多月的感受]] 22 | 23 | * Screenshot 24 | [[./local/img/spacemacs-demo-1.png]] 25 | [[./local/img/spacemacs-demo-2.png]] 26 | 27 | * :beginner: Installing 28 | #+BEGIN_SRC bash :mkdirp yes :tangle ~/.spacemacs.d/bin/install-spacemacs.sh 29 | #!/usr/bin/env bash 30 | ########################################################################## 31 | # install emacs config automatically. 32 | # by Apple Shan (apple.shan@gmail.com) 33 | ########################################################################## 34 | 35 | # sudo pacman -S emacs 36 | 37 | cd ~/projects/ 38 | 39 | # clone syl20bnr/spacemacs repo 40 | git clone -b develop --depth 1 https://github.com/syl20bnr/spacemacs.git spacemacs-develop 41 | 42 | # clone appleshan/my-spacemacs-config and submodule 43 | git clone --recursive https://github.com/appleshan/my-spacemacs-config.git spacemacs-private 44 | 45 | # git submodule 46 | # 如果已經抓下來才發現 submodule 是空的,可以用以下指令去抓 47 | cd spacemacs-private 48 | git submodule update --init --recursive 49 | 50 | rm ~/.emacs.d 51 | rm ~/.spacemacs.d 52 | 53 | # 建立软链接 54 | # ln -s <源文件> <目标> 创建一个符号链接 55 | ln -s ~/projects/spacemacs-develop ~/.emacs.d 56 | ln -s ~/projects/spacemacs-private ~/.spacemacs.d 57 | 58 | # 验证软链接建立成功 59 | la ~/ |grep emacs 60 | 61 | ################################################################################ 62 | # 按照其他 package 63 | 64 | # all-the-icons 65 | # Installing Fonts 66 | M-x all-the-icons-install-fonts 67 | 68 | # dired-k 69 | cd ~/.spacemacs.d/local/ 70 | git clone https://github.com/appleshan/emacs-dired-k dired-k 71 | 72 | # terminal-here 73 | cd ~/.spacemacs.d/local/ 74 | git clone https://github.com/appleshan/terminal-here terminal-here 75 | 76 | # pyim-bigdict.pyim 77 | wget http://tumashu.github.io/pyim-bigdict/pyim-bigdict.pyim.gz 78 | 79 | ################################################################################ 80 | # 安装外部程序 81 | 82 | # Install miniconda 83 | wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh 84 | bash ./Miniconda3-latest-Linux-x86_64.sh 85 | rm -rf ./Miniconda3-latest-Linux-x86_64.sh 86 | 87 | # ditaa 88 | mkdir -p /opt/java/ditaa0_9 89 | cd /opt/java/ditaa0_9 90 | wget https://downloads.sourceforge.net/project/ditaa/ditaa/0.9/ditaa0_9.zip 91 | unzip ditaa0_9.zip 92 | 93 | # graphviz 94 | 95 | #+END_SRC 96 | 97 | 现在可以打开 Emacs 24.5+ 开始使用我的配置了。 98 | 99 | * :books: 配置说明 100 | 1. 我的配置主要分成 16 个 layer: 101 | - appleshan-core 102 | - appleshan-complete 103 | - appleshan-appearance 104 | - appleshan-navigation 105 | - appleshan-notify 106 | - appleshan-shell 107 | - appleshan-dired 108 | - appleshan-org 109 | - appleshan-chinese 110 | - appleshan-programming 111 | - appleshan-python 112 | - appleshan-java 113 | - appleshan-javascript 114 | - appleshan-web 115 | - appleshan-lisp 116 | - appleshan-misc 117 | 这些 layer 是对 spacemacs 本身的一些扩展。 118 | 119 | 2. 我的这个配置使用了 evil。 120 | 所以,对于 Vim 党来说会比较友好一点。 121 | 122 | 3. 我的配置用了很长时间了,相信你也会喜欢的。 123 | 124 | * Dependencies 125 | 126 | ** 设置 HOME 环境变量 127 | - Linux 128 | 无需设置。例如:/home/appleshan 129 | - Windows 10 130 | HOME=D:/home/appleshan 131 | 132 | ** 使用软链接(符号链接)管理配置 133 | - Linux 134 | 135 | - Windows 10 136 | #+BEGIN_SRC bat 137 | mklink /D d:\.emacs.d d:\projects\spacemacs-develop.d 138 | mklink /D d:\.spacemacs.d d:\projects\my-spacemacs-config.d 139 | #+END_SRC 140 | 141 | 注意:mklink 支持 Windows 7 及以上版本 142 | 143 | ** Fonts 144 | 我最近几乎一直都在使用 Hack 或 Source Code Pro,在 Linux 和任何其他计算机上,对我来说都是相当不错的。 145 | 字体我可能会或可能不会使用(没有特定的顺序): 146 | - Hack 147 | - Source Code Pro 148 | - Input Mono 149 | - Inconsolata 150 | - DejaVu Sans 151 | - 文泉驿 152 | - 微软雅黑 153 | 154 | ** diff 155 | - Windows 10 156 | http://gnuwin32.sourceforge.net/packages/diffutils.htm 157 | 下载:Binaries 与 Dependencies,然后把 Dependencies 中解压出来的 libintl-2 和 158 | libiconv-2 copy 到 Binaries 的 bin 目录,最后,把 bin 目录加入环境变量 PATH . 159 | 160 | ** Git 161 | @see http://blog.miniasp.com/post/2014/05/22/Credential-Store-for-Git-HTTP-HTTPS.aspx 162 | 163 | #+BEGIN_SRC bash 164 | # 设置 github 的用户名 165 | git config --global user.name "appleshan" 166 | git config --global user.email apple.shan@gmail.com 167 | 168 | # 设置编辑器 169 | git config --global core.editor emacs 170 | 171 | # 设置永久存储用户名和密码 172 | git config --global credential.helper store 173 | 174 | # 关闭 git 自动改换行符的功能 175 | git config --global core.autocrlf false 176 | #+END_SRC 177 | 178 | ** python 179 | 180 | *** Python Language Server 181 | #+BEGIN_SRC bash 182 | pip install python-language-server[all] 183 | #+END_SRC 184 | 185 | *** Auto-completion: Anaconda dependencies 186 | #+BEGIN_SRC bash 187 | pip install --upgrade "jedi>=0.9.0" "json-rpc>=1.8.1" "service_factory>=0.1.5" 188 | #+END_SRC 189 | 190 | *** Syntax checking 191 | Syntax checking uses `flake8` package: 192 | #+BEGIN_SRC bash 193 | pip install flake8 194 | #+END_SRC 195 | 196 | *** importmagic 197 | importmagic 用来自动引入需要的包 198 | #+BEGIN_SRC bash 199 | pip install importmagic epc 200 | #+END_SRC 201 | 202 | *** autoflake 203 | To be able to suppress unused imports easily, install autoflake: 204 | #+BEGIN_SRC bash 205 | pip install autoflake 206 | #+END_SRC 207 | 208 | *** autopep8 209 | autopep8 用来检查 PEP8 规范 210 | #+BEGIN_SRC bash 211 | pip install autopep8 212 | #+END_SRC 213 | 214 | *** yapf 215 | yapf 用来格式化代码 216 | #+BEGIN_SRC bash 217 | pip install yapf 218 | #+END_SRC 219 | 220 | *** rope 221 | a python refactoring library 222 | #+BEGIN_SRC bash 223 | pip install rope 224 | #+END_SRC 225 | 226 | *** pylookup 227 | 要离线浏览 python 文档,按以下步骤安装环境: 228 | - 下载您自己的 python 文档版本(即 https://docs.python.org/3/archives/python-3.6.4-docs-html.zip) 229 | - 解压缩:'unzip python-3.6.4-docs-html.zip' 230 | - 索引:'./pylookup.py -u python-3.6.4-docs-html' 231 | - 测试:'./pylookup.py -l ljust' 232 | 233 | 该包提供了 makefile 可以完成以上的 3 个步骤: 234 | #+BEGIN_SRC bash 235 | make download 236 | #+END_SRC 237 | 注意:如果 OS 中的 python 版本与 python 文档的版本不一样,可以先手动修改 makefile 238 | 中的 VER 行, 指定文档的版本,再执行"make download". 239 | #+BEGIN_EXAMPLE 240 | VER := 3.6.4 241 | #+END_EXAMPLE 242 | 243 | ** Setup up Shell Environment 244 | ~\.spacemacs.d\layers\appleshan-shell\config.el 245 | - Linux 246 | #+BEGIN_EXAMPLE 247 | /home/appleshan/bin 248 | /home/appleshan/bin/cli 249 | /home/appleshan/.local/bin 250 | /home/appleshan/perl5/bin 251 | /home/appleshan/bin/sift 252 | /usr/local/sbin 253 | /usr/local/bin 254 | /usr/sbin 255 | /usr/bin 256 | /sbin 257 | /bin 258 | /opt/oracle/lib 259 | /opt/jdk/jdk1.8.0_102/bin 260 | /opt/jdk/apache-maven-3.3.9/bin 261 | /opt/eclipse-jee-neon/eclipse 262 | #+END_EXAMPLE 263 | 264 | - Windows 10 265 | #+BEGIN_EXAMPLE 266 | D:/bin 267 | D:/lang/python/Python361 268 | D:/lang/python/Python361/Scripts 269 | D:/lang/python/Python2713 270 | D:/lang/python/Python2713/Scripts 271 | D:/portable-soft/cmder 272 | D:/portable-soft/PortableGit/bin 273 | D:/portable-soft/PortableGit/mingw64/libexec/git-core 274 | C:/Program Files (x86)/GnuPG/bin/ 275 | C:/Windows/System32 276 | #+END_EXAMPLE 277 | 278 | * Skill 279 | 用 Emacs, 需: 忘记鼠标, 无视菜单. 280 | 281 | ** Emacs lsp-mode 282 | @see https://github.com/emacs-lsp/lsp-mode 283 | 284 | - completion 285 | C-M-i (completion-at-point) 286 | - Goto definition 287 | M-. (xref-find-definition) 288 | - Symbol references 289 | M-? (xref-find-references) 290 | - Flycheck 291 | SPC e l (spacemacs/toggle-flycheck-error-list) 292 | - Imenu 293 | helm-imenu 294 | 295 | * References & Resources 296 | 297 | - [[https://github.com/purcell/emacs.d][Purcell's emacs.d]] 298 | - [[https://github.com/syl20bnr/spacemacs][Spacemacs]] 299 | - [[https://github.com/bbatsov/prelude][Prelude]] 300 | - [[https://github.com/redguardtoo/emacs.d][Bin Chen's emacs.d]] 301 | - +[[https://github.com/xiaohanyu/oh-my-emacs][Oh-my-emacs]]+ 302 | - [[http://pages.sachachua.com/.emacs.d/Sacha.html][Sacha Chua's Emacs Configuration]] 303 | - [[https://www.masteringemacs.org/][Mastering Emacs]] 304 | - [[https://emacswiki.org/][Emacs Wiki]] 305 | - [[https://github.com/redguardtoo/mastering-emacs-in-one-year-guide][Mastering Emacs in One year]] 306 | - [[http://planet.emacsen.org/][Planet Emacsen]] 307 | - [[http://orgmode.org/worg/index.html][Worg, Org-Mode Community]] 308 | - [[http://endlessparentheses.com/][Endless Parentheses]] 309 | 310 | * Happy Hacking :smile: 311 | -------------------------------------------------------------------------------- /bin/delete_elc_file.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | path = './' 4 | 5 | for prefix, dirs, files in os.walk(path): 6 | for name in files: 7 | if name.endswith('.elc'): 8 | filename = os.path.join(prefix, name) 9 | os.remove(filename) 10 | -------------------------------------------------------------------------------- /bin/ec: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script starts emacs daemon if it is not running, opens whatever file 4 | # you pass in and changes the focus to emacs. Without any arguments, it just 5 | # opens the current buffer or *scratch* if nothing else is open. The following 6 | # example will open ~/.bashrc 7 | 8 | # ec ~/.bashrc 9 | 10 | # You can also pass it multiple files, it will open them all. Unbury-buffer 11 | # will cycle through those files in order 12 | 13 | # The compliment to the script is et, which opens emacs in the terminal 14 | # attached to a daemon 15 | 16 | # If you want to execute elisp, pass in -e whatever. 17 | # You may also want to stop the output from returning to the terminal, like 18 | # ec -e "(message \"Hello\")" > /dev/null 19 | 20 | # emacsclient options for reference 21 | # -a "" starts emacs daemon and reattaches 22 | # -c creates a new frame 23 | # -n returns control back to the terminal 24 | # -e eval the script 25 | 26 | # Number of current visible frames, 27 | # Emacs daemon always has a visible frame called F1 28 | visible_frames() { 29 | emacsclient -a "" -e '(length (visible-frame-list))' 30 | } 31 | 32 | change_focus() { 33 | emacsclient -n -e "(select-frame-set-input-focus (selected-frame))" > /dev/null 34 | } 35 | 36 | # try switching to the frame incase it is just minimized 37 | # will start a server if not running 38 | test "$(visible_frames)" -eq "1" && change_focus 39 | 40 | if [ "$(visible_frames)" -lt "2" ]; then # need to create a frame 41 | # -c $@ with no args just opens the scratch buffer 42 | emacsclient -n -c "$@" && change_focus 43 | else # there is already a visible frame besides the daemon, so 44 | change_focus 45 | # -n $@ errors if there are no args 46 | test "$#" -ne "0" && emacsclient -n "$@" 47 | fi 48 | 49 | # @see http://mjwall.com/blog/2013/10/04/how-i-use-emacs/ 50 | -------------------------------------------------------------------------------- /bin/es: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # simple script to shutdown the running Emacs daemon 4 | 5 | # emacsclient options for reference 6 | # -a Alternate editor, runs bin/false in this case 7 | # -e eval the script 8 | 9 | # If the server-process is bound and the server is in a good state, then kill 10 | # the server 11 | 12 | server_ok() { 13 | emacsclient -a "false" -e "(boundp 'server-process)" 14 | } 15 | 16 | if [ "t" == "$(server_ok)" ]; then 17 | echo "Shutting down Emacs server" 18 | # wasn't removing emacs from ALT-TAB on mac 19 | # emacsclient -e "(server-force-delete)" 20 | emacsclient -e '(kill-emacs)' 21 | else 22 | echo "Emacs server not running" 23 | fi 24 | -------------------------------------------------------------------------------- /bin/et: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Makes sure emacs daemon is running and opens the file in Emacs in 4 | # the terminal. 5 | 6 | # If you want to execute elisp, use -e whatever, like so 7 | 8 | # et -e "(message \"Word up\")" 9 | 10 | # You may want to redirect that to /dev/null if you don't want the 11 | # return to printed on the terminal. Also, just echoing a message 12 | # may not be visible if Emacs then gives you a message about what 13 | # to do when do with the frame 14 | 15 | # The compliment to this script is ec 16 | 17 | # Emacsclient option reference 18 | # -a "" starts emacs daemon and reattaches 19 | # -t starts in terminal, since I won't be using the gui 20 | # can also pass in -n if you want to have the shell return right away 21 | 22 | exec emacsclient -a "" -t "$@" 23 | -------------------------------------------------------------------------------- /bin/install-spacemacs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ########################################################################## 3 | # install emacs config automatically. 4 | # by Apple Shan (apple.shan@gmail.com) 5 | ########################################################################## 6 | 7 | # sudo pacman -S emacs 8 | 9 | cd ~/projects/ 10 | 11 | # clone syl20bnr/spacemacs repo 12 | git clone -b develop https://github.com/syl20bnr/spacemacs.git spacemacs-develop 13 | 14 | # clone appleshan/my-spacemacs-config and submodule 15 | git clone --recursive https://github.com/appleshan/my-spacemacs-config.git spacemacs-private 16 | 17 | # git submodule 18 | # 如果已經抓下來才發現 submodule 是空的,可以用以下指令去抓 19 | cd spacemacs-private 20 | git submodule update --init --recursive 21 | 22 | rm ~/.emacs.d 23 | rm ~/.spacemacs.d 24 | 25 | # 建立软链接 26 | # ln -s <源文件> <目标> 创建一个符号链接 27 | ln -s ~/projects/spacemacs-develop ~/.emacs.d 28 | ln -s ~/projects/spacemacs-private ~/.spacemacs.d 29 | 30 | # 验证软链接建立成功 31 | la ~/ |grep emacs 32 | 33 | ################################################################################ 34 | # 按照其他 package 35 | 36 | # all-the-icons 37 | # Installing Fonts 38 | M-x all-the-icons-install-fonts 39 | 40 | # dired-k 41 | cd ~/.spacemacs.d/local/ 42 | git clone https://github.com/appleshan/emacs-dired-k dired-k 43 | 44 | # terminal-here 45 | cd ~/.spacemacs.d/local/ 46 | git clone https://github.com/appleshan/terminal-here terminal-here 47 | 48 | # pyim-bigdict.pyim 49 | wget http://tumashu.github.io/pyim-bigdict/pyim-bigdict.pyim.gz 50 | 51 | ################################################################################ 52 | # 安装外部程序 53 | 54 | # ditaa 55 | mkdir -p /opt/java/ditaa0_9 56 | cd /opt/java/ditaa0_9 57 | wget https://downloads.sourceforge.net/project/ditaa/ditaa/0.9/ditaa0_9.zip 58 | unzip ditaa0_9.zip 59 | 60 | # graphviz 61 | 62 | # for python 63 | pip install python-language-server 64 | pip install rope # a python refactoring library 65 | pip install jedi # Python 自动补全库 66 | pip install flake8 # flake8 用来检查语法错误 67 | pip install importmagic # importmagic 用来自动引入需要的包 68 | pip install autopep8 # autopep8 用来检查 PEP8 规范 69 | pip install yapf # yapf 用来格式化代码 70 | -------------------------------------------------------------------------------- /layers/appleshan-appearance/README.org: -------------------------------------------------------------------------------- 1 | Appearance - change the look-and-feel 2 | -------------------------------------------------------------------------------- /layers/appleshan-appearance/config.el: -------------------------------------------------------------------------------- 1 | ;;; config.el --- appleshan-appearance Layer functions File for Spacemacs 2 | 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | 8 | ;; This file is not part of GNU Emacs. 9 | 10 | ;;; Commentary: 11 | 12 | ;;; License: GPLv3 13 | 14 | ;;; Code: 15 | 16 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 17 | ;; 测试字体: 18 | ;; 1lIi <-- 数字1,小写字母l,大小写字母i 19 | ;; 0Oo <-- 数字0,大小写字母o 20 | ;; '\"` <-- 单引号,双引号,反引号 21 | ;; 0O l1 Z2 S5 G6 B8 71 lI vy 22 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 23 | 24 | ;; Happy hacking apple! 25 | ;; 用 Emacs, 需忘记鼠标, 无视菜单. 26 | (with-current-buffer (get-buffer-create "*scratch*") 27 | (emacs-lisp-mode) 28 | (insert ";; Talk is cheap. Show me the code.\n\n")) 29 | 30 | ;; Display visited file's path in the frame title 31 | ;; @See http://emacsredux.com/blog/2013/04/07/display-visited-files-path-in-the-frame-title/ 32 | (setq frame-title-format 33 | `(,(user-login-name) "@" ,(system-name) " | " 34 | (:eval (if (buffer-file-name) 35 | (abbreviate-file-name (buffer-file-name)) 36 | "%b")))) 37 | 38 | ;; Experimenting with transparency 39 | (let ((tp (cons dotspacemacs-active-transparency 40 | dotspacemacs-inactive-transparency))) 41 | (push `(alpha . ,tp) default-frame-alist) 42 | (set-frame-parameter (selected-frame) 'alpha tp)) 43 | 44 | ;; http://stackoverflow.com/questions/3875213/turning-on-linum-mode-when-in-python-c-mode 45 | (setq linum-mode-inhibit-modes-list '(eshell-mode 46 | shell-mode 47 | profiler-report-mode 48 | dictionary-mode 49 | browse-kill-ring-mode 50 | dired-mode 51 | help-mode 52 | text-mode 53 | fundamental-mode 54 | inferior-js-mode 55 | inferior-python-mode 56 | inferior-scheme-mode 57 | compilation-mode 58 | woman-mode 59 | Info-mode 60 | calc-mode 61 | calc-trail-mode 62 | comint-mode 63 | gud-mode 64 | org-mode 65 | org-agenda-mode 66 | vc-git-log-edit-mode 67 | log-edit-mode 68 | spacemacs-buffer-mode 69 | calendar-mode)) 70 | (defadvice linum-on (around linum-on-inhibit-for-modes) 71 | "Stop the load of linum-mode for some major modes." 72 | (unless (member major-mode linum-mode-inhibit-modes-list) 73 | ad-do-it)) 74 | (ad-activate 'linum-on) 75 | 76 | ;; UI设置 77 | ;; more useful frame title, that show either a file or a 78 | ;; buffer name (if the buffer isn't visiting a file) 79 | (define-fringe-bitmap 'right-curly-arrow 80 | [#b00000000 81 | #b00000000 82 | #b00000000 83 | #b00000000 84 | #b01110000 85 | #b00010000 86 | #b00010000 87 | #b00000000]) 88 | 89 | (define-fringe-bitmap 'left-curly-arrow 90 | [#b00000000 91 | #b00001000 92 | #b00001000 93 | #b00001110 94 | #b00000000 95 | #b00000000 96 | #b00000000 97 | #b00000000]) 98 | 99 | ;; Turn off all kinds of modes, I don't need the menu bar, or the tool bar: 100 | ;; (when (functionp 'menu-bar-mode) 101 | ;; (menu-bar-mode -1)) 102 | (when (functionp 'set-scroll-bar-mode) 103 | (set-scroll-bar-mode 'nil)) 104 | (when (functionp 'mouse-wheel-mode) 105 | (mouse-wheel-mode -1)) 106 | ;; (when (functionp 'tooltip-mode) 107 | ;; (tooltip-mode -1)) 108 | ;; (when (functionp 'tool-bar-mode) 109 | ;; (tool-bar-mode -1)) 110 | ;; (when (functionp 'blink-cursor-mode) 111 | ;; (blink-cursor-mode -1)) 112 | 113 | ;; Hide the mouse while typing: 114 | (setq make-pointer-invisible t) 115 | 116 | ;; Don't use dialog boxes, just ask inside Emacs 117 | (setq use-dialog-box nil) 118 | 119 | ;; The number is in pixels. 120 | (setq-default line-spacing 0) 121 | 122 | ;; Don't open a file in a new frame 123 | (when (boundp 'ns-pop-up-frames) 124 | (setq ns-pop-up-frames nil)) 125 | 126 | ;; Don't use GTK+ tooltip 127 | (when (boundp 'x-gtk-use-system-tooltips) 128 | (setq x-gtk-use-system-tooltips nil)) 129 | 130 | ;;set unicode font for mode-line 131 | ; (set-fontset-font t '(#x2776 . #x2793) "Lucida Sans Unicode") ;;win numbers 132 | ; (set-fontset-font t '(#x24b6 . #x24fe) "Lucida Sans Unicode") ;;circled letters 133 | ; (set-fontset-font t '(#x2295 . #x22a1) "Lucida Sans Unicode") ;;additional characters 134 | 135 | ;; Local Variables: 136 | ;; coding: utf-8 137 | ;; no-byte-compile: nil 138 | ;; End: 139 | 140 | ;;; config.el ends here 141 | -------------------------------------------------------------------------------- /layers/appleshan-appearance/funcs.el: -------------------------------------------------------------------------------- 1 | ;;; funcs.el --- appleshan-appearance Layer functions File for Spacemacs 2 | 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | 8 | ;; This file is not part of GNU Emacs. 9 | 10 | ;;; Commentary: 11 | 12 | ;;; License: GPLv3 13 | 14 | ;;; Code: 15 | 16 | ;; Local Variables: 17 | ;; coding: utf-8 18 | ;; no-byte-compile: nil 19 | ;; End: 20 | 21 | ;;; funcs.el ends here 22 | -------------------------------------------------------------------------------- /layers/appleshan-appearance/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- appleshan-appearance Layer packages File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | (setq appleshan-appearance-packages 13 | '( 14 | anzu 15 | all-the-icons 16 | beacon 17 | on-screen 18 | paren-face 19 | popwin 20 | visual-regexp 21 | visual-regexp-steroids 22 | which-key 23 | spacemacs-whitespace-cleanup 24 | zoom 25 | )) 26 | 27 | ;; List of packages to exclude. 28 | (setq appleshan-appearance-excluded-packages '()) 29 | 30 | ;; Show number of matches in mode-line while searching 31 | (defun appleshan-appearance/post-init-anzu () 32 | (setq anzu-replace-to-string-separator 33 | (if (char-displayable-p ?→) " → " " -> "))) 34 | 35 | (defun appleshan-appearance/init-all-the-icons () 36 | (use-package all-the-icons)) 37 | 38 | ;; 不会丢失你的光标 39 | (defun appleshan-appearance/init-beacon () 40 | (use-package beacon 41 | :init 42 | (progn 43 | (spacemacs|add-toggle beacon 44 | :status beacon-mode 45 | :on (beacon-mode) 46 | :off (beacon-mode -1) 47 | :documentation "Enable point highlighting after scrolling" 48 | :evil-leader "tb") 49 | (spacemacs/toggle-beacon-on)) 50 | :config 51 | (spacemacs|hide-lighter beacon-mode))) 52 | 53 | (defun appleshan-appearance/init-on-screen () 54 | (use-package on-screen 55 | :init (require 'on-screen) 56 | :config (on-screen-global-mode +1))) 57 | 58 | (defun appleshan-appearance/init-paren-face () 59 | (use-package paren-face 60 | :ensure t 61 | :init (global-paren-face-mode))) 62 | 63 | ;; Popup Window Manager 64 | (defun appleshan-appearance/post-init-popwin () 65 | ;; man 66 | (push '(Man-mode :stick t :height 20) popwin:special-display-config) 67 | 68 | ;; Elisp 69 | (push '("*ielm*" :stick t) popwin:special-display-config) 70 | 71 | ;; python 72 | (push '("*Python*" :stick t) popwin:special-display-config) 73 | (push '("*Python Help*" :stick t :height 20) popwin:special-display-config) 74 | 75 | ;; prodigy 76 | (push '("*prodigy*" :stick t) popwin:special-display-config) 77 | 78 | ;; org-mode 79 | (push '("*Org tags*" :stick t :height 30) popwin:special-display-config) 80 | 81 | ;; Completions 82 | (push '("*Completions*" :stick t :noselect t) popwin:special-display-config) 83 | 84 | ;; I recommend you set popwin for quickrun.el 85 | ;; See also http://www.emacswiki.org/emacs/PopWin 86 | (push '("*quickrun*") popwin:special-display-config) 87 | 88 | (push "*appleshan/run-current-file output*" popwin:special-display-config) 89 | (delete "*Async Shell Command*" popwin:special-display-config)) 90 | 91 | ;; 可视化正则匹配 92 | ;; https://github.com/benma/visual-regexp.el 93 | ;; https://github.com/benma/visual-regexp-steroids.el 94 | 95 | (defun appleshan-appearance/init-visual-regexp () 96 | (use-package visual-regexp 97 | ; :commands (vr/replace vr/query-replace) ; See the bind of init-visual-regexp-steroids. 98 | :defer t)) 99 | 100 | (defun appleshan-appearance/init-visual-regexp-steroids () 101 | (use-package visual-regexp-steroids 102 | :commands (vr/select-replace vr/select-query-replace) 103 | :defer t 104 | :bind (("C-M-%" . vr/replace) 105 | ("M-%" . vr/query-replace) 106 | ("C-M-r" . vr/isearch-backward) 107 | ("C-M-s" . vr/isearch-forward) 108 | ("C-s" . isearch-forward) ; ordinary forward search 109 | ("C-r" . isearch-backward) ; ordinary backward search 110 | ("C-c m" . vr/mc-mark) ; for multiple-cursors 111 | ))) 112 | 113 | (defun appleshan-appearance/post-init-which-key () 114 | (spacemacs|diminish which-key-mode)) 115 | 116 | (defun appleshan-appearance/post-init-spacemacs-whitespace-cleanup () 117 | (spacemacs|diminish spacemacs-whitespace-cleanup-mode)) 118 | 119 | (defun appleshan-appearance/init-zoom () 120 | (use-package zoom 121 | :config 122 | (progn 123 | ;; Resize the selected window using the golden ratio: 124 | ; (setq zoom-size '(0.618 . 0.618)) 125 | 126 | ;; Resize the selected window according to the frame width, for example: 127 | ;; 90 columns and 75% of the frame height if the frame width is larger than 1024 pixels; 128 | ;; half the frame size otherwise. 129 | (defun size-callback () 130 | (cond ((> (frame-pixel-width) 1280) '(90 . 0.75)) 131 | (t '(0.5 . 0.5)))) 132 | (setq zoom-size 'size-callback) 133 | 134 | (setq zoom-ignored-major-modes '(dired-mode org-mode magit-mode)) 135 | (setq zoom-ignored-buffer-name-regexps '("^*calc" "*Ediff Control Panel*")) 136 | ;; 少于20行的任何缓冲区。 137 | (setq zoom-ignore-predicates '( 138 | (lambda () (> (count-lines (point-min) (point-max)) 20)))) 139 | (zoom-mode t)))) 140 | 141 | ;; Local Variables: 142 | ;; coding: utf-8 143 | ;; no-byte-compile: nil 144 | ;; End: 145 | 146 | ;;; packages.el ends here 147 | -------------------------------------------------------------------------------- /layers/appleshan-chinese/README.org: -------------------------------------------------------------------------------- 1 | Chinese - various settings for human language 2 | -------------------------------------------------------------------------------- /layers/appleshan-chinese/config.el: -------------------------------------------------------------------------------- 1 | ;;; config.el --- appleshan-chinese Layer configuration File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2012-2016 Sylvain Benner & Contributors 4 | ;; 5 | ;; Author: Sylvain Benner 6 | ;; URL: https://github.com/syl20bnr/spacemacs 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;; Variables 13 | 14 | (defvar *large-buffer-threshold* 300000 15 | "Buffer whose size beyond it will have a different behavior for the efficiency") 16 | 17 | (defvar chinese-default-input-method 'pinyin 18 | "The default chinese input method. Can be `wubi` or `pinyin`.") 19 | 20 | (defvar chinese-enable-avy-pinyin t 21 | "Enable ace-pinyin in avy-goto-char") 22 | 23 | (defvar chinese-enable-fcitx nil 24 | "Enable fcitx to help writing Chinese in Evil mode.") 25 | 26 | ;; Set the monospaced font size when mixed Chinese and English words 27 | (defun spacemacs//set-monospaced-font (english chinese english-size chinese-size) 28 | (set-face-attribute 'default nil :font 29 | (format "%s:pixelsize=%d" english english-size)) 30 | (dolist (charset '(kana han cjk-misc bopomofo)) 31 | (set-fontset-font (frame-parameter nil 'font) charset 32 | (font-spec :family chinese :size chinese-size)))) 33 | 34 | ;; Local Variables: 35 | ;; coding: utf-8 36 | ;; no-byte-compile: nil 37 | ;; End: 38 | 39 | ;;; config.el ends here 40 | -------------------------------------------------------------------------------- /layers/appleshan-chinese/funcs.el: -------------------------------------------------------------------------------- 1 | ;;; funcs.el --- appleshan-chinese Layer functions File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;; {{ make IME compatible with evil-mode 13 | (defun appleshan/evil-toggle-input-method () 14 | "when toggle on input method, goto evil-insert-state. " 15 | (interactive) 16 | 17 | (cond 18 | ((and (boundp 'evil-mode) evil-mode) 19 | ;; evil-mode 20 | (cond 21 | ((eq evil-state 'insert) 22 | (toggle-input-method)) 23 | (t 24 | (evil-insert-state) 25 | (unless current-input-method 26 | (toggle-input-method)) 27 | )) 28 | (if current-input-method (message "IME on!"))) 29 | (t 30 | ;; NOT evil-mode, some guy don't use evil-mode at all 31 | (toggle-input-method)))) 32 | 33 | (defadvice evil-insert-state (around evil-insert-state-hack activate) 34 | ad-do-it 35 | (if current-input-method (message "IME on!"))) 36 | ;; }} 37 | 38 | ;;add count for chinese, mainly used for writing chinese blog post 39 | ;; http://kuanyui.github.io/2014/01/18/count-chinese-japanese-and-english-words-in-emacs/ 40 | (defvar wc-regexp-chinese-char-and-punc 41 | (rx (category chinese))) 42 | (defvar wc-regexp-chinese-punc 43 | "[。,!?;:「」『』()、【】《》〈〉※—]") 44 | (defvar wc-regexp-english-word 45 | "[a-zA-Z0-9-]+") 46 | 47 | (defun appleshan/word-count-for-chinese () 48 | "「較精確地」統計中/日/英文字數。 49 | - 文章中的註解不算在字數內。 50 | - 平假名與片假名亦包含在「中日文字數」內,每個平/片假名都算單獨一個字(但片假 51 | 名不含連音「ー」)。 52 | - 英文只計算「單字數」,不含標點。 53 | - 韓文不包含在內。 54 | ※計算標準太多種了,例如英文標點是否算入、以及可能有不太常用的標點符號沒算入等 55 | 。且中日文標點的計算標準要看 Emacs 如何定義特殊標點符號如ヴァランタン・アルカン 56 | 中間的點也被 Emacs 算為一個字而不是標點符號。" 57 | (interactive) 58 | (let* ((v-buffer-string 59 | (progn 60 | (if (eq major-mode 'org-mode) ; 去掉 org 文件的 OPTIONS(以#+開頭) 61 | (setq v-buffer-string (replace-regexp-in-string "^#\\+.+" "" 62 | (buffer-substring-no-properties (point-min) (point-max)))) 63 | (setq v-buffer-string (buffer-substring-no-properties (point-min) (point-max)))) 64 | (replace-regexp-in-string (format "^ *%s *.+" comment-start) "" v-buffer-string))) 65 | ; 把註解行刪掉(不把註解算進字數)。 66 | (chinese-char-and-punc 0) 67 | (chinese-punc 0) 68 | (english-word 0) 69 | (chinese-char 0)) 70 | (with-temp-buffer 71 | (insert v-buffer-string) 72 | (goto-char (point-min)) 73 | ;; 中文(含標點、片假名) 74 | (while (re-search-forward wc-regexp-chinese-char-and-punc nil :no-error) 75 | (setq chinese-char-and-punc (1+ chinese-char-and-punc))) 76 | ;; 中文標點符號 77 | (goto-char (point-min)) 78 | (while (re-search-forward wc-regexp-chinese-punc nil :no-error) 79 | (setq chinese-punc (1+ chinese-punc))) 80 | ;; 英文字數(不含標點) 81 | (goto-char (point-min)) 82 | (while (re-search-forward wc-regexp-english-word nil :no-error) 83 | (setq english-word (1+ english-word)))) 84 | (setq chinese-char (- chinese-char-and-punc chinese-punc)) 85 | (message 86 | (format "中日文字數(不含標點):%s 87 | 中日文字數(包含標點):%s 88 | 英文字數(不含標點):%s 89 | ======================= 90 | 中英文合計(不含標點):%s" 91 | chinese-char chinese-char-and-punc english-word 92 | (+ chinese-char english-word))))) 93 | 94 | ;; Local Variables: 95 | ;; coding: utf-8 96 | ;; no-byte-compile: nil 97 | ;; End: 98 | 99 | ;;; funcs.el ends here 100 | -------------------------------------------------------------------------------- /layers/appleshan-chinese/local/unicad/FAQ.md: -------------------------------------------------------------------------------- 1 | ## What is Unicad? ## 2 | 3 | Unicad is short for Universal Charset Auto Detector. It is an 4 | Emacs-Lisp port of Mozilla Universal Charset Detector. 5 | 6 | ## What can Unicad do? ## 7 | 8 | Unicad helps Emacs to guess the correct coding system when opening a 9 | file. 10 | 11 | ## What languages and coding systems does Unicad support? ## 12 | 13 | * Chinese Simplified (gb18030, gbk, gb2312, hz-gb-2312, iso-2022-cn) 14 | * Chinese Triditional (big5, gb18030, gbk, euc-tw) 15 | * Japanese (sjis, euc-jp, iso-2022-jp) 16 | * Korean (euc-kr, iso-2022-kr) 17 | * Greek (iso-8859-7, windows-1253) 18 | * Russian (iso-8859-5, windows-1251, koi8-r, ibm855) 19 | * Bulgarian (iso-8859-5, windows-1251) 20 | * Western European (latin-1) 21 | * Central European (latin-2) 22 | * Unicode (utf-16le, utf-16be with/without signature, utf-8) 23 | 24 | ## Who should use Unicad? ## 25 | 26 | 1. **Emacs Users**. Unicad is an Emacs extension that written in Elisp. It is designed and works for Emacs. 27 | 1. **Multilanguage Users**. If you are English only speakers, then there is no need to install Unicad on Emacs. Otherwise, if you need to read and edit files in multiple language and use different coding systems, Unicad will definitely help you in recognizing coding systems. 28 | 1. Anyone who is tired of struggling with **garbled** text. Normal Text Editors are not so intelligent to choose correct coding system among various and complicated charsets. I suggest you try the most powerful text editor ever in the world - Emacs and Unicad. 29 | 30 | ## How to use Unicad? ## 31 | 32 | [Download](http://code.google.com/p/unicad/downloads/list) the latest unicad.el, copy it to your Emacs load path (e.g. 33 | site-lisp directory), and add the following line to your ~/.emacs: 34 | ``` 35 | (require 'unicad) 36 | ``` 37 | 38 | You may byte compile this file to speed up the charset detecting 39 | process. 40 | 41 | 42 | ## What's the difference between Unicad and Mozilla Universal Charset Detector? ## 43 | 44 | * optimized for detecting shorter text files. 45 | * add support for Central European Languages, that use iso-8859-2 coding system. 46 | * add support for Traditional Chinese that uses gbk coding system. 47 | * add support for single byte only katakana that uses sjis coding system. 48 | * ability of detecting utf-16le and utf-16be without signature. -------------------------------------------------------------------------------- /layers/appleshan-chinese/local/unicad/FAQ_Chinese.md: -------------------------------------------------------------------------------- 1 | ## 什么是 Unicad? ## 2 | 3 | Unicad 自动编码识别器的缩写。他是基于一个 Mozilla 语言/编码识别扩展的 Emacs-Lisp 程序。 4 | 5 | ## Unicad 能做什么? ## 6 | 7 | Unicad 可以帮助 Emacs 在打开文件的时候猜测语言编码,用正确的编码系统打开文件,避免乱码现象。 8 | 9 | ## Unicad 支持什么语言/编码系统? ## 10 | 11 | * 简体中文 (gb18030, gbk, gb2312, hz-gb-2312, iso-2022-cn) 12 | * 繁体中文 (big5, gb18030, gbk, euc-tw) 13 | * 日语 (sjis, euc-jp, iso-2022-jp) 14 | * 韩语 (euc-kr, iso-2022-kr) 15 | * 希腊语 (iso-8859-7, windows-1253) 16 | * 俄语 (iso-8859-5, windows-1251, koi8-r, ibm855) 17 | * 保加利亚语 (iso-8859-5, windows-1251) 18 | * 西欧语言,如德语、法语、西班牙语、意大利语、挪威语、瑞典语、葡萄牙语等等 (latin-1) 19 | * 中欧语言,如波兰语、罗马尼亚语、斯洛伐克语、斯洛文尼亚语、捷克语等等 (latin-2) 20 | * Unicode (utf-8, 包含或不包含BOM的ucs2编码utf-16le, utf-16be) 21 | 22 | ## 谁应该使用 Unicad? ## 23 | 24 | 1. **Emacs 用户**. Unicad 是一个 Emacs 扩展,所以首先是给 Emacs 用户使用的。 25 | 1. **多语言用户**. 如果你只需要编辑英语文件,只需要使用ASCII编码,那么你不需要在 Emacs 上使用 Unicad。反之,如果你使用多种语言,多种编码,那么 Unicad 肯定可以帮你识别文件编码。 26 | 1. 如果你经常碰到**乱码**文件,因为一般的编辑器没有那么聪明来选择正确的编码系统,你应该尝试一下世界上最强大的编辑器 Emacs 和最聪明的编码识别器 Unicad。 27 | 28 | ## 怎样使用 Unicad? ## 29 | 30 | [下载](http://code.google.com/p/unicad/downloads/list)最新版的 unicad.el, 复制到你的 Emacs load path (例如 site-lisp 目录), 在你的 ~/.emacs 文件里加上: 31 | ``` 32 | (require 'unicad) 33 | ``` 34 | 35 | 推荐 byte-compile 这个文件来加速检测编码和打开文件的速度。 36 | 37 | ## Unicad 和 Mozilla 语言/编码识别扩展有什么不同? ## 38 | 39 | 虽然 Unicad 是基于 Mozilla 语言/编码识别扩展的,但还是有一些不同之处: 40 | 41 | * 优化了检测短文件的能力。 42 | * 增加了对中欧语言、编码的支持。 43 | * 增加了对采用gbk编码的繁体中文文件的支持。 44 | * 增加了对采用sjis编码的只含有半角平假名的支持。 45 | * 具有检测不含BOM的utf-16le和utf-16be的能力。 46 | 47 | 48 | -------------------------------------------------------------------------------- /layers/appleshan-chinese/local/unicad/FAQ_Chinese.org: -------------------------------------------------------------------------------- 1 | * 什么是 Unicad? 2 | Unicad 自动编码识别器的缩写。他是基于一个 Mozilla 语言/编码识别扩展的 Emacs-Lisp 程序。 3 | 4 | * Unicad 能做什么? 5 | Unicad 可以帮助 Emacs 在打开文件的时候猜测语言编码,用正确的编码系统打开文件,避免乱码现象。 6 | 7 | * Unicad 支持什么语言/编码系统? 8 | 简体中文 (gb18030, gbk, gb2312, hz-gb-2312, iso-2022-cn) 9 | 繁体中文 (big5, gb18030, gbk, euc-tw) 10 | 日语 (sjis, euc-jp, iso-2022-jp) 11 | 韩语 (euc-kr, iso-2022-kr) 12 | 希腊语 (iso-8859-7, windows-1253) 13 | 俄语 (iso-8859-5, windows-1251, koi8-r, ibm855) 14 | 保加利亚语 (iso-8859-5, windows-1251) 15 | 西欧语言,如德语、法语、西班牙语、意大利语、挪威语、瑞典语、葡萄牙语等等 (latin-1) 16 | 中欧语言,如波兰语、罗马尼亚语、斯洛伐克语、斯洛文尼亚语、捷克语等等 (latin-2) 17 | Unicode (utf-8, 包含或不包含BOM的ucs2编码utf-16le, utf-16be) 18 | 19 | * 谁应该使用 Unicad? 20 | 1. Emacs 用户. Unicad 是一个 Emacs 扩展,所以首先是给 Emacs 用户使用的。 21 | 2. 多语言用户. 如果你只需要编辑英语文件,只需要使用ASCII编码,那么你不需要在 Emacs 上使用 Unicad。反之,如果你使用多种语言,多种编码,那么 Unicad 肯定可以帮你识别文件编码。 22 | 3. 如果你经常碰到乱码文件,因为一般的编辑器没有那么聪明来选择正确的编码系统,你应该尝试一下世界上最强大的编辑器 Emacs 和最聪明的编码识别器 Unicad。 23 | 24 | * 怎样使用 Unicad? 25 | 下载最新版的 unicad.el, 复制到你的 Emacs load path (例如 site-lisp 目录), 在你的 ~/.emacs 文件里加上: 26 | 27 | (require 'unicad) 28 | 29 | 推荐 byte-compile 这个文件来加速检测编码和打开文件的速度。 30 | 31 | * Unicad 和 Mozilla 语言/编码识别扩展有什么不同? 32 | 虽然 Unicad 是基于 Mozilla 语言/编码识别扩展的,但还是有一些不同之处: 33 | 34 | 优化了检测短文件的能力。 35 | 增加了对中欧语言、编码的支持。 36 | 增加了对采用gbk编码的繁体中文文件的支持。 37 | 增加了对采用sjis编码的只含有半角平假名的支持。 38 | 具有检测不含BOM的utf-16le和utf-16be的能力。 39 | -------------------------------------------------------------------------------- /layers/appleshan-chinese/local/unicad/ProjectHome.md: -------------------------------------------------------------------------------- 1 | ## News ## 2 | 3 | * [19-08-2007] v1.1.1 uploaded. Fixed a bug in unicad-sjis-sb-prober. 4 | 5 | ## What is Unicad? ## 6 | 7 | Unicad is short for Universal Charset Auto Detector. It is an 8 | **Emacs-Lisp** port of [Mozilla Universal Charset Detector](http://www.mozilla.org/projects/intl/detectorsrc.html). 9 | 10 | ## What can Unicad do? ## 11 | 12 | Unicad helps Emacs to guess the correct coding system when opening a 13 | file. It's designed to work automatically and quietly without user interaction. 14 | 15 | ## What languages and coding systems does Unicad support? ## 16 | 17 | * Chinese Simplified (gb18030, gbk, gb2312, hz-gb-2312, iso-2022-cn) 18 | * Chinese Triditional (big5, gb18030, gbk, euc-tw) 19 | * Japanese (sjis, euc-jp, iso-2022-jp) 20 | * Korean (euc-kr, iso-2022-kr) 21 | * Unicode (utf-16le, utf-16be with/without signature) 22 | * Greek (iso-8859-7, windows-1253) 23 | * Russian (iso-8859-5, windows-1251, koi8-r, ibm855) 24 | * Bulgarian (iso-8859-5, windows-1251) 25 | * Western European (latin-1) 26 | * Central European (latin-2) 27 | -------------------------------------------------------------------------------- /layers/appleshan-chinese/local/unicad/README: -------------------------------------------------------------------------------- 1 | unicad --- Universal Charset Auto Detector for Emacs -*-outline-*- 2 | ==================================================== 3 | 4 | * Introduction, Overview 5 | ======================== 6 | 7 | Unicad is short for Universal Charset Auto Detector. It is an 8 | Emacs-Lisp port of Mozilla Universal Charset Detector. 9 | 10 | Unicad helps Emacs to guess the correct coding system when opening a 11 | file. It's designed to work automatically and quietly without user 12 | interaction. 13 | 14 | Following languages and coding systems are supported by unicad: 15 | 16 | * Chinese Simplified (gb18030, gbk, gb2312, hz-gb-2312, iso-2022-cn) 17 | * Chinese Triditional (big5, gb18030, gbk, euc-tw) 18 | * Japanese (sjis, euc-jp, iso-2022-jp) 19 | * Korean (euc-kr, iso-2022-kr) 20 | * Unicode (utf-16le, utf-16be with/without signature) 21 | * Greek (iso-8859-7, windows-1253) 22 | * Russian (iso-8859-5, windows-1251, koi8-r, ibm855) 23 | * Bulgarian (iso-8859-5, windows-1251) 24 | * Western European (latin-1) 25 | * Central European (latin-2) 26 | 27 | * Requirements 28 | ============== 29 | 30 | Unicad has been tested on Emacs22.1 and Emacs23 (CVS branch 31 | emacs-unicode-2) under Ubuntu 7.04 and Windows XP. 32 | 33 | * Installation 34 | ============== 35 | 36 | You need to put the unicad.el in a directory in your load-path. For 37 | example, if you put all those files into ~/elisp/, then in your 38 | ~/.emacs, you should do: 39 | 40 | (add-to-list 'load-path "~/elisp/") 41 | (require 'unicad nil t) 42 | 43 | ** Compilation 44 | -------------- 45 | 46 | To speed up the charset detecting process, you can byte-compile 47 | unicad.el. 48 | 49 | 1a. Byte Compile within Emacs 50 | 51 | In Emacs, type M-x byte-compile-file and the path to unicad.el. 52 | 53 | 1b. Byte Compile outside Emacs 54 | 55 | In terminal, type 'emacs -q -batch -f bach-byte-compile path/to/unicad.el' 56 | (without single quote). 57 | 58 | * UPDATES 59 | ========= 60 | 61 | Unicad project is hosted on Google Code. The latest version can be 62 | found at . 63 | 64 | * BUG REPORTS 65 | ============= 66 | 67 | Any bug reports and suggestions are welcome. Please send me Email: 68 | . It is strongly recommended to attach the 69 | unrecognized or incorrectly detected files and tell me what 70 | languages and coding systems the files should use, since I only 71 | understand English, German and Chinese. 72 | 73 | * License 74 | ========= 75 | 76 | Unicad is available under the terms of the GNU General Public 77 | License. 78 | 79 | Long live Emacs. -------------------------------------------------------------------------------- /layers/appleshan-chinese/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- appleshan-chinese Layer packages File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | (setq appleshan-chinese-packages 13 | '( 14 | cal-china-x 15 | (fcitx :toggle chinese-enable-fcitx) 16 | find-by-pinyin-dired 17 | ace-pinyin 18 | pangu-spacing 19 | ;; 如果 Emacs GUI 可以输入中文,这里就可以关闭 pyim 20 | ;; (pyim :toggle (eq chinese-default-input-method 'pinyin)) 21 | ;; (pyim-basedict :location local) 22 | ;; (pyim-greatdict :location local) 23 | (unicad :location local) 24 | )) 25 | 26 | ;; List of packages to exclude. 27 | (setq appleshan-chinese-excluded-packages '()) 28 | 29 | ;; Chinese calendar 30 | (defun appleshan-chinese/init-cal-china-x () 31 | (use-package cal-china-x 32 | ;:defer t 33 | ;:init (require 'cal-china-x) 34 | :commands cal-china-x-setup 35 | :init (add-hook 'calendar-load-hook #'cal-china-x-setup) 36 | :config 37 | (progn 38 | ;; `S' can show the time of sunrise and sunset on Calendar 39 | (setq calendar-location-name "Guangzhou" 40 | calendar-latitude 23.16 41 | calendar-longitude 113.23) 42 | 43 | (setq mark-holidays-in-calendar t) 44 | 45 | (setq christian-holidays nil) ;; 不显示基督教的节日 46 | (setq hebrew-holidays nil) ;; 不显示希伯来人的节日 47 | (setq islamic-holidays nil) ;; 不显示伊斯兰教的节日 48 | 49 | ;; Holidays 50 | (setq calendar-mark-holidays-flag t) 51 | 52 | (setq cal-china-x-important-holidays cal-china-x-chinese-holidays) 53 | (setq cal-china-x-general-holidays 54 | '(;; 农历节日 55 | (holiday-lunar 1 1 "春节" 0) 56 | (holiday-lunar 1 2 "春节" 0) 57 | (holiday-lunar 1 3 "春节" 0) 58 | (holiday-lunar 1 15 "元宵节 (正月十五)") 59 | (holiday-solar-term "清明" "清明节") 60 | (holiday-lunar 5 5 "端午节 (五月初五)" 0) 61 | (holiday-lunar 7 7 "七夕情人节 (七月初七)") 62 | (holiday-lunar 8 15 "中秋节 (八月十五)" 0) 63 | (holiday-lunar 9 9 "重阳节 (九月初九)" 0) 64 | (holiday-lunar 12 8 "腊八节" 0) 65 | (holiday-lunar 12 22 "冬至" 0) 66 | (holiday-fixed 3 8 "妇女节") 67 | (holiday-fixed 3 12 "植树节") 68 | (holiday-fixed 5 4 "青年节") 69 | (holiday-fixed 6 1 "儿童节") 70 | (holiday-fixed 9 10 "教师节"))) 71 | (setq holiday-other-holidays 72 | '((holiday-fixed 2 14 "情人节") 73 | (holiday-fixed 4 1 "愚人节") 74 | (holiday-fixed 12 25 "圣诞节") 75 | (holiday-float 5 0 2 "母亲节") 76 | (holiday-float 6 0 3 "父亲节") 77 | (holiday-float 11 4 4 "感恩节") 78 | ;; 生日 -- 家人,朋友 79 | (holiday-fixed 11 18 "女儿生日") 80 | (holiday-lunar 4 25 "老婆生日" 0) 81 | (holiday-lunar 7 10 "我的生日" 0) 82 | )) 83 | ;; 只显示我定制的节日 84 | (setq calendar-holidays 85 | (append cal-china-x-important-holidays 86 | cal-china-x-general-holidays 87 | holiday-other-holidays)) 88 | 89 | ))) 90 | 91 | (defun appleshan-chinese/init-fcitx () 92 | (use-package fcitx 93 | :init 94 | (fcitx-evil-turn-on))) 95 | 96 | (defun appleshan-chinese/init-find-by-pinyin-dired () 97 | (use-package find-by-pinyin-dired 98 | :defer t)) 99 | 100 | (defun appleshan-chinese/init-ace-pinyin () 101 | (use-package ace-pinyin 102 | :defer t 103 | :init 104 | (progn 105 | (if chinese-enable-avy-pinyin 106 | (setq ace-pinyin-use-avy t)) 107 | (ace-pinyin-global-mode t) 108 | (spacemacs|hide-lighter ace-pinyin-mode)))) 109 | 110 | ;; 覆盖 Chinese Layer 的 init 方法 111 | (defun appleshan-chinese/init-pangu-spacing () 112 | "覆盖 Chinese-layer 中的设置。默认关闭 pangu-spacing,只有在 buffer 比较小的时候才启动, 113 | 如果是启动之后再关闭的话就开的太慢了。" 114 | (use-package pangu-spacing 115 | :init 116 | (progn 117 | (global-pangu-spacing-mode -1) 118 | (spacemacs|hide-lighter pangu-spacing-mode) 119 | ;; Always insert `real' space in org-mode. 120 | (add-hook 'org-mode-hook 121 | '(lambda () 122 | (set (make-local-variable 'pangu-spacing-real-insert-separtor) t))) 123 | 124 | (defun enable-pangu-spacing-when-buffer-not-large () 125 | "when buffer is not large, turn on it" 126 | (when (< (buffer-size) *large-buffer-threshold*) 127 | (pangu-spacing-mode 1))) 128 | 129 | (dolist (i '(org-mode-hook prog-mode-hook text-mode-hook)) 130 | (add-hook i 'enable-pangu-spacing-when-buffer-not-large))) 131 | :config 132 | ;; add toggle options 133 | (spacemacs|add-toggle toggle-pangu-spaceing 134 | :status pangu-spacing-mode 135 | :on (global-pangu-spacing-mode) 136 | :off (global-pangu-spacing-mode -1) 137 | :documentation "Toggle pangu spacing mode" 138 | :evil-leader "tp") 139 | )) 140 | 141 | (defun appleshan-chinese/init-pyim () 142 | (use-package pyim 143 | :if (eq 'pinyin chinese-default-input-method) 144 | :init 145 | (progn 146 | (setq pyim-directory (expand-file-name "pyim/" spacemacs-cache-directory) 147 | pyim-dcache-directory (expand-file-name "dcache/" pyim-directory) 148 | ;pyim-directory (concat dotspacemacs-directory ".cache/pyim/") 149 | ;pyim-dcache-directory (concat dotspacemacs-directory ".cache/pyim/dcache") 150 | ;pyim-personal-file (concat pyim-directory "pyim-personal.txt") 151 | ;pyim-property-file (concat pyim-directory "pyim-words-property.txt") 152 | default-input-method "pyim") 153 | (evilified-state-evilify pyim-dm-mode pyim-dm-mode-map)) 154 | :config 155 | (progn 156 | ;; 设置 pyim 探针设置,这是 pyim 高级功能设置,可以实现 *无痛* 中英文切换. 157 | ;; 我自己使用的中英文动态切换规则是: 158 | ;; 1. 光标只有在注释里面时,才可以输入中文。 159 | ;; 2. 光标前是汉字字符时,才能输入中文。 160 | ;; 3. 使用 M-j 快捷键,强制将光标前的拼音字符串转换为中文。 161 | ;(setq-default pyim-english-input-switch-functions 162 | ; '(pyim-probe-dynamic-english 163 | ; pyim-probe-isearch-mode 164 | ; pyim-probe-program-mode 165 | ; pyim-probe-org-structure-template)) 166 | 167 | ;(setq-default pyim-punctuation-half-width-functions 168 | ; '(pyim-probe-punctuation-line-beginning 169 | ; pyim-probe-punctuation-after-punctuation)) 170 | 171 | (if (version< emacs-version "26") 172 | (setq pyim-page-tooltip t) ; emacs 25 173 | ; 使用 emacs 26 的 child-frame 174 | ; @see https://emacs-china.org/t/topic/4451 175 | (setq pyim-page-tooltip 'child-frame)) 176 | 177 | ;; 选词框显示5个候选词 178 | (setq pyim-page-length 9) 179 | 180 | ;; 让 Emacs 启动时自动加载 pyim 词库 181 | (add-hook 'emacs-startup-hook 182 | #'(lambda () (pyim-restart-1 t))) 183 | 184 | ;; 为 isearch 开启拼音搜索功能 185 | (pyim-isearch-mode 1) 186 | (spacemacs|hide-lighter pyim-isearch-mode) 187 | ;; 强制关闭 isearch 搜索框中文输入(即使在 Chinese-pyim 激活的时候) 188 | (setq-default pyim-english-input-switch-functions 189 | '(pyim-probe-isearch-mode)) 190 | ;; 禁用 dabberv 中文补全 191 | (setq pyim-company-complete-chinese-enable nil) 192 | ) 193 | )) 194 | 195 | ;; 激活 basedict 拼音词库 196 | (defun appleshan-chinese/init-pyim-basedict () 197 | (use-package pyim-basedict 198 | :ensure nil 199 | :config 200 | (with-eval-after-load 'pyim 201 | (pyim-basedict-enable)) 202 | )) 203 | 204 | ;; 激活 greatdict 拼音词库 205 | (defun appleshan-chinese/init-pyim-greatdict () 206 | (use-package pyim-greatdict 207 | :ensure nil 208 | :config 209 | (with-eval-after-load 'pyim 210 | (pyim-greatdict-enable)) 211 | )) 212 | 213 | (defun appleshan-chinese/init-unicad () 214 | (use-package unicad 215 | :init 216 | (require 'unicad))) 217 | 218 | ;; Local Variables: 219 | ;; coding: utf-8 220 | ;; no-byte-compile: nil 221 | ;; End: 222 | 223 | ;;; packages.el ends here 224 | -------------------------------------------------------------------------------- /layers/appleshan-complete/README.org: -------------------------------------------------------------------------------- 1 | Complete - incremental completion and selection 2 | -------------------------------------------------------------------------------- /layers/appleshan-complete/config.el: -------------------------------------------------------------------------------- 1 | ;;; config.el --- appleshan-complete Layer configuration File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2012-2016 Sylvain Benner & Contributors 4 | ;; 5 | ;; Author: Sylvain Benner 6 | ;; URL: https://github.com/syl20bnr/spacemacs 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;; Variables 13 | 14 | ;; Files that helm should know how to open 15 | (setq helm-external-programs-associations 16 | '(("avi" . "vlc") 17 | ("part" . "vlc") 18 | ("mkv" . "vlc") 19 | ("webm" . "vlc") 20 | ("mp4" . "vlc"))) 21 | 22 | ;; Local Variables: 23 | ;; coding: utf-8 24 | ;; no-byte-compile: nil 25 | ;; End: 26 | 27 | ;;; config.el ends here 28 | -------------------------------------------------------------------------------- /layers/appleshan-complete/funcs.el: -------------------------------------------------------------------------------- 1 | ;;; funcs.el --- appleshan-complete Layer functions File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | (defvar helm-httpstatus-source 13 | '((name . "HTTP STATUS") 14 | (candidates . (("100 Continue") 15 | ("101 Switching Protocols") 16 | ("102 Processing") 17 | ("200 OK") 18 | ("201 Created") 19 | ("202 Accepted") 20 | ("203 Non-Authoritative Information") 21 | ("204 No Content") 22 | ("205 Reset Content") 23 | ("206 Partial Content") 24 | ("207 Multi-Status") 25 | ("208 Already Reported") 26 | ("300 Multiple Choices") 27 | ("301 Moved Permanently") 28 | ("302 Found") 29 | ("303 See Other") 30 | ("304 Not Modified") 31 | ("305 Use Proxy") 32 | ("307 Temporary Redirect") 33 | ("400 Bad Request") 34 | ("401 Unauthorized") 35 | ("402 Payment Required") 36 | ("403 Forbidden") 37 | ("404 Not Found") 38 | ("405 Method Not Allowed") 39 | ("406 Not Acceptable") 40 | ("407 Proxy Authentication Required") 41 | ("408 Request Timeout") 42 | ("409 Conflict") 43 | ("410 Gone") 44 | ("411 Length Required") 45 | ("412 Precondition Failed") 46 | ("413 Request Entity Too Large") 47 | ("414 Request-URI Too Large") 48 | ("415 Unsupported Media Type") 49 | ("416 Request Range Not Satisfiable") 50 | ("417 Expectation Failed") 51 | ("418 I'm a teapot") 52 | ("421 Misdirected Request") 53 | ("422 Unprocessable Entity") 54 | ("423 Locked") 55 | ("424 Failed Dependency") 56 | ("425 No code") 57 | ("426 Upgrade Required") 58 | ("428 Precondition Required") 59 | ("429 Too Many Requests") 60 | ("431 Request Header Fields Too Large") 61 | ("449 Retry with") 62 | ("500 Internal Server Error") 63 | ("501 Not Implemented") 64 | ("502 Bad Gateway") 65 | ("503 Service Unavailable") 66 | ("504 Gateway Timeout") 67 | ("505 HTTP Version Not Supported") 68 | ("506 Variant Also Negotiates") 69 | ("507 Insufficient Storage") 70 | ("509 Bandwidth Limit Exceeded") 71 | ("510 Not Extended") 72 | ("511 Network Authentication Required"))) 73 | (action . message))) 74 | 75 | (defun helm-httpstatus () 76 | (interactive) 77 | (helm-other-buffer '(helm-httpstatus-source) "*helm httpstatus*")) 78 | 79 | ;; Local Variables: 80 | ;; coding: utf-8 81 | ;; no-byte-compile: nil 82 | ;; End: 83 | 84 | ;;; funcs.el ends here 85 | -------------------------------------------------------------------------------- /layers/appleshan-complete/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- appleshan-complete layer packages file for Spacemacs 2 | 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | 8 | ;; This file is not part of GNU Emacs. 9 | 10 | ;;; Commentary: 11 | 12 | ;; 这个文件是 appleshan 个人专用的 emacs 配置文件,emacs 中文用户可以参考。 13 | 14 | ;;; License: GPLv3 15 | 16 | ;;; Code: 17 | 18 | (setq appleshan-complete-packages 19 | '( 20 | company 21 | helm-ag 22 | helm-flx 23 | projectile 24 | yasnippet 25 | smart-tab 26 | )) 27 | 28 | ;; List of packages to exclude. 29 | (setq appleshan-complete-excluded-packages '()) 30 | 31 | ;; company-mode 32 | (defun appleshan-complete/post-init-company () 33 | (setq company-selection-wrap-around t 34 | ;; do or don't automatically start completion after 35 | company-idle-delay 0.5 36 | ;; at least 1 letters need to be there though 37 | company-minimum-prefix-length 1 38 | ;; show completion numbers for hotkeys 39 | company-show-numbers t 40 | ;; align annotations to the right 41 | company-tooltip-align-annotations t 42 | company-search-regexp-function #'company-search-flex-regexp) 43 | 44 | (spacemacs|add-company-backends :modes 45 | ; !!! NOTE: 不能为 text-mode 开启 company , 当在 magit 中填写 commit message 的时候,会造成 emacs 崩溃. !!! 46 | ; text-mode 47 | shell-script-mode 48 | sh-mode 49 | nxml-mode 50 | conf-unix-mode 51 | json-mode 52 | graphviz-dot-mode) 53 | ) 54 | 55 | (defun appleshan-complete/post-init-helm-ag () 56 | (setq helm-ag-base-command "sift --no-color -n") 57 | ; (setq helm-ag-command-option "--all-text") 58 | (setq helm-ag-insert-at-point 'symbol) 59 | (setq helm-ag-ignore-buffer-patterns '("\\.txt\\'" "\\.mkd\\'"))) 60 | 61 | (defun appleshan-complete/post-init-helm-flx () 62 | ;; garbage collection 63 | (defun eos/minibuffer-setup-hook () 64 | (setq gc-cons-threshold most-positive-fixnum)) 65 | 66 | (defun eos/minibuffer-exit-hook () 67 | ;; 20mb 68 | (setq gc-cons-threshold (* 20 1024 1024))) 69 | 70 | (add-hook 'minibuffer-setup-hook #'eos/minibuffer-setup-hook) 71 | (add-hook 'minibuffer-exit-hook #'eos/minibuffer-exit-hook)) 72 | 73 | (defun appleshan-complete/post-init-projectile () 74 | (with-eval-after-load 'projectile 75 | ;; global ignores 76 | (add-to-list 'projectile-globally-ignored-files ".tern-port") 77 | (add-to-list 'projectile-globally-ignored-files "GTAGS") 78 | (add-to-list 'projectile-globally-ignored-files "GPATH") 79 | (add-to-list 'projectile-globally-ignored-files "GRTAGS") 80 | (add-to-list 'projectile-globally-ignored-files "GSYMS") 81 | (add-to-list 'projectile-globally-ignored-files ".DS_Store") 82 | ;; always ignore .class / .pyc files 83 | (add-to-list 'projectile-globally-ignored-file-suffixes ".class") 84 | (add-to-list 'projectile-globally-ignored-file-suffixes ".pyc"))) 85 | 86 | (defun appleshan-complete/post-init-yasnippet () 87 | (setq yas-snippet-dirs (delq 'yas-installed-snippets-dir yas-snippet-dirs)) 88 | ;; ~/.emacs.d/elpa/yasnippet-xxxxx/snippets 89 | ;; 不再加载这个目录,拷贝需要的到 ~/.spacemacs.d/snippets 90 | ;; (push yas-installed-snippets-dir yas-snippet-dirs) 91 | 92 | ;; Remove Yasnippet's default tab key binding 93 | (define-key yas-minor-mode-map (kbd "") nil) 94 | (define-key yas-minor-mode-map (kbd "TAB") nil) 95 | ;; Alternatively use Control-c + tab 96 | (define-key yas-minor-mode-map (kbd "\C-c TAB") 'yas-expand) 97 | 98 | (set-face-background 'secondary-selection "gray") 99 | 100 | (use-package dropdown-list :commands dropdown-list) 101 | (setq yas-prompt-functions '(yas-dropdown-prompt 102 | yas-x-prompt 103 | yas-maybe-ido-prompt 104 | yas-completing-prompt))) 105 | 106 | ;; Used smart-tab to complete everywhere except for ERC, shell and mu4e. 107 | (defun appleshan-complete/init-smart-tab () 108 | (use-package smart-tab 109 | :ensure t 110 | :defer t 111 | :diminish "" 112 | :init 113 | (global-smart-tab-mode 1) 114 | (setq smart-tab-using-hippie-expand t) 115 | :config 116 | (add-to-list 'smart-tab-disabled-major-modes 'mu4e-compose-mode) 117 | (add-to-list 'smart-tab-disabled-major-modes 'erc-mode) 118 | (add-to-list 'smart-tab-disabled-major-modes 'shell-mode))) 119 | 120 | ;; Local Variables: 121 | ;; coding: utf-8 122 | ;; no-byte-compile: nil 123 | ;; End: 124 | 125 | ;;; packages.el ends here 126 | -------------------------------------------------------------------------------- /layers/appleshan-core/README.org: -------------------------------------------------------------------------------- 1 | Core Emacs - base Emacs settings and configurations 2 | -------------------------------------------------------------------------------- /layers/appleshan-core/config.el: -------------------------------------------------------------------------------- 1 | ;;; config.el --- appleshan-core layer configuration file for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;;; Code: 13 | 14 | ;; Personal information about me: full name and email 15 | (setq user-full-name "Apple Shan" 16 | user-mail-address "apple.shan@gmail.com") 17 | 18 | (setq auto-coding-regexp-alist 19 | (delete (rassoc 'utf-16be-with-signature auto-coding-regexp-alist) 20 | (delete (rassoc 'utf-16le-with-signature auto-coding-regexp-alist) 21 | (delete (rassoc 'utf-8-with-signature auto-coding-regexp-alist) 22 | auto-coding-regexp-alist)))) 23 | 24 | (setq-default indent-tabs-mode nil) ; 使用空格缩进 25 | ;; set TAB and indention 26 | (setq-default indent-tabs-mode nil 27 | tab-width 4) ; 所有buffer默认使用4格缩进 28 | 29 | (delete-selection-mode t) ; delete the selection with a key press 30 | ; (global-font-lock-mode t) ; Turn on syntax highlighting for all buffers 31 | ; If you change buffer, or focus, disable the current buffer's mark: 32 | (transient-mark-mode 1) 33 | 34 | ;; Don't indicate empty lines or the end of a buffer with visual marks 35 | ;; (the lines are cleaned up automatically anyway) 36 | (setq-default indicate-empty-lines nil) 37 | (setq-default indicate-buffer-boundaries nil) 38 | 39 | ;; {{ 取代 smartparens,因为 smartparens 有一些性能问题 40 | ;; @See https://emacs-china.org/t/smartparens/2055/3 41 | (electric-pair-mode t) 42 | ;; https://www.reddit.com/r/emacs/comments/4xhxfw/how_to_tune_the_behavior_of_eletricpairmode/ 43 | (setq electric-pair-inhibit-predicate 'electric-pair-conservative-inhibit) 44 | 45 | ;; show parenthesis match 46 | (show-paren-mode t) 47 | ; (setq show-paren-style 'expression) 48 | (setq show-paren-style 'parentheses) ;括号匹配显示但不是烦人的跳到另一个括号。 49 | ;; }} 50 | 51 | (auto-compression-mode t) ;Transparently Open Compressed Files 52 | ;(mouse-avoidance-mode "banish") ;只要一操作鼠标自动闪开 53 | 54 | (setq-default major-mode 'text-mode) ;设置默认的主模式为 TEXT 模式 55 | (setq x-select-enable-clipboard t) ;支持 emacs 和外部程序的粘贴 56 | (setq x-stretch-cursor t) ;光标在 TAB 字符上会显示为一个大方块 57 | ; (setq max-specpdl-size 10000) ;最大容量 58 | (setq kill-ring-max 1024) ;用一个很大的 kill ring. 这样防止我不小心删掉重要的东西 59 | (setq undo-outer-limit 5000000) ;撤销限制 60 | (setq mark-ring-max 1024) ;设置的 mark ring 容量 61 | (setq global-mark-ring-max 1024) ;设置最大的全局标记容量 62 | (setq message-log-max t) ;设置 *Messages* 记录全部消息, 而不用截去 63 | (setq read-quoted-char-radix 16) ;设置 引用字符 的基数 64 | (setq void-text-area-pointer nil) ;禁止显示鼠标指针 65 | (setq blink-matching-paren nil) ;当插入右括号时不显示匹配的左括号 66 | (setq max-lisp-eval-depth 40000) ; lisp 最大执行深度 67 | (setq-default comment-style 'indent) ;设定自动缩进的注释风格 68 | (setq history-delete-duplicates t) ;删除 minibuffer 的重复历史 69 | (setq print-escape-newlines t) ;显示字符窗中的换行符为 \n 70 | 71 | ;; Only mark helm buffers as useless 72 | (setq spacemacs-useless-buffers-regexp '("\\*helm\.\+\\*")) 73 | 74 | ;; Marking the *Messages* buffer as useful 75 | (push "\\*Messages\\*" spacemacs-useful-buffers-regexp) 76 | 77 | ;; Prevent the visual selection overriding my system clipboard 78 | (fset 'evil-visual-update-x-selection 'ignore) 79 | 80 | ;; Don't move back the cursor one position when exiting insert mode 81 | (setq evil-move-cursor-back nil) 82 | 83 | (setq save-abbrevs nil) 84 | 85 | ;; turn on abbrev mode globally 86 | (setq-default abbrev-mode t) 87 | 88 | (setq url-show-status nil) 89 | 90 | ;; Allow font-lock-mode to do background parsing 91 | (setq font-lock-support-mode 'jit-lock-mode) 92 | (setq jit-lock-defer-time nil 93 | jit-lock-defer-contextually t 94 | jit-lock-stealth-nice 0.5 95 | jit-lock-stealth-time 16 96 | jit-lock-stealth-verbose nil) 97 | (setq-default font-lock-multiline t) 98 | 99 | ;; Wait a bit longer than the default (0.5 seconds) before assuming Emacs is idle 100 | (setq idle-update-delay 2) 101 | 102 | (setq line-number-display-limit-width 10000) 103 | 104 | ;; Make gnutls a bit safer, the default is an absurdly low 256 105 | (setq gnutls-min-prime-bits 4096) 106 | 107 | ;; Set up the fill-column to 80 characters and set tab width to 2 108 | (setq-default fill-column 80) 109 | (setq-default default-tab-width 2) 110 | (setq-default indent-tabs-mode nil) 111 | 112 | ;; Fix some weird color escape sequences 113 | (setq system-uses-terminfo nil) 114 | 115 | ;; Resolve symlinks: 116 | (setq-default find-file-visit-truename t) 117 | 118 | ;; Require a newline at the end of files: 119 | (setq require-final-newline t) 120 | ;; add no new lines when "arrow-down key" at the end of a buffer 121 | (setq next-line-add-newlines nil) 122 | 123 | ;; Ignore case when performing completion 124 | (setq completion-ignore-case t 125 | read-buffer-completion-ignore-case t) 126 | 127 | ;; Don't warn me about large files unless they're at least 25mb: 128 | (setq large-file-warning-threshold (* 25 1024 1024)) 129 | 130 | ;; Switch to unified diffs by default: 131 | ;; (setq diff-switches "-u") 132 | 133 | ;; Set the internal calculator not to go to scientific form quite so quickly: 134 | (setq calc-display-sci-low -5) 135 | 136 | ;; Don't bother saving things to the kill-ring twice, remove duplicates 137 | (setq kill-do-not-save-duplicates t) 138 | 139 | ;; Preserve the window location when opening things 140 | (setq switch-to-buffer-preserve-window-point t) 141 | 142 | ;; Use a sane re-builder syntax so I don't have to have crazy escapes, 143 | ;; see: https://masteringemacs.org/article/re-builder-interactive-regexp-builder 144 | (setq reb-re-syntax 'string) 145 | 146 | ;; Turn on auto-fill mode in text buffers: 147 | (add-hook 'text-mode-hook 'turn-on-auto-fill) 148 | ;(use-package diminish 149 | ; :init (diminish 'auto-fill-function "")) 150 | 151 | (when (boundp 'global-prettify-symbols-mode) 152 | (add-hook 'emacs-lisp-mode-hook 153 | (lambda () 154 | (push '("lambda" . ?λ) prettify-symbols-alist))) 155 | (global-prettify-symbols-mode +1)) 156 | 157 | ;; 搜索时任意字符都可以用空格代替 158 | ;; @See https://chriszheng.science/2016/01/03/One-line-makes-isearch-flexible/ 159 | (setq search-whitespace-regexp ".*?") 160 | 161 | ;; Mouse & Smooth Scroll 162 | ;; Scroll one line at a time (less "jumpy" than defaults) 163 | (setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) 164 | (setq mouse-wheel-progressive-speed nil) 165 | (setq scroll-step 1 166 | scroll-margin 1 167 | scroll-conservatively 100000) 168 | 169 | ;; Local Variables: 170 | ;; coding: utf-8 171 | ;; no-byte-compile: nil 172 | ;; End: 173 | 174 | ;;; config.el ends here 175 | -------------------------------------------------------------------------------- /layers/appleshan-core/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- appleshan-core layer packages file for Spacemacs 2 | 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | 8 | ;; This file is not part of GNU Emacs. 9 | 10 | ;;; Commentary: 11 | 12 | ;; 这个文件是 appleshan 个人专用的 emacs 配置文件,emacs 中文用户可以参考。 13 | 14 | ;;; License: GPLv3 15 | 16 | ;;; Code: 17 | 18 | (setq appleshan-core-packages 19 | '( 20 | (mule :location built-in) 21 | (recentf :location built-in) 22 | (profiler :location built-in) 23 | (whitespace :location built-in) 24 | (calendar :location built-in) 25 | (ibuffer :location built-in) 26 | helpful 27 | real-auto-save 28 | )) 29 | 30 | ;; List of packages to exclude. 31 | (setq appleshan-core-excluded-packages '()) 32 | 33 | ;; Charset 设置 34 | (defun appleshan-core/init-mule () 35 | (use-package mule 36 | :config 37 | (progn 38 | (appleshan/set-language-coding-systems) 39 | ))) 40 | 41 | (defun appleshan-core/post-init-recentf () 42 | "Save recently visited files" 43 | (use-package recentf 44 | :config 45 | (progn 46 | (setq recentf-auto-cleanup 600) 47 | (setq recentf-max-saved-items 200) 48 | (dolist (item '("bookmarks" 49 | "/\\.git/.*\\'" ; Git contents 50 | "COMMIT_MSG" 51 | "COMMIT_EDITMSG" 52 | "github.*txt$" 53 | ".*png$" 54 | "/tmp/" 55 | "/ssh:" 56 | "\\var\\'" 57 | ".*\\.gz\\'" 58 | "TAGS" 59 | ".*-autoloads\\.el\\'" 60 | "/elpa/" 61 | "/ssh:" 62 | "/sudo:" 63 | "/scp:" 64 | (expand-file-name my-org-gtd-directory) ; org-gtd files 65 | "/spacemacs-develop/.cache/" 66 | "/spacemacs-develop/snippets/" 67 | "/spacemacs-private/.cache/" 68 | "/opt/emacs*/.*\\.el\\'")) 69 | (add-to-list 'recentf-exclude item)) 70 | ))) 71 | 72 | (defun appleshan-core/init-profiler () 73 | (use-package profiler 74 | :init 75 | (evilified-state-evilify profiler-report-mode profiler-report-mode-map) 76 | :config 77 | (progn 78 | ;; 定义列的宽度 79 | (setq profiler-report-cpu-line-format 80 | '((75 left) 81 | (24 right ((19 right) (5 right))))) 82 | (setq profiler-report-memory-line-format 83 | '((75 left) 84 | (19 right ((14 right profiler-format-number) 85 | (5 right))))) 86 | ))) 87 | 88 | ;; Visualize TAB, (HARD) SPACE, NEWLINE 89 | (defun appleshan-core/post-init-whitespace () 90 | (progn 91 | ;; ;; http://emacsredux.com/blog/2013/05/31/highlight-lines-that-exceed-a-certain-length-limit/ 92 | (setq whitespace-line-column fill-column) ;; limit line length 93 | ;;https://www.reddit.com/r/emacs/comments/2keh6u/show_tabs_and_trailing_whitespaces_only/ 94 | (setq whitespace-display-mappings 95 | ;; all numbers are Unicode codepoint in decimal. try (insert-char 182 ) to see it 96 | '( 97 | (space-mark 32 [183] [46]) ; 32 SPACE, 183 MIDDLE DOT 「·」, 46 FULL STOP 「.」 98 | (newline-mark 10 [182 10]) ; 10 LINE FEED 99 | (tab-mark 9 [187 9] [9655 9] [92 9]) ; 9 TAB, 9655 WHITE RIGHT-POINTING TRIANGLE 「▷」 100 | )) 101 | (setq whitespace-style '(face tabs trailing tab-mark )) 102 | 103 | (with-eval-after-load 'whitespace 104 | (set-face-attribute 'whitespace-tab nil 105 | :background "#Adff2f" 106 | :foreground "#00a8a8" 107 | :weight 'bold) 108 | (set-face-attribute 'whitespace-trailing nil 109 | :background "#e4eeff" 110 | :foreground "#183bc8" 111 | :weight 'normal) 112 | ) 113 | )) 114 | 115 | (defun appleshan-core/init-calendar () 116 | (use-package calendar 117 | :defer t 118 | :config 119 | (progn 120 | ;; Month 121 | (setq calendar-month-name-array 122 | ["一月" "二月" "三月" "四月" "五月" "六月" 123 | "七月" "八月" "九月" "十月" "十一月" "十二月"]) 124 | ;; Week days 125 | (setq calendar-day-name-array 126 | ["星期一" "星期二" "星期三" "星期四" "星期五" "星期六" "星期日"]) 127 | ;; First day of the week 128 | (setq calendar-week-start-day 0) ; 0:Sunday, 1:Monday 129 | ))) 130 | 131 | (defun appleshan-core/post-init-ibuffer () 132 | (setq ibuffer-show-empty-filter-groups nil)) 133 | 134 | (defun appleshan-core/init-helpful () 135 | (use-package helpful)) 136 | 137 | (defun appleshan-core/init-real-auto-save () 138 | (use-package real-auto-save 139 | :diminish (real-auto-save-mode) 140 | :config 141 | (setq real-auto-save-interval 10) ;; in seconds 142 | (add-hook 'org-mode-hook 'real-auto-save-mode) 143 | (add-hook 'prog-mode-hook 'real-auto-save-mode))) 144 | 145 | ;; Local Variables: 146 | ;; coding: utf-8 147 | ;; no-byte-compile: nil 148 | ;; End: 149 | 150 | ;;; packages.el ends here 151 | -------------------------------------------------------------------------------- /layers/appleshan-database/config.el: -------------------------------------------------------------------------------- 1 | ;;; server list 2 | (setq sql-connection-alist 3 | '((mysql.nfdev.local (sql-product 'mysql) 4 | (sql-port 3306) 5 | (sql-server "192.168.14.41") 6 | (sql-user "nfdev") 7 | (sql-database "nfdev")) 8 | (mysql.dgdev.local (sql-product 'mysql) 9 | (sql-port 3306) 10 | (sql-server "192.168.14.41") 11 | (sql-user "ncl") 12 | (sql-database "dg1110")) 13 | (mysql.nftest.local (sql-product 'mysql) 14 | (sql-port 3306) 15 | (sql-server "192.168.14.60") 16 | (sql-user "nftest") 17 | (sql-database "nftest")) 18 | (oracle.lisdev.local (sql-product 'oracle) 19 | (sql-port 1521) 20 | (sql-server "192.168.14.42") 21 | (sql-user "yklisdev") 22 | (sql-database "daandev")) 23 | )) 24 | -------------------------------------------------------------------------------- /layers/appleshan-database/funcs.el: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appleshan/my-spacemacs-config/7101845a6a498ec1f3f96263cf71db9576de9472/layers/appleshan-database/funcs.el -------------------------------------------------------------------------------- /layers/appleshan-database/img/my-ejc-sql.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appleshan/my-spacemacs-config/7101845a6a498ec1f3f96263cf71db9576de9472/layers/appleshan-database/img/my-ejc-sql.png -------------------------------------------------------------------------------- /layers/appleshan-database/local/database-client/database-client.el: -------------------------------------------------------------------------------- 1 | ;;; database-client.el --- Setup Emacs as an SQL Database client 2 | ;;; -*- coding: utf-8 -*- 3 | 4 | ;;; Commentary: 5 | 6 | ;; @see https://truongtx.me/2014/08/23/setup-emacs-as-an-sql-database-client 7 | ;; @see https://github.com/tmtxt/.emacs.d/blob/master/config/tmtxt-sql.el 8 | 9 | ;;; Code: 10 | 11 | 12 | ;; (require 'sql) 13 | 14 | ;;; hooks 15 | (add-hook 'sql-interactive-mode-hook 16 | (lambda () 17 | (toggle-truncate-lines t) 18 | (setq-local show-trailing-whitespace nil) 19 | ;; (auto-complete-mode t) ;; TODO 20 | )) 21 | 22 | (add-hook 'sql-mode-hook 23 | (lambda () 24 | (setq-local ac-ignore-case t) 25 | (auto-complete-mode))) 26 | 27 | (defun dbclient/sql-connect-server (connection) 28 | "Connect to the input server using sql-connection-alist" 29 | (interactive 30 | (helm-comp-read "Select server: " (mapcar (lambda (item) 31 | (list 32 | (symbol-name (nth 0 item)) 33 | (nth 0 item))) 34 | sql-connection-alist))) 35 | (require 'my-password "./database-password.el.gpg") 36 | ;; get the sql connection info and product from the sql-connection-alist 37 | (let* ((connection-info (assoc connection sql-connection-alist)) 38 | (connection-product (nth 1 (nth 1 (assoc 'sql-product connection-info)))) 39 | (sql-password (nth 1 (assoc connection my-sql-password)))) 40 | ;; delete the connection info from the sql-connection-alist 41 | (setq sql-connection-alist (assq-delete-all connection sql-connection-alist)) 42 | ;; delete the old password from the connection-info 43 | (setq connection-info (assq-delete-all 'sql-password connection-info)) 44 | ;; add the password to the connection-info 45 | (nconc connection-info `((sql-password ,sql-password))) 46 | ;; add back the connection info to the beginning of sql-connection-alist 47 | ;; (last used server will appear first for the next prompt) 48 | (add-to-list 'sql-connection-alist connection-info) 49 | ;; override the sql-product by the product of this connection 50 | (setq sql-product connection-product) 51 | ;; connect 52 | (if current-prefix-arg 53 | (sql-connect connection connection) 54 | (sql-connect connection)))) 55 | 56 | 57 | (provide 'database-client) 58 | 59 | ;;; database-client.el ends here 60 | -------------------------------------------------------------------------------- /layers/appleshan-database/local/database-client/database-password.el.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appleshan/my-spacemacs-config/7101845a6a498ec1f3f96263cf71db9576de9472/layers/appleshan-database/local/database-client/database-password.el.gpg -------------------------------------------------------------------------------- /layers/appleshan-database/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- appleshan-database layer packages file for Spacemacs 2 | 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | 8 | ;; This file is not part of GNU Emacs. 9 | 10 | ;;; Commentary: 11 | 12 | ;; 这个文件是 appleshan 个人专用的 emacs 配置文件,emacs 中文用户可以参考。 13 | 14 | ;;; License: GPLv3 15 | 16 | ;;; Code: 17 | 18 | (setq appleshan-database-packages 19 | '( 20 | (database-client :location local) 21 | )) 22 | 23 | ;; List of packages to exclude. 24 | (setq appleshan-database-excluded-packages '()) 25 | 26 | (defun appleshan-database/init-database-client () 27 | (use-package database-client)) 28 | 29 | 30 | ;; Local Variables: 31 | ;; coding: utf-8 32 | ;; no-byte-compile: nil 33 | ;; End: 34 | 35 | ;;; packages.el ends here 36 | -------------------------------------------------------------------------------- /layers/appleshan-dired/README.org: -------------------------------------------------------------------------------- 1 | Dired - directory browsing and file management 2 | -------------------------------------------------------------------------------- /layers/appleshan-dired/funcs.el: -------------------------------------------------------------------------------- 1 | ;;; funcs.el --- appleshan-dired Layer functions File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;; dired 文件管理器可以把目录优先排在前面。 13 | (defun dired/list-dir-first () 14 | "Dired sort hook to list directories first." 15 | (save-excursion 16 | (let (buffer-read-only) 17 | (forward-line 2) ;; beyond dir. header 18 | (sort-regexp-fields t "^.*$" "[ ]*." (point) (point-max)))) 19 | (and (featurep 'xemacs) 20 | (fboundp 'dired-insert-set-properties) 21 | (dired-insert-set-properties (point-min) (point-max))) 22 | (set-buffer-modified-p nil)) 23 | 24 | (add-hook 'dired-after-readin-hook 'dired/list-dir-first) 25 | 26 | ;; dired-x.el 允许忽略不感兴趣的文件,不让他们显示出来,并且可以使用 M-o 来方便地切换忽略与显示。 27 | ;; 有两个变量可以控制究竟忽略哪些文件: 28 | ;; 1. dired-omit-files 是一个正则表达式,凡是匹配这个正则表达式的文件就会被忽略掉, 29 | ;; 默认情况下会忽略自动保存的文件(以 # 开头),当前目录和父目录(也就是 . 和 .. )。 30 | ;; 2. dired-omit-extensions 是一个字符串列表,凡是文件名结尾是这个列表中的某一个的时就会被忽略。 31 | ;; 32 | ;; 忽略掉以 . 开头的文件和文件夹,在 Linux 下面这通常表示隐藏文件和文件夹 33 | (defun appleshan//dired-hook () 34 | ; omit all hidden file which starts with `.' 35 | (setq dired-omit-files "^#\\|^\\..*") 36 | ; initially omit unintrested files 37 | ; Ⓞ : http://graphemica.com/%E2%93%84 38 | (spacemacs|diminish dired-omit-mode " Ⓞ" " O")) 39 | 40 | ;; @see http://oremacs.com/2015/01/12/dired-file-size/ 41 | (defun dired/get-size () 42 | (interactive) 43 | (let ((files (dired-get-marked-files))) 44 | (with-temp-buffer 45 | (apply 'call-process "/usr/bin/du" nil t nil "-sch" files) 46 | (message 47 | "Size of all marked files: %s" 48 | (progn 49 | (re-search-backward "\\(^[ 0-9.,]+[A-Za-z]+\\).*total$") 50 | (match-string 1)))))) 51 | 52 | (defun dired/open-in-external-app () 53 | "Open the current or marked files in external app." 54 | (interactive) 55 | (let (doIt 56 | (myFileList 57 | (cond 58 | ((string-equal major-mode "dired-mode") 59 | (dired-get-marked-files)) 60 | (t (list (buffer-file-name))) ) ) ) 61 | (setq doIt (if (<= (length myFileList) 5) 62 | t 63 | (y-or-n-p "Open more than 5 files?") ) ) 64 | (when doIt 65 | (mapc (lambda (fPath) 66 | (let ((process-connection-type nil)) 67 | (start-process "" nil "xdg-open" fPath))) 68 | myFileList)))) 69 | 70 | ;; @see http://oremacs.com/2016/02/24/dired-rsync/ 71 | (defun dired/rsync (dest) 72 | "Using rsync in dired." 73 | (interactive 74 | (list 75 | (expand-file-name 76 | (read-file-name 77 | "Rsync to:" 78 | (dired-dwim-target-directory))))) 79 | ;; store all selected files into "files" list 80 | (let ((files (dired-get-marked-files nil current-prefix-arg)) 81 | ;; the rsync command 82 | (tmtxt/rsync-command "rsync -arvz --progress ")) 83 | ;; add all selected file names as arguments 84 | ;; to the rsync command 85 | (dolist (file files) 86 | (setq tmtxt/rsync-command 87 | (concat tmtxt/rsync-command 88 | (shell-quote-argument file) 89 | " "))) 90 | ;; append the destination 91 | (setq tmtxt/rsync-command 92 | (concat tmtxt/rsync-command 93 | (shell-quote-argument dest))) 94 | ;; run the async shell command 95 | (async-shell-command tmtxt/rsync-command "*rsync*") 96 | ;; finally, switch to that window 97 | (other-window 1))) 98 | 99 | ;; Ignore case when using completion for file names: 100 | (setq read-file-name-completion-ignore-case t) 101 | 102 | (with-eval-after-load 'dired-sort 103 | (defun appleshan//dired-sort-hook () 104 | (interactive) 105 | 106 | (make-local-variable 'dired-sort-map) 107 | (setq dired-sort-map (make-sparse-keymap)) 108 | (define-key dired-mode-map "s" dired-sort-map) 109 | 110 | (define-key dired-sort-map "n" 'dired-sort-name) ; Name 111 | (define-key dired-sort-map "x" 'dired-sort-extension) ; Extension 112 | (define-key dired-sort-map "s" 'dired-sort-size) ; Size 113 | (define-key dired-sort-map "t" 'dired-sort-time) ; Modified Time 114 | (define-key dired-sort-map "u" 'dired-sort-utime) ; Access Time 115 | (define-key dired-sort-map "c" 'dired-sort-ctime) ; Create Time 116 | )) 117 | 118 | ;; Ignore running processes when closing Emacs 119 | ;; add `flet' 120 | (require 'cl) 121 | 122 | (defadvice save-buffers-kill-emacs 123 | (around no-query-kill-emacs activate) 124 | "Prevent \"Active processes exist\" query on exit." 125 | (flet ((process-list ())) ad-do-it)) 126 | -------------------------------------------------------------------------------- /layers/appleshan-dired/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- appleshan-dired Layer packages File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | (setq appleshan-dired-packages 13 | '( 14 | (dired :location built-in) 15 | (dired-x :location built-in) 16 | (dired-k :location "~/.spacemacs.d/local/dired-k/") 17 | dired-quick-sort 18 | dired-efap 19 | )) 20 | 21 | ;; List of packages to exclude. 22 | (setq appleshan-dired-excluded-packages '()) 23 | 24 | ;; Directory operations 25 | (defun appleshan-dired/post-init-dired () 26 | (with-eval-after-load 'dired 27 | ;; allow dired to be able to delete or copy a whole dir. 28 | (setq dired-recursive-copies 'always) ; "always" means no asking 29 | (setq dired-recursive-deletes 'top) ; "top" means ask once for top level directory 30 | 31 | ;; Show directory first 32 | ;; @see http://oremacs.com/2015/01/13/dired-options/ 33 | ;; 传给 ls 的参数: 34 | ;; l: Is the only mandatory one. 35 | ;; a: Means to list invisible files. 36 | ;; G: Don't show group information. These days, when there are more laptops 37 | ;; than people, the group info is rarely useful. 38 | ;; h: Human readable sizes, such as M for mebibytes. 39 | ;; 1v: Affects the sorting of digits, hopefully in a positive way. 40 | ;; u: sort by access time, newest first 41 | ;; --group-directories-first: self-explanatory, I like to have the directories 42 | ;; on the top, separate from the files. 43 | ;; 44 | ;; 另外注意:在 dired-sort 中会拼接参数, 45 | ;; 所以 "--group-directories-first" 必须写在 "-laGh1v" 前面. 46 | (setq dired-listing-switches "--group-directories-first -alh1vu") 47 | 48 | (setq directory-free-space-args "-Phk") ;目录空间选项 49 | (setq dired-auto-revert-buffer t) 50 | 51 | (setq find-ls-option '("-print0 | xargs -0 ls -ald" . "")) 52 | 53 | (define-key dired-mode-map (kbd "DEL") 'vinegar/up-directory) 54 | (define-key dired-mode-map (kbd "O") 'dired/open-in-external-app) 55 | (define-key dired-mode-map (kbd "z") 'dired/get-size) 56 | )) 57 | 58 | ;; @see http://oremacs.com/2015/01/04/dired-nohup/ 59 | (defun appleshan-dired/post-init-dired-x () 60 | (with-eval-after-load 'dired-x 61 | (setq dired-guess-shell-alist-user 62 | '(("\\.pdf\\'" "open") 63 | ("\\.docx\\'" "open") 64 | ("\\.\\(?:djvu\\|eps\\)\\'" "open") 65 | ("\\.\\(?:jpg\\|jpeg\\|png\\|gif\\|xpm\\)\\'" "open") 66 | ("\\.\\(?:xcf\\)\\'" "open") 67 | ("\\.csv\\'" "open") 68 | ("\\.tex\\'" "open") 69 | ("\\.\\(?:mp4\\|mkv\\|avi\\|flv\\|rm\\|rmvb\\|ogv\\)\\(?:\\.part\\)?\\'" 70 | "open") 71 | ("\\.\\(?:mp3\\|flac\\)\\'" "open") 72 | ("\\.html?\\'" "open") 73 | ("\\.md\\'" "open"))) 74 | 75 | (add-hook 'dired-mode-hook 'appleshan//dired-hook) 76 | )) 77 | 78 | ;; Highlights dired buffer like k 79 | (defun appleshan-dired/init-dired-k () 80 | "Git status in dired." 81 | (use-package dired-k 82 | :init 83 | (setq dired-k-padding 1) 84 | (setq dired-k-human-readable t) 85 | :config 86 | (progn 87 | ;; always execute dired-k when dired buffer is opened 88 | (add-hook 'dired-initial-position-hook 'dired-k) 89 | (add-hook 'dired-after-readin-hook #'dired-k-no-revert) 90 | 91 | (evilified-state-evilify-map dired-mode-map 92 | :mode dired-mode 93 | :bindings 94 | "K" 'dired-k) 95 | ))) 96 | 97 | ;; Quick sort dired buffers via hydra 98 | ;; bind key: `S' 99 | (defun appleshan-dired/init-dired-quick-sort () 100 | (use-package dired-quick-sort 101 | :if (or (executable-find "gls") (executable-find "ls")) 102 | :init (dired-quick-sort-setup))) 103 | 104 | ;; dired renaming like GUI file manager 105 | (defun appleshan-dired/init-dired-efap () 106 | (use-package dired-efap 107 | :config 108 | (bind-key "E" #'dired-efap dired-mode-map))) 109 | 110 | ;; Local Variables: 111 | ;; coding: utf-8 112 | ;; no-byte-compile: nil 113 | ;; End: 114 | 115 | ;;; packages.el ends here 116 | -------------------------------------------------------------------------------- /layers/appleshan-java/README.org: -------------------------------------------------------------------------------- 1 | 在 Emacs 下进行 Android Java 编程。 2 | -------------------------------------------------------------------------------- /layers/appleshan-java/funcs.el: -------------------------------------------------------------------------------- 1 | ;;; funcs.el --- appleshan-lisp Layer functions File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | (with-eval-after-load 'smartparens 13 | :config 14 | ;;; Java 15 | (sp-with-modes '(java-mode c++-mode) 16 | (sp-local-pair "{" nil :post-handlers '(("||\n[i]" "RET"))) 17 | (sp-local-pair "/*" "*/" :post-handlers '((" | " "SPC") 18 | ("* ||\n[i]" "RET")))) 19 | ) 20 | 21 | ;; {{{ intellij-java-style 22 | ;; via http://emacs.stackexchange.com/questions/17327/how-to-have-c-offset-style-correctly-detect-a-java-constructor-and-change-indent 23 | (defun my/point-in-defun-declaration-p () 24 | (let ((bod (save-excursion (c-beginning-of-defun) 25 | (point)))) 26 | (<= bod 27 | (point) 28 | (save-excursion (goto-char bod) 29 | (re-search-forward "{") 30 | (point))))) 31 | 32 | (defun my/is-string-concatenation-p () 33 | "Returns true if the previous line is a string concatenation" 34 | (save-excursion 35 | (let ((start (point))) 36 | (forward-line -1) 37 | (if (re-search-forward " \\\+$" start t) t nil)))) 38 | 39 | (defun my/inside-java-lambda-p () 40 | "Returns true if point is the first statement inside of a lambda" 41 | (save-excursion 42 | (c-beginning-of-statement-1) 43 | (let ((start (point))) 44 | (forward-line -1) 45 | (if (search-forward " -> {" start t) t nil)))) 46 | 47 | (defun my/trailing-paren-p () 48 | "Returns true if point is a training paren and semicolon" 49 | (save-excursion 50 | (end-of-line) 51 | (let ((endpoint (point))) 52 | (beginning-of-line) 53 | (if (re-search-forward "[ ]*);$" endpoint t) t nil)))) 54 | 55 | (defun my/prev-line-call-with-no-args-p () 56 | "Return true if the previous line is a function call with no arguments" 57 | (save-excursion 58 | (let ((start (point))) 59 | (forward-line -1) 60 | (if (re-search-forward ".($" start t) t nil)))) 61 | 62 | (defun my/arglist-cont-nonempty-indentation (arg) 63 | (if (my/inside-java-lambda-p) 64 | '+ 65 | (if (my/is-string-concatenation-p) 66 | 16 ;; TODO don't hard-code 67 | (unless (my/point-in-defun-declaration-p) '++)))) 68 | 69 | (defun my/statement-block-intro (arg) 70 | (if (and (c-at-statement-start-p) (my/inside-java-lambda-p)) 0 '+)) 71 | 72 | (defun my/block-close (arg) 73 | (if (my/inside-java-lambda-p) '- 0)) 74 | 75 | (defun my/arglist-close (arg) (if (my/trailing-paren-p) 0 '--)) 76 | 77 | (defun my/arglist-intro (arg) 78 | (if (my/prev-line-call-with-no-args-p) '++ 0)) 79 | 80 | (defconst intellij-java-style 81 | '((c-basic-offset . 4) 82 | (c-comment-only-line-offset . (0 . 0)) 83 | ;; the following preserves Javadoc starter lines 84 | (c-offsets-alist 85 | . 86 | ((inline-open . 0) 87 | (topmost-intro-cont . +) 88 | (statement-block-intro . my/statement-block-intro) 89 | (block-close . my/block-close) 90 | (knr-argdecl-intro . +) 91 | (substatement-open . +) 92 | (substatement-label . +) 93 | (case-label . +) 94 | (label . +) 95 | (statement-case-open . +) 96 | (statement-cont . +) 97 | (arglist-intro . my/arglist-intro) 98 | (arglist-cont-nonempty . (my/arglist-cont-nonempty-indentation c-lineup-arglist)) 99 | (arglist-close . my/arglist-close) 100 | (inexpr-class . 0) 101 | (access-label . 0) 102 | (inher-intro . ++) 103 | (inher-cont . ++) 104 | (brace-list-intro . +) 105 | (func-decl-cont . ++)))) 106 | "Intellij Java Programming Style") 107 | 108 | (c-add-style "intellij" intellij-java-style) 109 | 110 | ;; Available C style: 111 | ;; “gnu”: The default style for GNU projects 112 | ;; “k&r”: What Kernighan and Ritchie, the authors of C used in their book 113 | ;; “bsd”: What BSD developers use, aka “Allman style” after Eric Allman. 114 | ;; “whitesmith”: Popularized by the examples that came with Whitesmiths C, an early commercial C compiler. 115 | ;; “stroustrup”: What Stroustrup, the author of C++ used in his book 116 | ;; “ellemtel”: Popular C++ coding standards as defined by “Programming in C++, Rules and Recommendations,” Erik Nyquist and Mats Henricson, Ellemtel 117 | ;; “linux”: What the Linux developers use for kernel development 118 | ;; “python”: What Python developers use for extension modules 119 | ;; “java”: The default style for java-mode (see below) 120 | ;; “user”: When you want to define your own style 121 | (customize-set-variable 'c-default-style 122 | '((java-mode . "intellij") 123 | (awk-mode . "awk") 124 | (other . "gnu"))) 125 | ;; }}} 126 | 127 | (defun eos/setup-java () 128 | (interactive) 129 | (define-key java-mode-map (kbd "M-,") 'pop-tag-mark) 130 | (define-key java-mode-map (kbd "C-c M-i") 'java-imports-add-import-dwim) 131 | (c-set-style "intellij" t) 132 | (subword-mode 1) 133 | (toggle-truncate-lines 1) 134 | ;; Generic java stuff things 135 | (setq-local fci-rule-column 99) 136 | (when (fboundp 'eos/turn-on-whitespace-mode) 137 | (whitespace-mode -1) 138 | (eos/turn-on-whitespace-mode)) 139 | ;; remove the stupid company-eclim backend 140 | (when (boundp 'company-backends) 141 | (setq company-backends (delete 'company-eclim company-backends))) 142 | ;; hide the initial comment in the file (usually a license) if hs-minor-mode 143 | ;; is enabled 144 | (when (boundp' hs-minor-mode) 145 | (hs-hide-initial-comment-block))) 146 | 147 | ; (add-hook 'java-mode-hook #'eos/setup-java) 148 | 149 | ;; Make emacs' compile recognize broken gradle output 150 | (require 'compile) 151 | (add-to-list 'compilation-error-regexp-alist 152 | '("^:[^/.\n]+\\(/.+\\):\\([[:digit:]]+\\):" 1 2)) 153 | 154 | ;;; For maven 2/3 output 155 | (add-to-list 'compilation-error-regexp-alist 156 | '("^.*?\\(/.*\\):\\[\\([0-9]*\\),\\([0-9]*\\)\\]" 1 2 3)) 157 | 158 | ;; {{ maven 159 | ;; mvn compile 160 | (defun mvn-compile-full () 161 | (interactive) 162 | (mvn "dependency:sources")) 163 | 164 | ;; mvn package 165 | (defun mvn-package () 166 | (interactive) 167 | (mvn "package")) 168 | 169 | ;; mvn install 170 | (defun mvn-install () 171 | (interactive) 172 | (mvn "install")) 173 | ;; }} 174 | 175 | (setq completion-ignored-extensions (cons ".class" completion-ignored-extensions)) 176 | 177 | ;; Local Variables: 178 | ;; coding: utf-8 179 | ;; no-byte-compile: nil 180 | ;; End: 181 | 182 | ;;; funcs.el ends here 183 | -------------------------------------------------------------------------------- /layers/appleshan-java/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- appleshan-java Layer packages File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;; List of all packages to install and/or initialize. Built-in packages 13 | ;; which require an initialization must be listed explicitly in the list. 14 | (setq appleshan-java-packages 15 | '( 16 | lsp-java 17 | log4j-mode 18 | (maven-pom-mode :location local) 19 | mvn 20 | )) 21 | 22 | ;; List of packages to exclude. 23 | (setq appleshan-java-excluded-packages '()) 24 | 25 | ;; Java support for lsp-mode using the Eclipse JDT Language Server. 26 | ;; Install: 27 | ;; wget http://download.eclipse.org/jdtls/snapshots/jdt-language-server-latest.tar.gz 28 | ;; tar jdt-language-server-latest.tar.gz -C ~/.spacemacs.d/eclipse.jdt.ls/server/ 29 | (defun appleshan-java/init-lsp-java () 30 | (use-package lsp-java 31 | :commands lsp-java-enable 32 | :init 33 | (setq lsp-java-server-install-dir "~/.spacemacs.d/eclipse.jdt.ls/server/") 34 | (add-hook 'java-mode-hook #'lsp-java-enable))) 35 | 36 | (defun appleshan-java/init-log4j-mode () 37 | (use-package log4j-mode 38 | :init 39 | (autoload 'log4j-mode "log4j-mode" "Major mode for viewing log files." t) 40 | :config 41 | (progn 42 | (add-to-list 'auto-mode-alist '("\\.log\\'" . log4j-mode)) 43 | (add-hook 'log4j-mode-hook 44 | (lambda () 45 | (setq truncate-lines t) 46 | (text-scale-set -1) 47 | (toggle-read-only t) 48 | (buffer-disable-undo) 49 | (end-of-buffer))) 50 | ))) 51 | 52 | (defun appleshan-java/init-maven-pom-mode () 53 | (use-package maven-pom-mode 54 | :defer t)) 55 | 56 | (defun appleshan-java/init-mvn () 57 | (use-package mvn 58 | :defer t)) 59 | 60 | ;; Local Variables: 61 | ;; coding: utf-8 62 | ;; no-byte-compile: nil 63 | ;; End: 64 | 65 | ;;; packages.el ends here 66 | -------------------------------------------------------------------------------- /layers/appleshan-javascript/funcs.el: -------------------------------------------------------------------------------- 1 | ;;; funcs.el --- appleshan-javascript Layer functions File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;; reformat your json file, it requires python 13 | (defun appleshan/beautify-json () 14 | (interactive) 15 | (let ((b (if mark-active (min (point) (mark)) (point-min))) 16 | (e (if mark-active (max (point) (mark)) (point-max)))) 17 | (shell-command-on-region b e 18 | "python -mjson.tool" (current-buffer) t))) 19 | 20 | (defun appleshan/mdn-search (searchString) 21 | "Open a browser on the MDN page for SEARCHSTRING." 22 | (interactive (list (read-string "Search: " (thing-at-point 'symbol)))) 23 | (browse-url (format "https://developer.mozilla.org/en-US/search?q=%s&topic=js" searchString))) 24 | 25 | (defun my-js2-mode-hook () 26 | (progn 27 | (define-key js2-mode-map "\C-ci" 'my-js-doc-insert-function-doc-snippet) 28 | (define-key js2-mode-map "@" 'js-doc-insert-tag) 29 | (modify-syntax-entry ?_ "w") 30 | (which-function-mode t) 31 | (setq imenu-create-index-function 'js2-imenu-make-index) 32 | 33 | (setq mode-name "JS2") 34 | (define-key js2-mode-map (kbd "s-.") 'company-tern) 35 | (spacemacs/toggle-syntax-checking-on) 36 | (setq forward-sexp-function nil) 37 | (set (make-local-variable 'semantic-mode) nil) 38 | )) 39 | 40 | ;; http://blog.binchen.org/posts/use-which-func-mode-with-js2-mode.html 41 | (defun my-which-function () 42 | ;; clean the imenu cache 43 | ;; @see http://stackoverflow.com/questions/13426564/how-to-force-a-rescan-in-imenu-by-a-function 44 | (setq imenu--index-alist nil) 45 | (which-function)) 46 | 47 | (defun my-toggle-web-indent () 48 | (interactive) 49 | ;; web development 50 | (if (eq major-mode 'json-mode) 51 | (progn 52 | (setq js-indent-level (if (= js-indent-level 2) 4 2)))) 53 | 54 | (if (or (eq major-mode 'js-mode) (eq major-mode 'js2-mode)) 55 | (progn 56 | (setq js-indent-level (if (= js-indent-level 2) 4 2)))) 57 | 58 | (if (eq major-mode 'web-mode) 59 | (progn (setq web-mode-markup-indent-offset (if (= web-mode-markup-indent-offset 2) 4 2)) 60 | (setq web-mode-css-indent-offset (if (= web-mode-css-indent-offset 2) 4 2)) 61 | (setq web-mode-code-indent-offset (if (= web-mode-code-indent-offset 2) 4 2)))) 62 | (if (eq major-mode 'css-mode) 63 | (setq css-indent-offset (if (= css-indent-offset 2) 4 2))) 64 | ) 65 | 66 | ;; Local Variables: 67 | ;; coding: utf-8 68 | ;; no-byte-compile: nil 69 | ;; End: 70 | 71 | ;;; funcs.el ends here 72 | -------------------------------------------------------------------------------- /layers/appleshan-javascript/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- appleshan-javascript Layer packages File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;; List of all packages to install and/or initialize. Built-in packages 13 | ;; which require an initialization must be listed explicitly in the list. 14 | (setq appleshan-javascript-packages 15 | '( 16 | ; amd-mode 17 | json-mode 18 | js-doc 19 | js2-mode 20 | js2-refactor 21 | tern 22 | ; xref-js2 23 | )) 24 | 25 | ;; List of packages to exclude. 26 | (setq appleshan-javascript-excluded-packages '()) 27 | 28 | ;; TODO: startup slow!!!! 29 | ;; 启动 amd-mode 会造成 emacs 首页的 Projects 列表不能显示 30 | ; (defun appleshan-javascript/init-amd-mode () 31 | ; (use-package amd-mode 32 | ; :defer t 33 | ; :init 34 | ; (progn 35 | ; (require 'amd-mode) 36 | ; (amd-mode 1)) 37 | ; :config 38 | ; (progn 39 | ; (define-key amd-mode-map (kbd "C-c C-a") #'amd-initialize-makey-group) 40 | ; ))) 41 | 42 | (defun appleshan-javascript/post-init-json-mode () 43 | (add-to-list 'auto-mode-alist '("\\.tern-project\\'" . json-mode)) 44 | (spacemacs/set-leader-keys-for-major-mode 'json-mode 45 | "ti" 'my-toggle-web-indent)) 46 | 47 | (defun appleshan-javascript/post-init-js-doc () 48 | (setq js-doc-mail-address "apple.shan@gmail.com" 49 | js-doc-author (format "Apple Shan <%s>" js-doc-mail-address) 50 | js-doc-url "https://github.com/appleshan/" 51 | js-doc-license "MIT") 52 | 53 | (defun my-js-doc-insert-function-doc-snippet () 54 | "Insert JsDoc style comment of the function with yasnippet." 55 | (interactive) 56 | 57 | (with-eval-after-load 'yasnippet 58 | (js-doc--beginning-of-defun) 59 | 60 | (let ((metadata (js-doc--function-doc-metadata)) 61 | (field-count 1)) 62 | (yas-expand-snippet 63 | (concat 64 | js-doc-top-line 65 | " * ${1:Function description.}\n" 66 | (format "* @method %s\n" (nth-value 1 (split-string (which-function) "\\."))) 67 | (mapconcat (lambda (param) 68 | (format 69 | " * @param {${%d:Type of %s}} %s - ${%d:Parameter description.}\n" 70 | (incf field-count) 71 | param 72 | param 73 | (incf field-count))) 74 | (cdr (assoc 'params metadata)) 75 | "") 76 | (when (assoc 'returns metadata) 77 | (format 78 | " * @returns {${%d:Return Type}} ${%d:Return description.}\n" 79 | (incf field-count) 80 | (incf field-count))) 81 | (when (assoc 'throws metadata) 82 | (format 83 | " * @throws {${%d:Exception Type}} ${%d:Exception description.}\n" 84 | (incf field-count) 85 | (incf field-count))) 86 | js-doc-bottom-line))))) 87 | ) 88 | 89 | (defun appleshan-javascript/post-init-js2-mode () 90 | (progn 91 | (spacemacs|define-jump-handlers js2-mode) 92 | (add-hook 'spacemacs-jump-handlers-js2-mode 'etags-select-find-tag-at-point) 93 | 94 | (setq company-backends-js2-mode 95 | '((company-dabbrev-code :with company-keywords company-etags) 96 | company-files 97 | company-dabbrev)) 98 | 99 | (appleshan|toggle-company-backends company-tern) 100 | 101 | (spacemacs/set-leader-keys-for-major-mode 'js2-mode 102 | "tb" 'appleshan/company-toggle-company-tern) 103 | 104 | (add-hook 'js2-mode-hook 'my-js2-mode-hook) 105 | 106 | (spacemacs/declare-prefix-for-mode 'js2-mode "ms" "repl") 107 | 108 | (with-eval-after-load 'js2-mode 109 | (progn 110 | ;; these mode related variables must be in eval-after-load 111 | ;; https://github.com/magnars/.emacs.d/blob/master/settings/setup-js2-mode.el 112 | (setq-default js2-allow-rhino-new-expr-initializer nil) 113 | (setq-default js2-auto-indent-p nil) 114 | (setq-default js2-enter-indents-newline nil) 115 | (setq-default js2-global-externs '("module" "require" "buster" "sinon" "assert" "refute" "setTimeout" "clearTimeout" "setInterval" "clearInterval" "location" "__dirname" "console" "JSON")) 116 | (setq-default js2-idle-timer-delay 0.2) 117 | (setq-default js2-mirror-mode nil) 118 | (setq-default js2-strict-inconsistent-return-warning nil) 119 | (setq-default js2-include-rhino-externs nil) 120 | (setq-default js2-include-gears-externs nil) 121 | (setq-default js2-concat-multiline-strings 'eol) 122 | (setq-default js2-rebind-eol-bol-keys nil) 123 | (setq-default js2-auto-indent-p t) 124 | 125 | (setq-default js2-bounce-indent nil) 126 | (setq-default js-indent-level 4) 127 | (setq-default js2-basic-offset 4) 128 | (setq-default js2-indent-switch-body t) 129 | ;; Let flycheck handle parse errors 130 | (setq-default js2-mode-show-parse-errors nil) 131 | (setq-default js2-mode-show-strict-warnings nil) 132 | (setq-default js2-highlight-external-variables t) 133 | (setq-default js2-strict-trailing-comma-warning nil) 134 | 135 | (spacemacs/set-leader-keys-for-major-mode 'js2-mode 136 | "oi" 'my-toggle-web-indent) 137 | (spacemacs/set-leader-keys-for-major-mode 'js-mode 138 | "oi" 'my-toggle-web-indent) 139 | (spacemacs/set-leader-keys-for-major-mode 'web-mode 140 | "oi" 'my-toggle-web-indent) 141 | (spacemacs/set-leader-keys-for-major-mode 'css-mode 142 | "oi" 'my-toggle-web-indent) 143 | 144 | (spacemacs/declare-prefix-for-mode 'js2-mode "mt" "toggle") 145 | (spacemacs/declare-prefix-for-mode 'js-mode "mt" "toggle") 146 | (spacemacs/declare-prefix-for-mode 'web-mode "mt" "toggle") 147 | (spacemacs/declare-prefix-for-mode 'css-mode "mt" "toggle") 148 | 149 | (eval-after-load 'tern-mode 150 | '(spacemacs|hide-lighter tern-mode)) 151 | )) 152 | 153 | (evilified-state-evilify js2-error-buffer-mode js2-error-buffer-mode-map) 154 | )) 155 | 156 | (defun appleshan-javascript/post-init-js2-refactor () 157 | (spacemacs/set-leader-keys-for-major-mode 'js2-mode 158 | "r>" 'js2r-forward-slurp 159 | "r<" 'js2r-forward-barf)) 160 | 161 | (defun appleshan-javascript/post-init-tern () 162 | ;; tern will override js2r keybindings... 163 | (define-key tern-mode-keymap (kbd "C-c C-r") nil) 164 | 165 | ;; ... and xref. 166 | (define-key tern-mode-keymap (kbd "M-.") nil) 167 | (define-key tern-mode-keymap (kbd "M-,") nil)) 168 | 169 | ; (defun appleshan-javascript/init-xref-js2 () 170 | ; (use-package xref-js2 171 | ; :defer t 172 | ; :init 173 | ; (progn 174 | ; ;; add xref-js2 support 175 | ; (add-hook 'xref-backend-functions #'xref-js2-xref-backend nil t)) 176 | ; :config 177 | ; (progn 178 | ; ;; We have JS files in Scripts directories, ignore that 179 | ; (add-to-list 'xref-js2-ignored-dirs "Scripts") 180 | ; ;; Also ignore some other files 181 | ; ; (dolist (file '("require.js" 182 | ; ; "highcharts.js" 183 | ; ; "highcharts.src.js" 184 | ; ; "bootstrap.js" 185 | ; ; "Gruntfile.js" 186 | ; ; "moment.js" 187 | ; ; "moment-with-locales.js")) 188 | ; ; (add-to-list 'xref-js2-ignored-files file)) 189 | ; ))) 190 | 191 | ;; Local Variables: 192 | ;; coding: utf-8 193 | ;; no-byte-compile: nil 194 | ;; End: 195 | 196 | ;;; packages.el ends here 197 | -------------------------------------------------------------------------------- /layers/appleshan-lisp/funcs.el: -------------------------------------------------------------------------------- 1 | ;;; funcs.el --- appleshan-lisp Layer functions File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | (defun recompile-elpa () 13 | "Recompile packages in elpa directory. Useful if you switch Emacs versions." 14 | (interactive) 15 | (byte-recompile-directory package-user-dir nil t)) 16 | 17 | (defun eos/eval-last-sexp-or-region (prefix) 18 | "Eval region from BEG to END if active, otherwise the last sexp." 19 | (interactive "P") 20 | (if (and (mark) (use-region-p)) 21 | (eval-region (min (point) (mark)) (max (point) (mark))) 22 | (pp-eval-last-sexp prefix))) 23 | 24 | ;; (bind-key "C-x C-e" 'eos/eval-last-sexp-or-region emacs-lisp-mode-map) 25 | 26 | (defun conditionally-enable-lispy () 27 | (when (eq this-command 'eval-expression) 28 | (lispy-mode 1))) 29 | 30 | (defun appleshan/remove-elc-on-save () 31 | "If you're saving an elisp file, likely the .elc is no longer valid." 32 | (make-local-variable 'after-save-hook) 33 | (add-hook 'after-save-hook 34 | (lambda () 35 | (if (file-exists-p (concat buffer-file-name "c")) 36 | (delete-file (concat buffer-file-name "c")))))) 37 | 38 | ;; Local Variables: 39 | ;; coding: utf-8 40 | ;; no-byte-compile: nil 41 | ;; End: 42 | 43 | ;;; funcs.el ends here 44 | -------------------------------------------------------------------------------- /layers/appleshan-lisp/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- appleshan-lisp Layer packages File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;; List of all packages to install and/or initialize. Built-in packages 13 | ;; which require an initialization must be listed explicitly in the list. 14 | (setq appleshan-lisp-packages 15 | '( 16 | (emacs-lisp :location built-in) 17 | lispy 18 | elisp-refs 19 | )) 20 | 21 | ;; List of packages to exclude. 22 | (setq appleshan-lisp-excluded-packages '()) 23 | 24 | (defun appleshan-lisp/post-init-emacs-lisp () 25 | (remove-hook 'emacs-lisp-mode-hook 'auto-compile-mode) 26 | (add-hook 'emacs-lisp-mode-hook 'appleshan/remove-elc-on-save) 27 | (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode) 28 | (add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode)) 29 | 30 | (defun appleshan-lisp/init-lispy () 31 | (use-package lispy 32 | :defer t 33 | :diminish (lispy-mode) 34 | :init 35 | (progn 36 | (defun my-lispy-hook () 37 | (lispy-mode 1)) 38 | (add-hook 'emacs-lisp-mode-hook 'my-lispy-hook) 39 | (add-hook 'ielm-mode-hook 'my-lispy-hook) 40 | (add-hook 'inferior-emacs-lisp-mode-hook 'my-lispy-hook) 41 | (add-hook 'scheme-mode-hook 'my-lispy-hook)) 42 | :config 43 | (progn 44 | (add-hook 'minibuffer-setup-hook 'conditionally-enable-lispy) 45 | 46 | (define-key lispy-mode-map (kbd "s-m") 'lispy-mark-symbol) 47 | (define-key lispy-mode-map (kbd "s-1") 'lispy-describe-inline) 48 | (define-key lispy-mode-map (kbd "s-k") 'lispy-splice) 49 | (define-key lispy-mode-map (kbd "s-2") 'lispy-arglist-inline)))) 50 | 51 | (defun appleshan-lisp/init-elisp-refs () 52 | (use-package elisp-refs 53 | :config 54 | (bind-key "C-c C-r f" #'elisp-refs-function emacs-lisp-mode-map) 55 | (bind-key "C-c C-r m" #'elisp-refs-macro emacs-lisp-mode-map) 56 | (bind-key "C-c C-r v" #'elisp-refs-variable emacs-lisp-mode-map) 57 | (bind-key "C-c C-r p" #'elisp-refs-special emacs-lisp-mode-map) 58 | (bind-key "C-c C-r s" #'elisp-refs-symbol emacs-lisp-mode-map))) 59 | 60 | ;; Local Variables: 61 | ;; coding: utf-8 62 | ;; no-byte-compile: nil 63 | ;; End: 64 | 65 | ;;; packages.el ends here 66 | -------------------------------------------------------------------------------- /layers/appleshan-misc/config.el: -------------------------------------------------------------------------------- 1 | ;;; config.el --- appleshan-misc Layer configuration File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;; Variables 13 | 14 | (defvar my-gmail-bbdb-file nil) 15 | 16 | ;; 联系人的数据库文件 17 | (setq my-gmail-bbdb-file (concat user-dropbox-directory "apple-data/contacts/bbdb")) 18 | 19 | (with-eval-after-load 'paradox 20 | (setq paradox-column-width-package 35 21 | paradox-column-width-version 16 22 | paradox-column-width-status 12 23 | paradox-column-width-star 6)) 24 | 25 | (define-abbrev-table 'global-abbrev-table 26 | '( 27 | ;; math/unicode symbols 28 | ("8in" "∈") 29 | ("8nin" "∉") 30 | ("8inf" "∞") 31 | ("8luv" "♥") 32 | ("8smly" "☺") 33 | ("8en" "@~english") 34 | ("8zh" "@~chinese") 35 | ("8sp" "spacemacs") 36 | 37 | ;; computing tech 38 | ("8wp" "Wikipedia") 39 | ("8ms" "Microsoft") 40 | ("8g" "Google") 41 | ("8msw" "Microsoft Windows") 42 | ("8win" "Windows") 43 | ("8ie" "Internet Explorer") 44 | 45 | ;; email 46 | ("8as" "apple.shan@gmail.com") 47 | ;; signature 48 | ("8me" "appleshan") 49 | 50 | ;; emacs regex 51 | ("8d" "\\([0-9]+?\\)") 52 | ("8str" "\\([^\"]+?\\)\""))) 53 | 54 | ;; {{{ Spell check and flyspell settings 55 | ;; Standard location of personal dictionary 56 | (setq ispell-personal-dictionary "~/.emacs.d/.cache/.flydict") 57 | 58 | ;; Mostly taken from 59 | ;; http://blog.binchen.org/posts/what-s-the-best-spell-check-set-up-in-emacs.html 60 | (when (executable-find "aspell") 61 | (setq ispell-program-name (executable-find "aspell")) 62 | (setq ispell-extra-args 63 | (list "--sug-mode=fast" ;; ultra|fast|normal|bad-spellers 64 | "--lang=en_US" 65 | "--ignore=4"))) 66 | 67 | (add-to-list 'ispell-skip-region-alist '("[^\000-\377]+")) 68 | (add-to-list 'ispell-skip-region-alist '(":\\(PROPERTIES\\|LOGBOOK\\):" . ":END:")) 69 | (add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_SRC" . "#\\+END_SRC")) 70 | (add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_EXAMPLE" . "#\\+END_EXAMPLE")) 71 | ;; }}} 72 | 73 | ;; 绑定扩展名到特定的模式 74 | (dolist (elt-cons '((".*rc\\'" . conf-mode) 75 | ("\\.myclirc\\'" . conf-mode) 76 | (".xprofile'" . conf-mode) 77 | ("torrc'" . conf-mode) 78 | ("\\.lrc\\'" . emms-lyrics-mode) 79 | ("\\.org\\'" . org-mode) 80 | ("\\.cron\\(tab\\)?\\'" . crontab-mode) 81 | ("cron\\(tab\\)?\\." . crontab-mode))) 82 | (add-to-list 'auto-mode-alist elt-cons)) 83 | 84 | ;; Local Variables: 85 | ;; coding: utf-8 86 | ;; no-byte-compile: nil 87 | ;; End: 88 | 89 | ;;; config.el ends here 90 | -------------------------------------------------------------------------------- /layers/appleshan-misc/funcs.el: -------------------------------------------------------------------------------- 1 | ;;; funcs.el --- appleshan-misc Layer functions File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;; @see https://bitbucket.org/lyro/evil/issue/511/let-certain-minor-modes-key-bindings 13 | (defmacro adjust-major-mode-keymap-with-evil (m &optional r) 14 | `(eval-after-load (quote ,(if r r m)) 15 | '(progn 16 | (evil-make-overriding-map ,(intern (concat m "-mode-map")) 'normal) 17 | ;; force update evil keymaps after git-timemachine-mode loaded 18 | (add-hook (quote ,(intern (concat m "-mode-hook"))) #'evil-normalize-keymaps)))) 19 | 20 | ;; {{ scroll functions 21 | (defun appleshan/hold-line-scroll-up() 22 | "Scroll the page with the cursor in the same line" 23 | (interactive) 24 | ;; move the cursor also 25 | (let ((tmp (current-column))) 26 | (scroll-up 1) 27 | (line-move-to-column tmp) 28 | (forward-line 1))) 29 | 30 | (defun appleshan/hold-line-scroll-down() 31 | "Scroll the page with the cursor in the same line" 32 | (interactive) 33 | ;; move the cursor also 34 | (let ((tmp (current-column))) 35 | (scroll-down 1) 36 | (line-move-to-column tmp) 37 | (forward-line -1))) 38 | ;; }} 39 | 40 | ;; {{ Move Current Line Up or Down 41 | ;; @see http://emacsredux.com/blog/2013/04/02/move-current-line-up-or-down/ 42 | (defun appleshan/move-line-up () 43 | "Move up the current line." 44 | (interactive) 45 | (transpose-lines 1) 46 | (forward-line -2) 47 | (indent-according-to-mode)) 48 | 49 | (defun appleshan/move-line-down () 50 | "Move down the current line." 51 | (interactive) 52 | (forward-line 1) 53 | (transpose-lines 1) 54 | (forward-line -1) 55 | (indent-according-to-mode)) 56 | ;; }} 57 | 58 | ;; {{ insert date and time 59 | (defun appleshan/now () 60 | (interactive) ; permit invocation in minibuffer 61 | (insert (format-time-string "%Y-%m-%d %H:%M:%S"))) 62 | 63 | (defun appleshan/today () 64 | (interactive) ; permit invocation in minibuffer 65 | (insert (format-time-string "%Y-%m-%d"))) 66 | ;; }} 67 | 68 | (defun appleshan/open-readme-in-git-root-directory () 69 | (interactive) 70 | (let (filename 71 | (root-dir 72 | (locate-dominating-file 73 | (file-name-as-directory 74 | (file-name-directory buffer-file-name)) ".git")) 75 | ) 76 | ;; (message "root-dir=%s" root-dir) 77 | (and root-dir (file-name-as-directory root-dir)) 78 | (setq filename (concat root-dir "README.org")) 79 | (if (not (file-exists-p filename)) 80 | (setq filename (concat root-dir "README.md")) 81 | ) 82 | ;; (message "filename=%s" filename) 83 | (if (file-exists-p filename) 84 | (switch-to-buffer (find-file-noselect filename nil nil)) 85 | (message "NO README.org or README.md found!")) 86 | )) 87 | 88 | (add-hook 'minibuffer-inactive-mode-hook 89 | '(lambda() (set (make-local-variable 'semantic-mode) nil))) 90 | 91 | (defun ascii-table () 92 | "Display basic ASCII table (0 thru 128)." 93 | (interactive) 94 | (switch-to-buffer "*ASCII*") 95 | (erase-buffer) 96 | (setq buffer-read-only nil) ;; Not need to edit the content, just read mode (added) 97 | (local-set-key "q" 'bury-buffer) ;; Nice to have the option to bury the buffer (added) 98 | (setq lower32 '("nul" "soh" "stx" "etx" "eot" "enq" "ack" "bel" 99 | "bs" "ht" "nl" "vt" "np" "cr" "so" "si" 100 | "dle" "dc1" "dc2" "dc3" "dc4" "nak" "syn" "etb" 101 | "can" "em" "sub" "esc" "fs" "gs" "rs" "us" 102 | )) 103 | (save-excursion (let ((i -1)) 104 | (insert "ASCII characters 0 thru 127.\n\n") 105 | (insert " Hex Dec Char| Hex Dec Char| Hex Dec Char| Hex Dec Char\n") 106 | (while (< i 31) 107 | (insert (format "%4x %4d %4s | %4x %4d %4s | %4x %4d %4s | %4x %4d %4s\n" 108 | (setq i (+ 1 i)) i (elt lower32 i) 109 | (setq i (+ 32 i)) i (single-key-description i) 110 | (setq i (+ 32 i)) i (single-key-description i) 111 | (setq i (+ 32 i)) i (single-key-description i))) 112 | (setq i (- i 96)))))) 113 | 114 | (defun appleshan/show-current-buffer-major-mode () 115 | (interactive) 116 | (describe-variable 'major-mode)) 117 | 118 | ;; @see http://oremacs.com/2015/01/05/youtube-dl/ 119 | (defun appleshan/youtube-dl () 120 | (interactive) 121 | (let* ((str (current-kill 0)) 122 | (default-directory "~/download/media") 123 | (proc (get-buffer-process (ansi-term "/bin/bash")))) 124 | (term-send-string 125 | proc 126 | (concat "cd ~/download/media && youtube-dl " str "\n")))) 127 | 128 | ;; Configure network proxy 129 | (defun show-proxy () 130 | "Show http/https proxy." 131 | (interactive) 132 | (if url-proxy-services 133 | (message "Current proxy is \"%s\"" url-proxy-services) 134 | (message "No proxy"))) 135 | 136 | (defun set-proxy () 137 | "Set http/https proxy." 138 | (interactive) 139 | (setq url-proxy-services `(("http" . "127.0.0.1:18080") 140 | ("https" . "127.0.0.1:18080"))) 141 | (show-proxy)) 142 | 143 | (defun unset-proxy () 144 | "Unset http/https proxy." 145 | (interactive) 146 | (setq url-proxy-services nil) 147 | (show-proxy)) 148 | 149 | (defun toggle-proxy () 150 | "Toggle http/https proxy." 151 | (interactive) 152 | (if url-proxy-services 153 | (unset-proxy) 154 | (set-proxy))) 155 | 156 | ;; Local Variables: 157 | ;; coding: utf-8 158 | ;; no-byte-compile: nil 159 | ;; End: 160 | 161 | ;;; funcs.el ends here 162 | -------------------------------------------------------------------------------- /layers/appleshan-misc/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- appleshan-misc Layer packages File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | (setq appleshan-misc-packages 13 | '( 14 | bbdb-vcard 15 | browse-kill-ring 16 | ;; discover-my-major 17 | dockerfile-mode 18 | flyspell-correct 19 | multiple-cursors 20 | vlf 21 | wakatime-mode 22 | )) 23 | 24 | ;; List of packages to exclude. 25 | (setq appleshan-misc-excluded-packages '()) 26 | 27 | (defun appleshan-misc/init-bbdb-vcard () 28 | (use-package bbdb-vcard 29 | :defer t 30 | :init 31 | (progn 32 | ;; import Gmail contacts in vcard format into bbdb 33 | (setq bbdb-file my-gmail-bbdb-file) 34 | 35 | (add-hook 'message-mode-hook 36 | '(lambda () 37 | (enable-flyspell-mode-conditionally) 38 | (bbdb-initialize 'message) 39 | (bbdb-initialize 'gnus) 40 | (local-set-key "" 'bbdb-complete-name))) 41 | 42 | (add-hook 'bbdb-initialize-hook 43 | '(lambda () 44 | ;; @see http://emacs-fu.blogspot.com.au/2009/08/managing-e-mail-addresses-with-bbdb.html 45 | (setq 46 | bbdb-file-coding-system 'utf-8 47 | bbdb-complete-mail-allow-cycling t ;; cycle through matches 48 | ;; this only works partially 49 | 50 | ;; auto-create addresses from mail 51 | bbdb/mail-auto-create-p 'bbdb-ignore-some-messages-hook 52 | bbdb-ignore-some-messages-alist ;; don't ask about fake addresses 53 | ;; NOTE: there can be only one entry per header (such as To, From) 54 | ;; http://flex.ee.uec.ac.jp/texi/bbdb/bbdb_11.html 55 | 56 | '(( "From" . "no.?reply\\|DAEMON\\|daemon\\|facebookmail\\|twitter\\|notifications"))) 57 | 58 | ;; just remove some warning since bbdb package hook the mail-mode 59 | (setq compose-mail-user-agent-warnings nil) 60 | )) 61 | ))) 62 | 63 | ;; Interactively insert items from kill-ring 64 | (defun appleshan-misc/init-browse-kill-ring () 65 | (use-package browse-kill-ring 66 | :defer t 67 | :bind (("C-c y" . appleshan/browse-kill-ring)) 68 | :config 69 | (progn 70 | (setq browse-kill-ring-highlight-current-entry t) 71 | (setq browse-kill-ring-separator 72 | (concat "\n" (make-string 70 ?=) "\n")) 73 | 74 | (add-hook 'browse-kill-ring-hook 75 | 'appleshan/browse-kill-ring-settings) 76 | 77 | (defun appleshan/browse-kill-ring-settings () 78 | (interactive) 79 | (setq browse-kill-ring-show-preview nil) 80 | (define-key browse-kill-ring-mode-map (kbd "C-c C-k") 'browse-kill-ring-quit) 81 | (define-key browse-kill-ring-mode-map (kbd "C-k") 'browse-kill-ring-quit) 82 | (define-key browse-kill-ring-mode-map (kbd "k") 'browse-kill-ring-quit) 83 | (define-key browse-kill-ring-mode-map (kbd "C-/") 'browse-kill-ring-quit) 84 | (define-key browse-kill-ring-mode-map (kbd "C-n") 'browse-kill-ring-forward) 85 | (define-key browse-kill-ring-mode-map (kbd "C-p") 'browse-kill-ring-previous) 86 | (define-key browse-kill-ring-mode-map (kbd "C-c C-c") 'browse-kill-ring-insert-and-quit) 87 | (define-key browse-kill-ring-mode-map (kbd "y") 'browse-kill-ring-insert-and-quit)) 88 | 89 | (defun appleshan/browse-kill-ring () 90 | (interactive) 91 | (let ((clipboard-output 92 | (if (string= system-type "windows-nt") 93 | (w32-get-clipboard-data) 94 | (x-get-clipboard)))) 95 | (when (and clipboard-output 96 | (not (string= (car kill-ring) clipboard-output))) 97 | (kill-new clipboard-output)) 98 | (if (car kill-ring) 99 | (browse-kill-ring) 100 | (message "kill ring is empty")))) 101 | ))) 102 | 103 | ;; Discover key bindings and their meaning for the current Emacs major mode 104 | (defun appleshan-misc/init-discover-my-major () 105 | (use-package discover-my-major 106 | :defer t 107 | :init 108 | (progn 109 | (spacemacs/set-leader-keys (kbd "mhm") 'discover-my-major) 110 | (evilified-state-evilify makey-key-mode makey-key-mode-get-key-map) 111 | ))) 112 | 113 | (defun appleshan-misc/post-init-dockerfile-mode () 114 | (with-eval-after-load 'dockerfile-mode 115 | (add-to-list 'auto-mode-alist '("Dockerfile\\'" . dockerfile-mode)))) 116 | 117 | (defun appleshan-misc/post-init-flyspell-correct () 118 | (with-eval-after-load 'flyspell 119 | (define-key flyspell-mode-map (kbd "C-;") 'flyspell-correct-previous-word-generic))) 120 | 121 | (defun appleshan-misc/init-multiple-cursors () 122 | (use-package multiple-cursors 123 | :init 124 | (progn 125 | (setq mc/list-file (concat dotspacemacs-directory ".cache/.mc-lists.el"))) 126 | :bind (("C-s-l" . mc/edit-lines) 127 | ("C-s-f" . mc/mark-all-dwim) 128 | ("C-s-." . mc/mark-next-like-this) 129 | ("C-s-," . mc/mark-previous-like-this) 130 | ("s->" . mc/unmark-next-like-this) 131 | ("s-<" . mc/unmark-previous-like-this) 132 | ("C-c C-s-." . mc/mark-all-like-this)))) 133 | 134 | (defun appleshan-misc/init-vlf () 135 | (use-package vlf 136 | :init (require 'vlf-setup))) 137 | 138 | (defun appleshan-misc/init-wakatime-mode () 139 | (use-package wakatime-mode 140 | :init 141 | (let* ((wakatime-cfg "~/.wakatime.cfg") 142 | (wakatime-bin-name "wakatime") 143 | (wakatime-bin (locate-file wakatime-bin-name exec-path))) 144 | (if (and wakatime-bin 145 | (file-exists-p wakatime-bin) 146 | (file-exists-p wakatime-cfg)) 147 | (progn 148 | (setq-default wakatime-cli-path wakatime-bin) 149 | (setq-default wakatime-api-key 150 | (cadr (s-match "api_key\\s-*=\\s-*\\(.*\\)\\s-*" 151 | (with-temp-buffer 152 | (insert-file-contents wakatime-cfg) 153 | (buffer-string))))) 154 | (add-hook 'org-mode-hook 'wakatime-mode) 155 | (add-hook 'prog-mode-hook 'wakatime-mode) 156 | ))) 157 | :config 158 | (defun spacemacs/wakatime-dashboard () 159 | (interactive) 160 | (browse-url "http://wakatime.com/dashboard")) 161 | (spacemacs/set-leader-keys 162 | "aW" 'spacemacs/wakatime-dashboard) 163 | (spacemacs|diminish wakatime-mode " Ⓦa" " Wa"))) 164 | 165 | ;; Local Variables: 166 | ;; coding: utf-8 167 | ;; no-byte-compile: nil 168 | ;; End: 169 | 170 | ;;; packages.el ends here 171 | -------------------------------------------------------------------------------- /layers/appleshan-navigation/README.org: -------------------------------------------------------------------------------- 1 | Navigation - helpers when navigating around Emacs 2 | -------------------------------------------------------------------------------- /layers/appleshan-navigation/funcs.el: -------------------------------------------------------------------------------- 1 | ;;; funcs.el --- appleshan-navigation Layer functions File for Spacemacs 2 | 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | 8 | ;; This file is not part of GNU Emacs. 9 | 10 | ;;; Commentary: 11 | 12 | ;;; License: GPLv3 13 | 14 | ;;; Code: 15 | 16 | ;; @see https://github.com/emacs-china/emacsist/blob/master/articles/2016-11-07%E4%BD%A0%E8%83%BD%E6%83%B3%E5%88%B0%E7%9A%84%E5%87%A0%E4%B9%8E%E6%89%80%E6%9C%89%E5%85%B3%E4%BA%8E%E8%A1%8C%E7%9A%84%E6%93%8D%E4%BD%9C.org 17 | 18 | ;; 移动到行首/行尾 19 | 20 | (defun c-move-forward-line () 21 | (interactive) 22 | (if (eq major-mode 'org-mode) 23 | (cond ((eolp) (f-skip-bol) (setq -move 1)) 24 | (t (end-of-line) (setq -move 2))) 25 | (cond ((and (eolp) (not (bolp))) (beginning-of-line) (setq -move 0)) 26 | ((>= (current-column) (f-skip-bol t)) (end-of-line) (setq -move 2)) 27 | (t (f-skip-bol) (setq -move 1))))) 28 | 29 | (defun c-move-backward-line () 30 | (interactive) 31 | (let ((col (f-skip-bol t))) 32 | (if (eq major-mode 'org-mode) 33 | (cond ((and (<= (current-column) col) (not (= col 2))) 34 | (org-up-element) (skip-chars-forward -chars) (setq -move 1)) 35 | (t (f-skip-bol) (setq -move 1))) 36 | (cond ((and (bolp) (not (eolp))) (end-of-line) (setq -move 2)) 37 | ((<= (current-column) col) (beginning-of-line) (setq -move 0)) 38 | (t (f-skip-bol) (setq -move 1)))))) 39 | 40 | (defvar -chars " \t") 41 | (make-variable-buffer-local '-chars) 42 | 43 | ;; bol -> 0, skip-bol -> 1, eol -> 2 44 | (defvar -move 0) 45 | (make-variable-buffer-local '-move) 46 | 47 | ;; 判断当前光标是否位于 skip-bol 以及移动到此处的函数 48 | 49 | (defun f-skip-bol (&optional save) 50 | (let ((col (save-excursion 51 | (beginning-of-line) 52 | (skip-chars-forward -chars) 53 | (current-column)))) 54 | (unless save (move-to-column col)) col)) 55 | 56 | ;; 优化原本的上下方向键: 57 | ;; 指定光标在上下移动的时候,保持在行首/行尾或者 skip-bol 这三个位置, 58 | ;; 或者执行正常的移动 59 | 60 | (defun f-move-up-or-down (n) 61 | (unless (minibufferp) 62 | (cond ((and (= -move 2) (eolp)) 63 | (next-line n) (end-of-line)) 64 | ((and (= -move 1) (= (current-column) (f-skip-bol t))) 65 | (next-line n) (f-skip-bol)) 66 | (t (next-line n) (setq -move 0))) 67 | (f-visual-mode))) 68 | 69 | (defun c-move-down () 70 | (interactive) 71 | (f-move-up-or-down 1)) 72 | 73 | (defun c-move-up () 74 | (interactive) 75 | (f-move-up-or-down -1)) 76 | 77 | ;; 光标在段落间移动 78 | 79 | (defun c-paragraph-backward () 80 | (interactive) 81 | (unless (minibufferp) 82 | (if (not (eq major-mode 'org-mode)) 83 | (backward-paragraph) 84 | (org-backward-element) 85 | (skip-chars-forward -chars)) 86 | (f-visual-mode))) 87 | 88 | (defun c-paragraph-forward () 89 | (interactive) 90 | (unless (minibufferp) 91 | (if (not (eq major-mode 'org-mode)) 92 | (forward-paragraph) 93 | (org-forward-element) 94 | (skip-chars-forward -chars)) 95 | (f-visual-mode))) 96 | 97 | ;; 交换两行/两段落 98 | 99 | (defun c-transpose-lines-down () 100 | (interactive) 101 | (unless (minibufferp) 102 | (delete-trailing-whitespace) 103 | (end-of-line) 104 | (unless (eobp) 105 | (forward-line) 106 | (unless (eobp) 107 | (transpose-lines 1) 108 | (forward-line -1) 109 | (end-of-line))))) 110 | 111 | (defun c-transpose-lines-up () 112 | (interactive) 113 | (unless (minibufferp) 114 | (delete-trailing-whitespace) 115 | (beginning-of-line) 116 | (unless (or (bobp) (eobp)) 117 | (forward-line) 118 | (transpose-lines -1) 119 | (beginning-of-line -1)) 120 | (skip-chars-forward -chars))) 121 | 122 | (defun c-transpose-paragraphs-down () 123 | (interactive) 124 | (unless (minibufferp) 125 | (let ((p nil)) 126 | (delete-trailing-whitespace) 127 | (backward-paragraph) 128 | (when (bobp) (setq p t) (newline)) 129 | (forward-paragraph) 130 | (unless (eobp) (transpose-paragraphs 1)) 131 | (when p (save-excursion (goto-char (point-min)) (kill-line)))))) 132 | 133 | (defun c-transpose-paragraphs-up () 134 | (interactive) 135 | (unless (or (minibufferp) (save-excursion (backward-paragraph) (bobp))) 136 | (let ((p nil)) 137 | (delete-trailing-whitespace) 138 | (backward-paragraph 2) 139 | (when (bobp) (setq p t) (newline)) 140 | (forward-paragraph 2) 141 | (transpose-paragraphs -1) 142 | (backward-paragraph) 143 | (when p (save-excursion (goto-char (point-min)) (kill-line)))))) 144 | 145 | ;; other 146 | 147 | (defun c-copy-buffer () 148 | (interactive) 149 | (save-excursion 150 | (goto-char (point-max)) 151 | (unless (or (eobp) buffer-read-only) (newline))) 152 | (delete-trailing-whitespace) 153 | (kill-ring-save (point-min) (point-max)) 154 | (unless (minibufferp) (message "Current buffer copied"))) 155 | 156 | (defun c-indent-paragraph () 157 | (interactive) 158 | (save-excursion 159 | (mark-paragraph) 160 | (indent-region (region-beginning) (region-end)))) 161 | 162 | (defun c-kill-region () 163 | (interactive) 164 | (if (use-region-p) 165 | (kill-region (region-beginning) (region-end)) 166 | (kill-whole-line) 167 | (back-to-indentation))) 168 | 169 | (defun c-kill-ring-save () 170 | (interactive) 171 | (if (use-region-p) 172 | (kill-ring-save (region-beginning) (region-end)) 173 | (save-excursion 174 | (f-skip-bol) 175 | (kill-ring-save (point) (line-end-position))) 176 | (unless (minibufferp) (message "Current line copied")))) 177 | 178 | (defun c-set-or-exchange-mark (arg) 179 | (interactive "P") 180 | (if (use-region-p) (exchange-point-and-mark) 181 | (set-mark-command arg))) 182 | 183 | (defun c-toggle-comment (beg end) 184 | (interactive 185 | (if (use-region-p) (list (region-beginning) (region-end)) 186 | (list (line-beginning-position) (line-beginning-position 2)))) 187 | (unless (minibufferp) 188 | (comment-or-uncomment-region beg end))) 189 | 190 | ;; Local Variables: 191 | ;; coding: utf-8 192 | ;; no-byte-compile: nil 193 | ;; End: 194 | 195 | ;;; funcs.el ends here 196 | -------------------------------------------------------------------------------- /layers/appleshan-navigation/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- appleshan-navigation layer packages file for Spacemacs 2 | 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | 8 | ;; This file is not part of GNU Emacs. 9 | 10 | ;;; Commentary: 11 | 12 | ;; 这个文件是 appleshan 个人专用的 emacs 配置文件,emacs 中文用户可以参考。 13 | 14 | ;;; License: GPLv3 15 | 16 | ;;; Code: 17 | 18 | (setq appleshan-navigation-packages 19 | '( 20 | dumb-jump 21 | evil 22 | evil-escape 23 | ibuffer-sidebar 24 | imenu-anywhere 25 | treemacs 26 | )) 27 | 28 | ;; List of packages to exclude. 29 | (setq appleshan-navigation-excluded-packages '()) 30 | 31 | (defun appleshan-navigation/post-init-dumb-jump () 32 | ;; If your project has multi-line method signatures you should use ag. 33 | (setq dumb-jump-force-searcher 'ag) 34 | (setq dumb-jump-prefer-searcher 'ag)) 35 | 36 | (defun appleshan-navigation/post-init-evil () 37 | (progn 38 | (setcdr evil-insert-state-map nil) 39 | (define-key evil-insert-state-map [escape] 'evil-normal-state) 40 | 41 | ;; change evil initial mode state 42 | (loop for (mode . state) in 43 | '((shell-mode . normal)) 44 | do (evil-set-initial-state mode state)) 45 | 46 | ;;mimic "nzz" behaviou in vim 47 | (defadvice evil-search-next (after advice-for-evil-search-next activate) 48 | (evil-scroll-line-to-center (line-number-at-pos))) 49 | 50 | (defadvice evil-search-previous (after advice-for-evil-search-previous activate) 51 | (evil-scroll-line-to-center (line-number-at-pos))) 52 | 53 | (define-key evil-emacs-state-map (kbd "s-f") 'forward-word) 54 | (define-key evil-insert-state-map (kbd "s-f") 'forward-word) 55 | (define-key evil-emacs-state-map (kbd "s-b") 'backward-word) 56 | (define-key evil-insert-state-map (kbd "s-b") 'backward-word) 57 | 58 | (define-key evil-ex-completion-map "\C-a" 'move-beginning-of-line) 59 | (define-key evil-ex-completion-map "\C-b" 'backward-char) 60 | (define-key evil-ex-completion-map "\C-k" 'kill-line) 61 | 62 | (define-key minibuffer-local-map (kbd "C-w") 'evil-delete-backward-word) 63 | 64 | (define-key evil-normal-state-map (kbd ",/") 'evilnc-comment-or-uncomment-lines) 65 | (define-key evil-visual-state-map (kbd ",/") 'evilnc-comment-or-uncomment-lines) 66 | 67 | (define-key evil-visual-state-map (kbd "C-r") 'appleshan/evil-quick-replace) 68 | 69 | (define-key evil-visual-state-map (kbd "mn") 'mc/mark-next-like-this) 70 | (define-key evil-visual-state-map (kbd "mp") 'mc/mark-previous-like-this) 71 | (define-key evil-visual-state-map (kbd "ma") 'mc/mark-all-like-this) 72 | (define-key evil-visual-state-map (kbd "mf") 'mc/mark-all-like-this-in-defun) 73 | 74 | ;; in spacemacs, we always use evilify miscro state 75 | (evil-add-hjkl-bindings package-menu-mode-map 'emacs) 76 | 77 | (define-key evil-emacs-state-map (kbd "C-w") 'evil-delete-backward-word) 78 | 79 | (evil-define-key 'emacs term-raw-map (kbd "C-w") 'evil-delete-backward-word) 80 | 81 | (setq evil-normal-state-tag (propertize "[N]" 'face '((:background "DarkGoldenrod2" :foreground "black"))) 82 | evil-emacs-state-tag (propertize "[E]" 'face '((:background "SkyBlue2" :foreground "black"))) 83 | evil-insert-state-tag (propertize "[I]" 'face '((:background "chartreuse3") :foreground "white")) 84 | evil-motion-state-tag (propertize "[M]" 'face '((:background "plum3") :foreground "white")) 85 | evil-visual-state-tag (propertize "[V]" 'face '((:background "gray" :foreground "black"))) 86 | evil-operator-state-tag (propertize "[O]" 'face '((:background "purple")))) 87 | (setq evil-insert-state-cursor '("chartreuse3" box)) 88 | (define-key evil-insert-state-map (kbd "C-z") 'evil-emacs-state) 89 | )) 90 | 91 | (defun appleshan-navigation/post-init-evil-escape () 92 | (setq evil-escape-delay 0.2)) 93 | 94 | (defun appleshan-navigation/init-ibuffer-sidebar () 95 | (use-package ibuffer-sidebar 96 | :bind (("C-x C-b" . ibuffer-sidebar-toggle-sidebar) 97 | :map ibuffer-sidebar-mode-map 98 | ("j" . ibuffer-forward-line) 99 | ("k" . ibuffer-backward-line)) 100 | :config 101 | (setq ibuffer-sidebar-display-alist '((side . right) (slot . 1))) 102 | )) 103 | 104 | (defun appleshan-navigation/init-imenu-anywhere () 105 | (use-package imenu-anywhere 106 | :ensure t 107 | :bind (("C-c o" . helm-imenu-anywhere)))) 108 | 109 | ;; A tree layout file explorer 110 | (defun appleshan-navigation/post-init-treemacs () 111 | (with-eval-after-load 'treemacs 112 | (setq treemacs-show-hidden-files nil) 113 | )) 114 | 115 | ;; Local Variables: 116 | ;; coding: utf-8 117 | ;; no-byte-compile: nil 118 | ;; End: 119 | 120 | ;;; packages.el ends here 121 | -------------------------------------------------------------------------------- /layers/appleshan-notify/README.org: -------------------------------------------------------------------------------- 1 | Notification System - unifying notifications in Emacs with sauron 2 | -------------------------------------------------------------------------------- /layers/appleshan-notify/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- appleshan-notify layer packages file for Spacemacs 2 | 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | 8 | ;; This file is not part of GNU Emacs. 9 | 10 | ;;; Commentary: 11 | 12 | ;; 这个文件是 appleshan 个人专用的 emacs 配置文件,emacs 中文用户可以参考。 13 | 14 | ;;; License: GPLv3 15 | 16 | ;;; Code: 17 | 18 | (setq appleshan-notify-packages 19 | '( 20 | alert 21 | sauron 22 | (eshell :location built-in) 23 | )) 24 | 25 | ;; List of packages to exclude. 26 | (setq appleshan-notify-excluded-packages '()) 27 | 28 | (defun appleshan-notify/init-alert () 29 | (use-package alert 30 | :ensure t 31 | :config 32 | (when (eq system-type 'darwin) 33 | (setq alert-default-style 'notifier)) 34 | (when (eq system-type 'gnu/linux) 35 | (setq alert-default-style 'notifications)))) 36 | 37 | ;; The all-seeing eye of Sauron 38 | (defun appleshan-notify/init-sauron () 39 | (use-package sauron 40 | :ensure t 41 | :init 42 | (when (eq system-type 'gnu/linux) 43 | ;; Remove mu4e if on linux 44 | (require 'sauron) 45 | (setq sauron-modules (remove 'sauron-mu4e sauron-modules))) 46 | 47 | (setq sauron-max-line-length 120 48 | sauron-watch-patterns '("dakrone" "thnetos" "okenezak") 49 | sauron-watch-nicks '("dakrone" "thnetos") 50 | sauron-nick-insensitivity 20 51 | sauron-frame-geometry "120x36+0+0") 52 | ;; filter out IRC spam 53 | (defun tsp/hide-irc-user-spam (origin priority msg &optional properties) 54 | (or (string-match "^*** Users" msg))) 55 | (defun tsp/hide-tweet-counts (origin priority msg &optional properties) 56 | (or (string-match "^[0-9]+ new tweets" msg))) 57 | (add-hook 'sauron-event-block-functions #'tsp/hide-irc-user-spam) 58 | (add-hook 'sauron-event-block-functions #'tsp/hide-tweet-counts) 59 | 60 | (sauron-start-hidden) 61 | ;; Need to stop tracking notifications, because sauron will be sending 62 | ;; notifications! 63 | (sauron-notifications-stop) 64 | (add-hook 'sauron-event-added-functions 'sauron-alert-el-adapter) 65 | :commands (sauron-toggle-hide-show) 66 | :bind ("M-o" . sauron-toggle-hide-show) 67 | :config 68 | ;; Add the unread sauron notification count to the modeline 69 | (add-to-list 'global-mode-string '(cdr (sauron-count-events))) 70 | 71 | (defun eos/compilation-finish (buffer msg) 72 | "Send a sauron notification for compilation completing" 73 | (interactive) 74 | (sauron-add-event 'compilation 75 | 3 76 | (format "[%s]: %s" buffer msg) 77 | (lambda () (switch-to-buffer-other-window "*compilation*")) 78 | nil)) 79 | (add-to-list 'compilation-finish-functions #'eos/compilation-finish) 80 | 81 | (defun finish () 82 | "Generic function for signaling something is \"done\"." 83 | (interactive) 84 | (sauron-add-event major-mode 85 | 3 86 | (concat "Finished command in " (buffer-name)) 87 | (lambda () (switch-to-buffer-other-window (buffer-name))) 88 | nil)))) 89 | 90 | (defun appleshan-notify/post-init-eshell () 91 | (use-package eshell 92 | :config 93 | ;; Seconds a command must take before showing an alert 94 | (setq eos/eshell-time-before-alert 5.0) 95 | 96 | (defun eos/eshell-precommand () 97 | (interactive) 98 | (setq-local eos/eshell-command-start-time (current-time))) 99 | 100 | (defun eos/eshell-command-finished () 101 | (interactive) 102 | (when (and (boundp 'eos/eshell-command-start-time) 103 | (> (float-time (time-subtract (current-time) 104 | eos/eshell-command-start-time)) 105 | eos/eshell-time-before-alert)) 106 | (sauron-add-event major-mode 107 | (if (zerop eshell-last-command-status) 108 | 3 109 | 4) 110 | (format "EShell: command [%s] finished, status: %s" 111 | eshell-last-command-name 112 | eshell-last-command-status) 113 | (lambda () (switch-to-buffer-other-window (buffer-name))) 114 | nil))) 115 | (add-hook 'eshell-pre-command-hook #'eos/eshell-precommand) 116 | (add-hook 'eshell-post-command-hook #'eos/eshell-command-finished))) 117 | 118 | ;; Local Variables: 119 | ;; coding: utf-8 120 | ;; no-byte-compile: nil 121 | ;; End: 122 | 123 | ;;; packages.el ends here 124 | -------------------------------------------------------------------------------- /layers/appleshan-org/README.org: -------------------------------------------------------------------------------- 1 | Org-mode and agenda - org is a fantastic organization tool 2 | -------------------------------------------------------------------------------- /layers/appleshan-org/config.el: -------------------------------------------------------------------------------- 1 | ;;; config.el --- appleshan-org Layer configuration File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;; Variables 13 | (defvar org-gtd-dir nil) 14 | 15 | (defvar org-agenda-files nil) 16 | (defvar org-agenda-span nil) 17 | 18 | (defvar org-todo-keywords nil) 19 | (defvar org-todo-keyword-faces nil) 20 | 21 | (defvar org-capture-templates nil) 22 | 23 | (defvar org-columns-default-format nil) 24 | 25 | (defvar org-global-properties nil) 26 | 27 | (defvar org-tag-alist nil) 28 | 29 | ;; Make org-mode friendly for Chinese chars. 30 | (setq org-emphasis-regexp-components 31 | '( 32 | " ('\"{" 33 | "- .,:!?;'\")}\\[" 34 | ":,。、  \t('\"{" ;pre 35 | "- :,。、 \t.,:!?;'\")}\\" ;post 36 | 1 ; newline 37 | )) 38 | 39 | ;; 让 ispell 跳过某段文本不做拼写检查 40 | (defun appleshan/org-ispell () 41 | "Configure `ispell-skip-region-alist' for `org-mode'." 42 | (make-local-variable 'ispell-skip-region-alist) 43 | (add-to-list 'ispell-skip-region-alist '(org-property-drawer-re)) 44 | (add-to-list 'ispell-skip-region-alist '("~" "~")) 45 | (add-to-list 'ispell-skip-region-alist '("=" "=")) 46 | (add-to-list 'ispell-skip-region-alist '("^#\\+BEGIN_SRC" . "^#\\+END_SRC"))) 47 | 48 | (add-hook 'org-mode-hook #'appleshan/org-ispell) 49 | 50 | ;; icon 51 | (setq my-icon-dir (concat dotspacemacs-directory "local/icons/")) 52 | (setq org-agenda-category-icon-alist 53 | '(("[Ee]macs" (concat spacemacs-banner-directory "img/spacemacs.png") nil nil :ascent center) 54 | ("Gnus" (concat my-icon-dir "gnus.png") nil nil :ascent center) 55 | ("Org" (concat my-icon-dir "org.png") nil nil :ascent center) 56 | ("Medical" (concat my-icon-dir "medical.png") nil nil :ascent center) 57 | ("Music" (concat my-icon-dir "music.png") nil nil :ascent center) 58 | ("Trip" (concat my-icon-dir "trip.png") nil nil :ascent center) 59 | ("Train" (concat my-icon-dir "train.png") nil nil :ascent center) 60 | ("Reading" (concat my-icon-dir "book.png") nil nil :ascent center) 61 | ("\\(Holidays\\|Vacation\\)" (concat my-icon-dir "holidays.png") nil nil :ascent center) 62 | (".*" '(space . (:width (16)))))) 63 | 64 | ;; Local Variables: 65 | ;; coding: utf-8 66 | ;; no-byte-compile: nil 67 | ;; End: 68 | 69 | ;;; config.el ends here 70 | -------------------------------------------------------------------------------- /layers/appleshan-org/funcs.el: -------------------------------------------------------------------------------- 1 | ;;; funcs.el --- appleshan-org Layer functions File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;;{{ 更好看的符号列表标记 13 | ;; @see https://github.com/lujun9972/emacs-document/blob/master/org-mode/%E5%B0%86org%E7%9C%8B%E6%88%90%E6%96%87%E5%AD%97%E5%A4%84%E7%90%86%E5%99%A8.org 14 | ;; 这段代码将所有行中匹配指定正则表达式的内容都显示为一个Unicode的圆形符号, 15 | ;; 该段正则的意思是“以 1 个或多个破折号开头,紧接着是一个空格”. 16 | ;; 用星号和破折号来作为符号列表的标记挺好的, 但是使用一个真正的圆形符号来作标示也不错: 17 | (font-lock-add-keywords 18 | 'org-mode 19 | '(("^\\([-]\\) " 20 | (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•")))))) 21 | ;;}} 22 | 23 | ;; src_ 24 | (font-lock-add-keywords 25 | 'org-mode 26 | '(("\\(src_\\)\\([^[{]+\\)\\(\\[:.*\\]\\)\\({\\)\\([^}]*\\)\\(}\\)" 27 | (1 '(:foreground "black" :weight 'normal :height 0.1)) ; src_ part 28 | (2 '(:foreground "cyan" :weight 'bold :height 0.8 :box '(:color "cyan"))) ; "lang" part. 29 | (3 '(:foreground "#555555" :height 0.7)) ; [:header arguments] part. 30 | (4 '(:foreground "#333333")) ; { 31 | (5 'org-code) ; "code..." part. 32 | (6 '(:foreground "#333333")) ; } 33 | ))) 34 | 35 | ;; src without arguments 36 | (font-lock-add-keywords 37 | 'org-mode 38 | '(("\\(src_\\)\\([^[{]+\\)\\({\\)\\([^}]*\\)\\(}\\)" 39 | (1 '(:foreground "black" :weight 'normal :height 0.1)) ; src_ part 40 | (2 '(:foreground "cyan" :weight 'bold :height 0.8 :box '(:color "cyan"))) ; "lang" part. 41 | (3 '(:foreground "#333333")) ; { 42 | (4 'org-code) ; "code..." part. 43 | (5 '(:foreground "#333333")) ; } 44 | ))) 45 | 46 | ;; inline babel call 47 | ;; ... call_[]()[] ... 48 | (font-lock-add-keywords 49 | 'org-mode 50 | '(("\\(call_\\)\\([^[(]*\\)\\[\\(.*\\)\\](\\(.*\\))\\[\\(.*\\)\\]" 51 | ;; "\\(call_\\)\\([^[(]*\\)\\([([][^)]*]\\)+" 52 | (1 '(:foreground "orange red" :height 0.6)) ; call_ 53 | (2 '(:foreground "yellow" :weight 'bold :slant 'italic :underline "dark gray")) ; 54 | (3 '(:foreground "gray" :height 0.6)) ; [] 55 | (4 '(:foreground "cyan" :weight 'bold)) ; () 56 | (5 '(:foreground "gray" :height 0.6)) ; [] 57 | ))) 58 | 59 | ;; call_[]() 60 | (font-lock-add-keywords 61 | 'org-mode 62 | '(("\\(call_\\)\\([^[(]*\\)\\[\\(.*\\)\\](\\(.*\\))" 63 | (1 '(:foreground "orange red" :height 0.6)) ; call_ 64 | (2 '(:foreground "yellow" :weight 'bold :slant 'italic :underline "dark gray")) ; 65 | (3 '(:foreground "gray" :height 0.6)) ; [] 66 | (4 '(:foreground "cyan" :weight 'bold)) ; () 67 | ))) 68 | 69 | 70 | ;; call_(arguments) 71 | (font-lock-add-keywords 72 | 'org-mode 73 | '(("\\(call_\\)\\([^[(]*\\)\\((.*)\\)" 74 | (1 '(:foreground "orange red" :height 0.6)) ; call_ 75 | (2 '(:foreground "yellow" :weight 'bold :slant 'italic :underline "dark gray")) ; 76 | (3 '(:foreground "cyan" :weight 'bold)) ; () 77 | ))) 78 | 79 | ;; @@html:...@@, 80 | (defface org-html-kbd-tag 81 | '((nil (:foreground "cyan" :background "#004A5D" 82 | :box '(:color "cyan" :line-width 1) 83 | ;; :weight 'bold 84 | ))) 85 | "Face for highlight Org-mode html tag @...@ or @@html:...@@." 86 | :group 'org-faces) 87 | 88 | ;; @@html:C-h h@@ 89 | (font-lock-add-keywords 90 | 'org-mode 91 | '(("@@html:\\([^<]*\\)@@" 92 | (1 'org-html-kbd-tag)))) 93 | 94 | ;; @C-h h@ 95 | (font-lock-add-keywords 96 | 'org-mode 97 | '(("@\\([^@]*\\)@" 98 | (1 'org-html-kbd-tag)))) 99 | 100 | 101 | (defun my/org-insert-key () 102 | "Insert keybinding code in Org with a keybinding quickly. 103 | In common insert mode or in select region text to press this keybinding \\. 104 | to insert .. (HTML) org =[..]= (Org-mode)." 105 | (interactive) 106 | (if (region-active-p) 107 | (let ((where (cons (region-beginning) (region-end)))) 108 | (insert-pair where "=[" "]=")) 109 | ;; (insert-pair nil "=[" "]=") 110 | (progn 111 | (insert "=[]=") 112 | (backward-char 2))) 113 | ) 114 | 115 | (defun my/org-insert-kbd () 116 | "Insert literal HTML tag ." 117 | (interactive) 118 | (if (region-active-p) 119 | (let ((where (cons (region-beginning) (region-end)))) 120 | (insert-pair where "@@html:" "@@")) 121 | (progn 122 | (insert "@@html:@@ ") 123 | (backward-char 9))) 124 | ) 125 | 126 | 127 | ;; (defun my/org-insert-kbd (key) 128 | ;; "Ask for a KEY then insert its description. 129 | ;; Will work on both `org-mode' and any mode that accepts plain html." 130 | ;; (interactive "kType key sequence: ") 131 | ;; (let* ((is-org-mode (derived-mode-p 'org-mode)) 132 | ;; (tag (if is-org-mode 133 | ;; "@@html:@@%s@@html:@@" 134 | ;; "%s"))) 135 | ;; (if (null (equal key " 136 | ;; ")) 137 | ;; (insert 138 | ;; (format tag (help-key-description key nil))) 139 | ;; (insert (format tag "")) 140 | ;; (forward-char (if is-org-mode -15 -6))))) 141 | 142 | ;;; Inserting the kbd tag in interactively 143 | (eval-after-load 'ox-html 144 | ;; If you prefer to use ~ for tags. Replace "code" with 145 | ;; "verbatim" here, and replace "~" with "=" below. 146 | '(push '(code . "%s") org-html-text-markup-alist)) 147 | 148 | (defun my/insert-key (key) 149 | "Ask for a KEY then insert its description. 150 | Will work on both `org-mode' and any mode that accepts plain html." 151 | (interactive "kType key sequence: ") 152 | (let* ((orgp (derived-mode-p 'org-mode)) 153 | (tag (if orgp 154 | ;; "~%s~" 155 | "=[%s]=" 156 | ;; "@@html:%s@@" 157 | "%s"))) 158 | (if (null (equal key "\C-m")) 159 | (insert 160 | (format tag (help-key-description key nil))) 161 | ;; If you just hit RET. 162 | (insert (format tag "")) 163 | (forward-char (if orgp -2 -6))))) 164 | 165 | ; (define-key org-mode-map (kbd "C-c K") 'my/insert-kbd) 166 | ; (define-key org-mode-map (kbd "C-c k") 'my/org-insert-key) 167 | 168 | 169 | (with-eval-after-load 'smartparens 170 | :config 171 | (defun sp--org-skip-asterisk (ms mb me) 172 | (or (and (= (line-beginning-position) mb) 173 | (eq 32 (char-after (1+ mb)))) 174 | (and (= (1+ (line-beginning-position)) me) 175 | (eq 32 (char-after me))))) 176 | 177 | ;; Org-mode 178 | (sp-with-modes 'org-mode 179 | (sp-local-pair "*" "*" 180 | :actions '(insert wrap) 181 | :unless '(sp-point-after-word-p sp-point-at-bol-p) 182 | :wrap "C-*" :skip-match 'sp--org-skip-asterisk) 183 | (sp-local-pair "_" "_" :unless '(sp-point-after-word-p) :wrap "C-_") 184 | (sp-local-pair "/" "/" :unless '(sp-point-after-word-p) 185 | :post-handlers '(("[d1]" "SPC"))) 186 | (sp-local-pair "~" "~" :unless '(sp-point-after-word-p) 187 | :post-handlers '(("[d1]" "SPC"))) 188 | (sp-local-pair "=" "=" :unless '(sp-point-after-word-p) 189 | :post-handlers '(("[d1]" "SPC"))) 190 | (sp-local-pair "«" "»")) 191 | ) 192 | 193 | ;; {{ Move single cells using C-M-up C-M-down C-M-left C-M-right 194 | (add-hook 'org-mode-hook 195 | '(lambda () 196 | (local-set-key [C-M-up] (quote org-table-move-single-cell-up)) 197 | (local-set-key [C-M-down] (quote org-table-move-single-cell-down)) 198 | (local-set-key [C-M-left] (quote org-table-move-single-cell-left)) 199 | (local-set-key [C-M-right] (quote org-table-move-single-cell-right)))) 200 | 201 | (defun org-table-swap-cells (i1 j1 i2 j2) 202 | "Swap two cells" 203 | (let ((c1 (org-table-get i1 j1)) 204 | (c2 (org-table-get i2 j2))) 205 | (org-table-put i1 j1 c2) 206 | (org-table-put i2 j2 c1) 207 | (org-table-align))) 208 | 209 | (defun org-table-move-single-cell (direction) 210 | "Move the current cell in a cardinal direction according to the 211 | parameter symbol: 'up 'down 'left 'right. Swaps contents of 212 | adjacent cell with current one." 213 | (unless (org-at-table-p) 214 | (error "No table at point")) 215 | (let ((di 0) (dj 0)) 216 | (cond ((equal direction 'up) (setq di -1)) 217 | ((equal direction 'down) (setq di +1)) 218 | ((equal direction 'left) (setq dj -1)) 219 | ((equal direction 'right) (setq dj +1)) 220 | (t (error "Not a valid direction, must be up down left right"))) 221 | (let* ((i1 (org-table-current-line)) 222 | (j1 (org-table-current-column)) 223 | (i2 (+ i1 di)) 224 | (j2 (+ j1 dj))) 225 | (org-table-swap-cells i1 j1 i2 j2) 226 | (org-table-goto-line i2) 227 | (org-table-goto-column j2)))) 228 | 229 | (defun org-table-move-single-cell-up () 230 | "Move a single cell up in a table; swap with anything in target cell" 231 | (interactive) 232 | (org-table-move-single-cell 'up)) 233 | 234 | (defun org-table-move-single-cell-down () 235 | "Move a single cell down in a table; swap with anything in target cell" 236 | (interactive) 237 | (org-table-move-single-cell 'down)) 238 | 239 | (defun org-table-move-single-cell-left () 240 | "Move a single cell left in a table; swap with anything in target cell" 241 | (interactive) 242 | (org-table-move-single-cell 'left)) 243 | 244 | (defun org-table-move-single-cell-right () 245 | "Move a single cell right in a table; swap with anything in target cell" 246 | (interactive) 247 | (org-table-move-single-cell 'right)) 248 | ;; }} 249 | 250 | ;; Local Variables: 251 | ;; coding: utf-8 252 | ;; no-byte-compile: nil 253 | ;; End: 254 | 255 | ;;; funcs.el ends here 256 | -------------------------------------------------------------------------------- /layers/appleshan-programming/README.org: -------------------------------------------------------------------------------- 1 | Development (programming) System - various development settings 2 | -------------------------------------------------------------------------------- /layers/appleshan-programming/config.el: -------------------------------------------------------------------------------- 1 | ;;; config.el --- appleshan-programming Layer configuration File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;; Remove some back-ends from vc-mode, no need to check all these things, 13 | ;; I use magit for everything anyway: 14 | (setq vc-handled-backends '(git svn)) 15 | 16 | ;; 更新 modeline 上的 git version 信息 17 | ;; @See https://emacs-china.org/t/topic/5037 18 | (setq auto-revert-check-vc-info t) 19 | 20 | (spacemacs|add-toggle iimage 21 | :status iimage-mode 22 | :on (iimage-mode) 23 | :off (iimage-mode -1) 24 | :documentation "Enable iimage mode" 25 | :evil-leader "oTI") 26 | 27 | (add-to-list 'auto-mode-alist 28 | (cons (concat "\\." (regexp-opt '("xml" "xsd" "xslt" "xsl") t) "\\'") 29 | 'nxml-mode)) 30 | (setq nxml-slash-auto-complete-flag t) 31 | 32 | ;; {{ 设置 compile 33 | (setq compilation-always-kill t) ;编译时,若有编译窗口,则直接关闭掉,不需要询问 34 | (setq compilation-auto-jump-to-first-error t) ;编译出错,则自动跳转到第一个错误提示处 35 | ; (setq compilation-scroll-output t) ;自动滚动编译输出 36 | ;; 若编译无错误,则自动关闭compilation窗口 37 | (defun compilation-abnormally-exit-message-p (exit-message) 38 | (if (string-match-p "exited abnormally" exit-message) 39 | t 40 | nil)) 41 | 42 | (defun compilation-mode-buffer-p (buf) 43 | "判断buffer是否为compilation-mode 44 | 它与`compilation-buffer-p'不同之处在于`compilation-buffer-p'会对compilation-mode的子mode也返回t,而该函数返回nil" 45 | (eq 'compilation-mode (buffer-local-value 'major-mode (get-buffer buf)))) 46 | 47 | (defun compilation-kill-buffer-when-compile-success(buf exit-message) 48 | (tooltip-show exit-message) 49 | (when (and (not (compilation-abnormally-exit-message-p exit-message)) 50 | (compilation-mode-buffer-p buf)) 51 | (kill-buffer buf))) 52 | (add-to-list 'compilation-finish-functions #'compilation-kill-buffer-when-compile-success) 53 | 54 | ;; 记录上次编译失败时的compilation-buffer 55 | (defvar last-fail-compilation-buffer nil 56 | "上一次编译失败的compliation buffer") 57 | 58 | (defun log-last-fail-compliation-buffer (buf msg) 59 | "记录下上一次编译失败的compliation buffer到`last-fail-compilation-buffer'中" 60 | (if (compilation-abnormally-exit-message-p msg) 61 | (setq last-fail-compilation-buffer buf) 62 | (setq last-fail-compilation-buffer nil))) 63 | 64 | (add-to-list 'compilation-finish-functions #'log-last-fail-compliation-buffer) 65 | ;; }} 66 | 67 | ;; turn off `linum-mode' when there are more than 5000 lines 68 | (add-hook 'prog-mode-hook 69 | (lambda () 70 | (if (and (> (buffer-size) (* 5000 80))) 71 | (linum-mode -1)))) 72 | 73 | ;; Local Variables: 74 | ;; coding: utf-8 75 | ;; no-byte-compile: nil 76 | ;; End: 77 | 78 | ;;; config.el ends here 79 | -------------------------------------------------------------------------------- /layers/appleshan-programming/funcs.el: -------------------------------------------------------------------------------- 1 | ;;; funcs.el --- appleshan-programming Layer functions File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;;{{ 让 emacs 自动給 script 加上可执行权限 13 | ;; 保存时,检查文件的第一行是否包含#!,若包含则给文件添加执行权限 14 | (defun appleshan/maybe-make-executable () 15 | "Maybe make file executable unless it is a backup file." 16 | (unless (backup-file-name-p buffer-file-name) 17 | (executable-make-buffer-file-executable-if-script-p))) 18 | 19 | (add-hook 'after-save-hook 'appleshan/maybe-make-executable) 20 | ;;}} 21 | 22 | ;; add auto format paste code 23 | (dolist (command '(yank yank-pop)) 24 | (eval 25 | `(defadvice ,command (after indent-region activate) 26 | (and (not current-prefix-arg) 27 | (member major-mode 28 | '(emacs-lisp-mode 29 | lisp-mode 30 | scheme-mode 31 | python-mode 32 | js-mode)) 33 | (let ((mark-even-if-inactive transient-mark-mode)) 34 | (indent-region (region-beginning) (region-end) nil)))))) 35 | 36 | (defun appleshan/vcs-project-root () 37 | "Return the project root for current buffer." 38 | (let ((directory default-directory)) 39 | (or (locate-dominating-file directory ".git") 40 | (locate-dominating-file directory ".svn") 41 | (locate-dominating-file directory ".hg")))) 42 | 43 | (defun appleshan/goto-match-paren (arg) 44 | "Go to the matching if on (){}[], similar to vi style of % " 45 | (interactive "p") 46 | ;; first, check for "outside of bracket" positions expected by forward-sexp, etc 47 | (cond ((looking-at "[\[\(\{]") (evil-jump-item)) 48 | ((looking-back "[\]\)\}]" 1) (evil-jump-item)) 49 | ;; now, try to succeed from inside of a bracket 50 | ((looking-at "[\]\)\}]") (forward-char) (evil-jump-item)) 51 | ((looking-back "[\[\(\{]" 1) (backward-char) (evil-jump-item)) 52 | (t nil))) 53 | 54 | (defun appleshan/hidden-dos-eol () 55 | "Do not show ^M in files containing mixed UNIX and DOS line endings." 56 | (interactive) 57 | (setq buffer-display-table (make-display-table)) 58 | (aset buffer-display-table ?\^M [])) 59 | 60 | (defun appleshan/remove-dos-eol () 61 | "Replace DOS eolns CR LF with Unix eolns CR" 62 | (interactive) 63 | (goto-char (point-min)) 64 | (while (search-forward "\r" nil t) (replace-match ""))) 65 | 66 | ;; Notify that the compilation is finished 67 | ; (defun notify-compilation-result(buffer msg) 68 | ; "Notify that the compilation is finished, 69 | ; close the *compilation* buffer if the compilation is successful, 70 | ; and set the focus back to Emacs frame" 71 | ; (if (string-match "^finished" msg) 72 | ; (progn 73 | ; (delete-windows-on buffer) 74 | ; (tooltip-show "\n Compilation Successful :-) \n ")) 75 | ; (tooltip-show "\n Compilation Failed :-( \n ")) 76 | ; (setq current-frame (car (car (cdr (current-frame-configuration))))) 77 | ; (select-frame-set-input-focus current-frame) 78 | ; ) 79 | 80 | ; (add-to-list 'compilation-finish-functions 'notify-compilation-result) 81 | 82 | ;;{{ 更好的 compile 命令 83 | ;; see https://github.com/lujun9972/emacs-document/blob/master/emacs-common/%E6%9B%B4%E5%A5%BD%E7%9A%84compile%E5%91%BD%E4%BB%A4.org 84 | ;; This gives a regular `compile-command' prompt. 85 | (define-key prog-mode-map [C-f9] #'compile) 86 | ;; This just compiles immediately. 87 | (define-key prog-mode-map [f9] #'endless/compile-please) 88 | 89 | ;; I'm not scared of saving everything. 90 | (setq compilation-ask-about-save nil) 91 | ;; Stop on the first error. 92 | (setq compilation-scroll-output 'next-error) 93 | ;; Don't stop on info or warnings. 94 | (setq compilation-skip-threshold 2) 95 | 96 | (defcustom endless/compile-window-size 105 97 | "Width given to the non-compilation window." 98 | :type 'integer 99 | :group 'endless) 100 | 101 | (defun endless/compile-please (comint) 102 | "Compile without confirmation. 103 | With a prefix argument, use comint-mode." 104 | (interactive "P") 105 | ;; Do the command without a prompt. 106 | (save-window-excursion 107 | (compile (eval compile-command) (and comint t))) 108 | ;; Create a compile window of the desired width. 109 | (pop-to-buffer (get-buffer "*compilation*")) 110 | (enlarge-window 111 | (- (frame-width) 112 | endless/compile-window-size 113 | (window-width)) 114 | 'horizontal)) 115 | ;;}} 116 | 117 | ;; @see https://github.com/apg/mvn-el 118 | (ignore-errors 119 | (require 'ansi-color) 120 | (defun colorize-compilation-buffer () 121 | (when (eq major-mode 'compilation-mode) 122 | (let ((inhibit-read-only t)) 123 | (if (boundp 'compilation-filter-start) 124 | (ansi-color-apply-on-region compilation-filter-start (point)))))) 125 | (add-hook 'compilation-filter-hook 'colorize-compilation-buffer)) 126 | 127 | ;;{{ Better Comments or tooling as a time sink 128 | ;; @See http://cestlaz.github.io/posts/better-comments/ 129 | (make-face 'font-lock-comment-important) 130 | (set-face-foreground 'font-lock-comment-important "#00ff00") 131 | 132 | (make-face 'font-lock-comment-todo) 133 | (set-face-foreground 'font-lock-comment-todo "#ff0000") 134 | 135 | (make-face 'font-lock-comment-strike) 136 | (set-face-attribute 'font-lock-comment-strike 137 | nil :strike-through t) 138 | 139 | (defun add-custom-keywords() 140 | "adds a few special keywords" 141 | (font-lock-add-keywords 142 | nil 143 | '(("cx \\(.+\\)" 1 'font-lock-comment-strike prepend) 144 | ("ct \\(.+\\)" 1 'font-lock-comment-todo prepend) 145 | ("ci \\(.+\\)" 1 'font-lock-comment-important prepend) 146 | ))) 147 | 148 | (add-hook 'prog-mode-hook #'add-custom-keywords) 149 | ;;}} 150 | 151 | ;;{{ my fix for tab indent 152 | (defun appleshan/indent-region(numSpaces) 153 | (progn 154 | ; default to start and end of current line 155 | (setq regionStart (line-beginning-position)) 156 | (setq regionEnd (line-end-position)) 157 | 158 | ; if there's a selection, use that instead of the current line 159 | (when (use-region-p) 160 | (setq regionStart (region-beginning)) 161 | (setq regionEnd (region-end)) 162 | ) 163 | 164 | (save-excursion ; restore the position afterwards 165 | (goto-char regionStart) ; go to the start of region 166 | (setq start (line-beginning-position)) ; save the start of the line 167 | (goto-char regionEnd) ; go to the end of region 168 | (setq end (line-end-position)) ; save the end of the line 169 | 170 | (indent-rigidly start end numSpaces) ; indent between start and end 171 | (setq deactivate-mark nil) ; restore the selected region 172 | ) 173 | )) 174 | 175 | (defun appleshan/tab-region (N) 176 | (interactive "p") 177 | (if (use-region-p) 178 | (appleshan/indent-region 4) ; region was selected, call indent-region 179 | (insert " ") ; else insert four spaces as expected 180 | )) 181 | 182 | (defun appleshan/untab-region (N) 183 | (interactive "p") 184 | (appleshan/indent-region -4)) 185 | 186 | (defun appleshan/hack-tab-key () 187 | (interactive) 188 | (local-set-key (kbd "") 'appleshan/tab-region) 189 | (local-set-key (kbd "") 'appleshan/untab-region) 190 | ) 191 | 192 | (add-hook 'prog-mode-hook 'appleshan/hack-tab-key) 193 | ;;}} 194 | 195 | ;; In programming modes, make sure things like FIXME and TODO are highlighted so they stand out: 196 | ;; TODO: asg 197 | ;; HACK: adsf 198 | ;; REFACTOR: asd 199 | ;; FIXME: adf 200 | ;; OPTIMIZE: asdf 201 | (defun font-lock-comment-annotations () 202 | "Highlight a bunch of well known comment annotations. 203 | 204 | This functions should be added to the hooks of major modes for programming." 205 | (font-lock-add-keywords 206 | nil '(("\\<\\(TODO\\|REFACTOR\\): " 1 font-lock-warning-face t) 207 | ("\\<\\(HACK\\): " 1 '(:foreground "purple") t) 208 | ("\\<\\(FIXME\\|OPTIMIZE\\): " 1 '(:foreground "red") t) 209 | ))) 210 | 211 | (add-hook 'prog-mode-hook 'font-lock-comment-annotations) 212 | 213 | ;; Execute the current file. 214 | (defun appleshan/run-current-file () 215 | "Execute the current file. 216 | For example, if the current buffer is the file x.py, then it'll call 「python x.py」 in a shell. 217 | The file can be emacs lisp, php, perl, python, ruby, javascript, bash, ocaml, Visual Basic. 218 | File suffix is used to determine what program to run. 219 | 220 | If the file is modified, ask if you want to save first. 221 | 222 | URL `http://ergoemacs.org/emacs/elisp_run_current_file.html' 223 | version 2015-08-21" 224 | (interactive) 225 | (let* ( 226 | (ξsuffix-map 227 | ;; (‹extension› . ‹shell program name›) 228 | `( 229 | ("py" . "python") 230 | ("py3" . "python3") 231 | ; ("js" . "node") ; node.js 232 | ("sh" . "bash") 233 | )) 234 | (ξfname (buffer-file-name)) 235 | (ξfSuffix (file-name-extension ξfname)) 236 | (ξprog-name (cdr (assoc ξfSuffix ξsuffix-map))) 237 | (ξcmd-str (concat ξprog-name " \"" ξfname "\""))) 238 | 239 | (when (buffer-modified-p) 240 | (when (y-or-n-p "Buffer modified. Do you want to save first?") 241 | (save-buffer))) 242 | 243 | (if (string-equal ξfSuffix "el") ; special case for emacs lisp 244 | (load ξfname) 245 | (if ξprog-name 246 | (progn 247 | (message "Running…") 248 | (async-shell-command ξcmd-str "*appleshan/run-current-file output*")) 249 | (message "No recognized program file suffix for this file."))))) 250 | 251 | (defun appleshan/magit-browse () 252 | "Browse to the project's github URL, if available" 253 | (interactive) 254 | (let ((url (with-temp-buffer 255 | (unless (zerop (call-process-shell-command 256 | "git remote -v" nil t)) 257 | (error "Failed: 'git remote -v'")) 258 | (goto-char (point-min)) 259 | (when (re-search-forward 260 | "github\\.com[:/]\\(.+?\\)\\.git" nil t) 261 | (format "https://github.com/%s" (match-string 1)))))) 262 | (unless url 263 | (error "Can't find repository URL")) 264 | (browse-url url))) 265 | 266 | (defun appleshan/github-browse-commit () 267 | "Show the GitHub page for the current commit." 268 | (interactive) 269 | (use-package github-browse-file 270 | :commands (github-browse-file--relative-url)) 271 | 272 | (let* ((commit git-messenger:last-commit-id) 273 | (url (concat "https://github.com/" 274 | (github-browse-file--relative-url) 275 | "/commit/" 276 | commit))) 277 | (github-browse--save-and-view url) 278 | (git-messenger:popup-close))) 279 | 280 | (defun appleshan/magit-branch-pull-request (number &optional branch checkout) 281 | "Create a new branch from a Github pull request and show its log. 282 | Read \"NR[:BRANCH-NAME] from the user. If BRANCH-NAME is not 283 | provided use \"pr-NR\". Set \"master\" as the upstream. 284 | Assume all pull requests can be found on \"upstream\". With a 285 | prefix argument checkout branch instead of showing its log." 286 | (interactive 287 | (let ((input (magit-read-string "Branch pull request (NR[:BRANCH-NAME])"))) 288 | (if (string-match "\\([1-9][0-9]*\\)\\(?::\\(.+\\)\\)?" input) 289 | (list (match-string 1 input) 290 | (match-string 2 input) 291 | current-prefix-arg) 292 | (user-error "Invalid input")))) 293 | (unless branch 294 | (setq branch (format "pr-%s" number))) 295 | (magit-call-git "fetch" "upstream" (format "pull/%s/head:%s" number branch)) 296 | (if checkout 297 | (magit-run-git "checkout" branch) 298 | (apply #'magit-log (list branch) (magit-log-arguments)))) 299 | 300 | ;; Local Variables: 301 | ;; coding: utf-8 302 | ;; no-byte-compile: nil 303 | ;; End: 304 | 305 | ;;; funcs.el ends here 306 | -------------------------------------------------------------------------------- /layers/appleshan-programming/layers.el: -------------------------------------------------------------------------------- 1 | (configuration-layer/declare-layer 'auto-completion) 2 | (configuration-layer/declare-layer 'syntax-checking) 3 | -------------------------------------------------------------------------------- /layers/appleshan-programming/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- appleshan-programming Layer packages File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;; List of all packages to install and/or initialize. Built-in packages 13 | ;; which require an initialization must be listed explicitly in the list. 14 | (setq appleshan-programming-packages 15 | '( 16 | lsp-mode 17 | lsp-ui 18 | company-lsp 19 | ;; helm-xref 20 | engine-mode 21 | flycheck 22 | flycheck-package 23 | flycheck-pycheckers 24 | avy-flycheck 25 | gist 26 | git-messenger 27 | highlight-escape-sequences 28 | highlight-indent-guides 29 | highlight-thing 30 | indent-tools 31 | magit 32 | paredit 33 | prodigy 34 | plantuml-mode 35 | quickrun 36 | symbol-overlay 37 | tldr 38 | vdiff 39 | wakatime-mode 40 | zeal-at-point 41 | )) 42 | 43 | ;; List of packages to exclude. 44 | (setq appleshan-programming-excluded-packages '()) 45 | 46 | ;; Emacs client for the Language Server Protocol 47 | ;; https://github.com/emacs-lsp/lsp-mode 48 | (defun appleshan-programming/post-init-lsp-mode () 49 | (setq lsp-enable-eldoc nil) ; 禁止eldoc 50 | (setq lsp-response-timeout 25) 51 | (spacemacs|diminish lsp-mode " Ⓛ" " L") 52 | ) 53 | 54 | (defun appleshan-programming/post-init-lsp-ui () 55 | (setq lsp-ui-doc-include-signature nil) ; don't include type signature in the child frame 56 | 57 | (setq lsp-ui-peek-expand-function (lambda (xs) (mapcar #'car xs))) 58 | 59 | (evil-make-overriding-map lsp-ui-peek-mode-map 'normal) 60 | (define-key lsp-ui-peek-mode-map (kbd "h") 'lsp-ui-peek--select-prev-file) 61 | (define-key lsp-ui-peek-mode-map (kbd "l") 'lsp-ui-peek--select-next-file) 62 | (define-key lsp-ui-peek-mode-map (kbd "j") 'lsp-ui-peek--select-next) 63 | (define-key lsp-ui-peek-mode-map (kbd "k") 'lsp-ui-peek--select-prev) 64 | 65 | (define-key lsp-ui-mode-map (kbd "C-c l") 'lsp-ui-imenu) 66 | (define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions) 67 | (define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references) 68 | 69 | (setq lsp-ui-sideline-show-symbol nil) ; don't show symbol on the right of info 70 | (setq lsp-ui-sideline-ignore-duplicate t) 71 | (set-face-attribute 'lsp-ui-sideline-symbol nil :foreground "grey30" :box nil) 72 | (set-face-attribute 'lsp-ui-sideline-current-symbol nil :foreground "grey38" :box nil) 73 | (when (internal-lisp-face-p 'lsp-ui-sideline-contents) 74 | (set-face-attribute 'lsp-ui-sideline-contents nil :foreground "grey35") 75 | (set-face-attribute 'lsp-ui-sideline-current-contents nil :foreground "grey43"))) 76 | 77 | ;; `company' backend for `lsp-mode' 78 | (defun appleshan-programming/post-init-company-lsp () 79 | (with-eval-after-load 'company 80 | :init 81 | (push '(company-lsp :with company-yasnippet) company-backends))) 82 | 83 | (defun appleshan-programming/init-helm-xref () 84 | (use-package helm-xref 85 | :config 86 | ;; This is required to make xref-find-references work in helm-mode. 87 | ;; In helm-mode, it gives a prompt and asks the identifier (which has no text property) 88 | ;; and then passes it to lsp-mode, which requires the text property at point to locate the references. 89 | ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=29619 90 | (setq xref-prompt-for-identifier 91 | '(not xref-find-definitions 92 | xref-find-definitions-other-window 93 | xref-find-definitions-other-frame 94 | xref-find-references 95 | spacemacs/jump-to-definition 96 | spacemacs/jump-to-reference 97 | )) 98 | (setq xref-show-xrefs-function 'helm-xref-show-xrefs))) 99 | 100 | (defun appleshan-programming/post-init-engine-mode () 101 | (add-to-list 'search-engine-alist 102 | ;; elisp code search 103 | '(Elisp 104 | :name "Elisp code search" 105 | :url "http://www.google.com.au/search?q=%s+filetype:el") 106 | ;; javascript search on mozilla.org 107 | '(Elisp 108 | :name "Javascript search on mozilla.org" 109 | :url "http://www.google.com.au/search?q=%s+site:developer.mozilla.org") 110 | )) 111 | 112 | (defun appleshan-programming/pre-init-flycheck () 113 | (spacemacs|use-package-add-hook flycheck 114 | :post-init 115 | (progn 116 | ;; (setq flycheck-indication-mode 'right-fringe) 117 | (setq flycheck-check-syntax-automatically '(save mode-enabled)) 118 | ))) 119 | 120 | (defun appleshan-programming/post-init-flycheck () 121 | (setq-default flycheck-disabled-checkers 122 | '(emacs-lisp-checkdoc json-jsonlint json-python-json)) 123 | (setq flycheck-display-errors-delay 0.9) 124 | (setq flycheck-idle-change-delay 2.0) 125 | 126 | (flycheck-define-checker xml-xmllint 127 | "A XML syntax checker and validator using the xmllint utility. 128 | 129 | The xmllint is part of libxml2, see URL 130 | `http://www.xmlsoft.org/'." 131 | :command ("xmllint" "--noout" source) 132 | :error-patterns 133 | ((error line-start (file-name) ":" line ": " (message) line-end)) 134 | :modes (xml-mode nxml-mode))) 135 | 136 | (defun appleshan-programming/init-flycheck-package () 137 | (use-package flycheck-package 138 | :init 139 | (eval-after-load 'flycheck '(flycheck-package-setup)))) 140 | 141 | (defun appleshan-programming/init-flycheck-pycheckers () 142 | (use-package flycheck-pycheckers 143 | :config 144 | (with-eval-after-load 'flycheck 145 | (add-hook 'flycheck-mode-hook #'flycheck-pycheckers-setup)))) 146 | 147 | ;; Jump to and fix syntax errors via `avy' 148 | (defun appleshan-programming/init-avy-flycheck () 149 | (use-package avy-flycheck 150 | :init (avy-flycheck-setup))) 151 | 152 | (defun appleshan-programming/post-init-gist () 153 | (use-package gist 154 | :defer t 155 | :init 156 | (setq gist-list-format 157 | '((files "File" 30 nil "%s") 158 | (id "Id" 10 nil identity) 159 | (created "Created" 20 nil "%D %R") 160 | (visibility "Visibility" 10 nil 161 | (lambda 162 | (public) 163 | (or 164 | (and public "public") 165 | "private"))) 166 | (description "Description" 0 nil identity))) 167 | :config 168 | (progn 169 | (spacemacs|define-transient-state gist-list-mode 170 | :title "Gist-mode Transient State" 171 | :bindings 172 | ("k" gist-kill-current "delete gist") 173 | ("e" gist-edit-current-description "edit gist title") 174 | ("+" gist-add-buffer "add a file") 175 | ("-" gist-remove-file "delete a file") 176 | ("y" gist-print-current-url "print url") 177 | ("b" gist-browse-current-url "browse gist in browser") 178 | ("*" gist-star "star gist") 179 | ("^" gist-unstar "unstar gist") 180 | ("f" gist-fork "fork gist") 181 | ("q" nil "quit" :exit t) 182 | ("" nil nil :exit t)) 183 | (spacemacs/set-leader-keys-for-major-mode 'gist-list-mode 184 | "." 'spacemacs/gist-list-mode-transient-state/body)) 185 | )) 186 | 187 | ;;; Pop up last commit information of current line 188 | (defun appleshan-programming/post-init-git-messenger () 189 | (with-eval-after-load 'git-messenger 190 | (define-key git-messenger-map (kbd "f") 'appleshan/github-browse-commit))) 191 | 192 | (defun appleshan-programming/init-highlight-escape-sequences () 193 | (use-package highlight-escape-sequences 194 | :defer t 195 | :init 196 | (hes-mode))) 197 | 198 | (defun appleshan-programming/init-highlight-indent-guides () 199 | (use-package highlight-indent-guides 200 | :defer t 201 | :init 202 | (progn 203 | (add-hook 'prog-mode-hook 'highlight-indent-guides-mode) 204 | (spacemacs|diminish highlight-indent-guides-mode)) 205 | ; :config (setq highlight-indent-guides-method 'character) ; 'fill / 'column / 'character 206 | )) 207 | 208 | (defun appleshan-programming/init-highlight-thing () 209 | (use-package highlight-thing 210 | :defer t 211 | :init 212 | (progn 213 | (add-hook 'prog-mode-hook 'highlight-thing-mode) 214 | (spacemacs|diminish highlight-thing-mode)) 215 | :config 216 | (progn 217 | (setq highlight-thing-delay-seconds 1.5) 218 | (setq highlight-thing-case-sensitive-p t)))) 219 | 220 | (defun appleshan-programming/init-indent-tools () 221 | (use-package indent-tools 222 | :config 223 | (global-set-key (kbd "C-c i") 'indent-tools-hydra/body))) 224 | 225 | (defun appleshan-programming/post-init-magit () 226 | (with-eval-after-load 'magit 227 | (if (file-exists-p "/usr/bin/emacsclient") 228 | (setq magit-emacsclient-executable "/usr/bin/emacsclient") 229 | (setq magit-emacsclient-executable (executable-find "emacsclient"))) 230 | 231 | (add-to-list 'magit-no-confirm 'stage-all-changes) 232 | (define-key magit-mode-map (kbd "C-c C-b") 'appleshan/magit-browse) 233 | (define-key magit-mode-map "@" 'appleshan/magit-branch-pull-request) 234 | (define-key magit-log-mode-map (kbd "W") 'magit-copy-section-value) 235 | (define-key magit-status-mode-map (kbd "s-1") 'magit-jump-to-unstaged) 236 | (define-key magit-status-mode-map (kbd "s-2") 'magit-jump-to-untracked) 237 | (define-key magit-status-mode-map (kbd "s-3") 'magit-jump-to-staged) 238 | (define-key magit-status-mode-map (kbd "s-4") 'magit-jump-to-stashes) 239 | 240 | (setq magit-process-popup-time 10 241 | magit-push-always-verify nil 242 | magit-save-repository-buffers 'dontask 243 | magit-revert-buffers 'silent 244 | magit-refs-show-commit-count 'all 245 | magit-revision-show-gravatars nil) 246 | 247 | ;; http://emacs.stackexchange.com/questions/6021/change-a-branchs-upstream-with-magit/6023#6023 248 | (magit-define-popup-switch 'magit-push-popup ?u 249 | "Set upstream" "--set-upstream") 250 | )) 251 | 252 | (defun appleshan-programming/init-paredit () 253 | (use-package paredit 254 | :commands (paredit-wrap-round 255 | paredit-wrap-square 256 | paredit-wrap-curly 257 | paredit-splice-sexp-killing-backward) 258 | :init 259 | (progn 260 | (bind-key* "s-j" 261 | #'paredit-splice-sexp-killing-backward) 262 | 263 | (bind-key* "s-(" #'paredit-wrap-round) 264 | (bind-key* "s-[" #'paredit-wrap-square) 265 | (bind-key* "s-{" #'paredit-wrap-curly) 266 | ))) 267 | 268 | (defun appleshan-programming/post-init-prodigy () 269 | (with-eval-after-load 'prodigy 270 | (defface prodigy-dull-face 271 | '((((class color)) :foreground "#999999")) 272 | "Gray color indicating waiting." 273 | :group 'prodigy) 274 | 275 | (setq prodigy-view-buffer-maximum-size 2048 276 | prodigy-view-truncate-by-default t) 277 | 278 | (prodigy-define-status :id 'running :face 'prodigy-dull-face) 279 | (prodigy-define-status :id 'exception :face 'prodigy-red-face) 280 | 281 | (setq prodigy-service-file (concat dotspacemacs-directory "local/prodigy-services.el")) 282 | (when (file-exists-p prodigy-service-file) 283 | (load-file prodigy-service-file)) 284 | )) 285 | 286 | (defun appleshan-programming/pre-init-plantuml-mode () 287 | (spacemacs|use-package-add-hook plantuml-mode 288 | :post-config 289 | (setq plantuml-jar-path (concat (getenv "JAR_PATH") "/plantuml.jar")) 290 | )) 291 | 292 | (defun appleshan-programming/post-init-plantuml-mode () 293 | ;; Enable puml-mode for PlantUML files 294 | (add-to-list 'auto-mode-alist '("\\.puml\\'" . plantuml-mode)) 295 | (add-to-list 'auto-mode-alist '("\\.plantuml\\'" . plantuml-mode))) 296 | 297 | ;;; Compiling, Running Code 298 | (defun appleshan-programming/init-quickrun () 299 | (use-package quickrun)) 300 | 301 | ;; Highlight symbols 302 | (defun appleshan-programming/init-symbol-overlay () 303 | (use-package symbol-overlay 304 | :diminish symbol-overlay-mode 305 | :init (add-hook 'prog-mode-hook #'symbol-overlay-mode) 306 | )) 307 | 308 | (defun appleshan-programming/init-tldr () 309 | (use-package tldr 310 | :defer t 311 | :init 312 | (setq tldr-directory-path 313 | (concat user-home-directory ".config/tldr/")))) 314 | 315 | (defun appleshan-programming/init-vdiff () 316 | (use-package vdiff 317 | :defer t 318 | :commands (vdiff-buffers vdiff-files) 319 | :config 320 | (define-key vdiff-mode-map (kbd "C-c") vdiff-mode-prefix-map))) 321 | 322 | (defun appleshan-programming/post-init-wakatime-mode () 323 | (spacemacs|diminish wakatime-mode)) 324 | 325 | ;; 使用 zeal 查看 docset 326 | (defun appleshan-programming/post-init-zeal-at-point () 327 | (add-hook 'python-mode-hook 328 | (lambda () (setq zeal-at-point-docset "python3")))) 329 | 330 | ;; Local Variables: 331 | ;; coding: utf-8 332 | ;; no-byte-compile: nil 333 | ;; End: 334 | 335 | ;;; packages.el ends here 336 | -------------------------------------------------------------------------------- /layers/appleshan-python/README.org: -------------------------------------------------------------------------------- 1 | Python settings 2 | 3 | * flycheck supported-language: Python 4 | https://github.com/flycheck/flycheck/blob/master/doc/languages.rst 5 | -------------------------------------------------------------------------------- /layers/appleshan-python/config.el: -------------------------------------------------------------------------------- 1 | ;;; config.el --- appleshan-python Layer Configuration File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;; fix bug : void-variable python-shell--interpreter 13 | (setq python-shell-interpreter "python3" 14 | python-shell-interpreter-args "-i") 15 | 16 | (setq python-shell--interpreter "python3" 17 | python-shell--interpreter-args "-i") 18 | 19 | (add-to-list 'auto-mode-alist '("\\.wsgi\\'" . python-mode)) 20 | -------------------------------------------------------------------------------- /layers/appleshan-python/funcs.el: -------------------------------------------------------------------------------- 1 | ;;; funcs.el --- appleshan-python Layer functions File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;(defun elpy-goto-definition-or-rgrep () 13 | ; "Go to the definition of the symbol at point, if found. Otherwise, run `elpy-rgrep-symbol'." 14 | ; (interactive) 15 | ; (ring-insert find-tag-marker-ring (point-marker)) 16 | ; (condition-case nil (elpy-goto-definition) 17 | ; (error (elpy-rgrep-symbol 18 | ; (concat "\\(def\\|class\\)\s" (thing-at-point 'symbol) "("))))) 19 | 20 | ;(define-key elpy-mode-map (kbd "M-.") 'elpy-goto-definition-or-rgrep) 21 | 22 | (defun company-yasnippet-or-completion () 23 | "Solve company yasnippet conflicts." 24 | (interactive) 25 | (let ((yas-fallback-behavior 26 | (apply 'company-complete-common nil))) 27 | (yas-expand))) 28 | 29 | (add-hook 'company-mode-hook 30 | (lambda () 31 | (substitute-key-definition 32 | 'company-complete-common 33 | 'company-yasnippet-or-completion 34 | company-active-map))) 35 | 36 | ;; Local Variables: 37 | ;; coding: utf-8 38 | ;; no-byte-compile: nil 39 | ;; End: 40 | 41 | ;;; funcs.el ends here 42 | -------------------------------------------------------------------------------- /layers/appleshan-python/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- appleshan-python Layer packages File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;; List of all packages to install and/or initialize. Built-in packages 13 | ;; which require an initialization must be listed explicitly in the list. 14 | (setq appleshan-python-packages 15 | '( 16 | company 17 | lsp-python 18 | py-autopep8 19 | )) 20 | 21 | ;; List of packages to exclude. 22 | (setq appleshan-python-excluded-packages '()) 23 | 24 | (defun appleshan-python/post-init-company () 25 | (spacemacs|add-company-backends 26 | :backends (company-files company-capf) 27 | :modes python-mode 28 | :variables 29 | company-minimum-prefix-length 0 30 | company-idle-delay 0.5)) 31 | 32 | (defun appleshan-python/post-init-lsp-python () 33 | ;; Don't warn if guessing the indention fails, just set it to the value 34 | ;; of `python-indent-offset'. 35 | (setq python-indent-guess-indent-offset-verbose nil)) 36 | 37 | ;; Autopep8 38 | ;; enable autopep8 formatting on save 39 | ;; ignoring: 40 | ;; - E501 - Try to make lines fit within --max-line-length characters. 41 | ;; - W293 - Remove trailing whitespace on blank line. 42 | ;; - W391 - Remove trailing blank lines. 43 | ;; - W690 - Fix various deprecated code (via lib2to3). 44 | (defun appleshan-python/init-py-autopep8 () 45 | (use-package py-autopep8 46 | :defer t 47 | :config 48 | (progn 49 | (setq py-autopep8-options '("--ignore=E501,W293,W391,W690")) 50 | (add-hook 'python-mode-hook 'py-autopep8-enable-on-save) 51 | ))) 52 | 53 | ;; Local Variables: 54 | ;; coding: utf-8 55 | ;; no-byte-compile: nil 56 | ;; End: 57 | 58 | ;;; packages.el ends here 59 | -------------------------------------------------------------------------------- /layers/appleshan-remote/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- appleshan-remote layer packages file for Spacemacs 2 | 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | 8 | ;; This file is not part of GNU Emacs. 9 | 10 | ;;; Commentary: 11 | 12 | ;; 这个文件是 appleshan 个人专用的 emacs 配置文件,emacs 中文用户可以参考。 13 | 14 | ;;; License: GPLv3 15 | 16 | ;;; Code: 17 | 18 | (setq appleshan-remote-packages 19 | '( 20 | (tramp :location built-in) 21 | )) 22 | 23 | ;; List of packages to exclude. 24 | (setq appleshan-remote-excluded-packages '()) 25 | 26 | (defun appleshan-remote/init-tramp () 27 | (use-package tramp 28 | :defer 5 29 | :config 30 | ;; Turn of auto-save for tramp files 31 | (defun tramp-set-auto-save () 32 | (auto-save-mode -1)) 33 | (with-eval-after-load 'tramp-cache 34 | (setq tramp-persistency-file-name "~/.emacs.d/.cache/etc/tramp")) 35 | (setq tramp-default-method "ssh" 36 | tramp-default-user-alist '(("\\`su\\(do\\)?\\'" nil "root")) 37 | tramp-adb-program "adb" 38 | ;; use the settings in ~/.ssh/config instead of Tramp's 39 | tramp-use-ssh-controlmaster-options nil 40 | backup-enable-predicate 41 | (lambda (name) 42 | (and (normal-backup-enable-predicate name) 43 | (not (let ((method (file-remote-p name 'method))) 44 | (when (stringp method) 45 | (member method '("su" "sudo")))))))) 46 | 47 | (use-package tramp-sh 48 | :config 49 | (add-to-list 'tramp-remote-path "/usr/local/sbin") 50 | (add-to-list 'tramp-remote-path "/opt/java/current/bin") 51 | (add-to-list 'tramp-remote-path "~/bin")))) 52 | 53 | ;; Local Variables: 54 | ;; coding: utf-8 55 | ;; no-byte-compile: nil 56 | ;; End: 57 | 58 | ;;; packages.el ends here 59 | -------------------------------------------------------------------------------- /layers/appleshan-shell/README.org: -------------------------------------------------------------------------------- 1 | Shell - shells inside and outside of Emacs, mostly inside with eshell 2 | -------------------------------------------------------------------------------- /layers/appleshan-shell/config.el: -------------------------------------------------------------------------------- 1 | ;;; config.el --- appleshan-shell layer configuration file for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | ;;; Code: 13 | 14 | ;; Setup up Shell Environment 15 | ;; @see http://ergoemacs.org/emacs/emacs_env_var_paths.html 16 | 17 | ;; for Windows 10 18 | (when (spacemacs/system-is-mswindows) 19 | (let ((mypaths 20 | '( 21 | "D:/bin" 22 | "C:/lang/python/Python361" 23 | "C:/lang/python/Python361/Scripts" 24 | ; "C:/lang/python/Python2713" 25 | ; "C:/lang/python/Python2713/Scripts" 26 | "D:/portable-soft/cmder" 27 | "D:/portable-soft/develop/PortableGit/bin" ;; git 28 | "D:/portable-soft/develop/PortableGit/mingw64/libexec/git-core" ;; git 29 | "D:/portable-soft/develop/diffutils-2.8.7-1/bin" ;; diff 30 | "C:/Program Files (x86)/GnuPG/bin/" ;; gpg 31 | "C:/Windows/System32" 32 | ))) 33 | (setq exec-path (append mypaths (list "." exec-directory)) ) 34 | 35 | (setenv "PATH" (mapconcat 'identity mypaths ";") ) 36 | ) 37 | 38 | (setenv "HOME" "D:/home/appleshan/") 39 | (setenv "JAR_PATH" "D:/bin/java-lib") 40 | ) 41 | 42 | ;; for linux 43 | (when (spacemacs/system-is-linux) 44 | (setenv "JAR_PATH" "/opt/java")) 45 | 46 | ;; Local Variables: 47 | ;; coding: utf-8 48 | ;; no-byte-compile: nil 49 | ;; End: 50 | 51 | ;;; config.el ends here 52 | -------------------------------------------------------------------------------- /layers/appleshan-shell/packages.el: -------------------------------------------------------------------------------- 1 | ;;; packages.el --- appleshan-shell layer packages file for Spacemacs 2 | 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | 8 | ;; This file is not part of GNU Emacs. 9 | 10 | ;;; Commentary: 11 | 12 | ;; 这个文件是 appleshan 个人专用的 emacs 配置文件,emacs 中文用户可以参考。 13 | 14 | ;;; License: GPLv3 15 | 16 | ;;; Code: 17 | 18 | (setq appleshan-shell-packages 19 | '( 20 | exec-path-from-shell 21 | (terminal-here :location "~/.spacemacs.d/local/terminal-here/") 22 | )) 23 | 24 | ;; List of packages to exclude. 25 | (setq appleshan-shell-excluded-packages '()) 26 | 27 | (defun appleshan-shell/pre-init-exec-path-from-shell () 28 | (spacemacs|use-package-add-hook exec-path-from-shell 29 | :post-config 30 | (progn 31 | ;;Copy the following environent variables from shell 32 | (dolist (var '(;; my path 33 | "JAVA_HOME" 34 | "ORACLE_HOME" 35 | "LD_LIBRARY_PATH" 36 | "NLS_LANG" 37 | ;; system path 38 | "PATH" 39 | "SSH_AUTH_SOCK" 40 | "SSH_AGENT_PID" 41 | "GPG_AGENT_INFO" 42 | "LANG" 43 | "LC_ALL" 44 | "LC_CTYPE" 45 | )) 46 | (add-to-list 'exec-path-from-shell-variables var)) 47 | ))) 48 | 49 | (defun appleshan-shell/init-terminal-here () 50 | (use-package terminal-here)) 51 | 52 | ;; Local Variables: 53 | ;; coding: utf-8 54 | ;; no-byte-compile: nil 55 | ;; End: 56 | 57 | ;;; packages.el ends here 58 | -------------------------------------------------------------------------------- /layers/appleshan-web/funcs.el: -------------------------------------------------------------------------------- 1 | ;;; funcs.el --- appleshan-javascript Layer functions File for Spacemacs 2 | ;; 3 | ;; Copyright (c) 2016-2020 Apple Shan 4 | ;; 5 | ;; Author: Apple Shan 6 | ;; URL: https://github.com/appleshan/my-spacemacs-config 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;;; License: GPLv3 11 | 12 | (defun appleshan/web-mode-setup () 13 | ;; indentation 14 | ;; HTML offset indentation 15 | (setq web-mode-markup-indent-offset 2) 16 | ;; CSS offset indentation 17 | (setq web-mode-css-indent-offset 2) 18 | ;; Script offset indentation (for JavaScript, Java, PHP, etc.) 19 | (setq web-mode-code-indent-offset 2) 20 | ;; HTML content indentation 21 | (setq web-mode-indent-style 2) 22 | 23 | ;; @see https://emacs-china.org/t/web-mode/2130 24 | ;; padding 25 | ;; For