Skip to content

Commit a082097

Browse files
committed
Merge branch 'master' of github.com:redguardtoo/emacs.d
2 parents 4bcae5f + c1e49c1 commit a082097

File tree

152 files changed

+4929
-3259
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+4929
-3259
lines changed

.github/workflows/test.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
schedule:
11+
# build at 00:05 everyday
12+
- cron: '5 0 * * *'
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
emacs_version:
21+
- 26.3
22+
- 27.1
23+
- snapshot
24+
steps:
25+
- uses: purcell/setup-emacs@master
26+
with:
27+
version: ${{ matrix.emacs_version }}
28+
29+
- uses: actions/checkout@v2
30+
31+
- name: Print emacs version
32+
run: emacs --version
33+
34+
- name: Install dependency
35+
run: sudo apt install aspell aspell-en
36+
37+
- name: Run tests
38+
run: make test

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ cookies
3131
\#*
3232
/elpa
3333
eshell/
34+
eln-cache/
3435
semanticdb/
3536
*.swp
3637
*~

.travis.yml

-16
This file was deleted.

README.org

+132-63
Large diffs are not rendered by default.

early-init.el

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
(when (or (featurep 'esup-child)
2+
(fboundp 'profile-dotemacs)
3+
(daemonp)
4+
(boundp 'startup-now)
5+
noninteractive)
6+
(setq package-enable-at-startup nil))
7+
8+
(defvar my-computer-has-smaller-memory-p nil
9+
"Compiling and install too packages could cost too much memory.")
10+
11+
;; @see https://www.reddit.com/r/emacs/comments/ofhket/further_boost_start_up_time_with_a_simple_tweak/
12+
;; 10% speed up of startup for my configuration
13+
(unless my-computer-has-smaller-memory-p
14+
(setq gc-cons-percentage 0.6)
15+
(setq gc-cons-threshold most-positive-fixnum))
16+
17+
(setq inhibit-startup-message t)

init.el

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
(setq *emacs27* (>= emacs-major-version 27))
2323

2424
;; don't GC during startup to save time
25-
(setq gc-cons-percentage 0.6)
26-
(setq gc-cons-threshold most-positive-fixnum)
25+
(unless (bound-and-true-p my-computer-has-smaller-memory-p)
26+
(setq gc-cons-percentage 0.6)
27+
(setq gc-cons-threshold most-positive-fixnum))
2728

2829
;; {{ emergency security fix
2930
;; https://bugs.debian.org/766397
@@ -102,7 +103,6 @@
102103
(require-init 'init-org t)
103104
(require-init 'init-python t)
104105
(require-init 'init-lisp t)
105-
(require-init 'init-elisp t)
106106
(require-init 'init-yasnippet t)
107107
(require-init 'init-cc-mode t)
108108
(require-init 'init-linum-mode)
@@ -114,7 +114,7 @@
114114
(require-init 'init-gnus t)
115115
(require-init 'init-lua-mode t)
116116
(require-init 'init-workgroups2 t) ; use native API in lightweight mode
117-
(require-init 'init-term-mode t)
117+
(require-init 'init-term-mode)
118118
(require-init 'init-web-mode t)
119119
(require-init 'init-company t)
120120
; (require-init 'init-chinese t) ;; cannot be idle-required

lisp/init-autoload.el

+8-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
(autoload 'shellcop-erase-buffer "shellcop" "" t)
2424
(autoload 'shellcop-reset-with-new-command "shellcop" "" t)
2525
(autoload 'shellcop-start "shellcop" "" t)
26+
(autoload 'shellcop-search-in-shell-buffer-of-other-window "shellcop" "" t)
2627
(autoload 'mybigword-video2mp3 "mybigword" "" t)
2728
(autoload 'js2hl-show-thing-at-point "js2hl" "" t)
2829
(autoload 'js2hl-show-exits "js2hl" "" t)
@@ -31,6 +32,7 @@
3132
(autoload 'ivy-recentf "ivy" "" t)
3233
(autoload 'ivy-read "ivy")
3334
(autoload 'rainbow-mode "rainbow-mode" nil t)
35+
(autoload 'ffip-diff-mode "find-file-in-project" nil t)
3436
(autoload 'workgroups-mode "workgroups2" nil t)
3537
(autoload 'wg-create-workgroup "workgroups2" nil t)
3638
(autoload 'wg-open-workgroup "workgroups2" nil t)
@@ -91,13 +93,16 @@
9193
(autoload 'js-comint-send-region "js-comint" "")
9294
(autoload 'vc-msg-show "vc-msg" "")
9395
(autoload 'eacl-complete-line "eacl" "")
94-
(autoload 'eacl-complete-statement "eacl" "")
95-
(autoload 'eacl-complete-snippet "eacl" "")
96-
(autoload 'eacl-complete-tag "eacl" "")
9796
(autoload 'eacl-complete-multiline "eacl" "")
97+
(autoload 'eacl-complete-line-from-buffer "eacl" "")
98+
(autoload 'eacl-complete-line-from-buffer-or-project "eacl" "")
9899
(autoload 'dropdown-list "dropdown-list" "")
99100
(autoload 'magit-commit-popup "magit" "")
100101
(autoload 'global-git-gutter-mode "git-gutter" "" t)
102+
(autoload 'diff-lisp-mark-selected-text-as-a "diff-lisp" "" t)
103+
(autoload 'diff-lisp-compare-with-b "diff-lisp" "" t)
104+
(autoload 'shenshou-download-subtitle "shenshou" "" t)
105+
(autoload 'shenshou-logout-now "shenshou" "" t)
101106

102107
(provide 'init-autoload)
103108
;;; init-autoload.el ends here

lisp/init-cc-mode.el

+5-14
Original file line numberDiff line numberDiff line change
@@ -42,31 +42,22 @@
4242

4343
(setq cc-search-directories '("." "/usr/include" "/usr/local/include/*" "../*/include" "$WXWIN/include"))
4444

45-
;; {{ @see https://github.com/redguardtoo/cpputils-cmake
45+
;; @see https://github.com/redguardtoo/cpputils-cmake
4646
;; In theory, you can write your own Makefile for `flymake-mode' without cmake.
4747
;; Nobody actually does it in real world.
4848

49-
;; debugging Emacs c code
50-
(add-to-list 'imenu-generic-expression '(nil "^DEFUN *(\"\\([a-zA-Z0-9-]+\\)" 1))
49+
;; debugging Emacs C code
50+
(push '(nil "^DEFUN *(\"\\([a-zA-Z0-9-]+\\)" 1) imenu-generic-expression )
5151

5252
;; make a #define be left-aligned
5353
(setq c-electric-pound-behavior (quote (alignleft))))
5454

55-
;; donot use c-mode-common-hook or cc-mode-hook because many major-modes use this hook
5655
(defun c-mode-common-hook-setup ()
56+
"C/C++ setup."
5757
(unless (is-buffer-file-temp)
5858
(my-common-cc-mode-setup)
5959
(unless (or (derived-mode-p 'java-mode) (derived-mode-p 'groovy-mode))
60-
(my-c-mode-setup))
61-
62-
;; gtags (GNU global) stuff
63-
(when (and (executable-find "global")
64-
;; `man global' to figure out why
65-
(not (string-match-p "GTAGS not found"
66-
(shell-command-to-string "global -p"))))
67-
;; emacs 24.4+ will set up eldoc automatically.
68-
;; so below code is NOT needed.
69-
(eldoc-mode 1))))
60+
(my-c-mode-setup))))
7061
(add-hook 'c-mode-common-hook 'c-mode-common-hook-setup)
7162

7263
(provide 'init-cc-mode)

lisp/init-clipboard.el

-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
;; -*- coding: utf-8; lexical-binding: t; -*-
22

3-
;; Use the system clipboard
4-
;; @see https://www.emacswiki.org/emacs/CopyAndPaste
5-
;; So `C-y' could paste from clipboard if you are NOT using emacs-nox
6-
;; I only use `paste-from-x-clipboard', not `C-y'.
7-
(setq x-select-enable-clipboard t)
8-
(setq x-select-enable-primary t)
9-
10-
;; kill-ring and clipboard are same? No, it's annoying!
11-
(setq save-interprogram-paste-before-kill nil)
12-
133
(defun copy-yank-str (msg &optional clipboard-only)
144
(unless clipboard-only (kill-new msg))
155
(my-pclip msg)

lisp/init-company.el

+15-9
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44

55
;; evil has already integrated company-mode, see evil-integration.el
66

7+
(defvar my-company-select-by-number-p t
8+
"User can press number key to select company candidate.")
9+
710
(defvar my-company-zero-key-for-filter nil
8-
"If t, pressing 0 calls `company-filter-candidates' per company's status.")
11+
"If t, pressing 0 calls `company-filter-candidates' per company's status.
12+
If `my-company-select-by-number-p' is nil, this flag is ignored. ")
913

1014
(with-eval-after-load 'company
1115

@@ -28,7 +32,7 @@ In that case, insert the number."
2832
(cond
2933
((or (cl-find-if (lambda (s) (string-match re s)) company-candidates)
3034
(> n (length company-candidates))
31-
(looking-back "[0-9]+\\.[0-9]*" (line-beginning-position)))
35+
(looking-back "[0-9]" (line-beginning-position)))
3236
(self-insert-command 1))
3337

3438
((and (eq n 10) my-company-zero-key-for-filter)
@@ -46,11 +50,12 @@ In that case, insert the number."
4650

4751
;; @see https://oremacs.com/2017/12/27/company-numbers/
4852
;; Using digits to select company-mode candidates
49-
(let ((map company-active-map))
50-
(mapc
51-
(lambda (x)
52-
(define-key map (format "%d" x) 'my-company-number))
53-
(number-sequence 0 9)))
53+
(when my-company-select-by-number-p
54+
(let ((map company-active-map))
55+
(mapc
56+
(lambda (x)
57+
(define-key map (format "%d" x) 'my-company-number))
58+
(number-sequence 0 9))))
5459

5560
(setq company-auto-commit t)
5661
;; characters "/ ) . , ;"to trigger auto commit
@@ -116,6 +121,7 @@ In that case, insert the number."
116121
"Add ispell to the last of `company-backends'."
117122
(setq company-backends
118123
(add-to-list 'company-backends 'company-ispell)))
124+
119125
;; {{ setup company-ispell
120126
(defun toggle-company-ispell ()
121127
"Toggle company-ispell."
@@ -125,14 +131,14 @@ In that case, insert the number."
125131
(setq company-backends (delete 'company-ispell company-backends))
126132
(message "company-ispell disabled"))
127133
(t
128-
(my-add-ispell-to-company-backends)
134+
(push 'company-ispell company-backends)
129135
(message "company-ispell enabled!"))))
130136

131137
(defun company-ispell-setup ()
132138
;; @see https://github.com/company-mode/company-mode/issues/50
133139
(when (boundp 'company-backends)
134140
(make-local-variable 'company-backends)
135-
(my-add-ispell-to-company-backends)
141+
(push 'company-ispell company-backends)
136142
;; @see https://github.com/redguardtoo/emacs.d/issues/473
137143
(cond
138144
((and (boundp 'ispell-alternate-dictionary)

lisp/init-dired.el

+52-29
Original file line numberDiff line numberDiff line change
@@ -39,38 +39,57 @@ If no files marked, always operate on current line in dired-mode."
3939
(error "no more than 2 files should be marked")))))
4040

4141

42+
(defun my-dired-support-program (program pattern)
43+
"External PROGRAM can open files matching PATTERN."
44+
(push (list pattern program) dired-guess-shell-alist-user))
45+
4246
(with-eval-after-load 'dired-x
43-
(dolist (file `(((if *unix* "zathura" "open") "pdf" "dvi" "pdf.gz" "ps" "eps")
44-
("7z x" "rar" "zip" "7z") ; "e" to extract, "x" to extract with full path
45-
((if *is-a-mac* "open" (my-guess-mplayer-path)) "ogm"
46-
"avi"
47-
"mpg"
48-
"rmvb"
49-
"rm"
50-
"flv"
51-
"wmv"
52-
"mkv"
53-
"mp4"
54-
"m4v"
55-
"wav"
56-
"webm"
57-
"part"
58-
"mov"
59-
"3gp"
60-
"crdownload"
61-
"mp3")
62-
((concat (my-guess-mplayer-path) "-fs -playlist") "list" "pls" "m3u")
63-
((if *unix* "feh" "open") "gif" "jpeg" "jpg" "tif" "png" )
64-
((if *unix* "libreoffice" "open") "doc" "docx" "xls" "xlsx" "odt")
65-
("djview" "djvu")
66-
("firefox" "xml" "xhtml" "html" "htm" "mht" "epub")))
67-
(add-to-list 'dired-guess-shell-alist-user
68-
(list (concat "\\." (regexp-opt (cdr file) t) "$")
69-
(car file)))))
47+
(my-dired-support-program (if *is-a-mac* "open" (my-guess-mplayer-path))
48+
(my-file-extensions-to-regexp my-media-file-extensions))
49+
50+
(my-dired-support-program (if *unix* "zathura" "open")
51+
(my-file-extensions-to-regexp '("pdf"
52+
"pdf.gz"
53+
"dvi"
54+
"eps"
55+
"ps")))
56+
57+
;; "e" to extract, "x" to extract with full path
58+
(my-dired-support-program "7z x"
59+
(my-file-extensions-to-regexp '("rar"
60+
"zip"
61+
"7z")))
62+
63+
(my-dired-support-program (if *unix* "feh" "open")
64+
(my-file-extensions-to-regexp '("gif"
65+
"jpg"
66+
"jpeg"
67+
"tif"
68+
"png"
69+
"svg"
70+
"xpm")))
71+
72+
(my-dired-support-program (if *unix* "libreoffice" "open")
73+
(my-file-extensions-to-regexp '("doc"
74+
"docx"
75+
"xls"
76+
"xlsx"
77+
"odt")))
78+
79+
(my-dired-support-program "djview" "\\.djvu$")
80+
81+
(my-dired-support-program "firefox"
82+
(my-file-extensions-to-regexp '("xml"
83+
"xhtml"
84+
"html"
85+
"htm"
86+
"mht"
87+
"epub"))))
7088

7189
(defun dired-mode-hook-setup ()
7290
"Set up dired."
7391
(dired-hide-details-mode 1)
92+
(local-set-key "r" 'dired-up-directory)
7493
(local-set-key "e" 'my-ediff-files)
7594
(local-set-key "/" 'dired-isearch-filenames)
7695
(local-set-key "\\" 'diredext-exec-git-command-in-shell))
@@ -83,6 +102,10 @@ If no files marked, always operate on current line in dired-mode."
83102
"Recent directories accessed by dired.")
84103

85104
(with-eval-after-load 'dired
105+
;; re-use dired buffer, available in Emacs 28
106+
;; @see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=20598
107+
(setq dired-kill-when-opening-new-dired-buffer t)
108+
86109
;; search file name only when focus is over file
87110
(setq dired-isearch-filenames 'dwim)
88111

@@ -158,7 +181,7 @@ If SEARCH-IN-DIR is t, try to find the subtitle by searching in directory."
158181
"Detect subtitles for mplayer."
159182
(let* ((rlt (apply orig-func args)))
160183
(when (and (stringp rlt)
161-
(string-match-p "^mplayer -quiet" rlt))
184+
(string-match-p "^mplayer .*-quiet" rlt))
162185
;; append subtitle to mplayer cli
163186
(setq rlt
164187
(format "%s %s"
@@ -178,7 +201,7 @@ If SEARCH-IN-DIR is t, try to find the subtitle by searching in directory."
178201
"Avoid accidentally editing huge file in dired."
179202
(let* ((file (dired-get-file-for-visit)))
180203
(cond
181-
((string-match-p my-binary-file-name-regexp file)
204+
((my-binary-file-p file)
182205
;; confirm before opening big file
183206
(when (yes-or-no-p "Edit binary file?")
184207
(apply orig-func args)))

lisp/init-elisp.el

-17
This file was deleted.

0 commit comments

Comments
 (0)