|
|
| (19 intermediate revisions by the same user not shown) |
| Line 1: |
Line 1: |
| == basic ==
| | 已全面采用 github 管理。 |
| <syntaxhighlight lang="elisp" line>
| |
| ;; (set-face-attribute 'default nil :font "DejaVu Serif:pixelsize=30")
| |
| ;; (set-fontset-font t 'han "TW-MOE-Std-Kai:pixelsize=30")
| |
| ;; (set-fontset-font t 'han "WenQuanYi Zen Hei:pixelsize=25" nil 'append)
| |
| ;; DejaVu Serif, TW-MOE-Std-Kai, WenQuanYi Micro Hei
| |
| (set-face-attribute 'default nil :height 160)
| |
| (set-fontset-font t 'han "WenQuanYi Micro Hei:pixelsize=20")
| |
| </syntaxhighlight>
| |
| | |
| == onoff ==
| |
| <syntaxhighlight lang="elisp" line>
| |
| (load-theme 'adwaita t)
| |
| | |
| (setq suggest-key-bindings 10) ;十秒后建议才消失
| |
| (show-paren-mode) ;显示对应括号
| |
| (electric-pair-mode) ;自动右括号
| |
| (delete-selection-mode t)
| |
| | |
| (global-auto-revert-mode t)
| |
| (global-visual-line-mode t)
| |
| </syntaxhighlight>
| |
| | |
| == packages ==
| |
| <syntaxhighlight lang="elisp" line>
| |
| ;; List the packages want to install
| |
| (setq package-list '(
| |
| benchmark-init
| |
| use-package
| |
| which-key
| |
| company
| |
| magit
| |
| yaml-mode
| |
| yasnippet
| |
| smart-compile
| |
| markdown-mode
| |
| lsp-mode
| |
| sdcv
| |
| | |
| ;; auctex
| |
| ;; let-alist ;; for pdf-tools
| |
| ;; tablist ;; for pdf-tools
| |
| ;; cask ;; for pdf-tools
| |
| ;; pdf-tools
| |
| ;; youdao-dictionary
| |
| | |
| ;; Opt
| |
| ;; ace-window
| |
| web-mode
| |
| projectile
| |
| htmlize
| |
| edit-server
| |
| mediawiki
| |
| ))
| |
| | |
| (unless package-archive-contents
| |
| (package-refresh-contents))
| |
| | |
| ;; Install the missing packages
| |
| (dolist (package package-list)
| |
| (unless (package-installed-p package)
| |
| (package-install package)))
| |
| | |
| ;; (pdf-tools-install)
| |
| </syntaxhighlight>
| |
| | |
| == alias ==
| |
| <syntaxhighlight lang="elisp" line>
| |
| (defalias 'yes-or-no-p 'y-or-n-p)
| |
| (defalias 'qr 'query-replace)
| |
| (defalias 'rr 'replace-regexp)
| |
| (defalias 'bs 'bookmark-set)
| |
| (defalias 'bj 'bookmark-jump)
| |
| (defalias 'dc 'describe-char)
| |
| (defalias 'sl 'sort-lines)
| |
| (defalias 'cr 'comment-region)
| |
| (defalias 'ur 'uncomment-region)
| |
| (defalias 'lm 'list-matching-lines)
| |
| (defalias 'md 'edit-server-done)
| |
| (defalias 'sd 'server-edit 1)
| |
| </syntaxhighlight>
| |
| | |
| == defun ==
| |
| === q-open-init-file ===
| |
| <syntaxhighlight lang="elisp" line>
| |
| (defun q-open-init-file()
| |
| (interactive)
| |
| (dired "~/.emacs.d/lisp/"))
| |
| </syntaxhighlight>
| |
| | |
| === say-ok-after-server-edit ===
| |
| <syntaxhighlight lang="elisp" line>
| |
| ;; 抄自 https://www.emacswiki.org/emacs/YesOrNoP,负作用不详,symbol-function 不懂
| |
| ;; 作用为:建议server-edit函数执行后的询问是否保存,一概选是
| |
| ;; (defadvice server-edit (around auto-confirm compile activate)
| |
| ;; (cl-letf (((symbol-function 'yes-or-no-p) (lambda (&rest args) t))
| |
| ;; ((symbol-function 'y-or-n-p) (lambda (&rest args) t)))
| |
| ;; ad-do-it)
| |
| ;; (sanityinc/maybe-suspend-frame))
| |
| | |
| (defadvice kill-current-buffer (around auto-confirm compile activate)
| |
| (cl-letf (((symbol-function 'yes-or-no-p) (lambda (&rest args) t))
| |
| ((symbol-function 'y-or-n-p) (lambda (&rest args) t)))
| |
| ad-do-it)
| |
| (sanityinc/maybe-suspend-frame))
| |
| </syntaxhighlight>
| |
| | |
| === q-compile-run-c ===
| |
| <syntaxhighlight lang="elisp" line>
| |
| (defun q-compile-run-c ()
| |
| "Compile C code, my first elisp program.
| |
| | |
| When run f8, C code will compile and print out some messages.
| |
| | |
| ARG1 `mediawiki-site'.
| |
| | |
| ARG2 `mediawiki-browse'.
| |
| | |
| See URL `http://xahlee.info/' to learn more practice code experience.
| |
| | |
| See `magit'.
| |
| | |
| See Info node `(emacs) grep'.
| |
| | |
| Type \\[dired] to go into dired.
| |
| | |
| Type f8 to run this function.
| |
| | |
| Clickable list of all keys of a given keymap name.
| |
| \\{emacs-lisp-mode-map}"
| |
| (interactive)
| |
| (save-buffer)
| |
| (delete-other-windows)
| |
| (setq i (buffer-name))
| |
| (setq o (file-name-sans-extension (file-name-nondirectory (buffer-file-name (current-buffer)))))
| |
| (switch-to-buffer (eshell))
| |
| (split-window-right -100)
| |
| (eshell-bol)
| |
| (kill-visual-line)
| |
| (insert "cc -O2 " i " -lm -o " o " && ./" o)
| |
| (eshell-send-input)
| |
| (other-window 1)
| |
| (end-of-buffer)
| |
| (switch-to-buffer i)
| |
| (other-window 1))
| |
| </syntaxhighlight>
| |
| | |
| === switch-other-window-to-buffer ===
| |
| <syntaxhighlight lang="elisp" line>
| |
| (defun switch-other-window-to-buffer (name)
| |
| (other-window 1)
| |
| (switch-to-buffer name)
| |
| (other-window 1))
| |
| </syntaxhighlight>
| |
| | |
| === run-scheme ===
| |
| <syntaxhighlight lang="elisp" line>
| |
| ;; 这行必须写,否则报错:找不到scheme函数
| |
| (require 'cmuscheme)
| |
| | |
| ;; 是否指定用chezscheme都无所谓,emacs自己能找到,更没必要找chezscheme二进制文件
| |
| ;; 这些应该是purcell的配置设置好了的,留待后究
| |
| ;; 若要写,chez不行;scheme或chezscheme可行。
| |
| | |
| ;; bypass the interactive question and start the default interpreter
| |
| (defun scheme-proc ()
| |
| "Return the current Scheme process, starting one if necessary."
| |
| (unless (and scheme-buffer
| |
| (get-buffer scheme-buffer)
| |
| (comint-check-proc scheme-buffer))
| |
| (save-window-excursion
| |
| (run-scheme scheme-program-name)))
| |
| (or (scheme-get-process)
| |
| (error "No current process. See variable `scheme-buffer'")))
| |
| | |
| (defun scheme-split-window ()
| |
| (cond
| |
| ((= 1 (count-windows))
| |
| (split-window-vertically (floor (* 0.68 (window-height))))
| |
| ;; (split-window-horizontally (floor (* 0.5 (window-width))))
| |
| (switch-other-window-to-buffer "*scheme*"))
| |
| ((not (member "*scheme*"
| |
| (mapcar (lambda (w) (buffer-name (window-buffer w)))
| |
| (window-list))))
| |
| (switch-other-window-to-buffer "*scheme*"))))
| |
| | |
| (defun scheme-send-last-sexp-split-window ()
| |
| (interactive)
| |
| (scheme-split-window)
| |
| (scheme-send-last-sexp))
| |
| | |
| (defun scheme-send-definition-split-window ()
| |
| (interactive)
| |
| (scheme-split-window)
| |
| (scheme-send-definition))
| |
| | |
| (add-hook 'scheme-mode-hook
| |
| (lambda ()
| |
| (paredit-mode 1)
| |
| ;; (define-key scheme-mode-map (kbd "<f5>") 'scheme-send-last-sexp-split-window)
| |
| (define-key scheme-mode-map (kbd "<f5>") 'scheme-send-definition-split-window)))
| |
| </syntaxhighlight>
| |
| | |
| === t-mw-define ===
| |
| <syntaxhighlight lang="elisp" line>
| |
| (defun t-mw-define ()
| |
| (interactive)
| |
| "give mediawiki define element a :"
| |
| (replace-regexp "^ ?" ": " nil))
| |
| </syntaxhighlight>
| |
| | |
| == keys ==
| |
| <syntaxhighlight lang="elisp" line>
| |
| (global-set-key (kbd "<f1>") 'sdcv-search-pointer+)
| |
| (global-set-key (kbd "<f2>") 'switch-to-buffer)
| |
| (global-set-key (kbd "<f4>") 'q-open-init-file)
| |
| (global-set-key (kbd "<f5>") 'eval-buffer)
| |
| (global-set-key (kbd "<f8>") 'q-compile-run-c)
| |
| (global-set-key (kbd "<f9>") 'read-only-mode)
| |
| (global-set-key (kbd "<f12>") 'kill-current-buffer)
| |
| </syntaxhighlight>
| |
| | |
| == hooks ==
| |
| <syntaxhighlight lang="elisp" line>
| |
| (add-hook 'after-init-hook 'benchmark-init/activate)
| |
| (add-hook 'dired-mode-hook 'dired-hide-details-mode t)
| |
| | |
| ;; (add-hook 'after-init-hook #'auto-save-visited-mode)
| |
| ;; (setq auto-save-visited-interval 1)
| |
| ;; (add-hook 'pdf-view-mode-hook 'pdf-view-auto-slice-minor-mode)
| |
| </syntaxhighlight>
| |
| | |
| == tranlate ==
| |
| === sdcv ===
| |
| <syntaxhighlight lang="elisp" line>
| |
| ;; 直接按 f1 即可用
| |
| ;; 需 sudo apt install stardict sdcv,待验证
| |
| ;; 需 posframe
| |
| | |
| (require 'sdcv)
| |
| ;; (require 'company-english-helper) ;; 似乎存在字体 bug,对硬件要求很高,也不实用,暂且搁置
| |
| | |
| (setq sdcv-say-word-p t)
| |
| (setq sdcv-dictionary-data-dir "/home/qlzq/Documents/En") ;setup directory of stardict dictionary
| |
| (setq sdcv-dictionary-simple-list ;setup dictionary list for simple search
| |
| '("简明英汉字典增强版"))
| |
| (setq sdcv-dictionary-complete-list ;setup dictionary list for complete search Etymonline
| |
| '("简明英汉字典增强版"))
| |
| | |
| (global-set-key (kbd "C-x t C-d") 'sdcv-search-input)
| |
| (global-set-key (kbd "C-x t d") 'sdcv-search-pointer+)
| |
| (global-set-key (kbd "<f1>") 'sdcv-search-pointer+)
| |
| </syntaxhighlight>
| |
| | |
| === goldendict ===
| |
| <syntaxhighlight lang="elisp" line>
| |
| ;; 直接输命令 +dict- 即可用
| |
| ;; 无需额外依赖
| |
| (defun +dict-word-at-point ()
| |
| "Search word in goldendict"
| |
| (interactive)
| |
| (call-process-shell-command (concat "goldendict " (current-word) " &") nil 0))
| |
| </syntaxhighlight>
| |
| | |
| === fanyi ===
| |
| <syntaxhighlight lang="elisp" line>
| |
| ;; 直接输入命令 fanyi- 即可用
| |
| ;; 依赖 fanyi.el
| |
| ;; M-x package-install RET fanyi RET 即可
| |
| (custom-set-variables
| |
| '(fanyi-providers '(fanyi-haici-provider
| |
| fanyi-youdao-thesaurus-provider
| |
| fanyi-etymon-provider
| |
| fanyi-longman-provider)))
| |
| </syntaxhighlight>
| |
| | |
| == mediawiki ==
| |
| <syntaxhighlight lang="elisp" line>
| |
| '(mediawiki-site-alist
| |
| '(("name" "http://n.n.n.n/mediawiki/" "user" "passwd" nil "Main Page")
| |
| ("name" "https://someplace.com/mediawiki/" "user" "passwd" nil "Main Page")))
| |
| </syntaxhighlight>
| |
| | |
| == end ==
| |
| <syntaxhighlight lang="elisp" line>
| |
| (setq company-minimum-prefix-length 3)
| |
| (global-company-mode t)
| |
| ;; (setq markdown-command "/usr/bin/pandoc")
| |
| | |
| (provide 'init-local)
| |
| ;; init-local.el ends here.
| |
| </syntaxhighlight>
| |