<commit_before>; copy from [How to automatically install Emacs packages by specifying a list of package names?](https://stackoverflow.com/questions/10092322/how-to-automatically-install-emacs-packages-by-specifying-a-list-of-package-name)
; list the packages you want
(setq package-list '(edts company indent-guide pangu-spacing spinner undo-tree highlight-thing markdown-mode switch-window protobuf-mode elixir-mode alchemist tide dart-mode dart-server mix csharp-mode omnisharp lua-mode flycheck-rust rust-mode swift-mode use-package))

; list the repositories containing them
(setq package-archives '(("gnu"   . "http://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")
                         ("melpa" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")))

; activate all the packages (in particular autoloads)
(package-initialize)

; fetch the list of packages available
(unless package-archive-contents
    (package-refresh-contents))

; install the missing packages
(dolist (package package-list)
    (unless (package-installed-p package)
          (package-install package)))

;;设定光标为短线
(setq-default cursor-type 'bar)

;; ispell 中文问题
;; use apsell as ispell backend
(setq-default ispell-program-name "aspell")
;; use American English as ispell default dictionary
(ispell-change-dictionary "american" t)

(setq-default indent-tabs-mode nil)
(setq default-tab-width 4)

(setq dart-server-sdk-path "~/flutter/bin/cache/dart-sdk/")
(setq dart-server-enable-analysis-server t)
(add-hook 'dart-server-hook 'flycheck-mode)

;;参考 http://www.aiuxian.com/article/p-823990.html
;; Linux下emacs如何和X-Window系统共享剪贴板
;;(setq x-select-enable-clipboard t)
;;
;;;; use xsel to copy/paste in emacs-nox
;;(unless window-system
;;  (when (getenv "DISPLAY")
;;	(defun xsel-cut-function (text &optional push)
;;    (with-temp-buffer
;;		(insert text)
;;		(call-process-region (point-min) (point-max) "xsel" nil 0 nil "--clipboard" "--input")))
;;	(defun xsel-paste-function()
;;    (let ((xsel-output (shell-command-to-string "xsel --clipboard --output")))
;;		(unless (string= (car kill-ring) xsel-output)
;;        xsel-output )))
;;	(setq interprogram-cut-function 'xsel-cut-function)
;;	(setq interprogram-paste-function 'xsel-paste-function)
;;	))


(global-superword-mode t)

(global-hl-line-mode t)
;;(set-face-background 'hl-line "blue")
;;(set-face-foreground 'highlight nil)
;;(set-face-background 'hl-line "#BEBEBE")
;;(set-face-foreground 'hl-line "#0000000")
;; copy from [hl-line-mode hide background, how to avoid this?](https://emacs.stackexchange.com/questions/10445/hl-line-mode-hide-background-how-to-avoid-this)
(defun my-hl-line-range-function ()
  (cons (line-end-position) (line-beginning-position 2)))
(setq hl-line-range-function #'my-hl-line-range-function)

(when window-system
  (require 'hl-line)
  (set-face-attribute 'hl-line nil :inherit nil :background "light yellow")
  (setq global-hl-line-sticky-flag t)
  (global-hl-line-mode 1))

(blink-cursor-mode 0)
(setq blink-cursor-blinks 0)
(setq-default cursor-type 'bar);光标显示为一竖线
(set-cursor-color "blue")
(global-font-lock-mode t)

(global-linum-mode 1)
(setq linum-format "%3d ")
(add-hook 'prog-mode-hook 'linum-mode)

;;(setq-default indent-tabs-mode nil)
(ido-mode 1)
(setq column-number-mode t)

(setq inhibit-startup-message t) ;; 关闭起动时LOGO
(setq visible-bell t);;关闭出错时的提示声
(global-font-lock-mode t);语法高亮
(show-paren-mode t) ;; 显示括号匹配
(setq show-paren-style 'parenthesis)
(setq mouse-yank-at-point t);;支持中键粘贴
(mouse-avoidance-mode 'animate) ;;光标靠近鼠标指针时，让鼠标指针自动让开，别挡住视线。
(setq appt-issue-message t)

(add-to-list 'auto-mode-alist '("\\.erl?$" . erlang-mode))
(add-to-list 'auto-mode-alist '("\\.hrl?$" . erlang-mode))

(add-to-list 'auto-mode-alist '("\\.ex?$" . elixir-mode))
(add-to-list 'auto-mode-alist '("\\.exs?$" . elixir-mode))
(add-to-list 'auto-mode-alist '("\\.dart\\'" . dart-mode))
;; Load rust-mode when you open `.rs` files
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode))

;; Set path to rust src directory
;; copy from https://github.com/racer-rust/emacs-racer/issues/138
;; copy from https://stackoverflow.com/questions/5014246/how-to-capture-standard-output-of-a-shell-command-in-elisp
;;(setq racer-rust-src-path
;;	(substring
;;		(shell-command-to-string "/bin/echo $(rustc --print sysroot)/lib/rustlib/src/rust/library")
;;	0 -1))

(require 'rust-mode)
(define-key rust-mode-map (kbd "TAB") #'company-indent-or-complete-common)
(setq company-tooltip-align-annotations t)


(setq rust-format-on-save t)

(setq backup-directory-alist (quote (("." . "~/.backups"))))
(setq version-control t)
(setq kept-old-versions 2)
(setq kept-new-versions 5)
(setq delete-old-versions t)
(setq backup-directory-alist '(("." . "~/.backups")))
(setq backup-by-copying t)

(global-auto-revert-mode 1)

;; Behave like vi's o command
(defun open-next-line (arg)<commit_msg>delete<commit_after>; copy from [How to automatically install Emacs packages by specifying a list of package names?](https://stackoverflow.com/questions/10092322/how-to-automatically-install-emacs-packages-by-specifying-a-list-of-package-name)
; list the packages you want
(setq package-list '(edts company indent-guide pangu-spacing spinner undo-tree highlight-thing markdown-mode switch-window protobuf-mode elixir-mode alchemist tide dart-mode dart-server mix csharp-mode omnisharp lua-mode flycheck-rust rust-mode swift-mode use-package))

; list the repositories containing them
(setq package-archives '(("gnu"   . "http://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")
                         ("melpa" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")))

; activate all the packages (in particular autoloads)
(package-initialize)

; fetch the list of packages available
(unless package-archive-contents
    (package-refresh-contents))

; install the missing packages
(dolist (package package-list)
    (unless (package-installed-p package)
          (package-install package)))

;;设定光标为短线
(setq-default cursor-type 'bar)

;; ispell 中文问题
;; use apsell as ispell backend
(setq-default ispell-program-name "aspell")
;; use American English as ispell default dictionary
(ispell-change-dictionary "american" t)

(setq-default indent-tabs-mode nil)
(setq default-tab-width 4)

(setq dart-server-sdk-path "~/flutter/bin/cache/dart-sdk/")
(setq dart-server-enable-analysis-server t)
(add-hook 'dart-server-hook 'flycheck-mode)

;;参考 http://www.aiuxian.com/article/p-823990.html
;; Linux下emacs如何和X-Window系统共享剪贴板
;;(setq x-select-enable-clipboard t)
;;
;;;; use xsel to copy/paste in emacs-nox
;;(unless window-system
;;  (when (getenv "DISPLAY")
;;	(defun xsel-cut-function (text &optional push)
;;    (with-temp-buffer
;;		(insert text)
;;		(call-process-region (point-min) (point-max) "xsel" nil 0 nil "--clipboard" "--input")))
;;	(defun xsel-paste-function()
;;    (let ((xsel-output (shell-command-to-string "xsel --clipboard --output")))
;;		(unless (string= (car kill-ring) xsel-output)
;;        xsel-output )))
;;	(setq interprogram-cut-function 'xsel-cut-function)
;;	(setq interprogram-paste-function 'xsel-paste-function)
;;	))


(global-superword-mode t)

(global-hl-line-mode t)
;;(set-face-background 'hl-line "blue")
;;(set-face-foreground 'highlight nil)
;;(set-face-background 'hl-line "#BEBEBE")
;;(set-face-foreground 'hl-line "#0000000")
;; copy from [hl-line-mode hide background, how to avoid this?](https://emacs.stackexchange.com/questions/10445/hl-line-mode-hide-background-how-to-avoid-this)
(defun my-hl-line-range-function ()
  (cons (line-end-position) (line-beginning-position 2)))
(setq hl-line-range-function #'my-hl-line-range-function)

(when window-system
  (require 'hl-line)
  (set-face-attribute 'hl-line nil :inherit nil :background "light yellow")
  (setq global-hl-line-sticky-flag t)
  (global-hl-line-mode 1))

(blink-cursor-mode 0)
(setq blink-cursor-blinks 0)
(setq-default cursor-type 'bar);光标显示为一竖线
(set-cursor-color "blue")
(global-font-lock-mode t)

(global-linum-mode 1)
(setq linum-format "%3d ")
(add-hook 'prog-mode-hook 'linum-mode)

;;(setq-default indent-tabs-mode nil)
(ido-mode 1)
(setq column-number-mode t)

(setq inhibit-startup-message t) ;; 关闭起动时LOGO
(setq visible-bell t);;关闭出错时的提示声
(global-font-lock-mode t);语法高亮
(show-paren-mode t) ;; 显示括号匹配
(setq show-paren-style 'parenthesis)
(setq mouse-yank-at-point t);;支持中键粘贴
(mouse-avoidance-mode 'animate) ;;光标靠近鼠标指针时，让鼠标指针自动让开，别挡住视线。
(setq appt-issue-message t)

(add-to-list 'auto-mode-alist '("\\.erl?$" . erlang-mode))
(add-to-list 'auto-mode-alist '("\\.hrl?$" . erlang-mode))

(add-to-list 'auto-mode-alist '("\\.ex?$" . elixir-mode))
(add-to-list 'auto-mode-alist '("\\.exs?$" . elixir-mode))
(add-to-list 'auto-mode-alist '("\\.dart\\'" . dart-mode))
;; Load rust-mode when you open `.rs` files
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode))

(require 'rust-mode)
(define-key rust-mode-map (kbd "TAB") #'company-indent-or-complete-common)
(setq company-tooltip-align-annotations t)


(setq rust-format-on-save t)

(setq backup-directory-alist (quote (("." . "~/.backups"))))
(setq version-control t)
(setq kept-old-versions 2)
(setq kept-new-versions 5)
(setq delete-old-versions t)
(setq backup-directory-alist '(("." . "~/.backups")))
(setq backup-by-copying t)

(global-auto-revert-mode 1)

;; Behave like vi's o command
(defun open-next-line (arg)
{'fraction_non_alphanumeric': 0.17621807254775704, 'fraction_numerical': 0.0094440867138871, 'mean_word_length': 4.312998859749145, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '611710', 'n_tokens_mistral': 3716, 'n_tokens_neox': 3631, 'n_words': 737}