Nasy Emacs 配置
新配置文件尙在加工中
此處留些許文字以方便諸君使用
安裝 Install
克隆到 .emacs.d
git clone https://github.com/nasyxx/emacs.d ~/nasy-emacs --recursive
ln -s ~/nasy-emacs ~/.emacs.d
生成 el 文件 Generate el files
make generate -j
生成 elc 與 eln 文件 Generate elc & eln files (可選 optional)
make config -j
更新 Update
簡而言之兩步
更新倉庫 Update repo
make update
更新 Update straight (可選 optional)
同時更新 elc 與 eln
make update-all
自定義
自定義文件全位于~芄蘭~有~芄蘭.el~與~custom.el~
雖有 custom.el
但未在配置中加載苟欲用之加載于 芄蘭/芄蘭.el
頟外
Python isort
;;; python-isort.el --- Utility to sort Python imports -*- lexical-binding: t; -*-
(require 'reformatter)
(defcustom python-isort-command "isort"
"Name of the `isort` executable."
:group 'nasy
:type 'string)
(defvar python-isort--base-args '("--quiet" "--atomic")
"Base arguments to pass to isort.")
(defcustom python-isort-extra-args nil
"Extra arguments to pass to isort."
:group 'nasy
:type '(repeat string))
;;;###autoload (autoload 'python-isort-buffer "python-isort" nil t)
;;;###autoload (autoload 'python-isort-region "python-isort" nil t)
;;;###autoload (autoload 'python-isort-on-save-mode "python-isort" nil t)
(reformatter-define python-isort
:program python-isort-command
:args (python-isort--make-args beg end)
:lighter " isort"
:group 'python-isort)
(defun python-isort--make-args (beg end)
"Helper to build the argument list for isort for span BEG to END."
(append python-isort--base-args
python-isort-extra-args
'("-")))
(provide 'python-isort)
;;; python-isort.el ends here
外皃 Theme
外皃
Nasy's Emacs Theme
Colors
;;; 彩.el --- Nasy's Emacs theme colors. -*- lexical-binding: t; -*-
;;; Commentary:
;;; Code:
;;; 正色
(defconst n-青 "#00ffff")
(defconst n-赤 "#c3272b")
(defconst n-白 "#ffffff") ;; 精白
(defconst n-黑 "#000000")
(defconst n-黄 "#fff143") ;; 不知其法而用鵝黃
;;; 間色
(defconst n-紺青 "#3f4470")
(defconst n-鴉青 "#424c50")
(defconst n-靛藍 "#065279")
(defconst n-羣青 "#2e59a7")
(defconst n-深竹月 "#2e62cd")
(defconst n-寶藍 "#4b5cc4")
(defconst n-青冥 "#3271ae")
(defconst n-靛青 "#177CB0")
(defconst n-湖藍 "#30DFF3")
(defconst n--青 "#00ffff")
(defconst n-松绿 "#057748")
(defconst n-官緑 "#2a6e3f")
(defconst n-青青 "#4f6f46")
(defconst n-蒼翠 "#519a73")
(defconst n-菉竹 "#698e6a")
(defconst n-竹靑 "#789262")
(defconst n-春辰 "#a9be7b")
(defconst n-松花 "#bce672")
(defconst n-歐碧 "#c0d695")
(defconst n-龍泉靑瓷 "#c8e6c6")
(defconst n-水緑 "#d4f2e7")
(defconst n-水黄 "#ddeec4")
(defconst n-春緑 "#e3efd1")
(defconst n-蔥青 "#edfebb")
(defconst n-絳 "#510312")
(defconst n-胭脂 "#960018")
(defconst n-綪 "#b13546")
(defconst n-品红 "#F00056")
(defconst n-朱 "#ff0000")
(defconst n-火红 "#FF2D51")
(defconst n-丹 "#ff4c00")
(defconst n-妃 "#ed5736")
(defconst n-海棠 "#DB5A6B")
(defconst n-桃红 "#f47983")
(defconst n-鳳仙粉 "#FF9393")
(defconst n-粉红 "#ffb3a7")
(defconst n-露玫瑰 "#ffe4e1")
(defconst n-墨 "#50616D")
(defconst n-蒼青 "#7397ab")
(defconst n-墨灰 "#758A99")
(defconst n-养生主 "#b49b7f")
(defconst n-茶 "#B35C44")
(defconst n-鱼肚 "#FCEFE8")
(defconst n-珈琲椶 "#705438")
(defconst n-紙棕 "#D2B38C")
(defconst n-向日黃 "#FFC34D")
(defconst n-缟 "#F2ECDE")
(defconst n-牙 "#EEDEB0")
(defconst n-米灰 "#D3CBAF")
(defconst n-芽灰 "#E3DBBF")
(defconst n-胡粉 "#FFFAE8")
(defconst n-蠟白 "#FEF8DE")
(defconst n-富春紡 "#FEF4B4")
(defconst n-鹅黄 "#FFF143")
(defconst n-嬭油 "#fffdd0")
(defconst n-鸭黄 "#FAFF72")
(defconst n-蛤粉 "#fdfff4")
(defconst n-荼 "#F3F9F1")
(defconst n-素 "#E0F0E9")
(defconst n-霜 "#E9F1F6")
(defconst n-漆 "#161823")
(defconst n-黛 "#4A4266")
(defconst n-丁香 "#CCA4E3")
(defconst n-青莲 "#801DAE")
(defconst n-淡紫丁香 "#e6cfe6")
(defconst n-水紅 "#f3d3e7")
(defconst n-長萅蕐 "#FF47D1")
(defconst n-紫扇貝 "#923A60")
(provide '彩)
;;; 彩.el ends here
Definition
(defgroup nasy-theme nil
"Options of Nasy's theme."
:group 'faces)
(defcustom nasy-theme-light/dark 'light
"Nasy theme uses light theme or dark theme?"
:group 'nasy-theme
:type 'symbol)
(defcustom nasy-theme-org-scale t
"Nasy theme uses scale up in `org-mode' or not."
:group 'nasy-theme
:type 'boolean)
(defcustom nasy-theme-underlines-list '(comment constant dash-string keyword hl-line)
"Nasy theme uses underline on list.
Should be one or more in `comment', `hl-line', `constant', `dash-string', `keyword'."
:group 'nasy-theme
:type '(list symbol))
(defcustom nasy-theme-fixed-pitch-font "Recursive Mono Casual Static"
"Nasy theme fixed pitch font."
:group 'nasy-theme
:type 'string)
(defcustom nasy-theme-variable-pitch-font "Cardo"
"Nasy theme variable pitch font."
:group 'nasy-theme
:type 'string)
(defcustom nasy-theme-variable-pitch-font-weight 'regular
"Nasy theme variable pitch font weight."
:group 'nasy-theme
:type 'symbol)
(defcustom nasy-theme-fixed-pitch-font-scale 1.0
"Nasy theme fixed pitch font scale."
:group 'nasy-theme
:type 'float)
(defcustom nasy-theme-variable-pitch-font-scale 1.3
"Nasy theme variable pitch font scale."
:group 'nasy-theme
:type 'float)
(defcustom nasy-theme-rescale-f/v-pitch-font t
"Nasy theme rescale f/v-pitch-font or not."
:group 'nasy-theme
:type 'boolean)
(defun nasy-theme--light?dark (light dark)
"Determine using the LIGHT or the DARK color of nasy-theme."
(if (eq nasy-theme-light/dark 'light)
light
dark))
(defalias '--l?d #'nasy-theme--light?dark)
(defun nasy-theme--scale? (scale)
"Determine using `org-mode' SCALE or not."
(if nasy-theme-org-scale
scale
1))
(defalias '--s? #'nasy-theme--scale?)
(defun nasy-theme--check-underline-list (sym)
"Check if SYM in `nasy-theme-underlines-list' or not."
(when (memq sym nasy-theme-underlines-list)
t))
(defalias '--u? #'nasy-theme--check-underline-list)
(defun nasy-theme--rescale-font ()
"Nasy theme rescale font."
(when nasy-theme-rescale-f/v-pitch-font
(setf (alist-get
nasy-theme-fixed-pitch-font
face-font-rescale-alist
nasy-theme-fixed-pitch-font-scale nil 'string=)
nasy-theme-fixed-pitch-font-scale)
(setf (alist-get
nasy-theme-variable-pitch-font
face-font-rescale-alist
nasy-theme-variable-pitch-font-scale nil 'string=)
nasy-theme-variable-pitch-font-scale)))
(nasy-theme--rescale-font)
Theme
(deftheme nasy)
(let* ((class '((class color) (min-colors 88) (background light)))
(classd '((class color) (min-colors 88) (background dark)))
(n/淺背景 "#f4daefb6e3b6") ;; (color-lighten-name n-缟 1.45)
(n/深背景 "#f109ea21da05") ;; (color-darken-name n-缟 1.45)
(n/深深背景 "#ef20e757d52d") ;; (color-darken-name n-缟 2.9)
(nd/淺背景 "#1667187123a5") ;; (color-lighten-name n-漆 1.45)
(nd/淺淺背景 "#16b918ca2427") ;; (color-lighten-name n-漆 2.9)
(n/丁香青莲 (--l?d n-青莲 n-青莲))
(n/墨墨灰 (--l?d n-墨 n-墨灰))
(n/墨灰墨 (--l?d n-墨灰 n-墨))
(n/墨灰素 (--l?d n-墨灰 n-素))
(n/墨缟 (--l?d n-墨 n-缟))
(n/湖藍靛青 (--l?d n-湖藍 n-靛青))
(n/漆缟 (--l?d n-漆 n-缟))
(n/牙墨 (--l?d n-牙 n-墨))
(n/牙黛 (--l?d n-牙 n-黛))
(n/素墨 (--l?d n-素 n-墨))
(n/素墨灰 (--l?d n-素 n-墨灰))
(n/缟墨 (--l?d n-缟 n-墨))
(n/缟漆 (--l?d n-缟 n-漆))
(n/缟黛 (--l?d n-缟 n-黛))
(n/霜黛 (--l?d n-霜 n-黛))
(n/青莲丁香 (--l?d n-青莲 n-丁香))
(n/青莲牙 (--l?d n-青莲 n-牙))
(n/靛青湖藍 (--l?d n-靛青 n-湖藍))
(n/黛缟 (--l?d n-黛 n-缟))
(n/黛霜 (--l?d n-黛 n-霜)))
(custom-theme-set-faces
'nasy
;;; essential styles
`(default ((,class (:foreground ,n/墨缟 :background ,n/缟漆))))
;;; Basic
`(bold ((,class (:weight bold))))
`(button ((,class (:box (:line-width 1) :underline t :weight bold))))
`(cursor ((,class (:background ,n/黛霜 :foreground ,n/霜黛))))
`(error ((,class (:background ,n-鳳仙粉 :foreground ,n-紫扇貝 :weight bold))))
`(escape-glyph ((,class (:foreground ,n-茶))))
`(fixed-pitch
((,class (:family ,nasy-theme-fixed-pitch-font))))
`(fixed-pitch-serif ((t (:inherit fixed-pitch))))
`(fringe ((,class (:background ,n/缟漆 :foreground ,n/墨缟))))
`(header-line ((,class (:background ,n-荼
:box (:line-width 2 :style released-button)
:extend t
:foreground ,n/靛青湖藍))))
`(highlight ((,class (:background ,n-米灰
:distant-foreground ,n/霜黛))))
`(internal-border ((,class (:background ,n/缟漆))))
`(link ((,class (:foreground ,n-靛青 :underline t))))
`(link-visited ((,class (:foreground ,n-青莲 :underline t))))
`(region ((,class (:background ,n-蠟白 :distant-foreground ,n/墨缟 :extend t))))
`(secondary-selection ((,class (:background ,n-芽灰))))
`(success ((,class (:background ,n-鱼肚 :foreground ,n-靛青 :weight bold))))
`(variable-pitch
((,class (:family ,nasy-theme-variable-pitch-font
:weight ,nasy-theme-variable-pitch-font-weight))))
`(warning ((,class (:background ,n-富春紡 :foreground ,n-珈琲椶 :weight bold))))
;;; centaur-tabs
`(centaur-tabs-default
((,class (:background ,n-米灰
:foreground ,n-墨))))
`(centaur-tabs-selected
((,class (:background ,n-富春紡
:foreground ,n-墨))))
`(centaur-tabs-selected-modified
((,class (:background ,n-富春紡
:foreground ,n-墨
:slant italic))))
`(centaur-tabs-unselected
((,class (:background ,n-春緑
:foreground ,n-墨灰))))
`(centaur-tabs-unselected-modified
((,class (:background ,n-水黄
:foreground ,n-墨灰
:slant italic))))
`(centaur-tabs-active-bar-face
((,class (:background ,n-墨))))
;;; company
`(company-box-scrollbar
((,class (:background ,n/黛缟
:box (:line-width 2 :style released-button)
:extend t
:foreground ,n/缟黛))))
`(company-box-selection
((,class (:inherit company-box-scrollbar))))
`(company-echo-common
((,class (:background ,n-茶 :foreground ,n-缟))))
`(company-preview-common
((,class (:background ,n-荼 :foreground ,n-墨 :slant italic :weight bold))))
`(company-scrollbar-bg
((,class (:background ,n-牙))))
`(company-scrollbar-fg
((,class (:background ,n-茶 :foreground ,n-缟))))
`(company-tooltip
((,class (:background ,n/霜黛 :foreground ,n/黛霜))))
`(company-tooltip-common
((,class (:background ,n-素 :foreground ,n-松绿 :weight bold))))
`(company-tooltip-common-selection
((,class (:background ,n/黛缟 :foreground ,n-松花 :inherit company-tooltip-common))))
`(company-tooltip-selection
((,class (:background ,n/黛缟
:box (:style released-button)
:extend t
:foreground ,n/缟黛))))
;;; counsel & ivy
`(all-the-icons-ivy-rich-icon-face
((t (:box (:line-width 2 :style released-button)
:inherit default))))
`(ivy-current-match
((,class (:background ,n/黛缟
:extend t
:foreground ,n/缟墨
:weight bold))))
`(ivy-highlight-face
((,class (:inherit counsel-active-mode))))
`(ivy-minibuffer-match-face-1
((,class (:background ,n-松花
:foreground ,n-墨
:weight bold))))
`(ivy-minibuffer-match-face-2
((,class (:background ,n-鹅黄
:foreground ,n-墨
:weight bold))))
`(ivy-minibuffer-match-face-3
((,class (:background ,n-丁香
:foreground ,n-墨
:weight bold))))
`(ivy-minibuffer-match-face-4
((,class (:background ,n-火红
:foreground ,n-墨
:weight bold))))
;;; customize faces
`(custom-button
((,class (:box (:line-width 2 :style released-button)
:foreground ,n/霜黛
:background ,n/黛霜))))
`(custom-button-mouse
((,class (:box (:line-width 2 :style released-button)
:background ,n/霜黛
:foreground ,n/黛霜))))
`(custom-button-pressed
((,class (:box (:line-width 2 :style pressed-button)
:inherit custom-button))))
`(custom-button-pressed-unraised
((,class (:foreground ,n-青莲 :inherit custom-button-unraised))))
`(custom-button-unraised
((,class (:underline t))))
`(custom-comment
((,class (:background ,n/霜黛 :foreground ,n/黛霜))))
`(custom-group-tag
((,class (:foreground ,n-靛青
:height 1.4
:slant normal
:weight bold
:inherit variable-pitch))))
`(custom-group-subtitle
((,class (:foreground ,n/墨缟
:height 1.2
:underline t
:weight bold))))
`(custom-variable-obsolete
((,class (:foreground ,n/黛霜
:strike-through t))))
`(custom-variable-tag
((,class (:foreground ,n-靛青
:slant normal
:weight bold))))
;;; dashboard
`(dashboard-heading
((,class (:inherit font-lock-string-face :underline ,(--u? 'dash-string)))))
`(widget-button
((,class (:weight unspecified))))
;;; display-fill-column-indicator-mode
`(fill-column-indicator ((,class (:background ,n-湖藍 :foreground ,n-靛青))))
;;; flycheck
`(flycheck-warning ((,class (:background ,n-牙
:underline (:style wave :color ,n-丁香)))))
;;; font-lock faces
`(font-lock-bracket-face
((,class (:foreground ,n-茶))))
`(font-lock-builtin-face
((,class (:foreground ,n-黛 :weight bold))))
`(font-lock-comment-delimiter-face
((,class (:foreground ,n-墨 :weight bold
:underline ,(--u? 'comment)))))
`(font-lock-comment-face
((,class (:foreground ,n-墨 :weight light
:slant italic
:underline ,(--u? 'comment)))))
`(font-lock-constant-face
((,class (:foreground ,n-黛
:underline ,(--u? 'constant)
:weight bold))))
`(font-lock-delimiter-face
((,class (:foreground ,n-蒼翠
:background ,n/深深背景))))
`(font-lock-doc-face
((,class (:background ,n-春緑 :foreground ,n-墨 :weight light :extend t))))
`(font-lock-doc-markup-face
((,class (:inherit font-lock-constant-face))))
`(font-lock-escape-face
((,class (:foreground ,n-丁香))))
`(font-lock-function-name-face
((,class (:background ,n/深背景 :foreground ,n-墨 :weight bold))))
`(font-lock-keyword-face
((,class (:foreground ,n-黛
:weight bold
:underline ,(--u? 'keyword)))
(,classd (:foreground ,n-缟
:weight bold
:underline ,(--u? 'keyword)))))
`(font-lock-misc-punctuation-face
((,class (:inherit font-lock-punctuation-face))))
`(font-lock-negation-char-face
((,class (:foreground ,n-珈琲椶))))
`(font-lock-number-face
((,class (:foreground ,n-深竹月))))
`(font-lock-operator-face
((,class (:foreground ,n-羣青))))
`(font-lock-preprocessor-face
((,class (:foreground ,n-紙棕 :slant italic))))
`(font-lock-property-face
((,class (:foreground ,n-靛藍 :slant italic))))
`(font-lock-punctuation-face
((,class (:foreground ,n-蔥青))))
`(font-lock-regexp-grouping-backslash
((,class (:background ,n-淡紫丁香))))
`(font-lock-regexp-grouping-construct
((,class (:background ,n-淡紫丁香))))
`(font-lock-string-face
((,class (:background ,n/淺背景 :foreground ,n-青青))))
`(font-lock-type-face
((,class (:background ,n/深深背景
:foreground ,n-墨
:slant italic
:weight bold))))
`(font-lock-variable-name-face
((,class (:foreground ,n-墨 :slant italic))))
`(font-lock-warning-face
((,class (:background ,n-鸭黄 :foreground ,n-墨 :weight bold))))
;;; highlight
;; highlight-indents-guide
`(highlight-indent-guides-even-face
((,class (:background ,n-水黄))))
`(highlight-indent-guides-odd-face
((,class (:background ,n-春緑))))
;; hl-line
`(hl-line ((,class (:underline ,(--u? 'hl-line)
;; :background ,n-芽灰
;; :distant-foreground ,n-墨
:extend t
:weight bold))))
;;; minibuffer
`(minibuffer-prompt ((,class (:foreground ,n-松绿 :weight bold
:underline t))))
;;; mode line
`(doom-modeline-battery-charging
((,class (:foreground ,n-寶藍))))
`(doom-modeline-battery-full
((,class (:foreground ,n-松绿))))
`(doom-modeline-buffer-file
((,class (:foreground ,n-墨
:weight light))))
`(doom-modeline-buffer-minor-mode
((,class (:inherit mode-line))))
`(doom-modeline-buffer-modified
((,class (:foreground ,n-火红
:inherit mode-line
:weight bold))))
`(doom-modeline-buffer-major-mode
((,class (:foreground ,n-火红 :weight light))))
`(doom-modeline-buffer-path
((,class (:foreground ,n-墨
:weight light))))
`(doom-modeline-debug
((,class (:foreground ,n-墨 :weight light))))
`(doom-modeline-info
((,class (:foreground ,n-靛青
:inherit mode-line
:weight light))))
`(doom-modeline-lsp-error
((,class (:inherit doom-modeline-urgent))))
`(doom-modeline-lsp-running
((,class (:inherit doom-modeline-warning))))
`(doom-modeline-lsp-warning
((,class (:inherit doom-modeline-warning))))
`(doom-modeline-buffer-minor-mode
((,class (:inherit mode-line :background nil))))
`(doom-modeline-project-dir
((,class (:foreground ,n-青青 :weight bold))))
`(doom-modeline-urgent
((,class (:foreground ,n-品红
:inherit mode-line
:weight bold))))
`(doom-modeline-warning
((,class (:foreground ,n-松花
:inherit mode-line
:weight bold))))
`(mode-line ((,class (:background ,n-胡粉 :weight light))))
`(mode-line-inactive ((,class (:background ,n-素 :weight light))))
;;; orderless
`(orderless-match-face-0
((,class (:background ,n-富春紡 :foreground ,n-蒼翠 :weight bold))))
`(orderless-match-face-1
((,class (:background ,n-鳳仙粉 :foreground ,n-珈琲椶 :weight bold))))
`(orderless-match-face-2
((,class (:background ,n-龍泉靑瓷 :foreground ,n-靛青 :weight bold))))
`(orderless-match-face-3
((,class (:background ,n-紙棕 :foreground ,n-松绿 :weight bold))))
;;; org mode
`(org-block
((,class (:background ,n/淺背景 :foreground ,n-墨 :extend t))
(,classd (:background ,nd/淺背景 :foreground ,n-缟 :extend t))))
`(org-block-begin-line
((,class (:background ,n-嬭油
:box (:line-width 1 :style released-button)
:extend t
:foreground ,n/墨缟
:weight bold
:slant italic))))
`(org-cite-key
((,class (:foreground ,n-松绿))
(,classd (:foreground ,n-蔥青))))
`(org-code ((,class (:background ,n-米灰
:foreground ,n-墨
:inheit fixed-pitch))))
`(org-document-title
((,class (:background ,n-富春紡
:extend t
:foreground ,n/墨缟
:height ,(--s? 1.7)
:weight bold))))
`(org-document-info
((,class (:extend nil
:foreground ,n/墨缟
:height ,(--s? 1.2)
:slant italic))))
`(org-document-info-keyword
((,class (:background ,n/素墨
:foreground ,n/墨缟
:height ,(--s? 1.2)
:slant italic))))
`(org-done
((,class (:box (:line-width 2 :style released-button)
:foreground ,n/墨缟))))
`(org-headline-done
((,class (:underline (:color ,n-松花)))))
`(org-list-dt ((,class (:height ,(--s? 1.1) :weight bold))))
`(org-meta-line
((,class (:inherit font-lock-comment-face
:underline nil))))
`(org-property-value ((,class (:foreground ,n-松绿))))
`(org-roam-link
((,class (:inherit org-link
:overline t
:underline t))))
`(org-special-keyword ((,class (:foreground ,n-深竹月))))
`(org-superstar-header-bullet ((,class (:background ,n-富春紡))))
`(org-superstar-item ((,class (:foreground ,n-靛青))))
`(org-tag
((,class (:background ,n/牙黛
:box t
:foreground ,n/墨缟
:slant normal
:underline nil
:weight bold))))
`(org-verbatim ((,class (:background ,n-春緑
:foreground ,n-墨
:inheit fixed-pitch))))
;;; Outline
;; Also the org-levels
`(outline-1
((,class (:background ,n-霜
:extend nil
:foreground ,n-靛青
:height ,(--s? 1.4)
:overline t
:weight bold))))
`(outline-2
((,class (:background ,n-露玫瑰
:extend nil
:foreground ,n-紫扇貝
:height ,(--s? 1.2)
:overline t
:weight bold))))
`(outline-3
((,class (:background ,n-春緑
:extend nil
:foreground ,n-松绿
:height ,(--s? 1.1)
:overline t
:weight bold))))
`(outline-4
((,class (:background ,n-淡紫丁香
:extend nil
:foreground ,n/青莲丁香
:height ,(--s? 1.1)
:overline t
:weight bold))))
`(outline-5
((,class (:extend t
:foreground ,n-靛青
:height ,(--s? 1.1)
:slant italic
:weight normal))))
`(outline-6
((,class (:extend t
:foreground ,n-茶
:height ,(--s? 1.1)
:slant italic
:weight normal))))
`(outline-7
((,class (:extend t
:foreground ,n-松绿
:height ,(--s? 1.1)
:slant italic
:weight normal))))
`(outline-8
((,class (:extend t
:foreground ,n/青莲丁香
:height ,(--s? 1.1)
:slant italic
:weight normal))))
;;; page break lines
`(page-break-lines
((,class (:inherit font-lock-comment-face :slant normal :underline nil))))
;;; Show parens
`(show-paren-match ((,class (:background ,n-丁香))))
`(show-paren-mismatch ((,class (:background ,n-鳳仙粉))))
;;; tab-line and tab-bar
`(tab-line ((t (:inherit mode-line))))
`(tab-line-tab ((t (:inherit mode-line))))
`(tab-line-tab-inactive ((t (:inherit mode-line-inactive))))
`(tab-line-tab-face-inactive-alternating ((t (:inherit mode-line-inactive))))
`(tab-line-tab-current ((t (:inherit mode-line :foreground ,n-富春紡))))
`(tab-line-highlight ((t (:inherit tab-line-tab))))
`(tab-bar ((t (:inherit tab-line))))
`(tab-bar-tab ((t (:inherit tab-line-tab))))
`(tab-bar-tab-inactive ((t (:inherit tab-line-tab-inactive))))
;;; term
`(term-color-black ((,class (:background ,n-墨 :foreground ,n-墨))))
`(term-color-blue ((,class (:background ,n-靛青 :foreground ,n-靛青))))
`(term-color-cyan ((,class (:background ,n-湖藍 :foreground ,n-湖藍))))
`(term-color-green ((,class (:background ,n-松绿 :foreground ,n-松绿))))
`(term-color-magenta ((,class (:background ,n-長萅蕐 :foreground ,n-長萅蕐))))
`(term-color-red ((,class (:background ,n-火红 :foreground ,n-火红))))
`(term-color-white ((,class (:background ,n-缟 :foreground ,n-缟))))
`(term-color-yellow ((,class (:background ,n-紙棕 :foreground ,n-紙棕))))
`(vterm-color-inverse-video
((,class (:background ,n-墨))))
;;; vertico
`(vertico-mouse ((,class (:background ,n-紙棕
:inherit highlight))))
;;; which-func
`(which-func ((,class (:foreground ,n-青青 :weight light))))))
;;;###autoload
(and load-file-name
(boundp 'custom-theme-load-path)
(add-to-list 'custom-theme-load-path
(file-name-as-directory
(file-name-directory load-file-name))))
(provide-theme 'nasy)
襍
Single Function to Center Emacs Window on Screen
;;;###autoload
(defun nasy/frame-recenter (&optional frame)
"Center FRAME on the screen.
FRAME can be a frame name, a terminal name, or a frame.
If FRAME is omitted or nil, use currently selected frame."
(interactive)
(unless (eq 'maximised (frame-parameter nil 'fullscreen))
(let* ((frame (or (and (boundp 'frame) frame) (selected-frame)))
(frame-w (frame-pixel-width frame))
(frame-h (frame-pixel-height frame))
;; frame-monitor-workarea returns (x y width height) for the monitor
(monitor-w (nth 2 (frame-monitor-workarea frame)))
(monitor-h (nth 3 (frame-monitor-workarea frame)))
(center (list (/ (- monitor-w frame-w) 2)
(/ (- monitor-h frame-h) 2))))
(apply 'set-frame-position (flatten-list (list frame center))))))
配置
國風・鄭風・蔓艸
埜有蔓艸、霝露漙兮
有美一人、淸揚婉兮
邂逅相遇、冟我願兮
埜有蔓艸、霝路瀼瀼
有美一人、婉如淸揚
邂逅相遇、與子偕臧
叙
吾學埶不精所述設定必有遺屚朢恕
篇者聚章而成試以詩之名名設定之篇不求其意但求其魂
設定之初也擊鼔而启
譯
譯 el 至 elc 與 eln
;;; 譯.el --- -*- lexical-binding: t; -*-
;;; Commentary:
;; 譯 el 至 elc 與 eln
;;; Code:
(require 'comp)
(setq load-prefer-newer t
native-comp-deferred-compilation nil
org-roam-v2-ack t
nasy--require nil)
(message "\n\n---------------- 下載與加載 ----------------\n\n")
(add-to-list 'load-path (locate-user-emacs-file "桃夭/擊鼓"))
(load (locate-user-emacs-file "桃夭/擊鼓/擊鼓.el"))
;; (when (and (eq system-type 'darwin) (executable-find "cargo"))
;; (shell-command (concat "make " (straight--build-dir "tsc") "tsc-dyn.dylib")))
(message "\n\n---------------- Run hooks ----------------\n\n")
(run-hooks
'after-init-hook
'emacs-startup-hook
'nasy/config-before-hook
'nasy/config-after-hook
'nasy-first-key-hook
'org-mode-hook
'org-first-key-hook
'prog-mode-hook
'pre-command-hook)
(message "\n\n---------------- Wait straight.el ----------------\n\n")
(when (native-comp-available-p)
(while (or comp-files-queue
(> (comp-async-runnings) 0))
(sleep-for 2)))
(unless (and (boundp 'nasy-first-p)
nasy-first-p)
(message "\n\n---------------- Build elc in 桃夭 ----------------\n\n")
(byte-recompile-directory (locate-user-emacs-file "桃夭/") 0 t)
(when (native-comp-available-p)
(message "\n\n---------------- Build eln in 桃夭 ----------------")
(dolist (folder '("擊鼓" "風雨" "緑衣"
"月出" "庭燎" "日月"
"麐之趾" "小曐"))
(message "\n\n---------------- Build eln of %s ----------------" folder)
(dolist (elf (directory-files-recursively
(locate-user-emacs-file (concat "桃夭/" folder)) "\\.el$"))
(native-compile elf)
(while (or comp-files-queue
(> (comp-async-runnings) 0))
(sleep-for 2))))
(while (or comp-files-queue
(> (comp-async-runnings) 0))
(sleep-for 2))))
(provide '譯)
;;; 譯.el ends here
初 early-init
(unless (boundp '*nasy*)
(load (locate-user-emacs-file"early-init.el") nil t))
開始之歬 加載之初 所用
;;; early-init.el --- Nasy's early-init.el -*- coding: utf-8; lexical-binding: t; -*-
;;; Commentary:
;; Nasy's early-init.el
;;; Code:
(setq
ad-redefinition-action 'accept
fast-but-imprecise-scrolling t
ffap-machine-p-known 'reject
gc-cons-percentage 1.0
gc-cons-threshold most-positive-fixnum
idle-update-delay 1
inhibit-compacting-font-caches t
inhibit-default-init t
inhibit-startup-message t
inhibit-startup-screen t
initial-major-mode 'fundamental-mode
load-prefer-newer t
native-comp-async-jobs-number 10
package-enable-at-startup nil
read-process-output-max #x10000
redisplay-skip-fontification-on-input t
native-comp-async-report-warnings-errors 'silent)
(setq initial-scratch-message
(concat ";; Happy hacking, "
user-login-name " - Emacs ♥ you!\n\n"))
(let ((old-file-name-handler-alist file-name-handler-alist))
(setq-default file-name-handler-alist nil)
(defun nasy/restore-default ()
"Restore gc setting to default."
(setq file-name-handler-alist
(delete-dups
(append file-name-handler-alist
old-file-name-handler-alist))
inhibit-trace nil))
(add-hook 'emacs-startup-hook #'nasy/restore-default))
(set-language-environment "UTF-8")
(setq selection-coding-system 'utf-8)
(defconst *nasy* "20221109")
(defconst *is-a-mac* (eq system-type 'darwin))
(defconst *nasy-custom* (concat (expand-file-name user-emacs-directory) "芄蘭/"))
(defconst *nasy-site* (concat (expand-file-name user-emacs-directory) "木瓜/"))
(defconst *nasy-dir* (concat (expand-file-name user-emacs-directory) "萚兮/"))
(defconst *nasy-etc* (concat *nasy-dir* "恆/"))
(defconst *nasy-var* (concat *nasy-dir* "時/"))
(when (boundp 'native-comp-eln-load-path)
(add-to-list 'native-comp-eln-load-path (concat *nasy-var* "eln/")))
(when (fboundp 'startup-redirect-eln-cache)
(startup-redirect-eln-cache
(convert-standard-filename
(concat *nasy-var* "eln/"))))
(defvar *debug* (or (getenv-internal "DEBUG") init-file-debug))
(setq inhibit-trace (not *debug*))
(defvar native-comp-deferred-compilation-deny-list nil)
(defvar nasy--require nil
"Require all packages.")
(defvar nasy-pdump nil
"Use pdump.")
(setq async-byte-compile-log-file (concat *nasy-var* "async-bytecomp.log")
debug-on-error *debug*
jka-compr-verbose *debug*)
(defvar nasy-first-key-hook nil
"The hook to run functions before press first key.")
(provide 'early-init)
;;; early-init.el ends here
擊鼓
(add-to-list 'load-path (locate-user-emacs-file "桃夭/擊鼓"))
(require '擊鼓)
國風・邶風・擊鼓
擊鼓其鏜、踊躍用兵
土國城漕、我獨南行
從孫子仲、平陳與宋
不我以歸、憂心有忡
爰居爰處、爰喪其馬
于以求之、于林之下
死生契闊、與子成說
執子之手、與子偕老
于嗟闊兮、不我活兮
于嗟洵兮、不我信兮
啓勭組件
叙
以 raxod502 之 straight.el 載入包以 setup.el.
整置文件 convenience
(with-no-warnings
(customize-set-variable
'abbrev-file-name
(concat *nasy-etc* "abbrev.el") "Customized by Nasy.")
(customize-set-variable
'auto-save-list-file-prefix
(concat *nasy-var* "auto-save/sessions/") "Customized by Nasy.")
(customize-set-variable
'auto-save-file-name-transforms
`((".*" ,(concat *nasy-var* "auto-save/") t))
"Customized by Nasy.")
(customize-set-variable
'bookmark-default-file
(concat *nasy-var* "bookmarks.el") "Customized by Nasy.")
(customize-set-variable
'dirvish-cache-dir
(concat *nasy-var* "dirvish/") "Customized by Nasy.")
(customize-set-variable
'eshell-aliases-file
(concat *nasy-etc* "eshell/aliases") "Customized by Nasy.")
(customize-set-variable
'eshell-directory-name
(concat *nasy-var* "eshell/") "Customized by Nasy.")
(customize-set-variable
'save-place-file
(concat *nasy-var* "save-place.el") "Customized by Nasy.")
(customize-set-variable
'svg-lib-icons-dir
(concat *nasy-var* "svg-lib/") "Customized by Nasy.")
(customize-set-variable
'tramp-auto-save-directory
(concat *nasy-var* "tramp/auto-save/") "Customized by Nasy.")
(customize-set-variable
'tramp-persistency-file-name
(concat *nasy-var* "tramp/persistency.el") "Customized by Nasy.")
(customize-set-variable
'url-cache-directory
(concat *nasy-var* "url/cache/") "Customized by Nasy.")
(customize-set-variable
'url-configuration-directory
(concat *nasy-var* "url/configuration/") "Customized by Nasy."))
straight
(setq-default straight-vc-git-default-clone-depth 1
straight-repository-branch "develop"
straight-enable-use-package-integration nil
straight-enable-package-integration nil
straight-check-for-modifications nil
straight-fix-flycheck t)
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 6))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(defun nasy/-s-u-p (package)
"Handle special PACKAGE var."
(if (boundp package)
(when (eval package)
(straight-use-package (eval package)))
(straight-use-package package)))
(defun nasy/sup (&rest packages-sets)
"Straight use multiple PACKAGES-SETS."
(cl-loop for packages-set in packages-sets
when (not (null packages-set))
do
(cl-loop for package in packages-set
do
(cond ((symbolp package)
(nasy/-s-u-p package))
((listp package)
(dolist (p package)
(nasy/-s-u-p p)))
(t (error "???"))))))
(defmacro sup (package &optional req)
"Straight use PACKAGE and or require it if REQ."
(when (and (listp package) (or (eq '\` (car package))
(eq 'quote (car package))))
(setq package (eval package)))
(let ((pkg (if (symbolp package) package (car package)))
bs)
(push `(straight-use-package ',package) bs)
(when (eval req)
(if (eq (eval req) t)
(push `(require ',pkg) bs)
(push `(require ,req) bs)))
(macroexp-progn (nreverse bs))))
Elpaca
https://github.com/progfolio/elpaca
Elpaca is an elisp package manager. It allows users to find, install, update, and remove third-party packages for Emacs. It is a replacement for the built-in Emacs package manager, package.el.
;; (eval-and-compile
;; (declare-function elpaca-generate-autoloads "elpaca")
;; (defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory))
;; (defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory))
;; (when-let ((elpaca-repo (expand-file-name "repos/elpaca/" elpaca-directory))
;; (elpaca-build (expand-file-name "elpaca/" elpaca-builds-directory))
;; (elpaca-target (if (file-exists-p elpaca-build) elpaca-build elpaca-repo))
;; (elpaca-url "https://www.github.com/progfolio/elpaca.git")
;; ((add-to-list 'load-path elpaca-target))
;; ((not (file-exists-p elpaca-repo)))
;; (buffer (get-buffer-create "*elpaca-bootstrap*")))
;; (condition-case-unless-debug err
;; (progn
;; (unless (zerop (call-process "git" nil buffer t "clone" elpaca-url elpaca-repo))
;; (error "%s" (list (with-current-buffer buffer (buffer-string)))))
;; (byte-recompile-directory elpaca-repo 0 'force)
;; (require 'elpaca)
;; (elpaca-generate-autoloads "elpaca" elpaca-repo)
;; (kill-buffer buffer))
;; ((error)
;; (delete-directory elpaca-directory 'recursive)
;; (with-current-buffer buffer
;; (goto-char (point-max))
;; (insert (format "\n%S" err))
;; (display-buffer buffer)))))
;; (require 'elpaca-autoloads)
;; (add-hook 'after-init-hook #'elpaca-process-queues)
;; (elpaca (elpaca :host github :repo "progfolio/elpaca")))
餘
(defun nasy/-package-filter (name &rest _)
"Ignore package NAME if *no-packages* is t."
(let ((sym (intern (format "*no-%s*" name))))
(if (and (boundp sym) sym)
(progn
(message "Ignore package: %s" name)
nil)
t)))
Leaf
;; (eval-and-compile
;; (setq leaf-defaults '(:leaf-autoload nil :leaf-defun nil :leaf-defer t))
;; (leaf-keywords-init))
;; (advice-add 'leaf :before-while #'nasy/-package-filter)
use-package
;; (eval-when-compile
;; (require 'use-package)
;; (require 'bind-key)
;; (defalias 'use-package-normalize/:doc 'use-package-normalize-test)
;; (defun use-package-handler/:doc (name keyword _ rest state)
;; (use-package-process-keywords name rest state))
;; (defalias 'use-package-normalize/:tag #'(lambda (&rest _) nil))
;; (defalias 'use-package-handler/:tag 'use-package-handler/:doc)
;; (defalias 'use-package-normalize/:url 'use-package-normalize-test)
;; (defalias 'use-package-handler/:url 'use-package-handler/:doc)
;; (add-to-list 'use-package-keywords :doc)
;; (add-to-list 'use-package-keywords :tag)
;; (add-to-list 'use-package-keywords :url)
;; (unintern "use-package-autoloads/:hook" nil)
;; (unintern "use-package-autoloads/:bind" nil)
;; (advice-add 'use-package :before-while #'nasy/-package-filter))
;; (customize-set-variable 'use-package-always-defer t "Customized by Nasy.")
Setup EL
setup.el
provides a macro to ease repetitive configuration patterns in Emacs. This is done by providing context sensitive local macros, that expand to regular, pure EmacsLisp.
The package is available on GnuELPA and is currently maintained by PhilipKaludercic on SourceHut: https://git.sr.ht/~pkal/setup.
Documentation is available at https://www.emacswiki.org/emacs/SetupEl
(sup 'setup)
(require 'setup)
(setup-define :doc
(lambda (&rest _) nil)
:documentation "The one line doc for the setup package.")
(setup-define :tag
(lambda (&rest _) nil)
:documentation "The one line doc for the setup package.")
(setup-define :url
(lambda (&rest _) nil)
:documentation "The one line doc for the setup package.")
(setup-define :sup
(lambda (name) `(sup ',name))
:documentation "Customize variables."
:debug '(sexp)
:repeatable t)
(setup-define :opt
(lambda (name val) `(customize-set-variable ',name ,val "Customized by Nasy."))
:documentation "Customize variables."
:after-loaded t
:repeatable t)
(setup-define :opt*
(lambda (name val) `(customize-set-variable ',name ,val "Customized by Nasy."))
:documentation "Customize variables."
:debug '(sexp form)
:repeatable t)
(setup-define :opts
(lambda (nsv)
(let ((names (car nsv))
(val (cdr nsv))
bs)
(dolist (name (if (listp names) names (list names)))
(push `(customize-set-variable ',name ,val "Customized by Nasy.") bs))
(macroexp-progn (nreverse bs))))
:documentation "Customize variables."
:after-loaded t
:repeatable t)
(setup-define :opts*
(lambda (nsv)
(let ((names (car nsv))
(val (cdr nsv))
bs)
(dolist (name (if (listp names) names (list names)))
(push `(customize-set-variable ',name ,val "Customized by Nasy.") bs))
(macroexp-progn (nreverse bs))))
:documentation "Customize variables."
:repeatable t)
(setup-define :custom
(lambda (name val) `(customize-set-variable ',name ,val "Customized by Nasy."))
:documentation "Customize variables."
:debug '(sexp form)
:after-loaded t
:repeatable t)
(setup-define :customs
(lambda (nsv)
(let ((names (car nsv))
(val (cdr nsv))
bs)
(dolist (name (if (listp names) names (list names)))
(push `(customize-set-variable ',name ,val "Customized by Nasy.") bs))
(macroexp-progn (nreverse bs))))
:documentation "Customize variables."
:repeatable t)
(setup-define :customs*
(lambda (names val)
(let (bs)
(dolist (name names)
(push `(customize-set-variable ',name ,val "Customized by Nasy.") bs))
(macroexp-progn (nreverse bs))))
:documentation "Customize variables."
:repeatable t)
(setup-define :hooks
(lambda (hook func)
`(add-hook ',hook #',func))
:documentation "Add pairs of hooks."
:repeatable t)
(setup-define :init
(lambda (&rest body) (macroexp-progn body))
:documentation "Init keywords like use-package and leaf.")
(setup-define :load-after
(lambda (&rest features)
(let ((body `(require ',(setup-get 'feature))))
(dolist (feature (nreverse features))
(setq body `(with-eval-after-load ',feature ,body)))
body))
:documentation "Load the current feature after FEATURES.")
(setup-define :load-first
(lambda (&rest features)
`(:first-key*
(:load-after ,@features))))
(setup-define :after
(lambda (feature &rest body)
`(with-eval-after-load ',feature ,@body))
:documentation "Eval BODY after FEATURE."
:after-loaded t
:indent 1)
(setup-define :after*
(lambda (feature &rest body)
`(with-eval-after-load ',feature ,@body))
:documentation "Eval BODY after FEATURE."
:indent 1)
(setup-define :quit
#'setup-quit
:documentation "Unconditionally abort the evaluation of the current body.")
(setup-define :first-key
(lambda (name) `(add-hook 'nasy-first-key-hook #',name))
:documentation "Add to `nasy-first-key-hook'."
:repeatable t)
(setup-define :first-key*
(lambda (&rest body) `(add-hook 'nasy-first-key-hook #'(lambda () (progn ,@body))))
:documentation "Add to `nasy-first-key-hook'.")
(setup-define :first-org
(lambda (name) `(add-hook 'nasy-org-first-key-hook #',name))
:documentation "Add to `nasy-first-key-hook'."
:repeatable t)
(setup-define :first-org*
(lambda (&rest body) `(add-hook 'nasy-org-first-key-hook #'(lambda () (progn ,@body))))
:documentation "Add to `nasy-first-key-hook'.")
(setup-define :advice
(lambda (symbol where function)
`(advice-add ',symbol ,where ,function))
:documentation "Add a piece of advice on a function.
See `advice-add' for more details."
:after-loaded t
:debug '(sexp sexp function-form)
:ensure '(nil nil func)
:repeatable t)
(setup-define :mode-hook
(lambda (&rest body)
`(add-hook ',(setup-get 'hook) #'(lambda () (progn ,@body))))
:documentation "Add to the mode hook.")
(setup-define :autoload
(lambda (func)
(let ((fn (if (memq (car-safe func) '(quote function))
(cadr func)
func)))
`(unless (fboundp (quote ,fn))
(autoload (function ,fn) ,(symbol-name (setup-get 'feature)) nil t))))
:documentation "Autoload COMMAND if not already bound."
:repeatable t
:signature '(FUNC ...))
(advice-add 'setup :before-while #'nasy/-package-filter)
包之墬阯 load-path
以 straight
載入本墬包即可。
;; (defmacro nasy/local-repo (repo &rest body)
;; "Nasy load local REPO."
;; (let ((n-repo (symbol-name repo)))
;; `(sup
;; '(,(intern n-repo)
;; ,@body
;; :build nil
;; :local-repo ,(expand-file-name
;; (format "桃夭/%s" (symbol-name repo))
;; user-emacs-directory)))))
(defmacro nasy/config-path (config)
"Nasy CONFIG path."
(locate-user-emacs-file
(format "桃夭/%s" (symbol-name config))))
(defmacro nasy/extra-repo (repo &optional path &rest body)
"Nasy extra local site-lisp REPO."
(let ((path (or path (symbol-name repo))))
`(sup
'(,repo
,@body
:local-repo ,(locate-user-emacs-file
(format "木瓜/%s" path))))))
(defmacro nasy/-repo (repo &rest body)
"Nasy extra local site-lisp REPO."
(let ((path (symbol-name repo)))
`(sup
'(,repo
,@body
:local-repo ,(locate-user-emacs-file
(format "木瓜/nasy/%s" path))))))
melpa/elpa 之外
(straight-register-package
'(keytar :type git
:host github
:repo "emacs-grammarly/keytar"))
(straight-register-package
'(point-history :type git
:host github
:repo "blue0513/point-history"))
(straight-register-package
'(vundo :type git
:host github
:repo "casouri/vundo"))
載入
;; (sup '(org :type git
;; :repo "https://git.tecosaur.net/tec/org-mode.git"
;; :branch "dev"))
(sup 'org)
(sup 'org-contrib)
(sup 'gcmh)
自定義
例子~芄蘭之例~、个人配置~芄蘭~與自定義~custom-file~
肰定義 custom-file
于此並無載入之意苟欲載入置 (load custom-file)
于个人配置 芄蘭
之內。
(add-to-list 'load-path *nasy-custom*)
(require '芄蘭)
自定義例
;; (leaf custom-settings
;; :custom
;; ;; (calendar-latitude . 24.8801)
;; ;; (calendar-longitude . 102.8329)
;; ;; (user-mail-address . "[email protected]")
;; ;; (initial-buffer-choice . #'(lambda () (get-buffer "*dashboard*")))
;; ;; (diary-file . ~/dairy/emacs-dairy)
;; (*debug* . nil)
;; (*theme* . 'nasy))
;; (leaf disabled-packages
;; :custom
;; ((*no-eldoc-overlay*
;; *no-highlight-indent-guides*
;; *no-indent-tools*
;; *no-point-history*
;; *no-tree-sitter-indent*)
;; . t))
(setup custom-settings
(:opt* *debug* nil
*theme* 'nasy))
(setup disabled-packages
(:opts*
((*no-eldoc-overlay*
*no-highlight-indent-guides*
*no-indent-tools*
*no-point-history*
*no-tree-sitter-indent*)
. t)))
(provide '芄蘭之例)
包
(eval-and-compile
(message "載包: %s" (if nasy--require
"是"
"否"))
(sup 'org nasy--require)
;; (sup '(org :type git
;; :repo "https://git.tecosaur.net/tec/org-mode.git"
;; :branch "dev"))
(sup 'org-contrib nasy--require)
(sup 'gcmh nasy--require)
(sup 'setup nasy--require)
;; 風雨
(sup 'beacon nasy--require)
(sup 'expand-region nasy--require)
(sup 'flycheck nasy--require)
(sup 'treemacs nasy--require)
(sup 'avy nasy--require)
(sup 'beacon nasy--require)
(sup 'dashboard nasy--require)
(sup 'doom-modeline nasy--require)
(sup 'flycheck nasy--require)
(sup 'ibuffer nasy--require)
(sup 'projectile nasy--require)
(sup 'smartparens nasy--require)
(sup `(彩 :local-repo ,(concat *nasy-site* "nasy/nasy-theme")
:files ("彩.el"))
nasy--require)
;; 緑衣
(sup 'alert nasy--require)
(sup 'all-the-icons-completion nasy--require)
(sup 'anzu nasy--require)
(sup 'avy nasy--require)
(sup 'beginend nasy--require)
(sup 'cape nasy--require)
(sup 'company nasy--require)
(sup 'consult nasy--require)
(sup 'consult-dir nasy--require)
(sup 'consult-flycheck nasy--require)
(sup '(copilot :host github :repo "zerolfx/copilot.el"
:files ("dist" "copilot.el"))
nasy--require)
(sup 'corfu nasy--require)
(sup `(corfu-extensions
:local-repo ,(concat (straight--repos-dir "corfu") "extensions"))
nasy--require)
(sup 'easy-kill nasy--require)
(sup 'elisp-demos nasy--require)
(sup 'embark-consult nasy--require)
(sup 'embark nasy--require)
(sup 'flycheck nasy--require)
(sup 'helpful nasy--require)
(sup 'keyfreq nasy--require)
(sup 'marginalia nasy--require)
(sup 'orderless nasy--require)
(sup 'page-break-lines nasy--require)
(sup 'projectile nasy--require)
(sup '(emacs-session
:repo "https://git.sr.ht/~nasy/emacs-session"
:type git
:host nil)
nasy--require)
(sup 'savehist nasy--require)
(sup 'spatial-navigate nasy--require)
(sup 'sudo-edit nasy--require)
(sup 'switch-window nasy--require)
(sup 'transient nasy--require)
(sup 'treesit-auto nasy--require)
(sup 'unfill nasy--require)
(sup 'valign nasy--require)
(sup '(vertico :files (:defaults "extensions/*")) nasy--require)
(sup 'vlf nasy--require)
(sup 'wgrep nasy--require)
(sup 'which-key nasy--require)
(sup 'whitespace-cleanup-mode nasy--require)
;; 月出
(sup 'abridge-diff nasy--require)
(sup 'ansi-color nasy--require)
(sup 'async nasy--require)
(sup 'beacon nasy--require)
(sup 'beacon nasy--require)
(sup 'color-identifiers-mode nasy--require)
(sup 'corfu nasy--require)
(sup 'default-text-scale nasy--require)
(sup 'diff-hl nasy--require)
(sup 'dired-collapse nasy--require)
(sup 'dired-filter nasy--require)
(sup 'dired-hacks nasy--require)
(sup 'dired-narrow nasy--require)
(sup 'dired-rainbow nasy--require)
(sup 'dirvish nasy--require)
(sup 'eldoc-box nasy--require)
(sup 'eldoc-box nasy--require)
(sup 'eldoc-overlay nasy--require)
(sup 'expand-region nasy--require)
(sup 'f nasy--require)
(sup 'find-file-in-project nasy--require)
(sup 'ftable nasy--require)
(sup 'git-gutter nasy--require)
(sup 'highlight-indent-guides nasy--require)
(sup 'highlight-tail nasy--require)
(sup 'imenu-list nasy--require)
(sup 'kind-icon nasy--require)
(sup 'license-snippets nasy--require)
(sup 'mixed-pitch nasy--require)
(sup 'mmm-mode nasy--require)
(sup 'multiple-cursors nasy--require)
(sup 'pcre2el nasy--require)
(sup 'persistent-scratch nasy--require)
(sup 'point-history nasy--require)
(sup 'rainbow-delimiters nasy--require)
(sup 'rainbow-mode nasy--require)
(sup 'shellcop nasy--require)
(sup 'smartparens nasy--require)
(sup 'symbol-overlay nasy--require)
(sup 'treemacs nasy--require)
;; (sup 'treemacs-icons-dired nasy--require)
(sup 'treemacs-magit nasy--require)
(sup 'treemacs-projectile nasy--require)
(sup 'undo-propose nasy--require)
(sup 'visual-fill-column nasy--require)
(sup 'vundo nasy--require)
(sup 'which-key nasy--require)
(sup 'winum nasy--require)
(sup 'writeroom-mode nasy--require)
(sup 'yasnippet nasy--require)
(sup 'yasnippet-snippets nasy--require)
;; (sup 'tsc nasy--require)
;; (sup 'tree-sitter nasy--require)
;; (sup 'tree-sitter-indent nasy--require)
;; (sup 'tree-sitter-langs nasy--require)
;; (sup '(ts-fold :type git :host github :repo "jcs090218/ts-fold") nasy--require)
;; 庭燎
(sup 'all-the-icons nasy--require)
(sup 'consult nasy--require)
(sup 'dash nasy--require)
(sup 'projectile nasy--require)
(sup 'cal-china-x nasy--require)
(sup 'centaur-tabs nasy--require)
(sup 'dashboard nasy--require)
(sup 'doom-themes nasy--require)
(sup 'pretty-mode nasy--require)
(sup 'nyan-mode nasy--require)
(sup 'minions nasy--require)
(sup 'doom-modeline nasy--require)
(sup `(nasy-theme :local-repo ,(concat *nasy-site* "nasy/nasy-theme")) nasy--require)
;; 日月
(sup 'alert nasy--require)
(sup 'carbon-now-sh nasy--require)
(sup 'cheat-sh nasy--require)
(sup 'rime nasy--require)
(sup 'esup nasy--require)
(sup 'explain-pause-mode nasy--require)
(sup 'gptel nasy--require)
(sup 'grab-mac-link nasy--require)
(sup 'htmlize nasy--require)
(sup 'indent-tools nasy--require)
(sup 'list-unicode-display nasy--require)
(sup 'magit nasy--require)
(sup 'forge nasy--require)
(sup 'magit-delta nasy--require)
(sup 'magit-org-todos nasy--require)
(sup 'magit-todos nasy--require)
;; (sup
;; '(mind-wave :type git :host github :repo "manateelazycat/mind-wave"
;; :files ("*.el" "*.py"))
;; nasy--require)
(sup '(openai :type git :host github :repo "emacs-openai/openai"))
(sup '(nasy-emacs-ai :type git :host github :repo "nasyxx/nasy-emacs-ai")
nasy--require)
(sup 'pdf-tools nasy--require)
(sup 'prettier nasy--require)
(sup 'request nasy--require)
(sup 'svg-clock nasy--require)
(with-no-warnings
(setq vterm-always-compile-module t))
(sup 'vterm nasy--require)
(sup '(vterm-toggle :build (:not native-compile)) nasy--require)
(sup 'wakatime-mode nasy--require)
;; 麐之趾
(sup 'cdlatex nasy--require)
(sup 'reformatter nasy--require)
(sup `(bibtex-tidy :local-repo ,(concat *nasy-site* "nasy/bibtex-tidy-mode"))
nasy--require)
(sup 'lsp-mode nasy--require)
(sup 'lsp-ui nasy--require)
(sup 'lsp-treemacs nasy--require)
(sup `(flex-mode :local-repo ,(concat *nasy-site* "villadora")) nasy--require)
(sup 'haskell-mode nasy--require)
(sup 'lsp-haskell nasy--require)
(sup 'dap-mode nasy--require)
(sup 'elisp-def nasy--require)
(sup 'highlight-quoted nasy--require)
(sup '(ipretty :type git :repo "https://framagit.org/steckerhalter/ipretty.git")
nasy--require)
(sup 'macrostep nasy--require)
(with-no-warnings
(setq parinfer-rust-auto-download nil
parinfer-rust-library
(concat *nasy-var* "parinfer-rust/parinfer-rust-darwin.so")))
(sup 'parinfer-rust-mode nasy--require)
(sup `(tex-site
:type git :host nil
:repo "https://git.savannah.gnu.org/git/auctex.git"
:pre-build ,(pcase system-type
(`berkeley-unix '("gmake"))
(_ '( ;; also for macos
`("bash" "-c" "cd" ,(straight--repos-dir "auctex"))
("./autogen.sh")
("./configure" "--without-texmf-dir" "--with-lispdir=.")
("gmake")))))
nasy--require)
(sup 'markdown-mode nasy--require)
(sup 'nix-mode nasy--require)
(sup '(nushell-mode :type git :host github :repo "azzamsa/emacs-nushell"))
(sup 'citeproc nasy--require)
(sup
'(org-ai :type git :host github :repo "rksm/org-ai"
:local-repo "org-ai"
:files ("*.el" "README.md" "snippets"))
nasy--require)
(sup 'org-appear nasy--require)
(sup 'org-fragtog nasy--require)
(sup 'org-latex-impatient nasy--require)
(sup 'org-modern nasy--require)
(sup '(org-rainbow-tags :host github :repo "KaratasFurkan/org-rainbow-tags")
nasy--require)
(sup 'org-roam nasy--require)
(sup 'elpy nasy--require)
(sup 'python-black nasy--require)
(sup 'lsp-pyright nasy--require)
(sup `(python-isort :local-repo ,(concat *nasy-site* "nasy/python-isort"))
nasy--require)
(sup 'restclient nasy--require)
(sup 'company-restclient nasy--require)
(sup 'ob-restclient nasy--require)
(sup 'yaml-mode nasy--require)
(sup 'ob-elvish nasy--require)
(sup 'elvish-mode nasy--require)
;; (sup 'toml-mode nasy--require)
;; 小曐
(sup 'git-blamed nasy--require)
(sup 'git-messenger nasy--require)
(sup 'git-modes nasy--require)
(sup 'git-timemachine nasy--require)
(sup 'wgrep nasy--require)
(sup 'rg nasy--require)
(sup 'company-dict nasy--require)
(sup 'company-math nasy--require)
(sup 'flycheck-package nasy--require)
(sup 'ibuffer-vc nasy--require)
(sup 'all-the-icons-ibuffer nasy--require)
(sup 'nix-buffer nasy--require)
(sup 'nix-update nasy--require)
(sup 'nixpkgs-fmt nasy--require)
(sup 'thingopt nasy--require)
(sup 'haskell-snippets nasy--require))
風雨
(add-to-list 'load-path (locate-user-emacs-file "桃夭/風雨"))
(require '風雨)
(add-hook #'nasy-first-key-hook #'(lambda () (require '風雨時用)))
風雨淒淒、雞鳴喈喈
既見君子、云胡不夷
風雨瀟瀟、雞鳴膠膠
既見君子、云胡不瘳
風雨如晦、雞鳴不已
既見君子、云胡不喜
函數與宏定製其文宜其用之
恆用之
元
(defvar nasy/config-before-hook nil
"Hook to run config functions before load custom.el.")
(defvar nasy/config-after-hook nil
"Hook to run config functions after load custom.el.")
(add-hook 'nasy/config-after-hook
#'(lambda () (message "Hi~ Hope you have fun with this config.")))
(defvar nasy--defer-loads nil
"Nasy defer load packages.")
(defvar nasy--defer-load-hook nil
"Nasy defer load hook.")
函數
(defun nasy/change-char-width (char width)
"Change CHAR width to WIDTH."
(let ((table (make-char-table nil)))
(set-char-table-parent table char-width-table)
(set-char-table-range table char width)
(setq char-width-table table)))
;;;###autoload
(defun nasy/enlist (exp)
"Return EXP wrapped in a list, or as-is if already a list."
(declare (pure t) (side-effect-free t))
(if (listp exp) exp (list exp)))
(defun nasy/run-hook-once-on (hook on-hook)
"Run HOOK on ON-HOOK once."
(let ((fn (intern (format "nasy-once-hook--%s-on-%s" hook on-hook)))
(hook* hook))
(fset
fn
(lambda (&rest _)
(run-hooks hook*)
(set hook* nil)))
(add-hook on-hook fn)))
(defun nasy/defer-load ()
(nasy/sup nasy--defer-loads)
(run-hooks 'nasy--defer-load-hook))
(add-hook 'nasy-first-key-hook #'nasy/defer-load -1)
;;;###autoload
(defun stop-minimizing-window ()
"Stop minimizing window under macOS."
(interactive)
(unless (and *is-a-mac*
window-system)
(suspend-frame)))
宏
(cl-eval-when (compile eval load)
(if (fboundp 'with-eval-after-load)
(defalias 'after-x 'with-eval-after-load)
(defmacro after-x (feature &rest body)
"Eval BODY afetr FEATURE have loaded."
(declare (indent defun))
`(eval-after-load ,feature
'(progn ,@body)))))
字体
(defvar nasy/font-change-hook nil
"Hooks to run after font changed.")
(defvar nasy--cus-font nil)
(defvar nasy--set-font nil)
(defun nasy/-set-font (&rest _)
"Font."
(setq nasy--set-font t)
(setup nasy-font
(:doc "字軆初值")
(:opt*
*font-main-family* "MonoLisa Nasy"
*font-symbol-family* "SF Pro"
*font-cjk-family* "STFLGQKJF"
*font-cjk-2-family* "FZLiuGongQuanKaiShuJF"
;; I.Ngaan' font from `http://founder.acgvlyric.org/iu/doku.php/造字:開源字型_i.顏體'.
*font-cjk-3-family* "I.Ngaan"
*font-cjk-4-family* "Kaiti SC"
*font-cjk-5-family* "Kaiti TC"
*font-math-family* "Euler Math")
(:opts*
((*font-mode-line-family*
*font-header-line-family*
*font-tab-line-family*)
. "Recursive Mono Casual Static"))
(:opt*
*font-main-size* 14
*font-mode-line-size* 14
*font-tab-line-size* 13
*font-symbol-size* 17
*font-header-line-size* 12
*font-main-weight* 'medium)
(:opts*
((*font-cjk-size*
*font-cjk-2-size*
*font-cjk-3-size*
*font-cjk-4-size*
*font-cjk-5-size*)
. nil)
((*font-cjk-scale*
*font-cjk-2-scale*
*font-cjk-3-scale*
*font-cjk-4-scale*
*font-cjk-5-scale*)
. 1.3)
((*font-symbol-weight*
;; *font-cjk-4-weight*
;; *font-cjk-5-weight*
*font-mode-line-weight*
*font-tab-line-weight*
*font-header-line-weight*
*font-cjk-weight*
*font-cjk-2-weight*
*font-cjk-3-weight*)
. 'normal)
((*font-cjk-4-weight*
*font-cjk-5-weight*)
. 'bold)))
(require '芄蘭 nil t))
(cl-eval-when (compile eval load)
(defun nasy/-font-doc (cname ftype)
"Generate font custome variable doc with CNAME and FTYPE."
(concat "The " cname " font " ftype ".
After change it, run `M-x nasy/set-font' to see the effect."))
(defun nasy/-cus-font ()
"Defcustom some fonts."
(setq nasy--cus-font t)
(dolist (cname '("main" "symbol" "cjk" "mode-line" "tab-line" "header-line"))
(cl-loop for ftype in '("family" "weight" "size" "scale")
for type = (cond ((string= "family" ftype) 'string)
((string= "weight" ftype) 'symbol)
((string= "size" ftype) 'float)
((string= "scale" ftype) 'float)
(t (error "Wrong Font Type")))
for doc = (nasy/-font-doc cname ftype)
for name = (intern (format "*font-%s-%s*" cname ftype))
do
(progn
(custom-declare-variable name nil doc :group 'nasy-font :type type)
(when (string= "cjk" cname)
(cl-loop for sfxn in '(2 3 4 5)
for cname_ = (format "%s-%d" cname sfxn)
for name_ = (intern (format "*font-%s-%s*" cname_ ftype))
for doc_ = (nasy/-font-doc cname_ ftype)
do
(progn
(custom-declare-variable name_ nil doc_
:group 'nasy-font
:type type)))))))))
(cl-eval-when (compile)
(nasy/-cus-font)
(nasy/-set-font))
(defun nasy/check-font (font)
"Check if FONT avaliable."
(if (find-font (font-spec :family font))
t
(message (format "`%s' font not find" font))))
(defun nasy/set-default-font (charset &optional size frame)
"Set CHARSET fontset to default *font-main* with SIZE on FRAME."
(when (and (display-graphic-p)
(nasy/check-font *font-main-family*))
(let ((size (or size *font-main-size*)))
(set-fontset-font t
charset
(font-spec :family *font-main-family*
:weight *font-main-weight*
:size size)
frame
'prepend))))
(defun nasy/set-hanamin (charset &optional size frame)
"Set CHARSET fontset to HanaMin with SIZE on FRAME.
https://github.com/cjkvi/HanaMinAFDKO/releases
Font for char like 𨉚."
(when (display-graphic-p)
(let ((size (or size *font-cjk-size*)))
(when (nasy/check-font "HanaMinB")
(set-fontset-font (frame-parameter nil 'font)
charset
(font-spec :family "HanaMinB"
:weight 'normal
:size size)
frame
'prepend))
(when (nasy/check-font "HanaMinA")
(set-fontset-font (frame-parameter nil 'font)
charset
(font-spec :family "HanaMinA"
:weight 'normal
:size size)
frame
'prepend))
(setf (alist-get ".*HanaMinA.*" face-font-rescale-alist *font-cjk-scale* nil 'string=)
*font-cjk-scale*)
(setf (alist-get ".*HanaMinB.*" face-font-rescale-alist *font-cjk-scale* nil 'string=)
*font-cjk-scale*)
(cl-loop for sfx in (reverse '("A" "B" "C" "Ex A1" "Ex A2" "Ex B" "Ex C" "I"))
for hfont = (concat "Hanazono Mincho " sfx)
do
(progn
(when (nasy/check-font hfont)
(set-fontset-font (frame-parameter nil 'font)
charset
(font-spec :family hfont
:weight 'normal
:size size)
frame
'prepend))
(setf (alist-get (format ".*%s.*" hfont)
face-font-rescale-alist
*font-cjk-scale*
nil
'string=)
*font-cjk-scale*))))))
(defun nasy/set-symbol (charset &optional size weight frame)
"Set CHARSET fontset to Symbol with SIZE with WEIGHT on FRAME.
Font for char like ∷."
(when (display-graphic-p)
(let ((size (or size *font-symbol-size*)))
(when (nasy/check-font *font-symbol-family*)
(set-fontset-font (frame-parameter nil 'font)
charset
(font-spec :family *font-symbol-family*
:weight weight
:size size)
frame
'prepend)))))
(defun nasy/set-apple-symbol (charset &optional frame)
"Set CHARSET fontset to Apple Color Emoji with SIZE with WEIGHT on FRAME.
Font for char like ∷."
(when (display-graphic-p)
(when (nasy/check-font "SF Pro")
(set-fontset-font (frame-parameter nil 'font)
charset
(font-spec :family "SF Pro")
frame
'prepend))))
(defun nasy/-set--font (frame)
"Nasy set font for `FRAME'."
(unless nasy--cus-font
(nasy/-cus-font))
(unless nasy--set-font
(nasy/-set-font))
(when (display-graphic-p)
;; default
(when (nasy/check-font *font-main-family*)
(set-face-attribute
'default nil
:font (font-spec :family *font-main-family*
:weight *font-main-weight*
:size *font-main-size*)))
;; 中文
(dolist (charset '(kana han cjk-misc bopomofo))
(progn
(nasy/set-hanamin charset)
(cl-loop for fn in (reverse '("" "-2" "-3" "-4" "-5"))
for fpf = (format "*font-cjk%s" fn)
for ff = (eval (intern (concat fpf "-family*")))
for fw = (eval (intern (concat fpf "-weight*")))
for fs = (eval (intern (concat fpf "-size*")))
for fss = (eval (intern (concat fpf "-scale*")))
do
(progn
(when (nasy/check-font ff)
(set-fontset-font (frame-parameter nil 'font)
charset
(font-spec :family ff
:weight fw)
;; :size fs)
frame
'prepend))
(let ((ffn (concat ".*" ff ".*")))
(setf (alist-get ffn face-font-rescale-alist fss nil 'string=) fss))))))
(when (and *is-a-mac*
(nasy/check-font "SF Pro"))
;; For NS/Cocoa
(set-fontset-font (frame-parameter nil 'font)
'symbol
(font-spec :family "SF Pro")
frame
'prepend))
(when (nasy/check-font *font-symbol-family*)
(set-fontset-font (frame-parameter nil 'font)
'symbol
(font-spec :family *font-symbol-family*
:weight *font-symbol-weight*
:size *font-symbol-size*)
frame
'append)
(set-fontset-font (frame-parameter nil 'font)
'unicode
(font-spec :family *font-symbol-family*
:weight *font-symbol-weight*
:size *font-symbol-size*)
frame
'append))
(when (nasy/check-font "Apple Color Emoji")
(set-fontset-font (frame-parameter nil 'font)
'symbol
(font-spec :family "Apple Color Emoji")
frame
'append)
(set-fontset-font (frame-parameter nil 'font)
'unicode
(font-spec :family "Apple Color Emoji")
frame
'append))
(when (nasy/check-font *font-math-family*)
(set-fontset-font (frame-parameter nil 'font)
(cons #x1D400 #x1D7FF)
(font-spec :family *font-math-family*)
frame
'prepend)
(set-fontset-font (frame-parameter nil 'font)
(cons #x2100 #x214f)
(font-spec :family *font-math-family*)
frame
'prepend))
(when (nasy/check-font *font-mode-line-family*)
(set-face-attribute 'mode-line nil
:font (font-spec :family *font-mode-line-family*
:weight *font-mode-line-weight*
:size *font-mode-line-size*))
(set-face-attribute 'mode-line-inactive nil
:font (font-spec :family *font-mode-line-family*
:weight *font-mode-line-weight*
:size *font-mode-line-size*)))
(when (nasy/check-font *font-tab-line-family*)
(set-face-attribute 'tab-line nil
:font (font-spec :family *font-tab-line-family*
:weight *font-tab-line-weight*
:size *font-tab-line-size*)))
(when (nasy/check-font *font-header-line-family*)
(set-face-attribute 'header-line nil
:font (font-spec :family *font-header-line-family*
:weight *font-header-line-weight*
:size *font-header-line-size*))))
;; (after-x 'doom-modeline
;; (doom-modeline--set-char-widths doom-modeline-rhs-icons-alist))
(run-hooks 'nasy/font-change-hook))
(defun nasy/set-font (&rest _)
"Nasy set font."
(interactive)
(message "setting font...")
(nasy/-set--font nil)
(message "setting font...done"))
(add-hook 'emacs-startup-hook #'nasy/-set-font 98)
(add-hook 'emacs-startup-hook #'nasy/-cus-font 97)
;; (add-hook 'after-init-hook #'nasy/set-font)
(add-hook 'emacs-startup-hook #'nasy/set-font 99)
;; (add-hook 'nasy-first-key-hook #'nasy/set-font)
;; (add-hook 'after-make-frame-functions #'nasy/set-font)
(when noninteractive
(nasy/set-font))
光幖
(defvar nasy-cursor-colors '("#F00056"
"#057748"
"#30DFF3"
"#FF9393"
"#50616D"
"#FFC34D"
"#801DAE"
"#705438"
"#FAFF72")
"Blink cursor colors.")
(defvar nasy--blink-cursor-count 0
"Blink cursor counter.")
(defun nasy/blink-cursor-timer-function (&rest _)
(when (not (internal-show-cursor-p))
(when (>= nasy--blink-cursor-count (length nasy-cursor-colors))
(setq nasy--blink-cursor-count 0))
(let ((color (nth nasy--blink-cursor-count nasy-cursor-colors))
(hl-color (nth nasy--blink-cursor-count (reverse nasy-cursor-colors))))
(set-cursor-color color)
(when (featurep 'beacon)
(setq beacon-color color))
(setq nasy--blink-cursor-count (1+ nasy--blink-cursor-count)))))
(add-hook 'nasy-first-key-hook
#'(lambda ()
(advice-add 'blink-cursor-timer-function :before
#'nasy/blink-cursor-timer-function)))
定製
餘
(defgroup nasy nil
"Nasy Emacs Custom Configurations."
:group 'emacs)
(defgroup nasy-font nil
"Nasy Emacs Custom Font Configurations."
:group 'nasy)
(defcustom lisp-modes-hooks '(common-lisp-mode-hook
emacs-lisp-mode-hook
lisp-mode-hook
lisp-interaction-mode-hook
racket-mode-hook
scheme-mode-hook)
"List of lisp-related modes hooks."
:type '(repeat symbol)
:group 'nasy)
(defmacro lisp-modes-hooks-add (func)
"Add FUNC to all lisp-related modes hooks."
(let ((bs))
(dolist (hook lisp-modes-hooks)
(push `(add-hook ',hook #',func) bs))
(macroexp-progn bs)))
(defcustom *theme* 'nasy-theme
"The Theme."
:group 'nasy
:type 'symbol)
(defun nasy/-cus-emacs ()
"Nasy customize emacs misc variable."
(customize-set-variable 'colon-double-space nil "Customized by Nasy.")
(customize-set-variable 'cursor-type 'box "Customized by Nasy.")
(customize-set-variable 'custom-raised-buttons nil "Customized by Nasy.")
(customize-set-variable 'help-window-select t "Customized by Nasy.")
(customize-set-variable 'make-backup-files nil "Customized by Nasy.")
(customize-set-variable 'mouse-yank-at-point t "Customized by Nasy.")
(customize-set-variable 'mouse-drag-and-drop-region-cross-program
t "Customized by Nasy.")
(customize-set-variable 'resize-mini-windows t "Customized by Nasy.")
(customize-set-variable 'scroll-conservatively 5 "Customized by Nasy.")
(customize-set-variable 'scroll-margin 5 "Customized by Nasy.")
(customize-set-variable 'tab-always-indent 'complete "Customized by Nasy.")
(customize-set-variable 'use-dialog-box nil "Customized by Nasy.")
(customize-set-variable 'use-file-dialog nil "Customized by Nasy.")
(customize-set-variable 'word-wrap-by-category t "Customized by Nasy.")
(customize-set-variable 'enable-recursive-minibuffers t "Customized by Nasy.")
(customize-set-variable 'ediff-split-window-function
'split-window-horizontally "Customized by Nasy.")
(customize-set-variable 'ediff-window-setup-function
'ediff-setup-windows-plain "Customized by Nasy.")
(setq-default indent-tabs-mode nil)
(fset 'yes-or-no-p 'y-or-n-p)
(column-number-mode 1)
(delete-selection-mode 1)
(display-battery-mode 1)
(global-auto-revert-mode 1)
(minibuffer-depth-indicate-mode 1)
(save-place-mode 1)
(pixel-scroll-precision-mode 1))
(add-hook 'nasy-first-key-hook #'nasy/-cus-emacs)
匩
(defun nasy/-insert-backslash ()
(interactive)
(insert-char ?\\))
(defun n/kill-line-0 ()
(interactive)
(kill-line 0))
(defun nasy/-cus-mac ()
"Customize macOS."
(setup mac
(:only-if *is-a-mac*)
(:opt*
mac-function-modifier 'super
mac-option-modifier 'meta
mac-command-modifier 'hyper
mac-right-command-modifier 'super
mac-right-option-modifier 'alt
default-frame-alist '((ns-transparent-titlebar . t)
(ns-appearance . light)
(alpha-background . 75)
(vertical-scroll-bars . nil)
(undecorated-round . t)
(border-width . 5)
(internal-border-width . 24)))
(:global
"C-z" stop-minimizing-window
"M-¥" nasy/-insert-backslash
"A-¥" nasy/-insert-backslash
"A-C-¥" toggle-input-method
[remap list-buffers] ibuffer
;; cursor Movement
"H-<up>" beginning-of-buffer
"H-<down>" end-of-buffer
"H-l" goto-line
;; text Operations
"H-a" mark-whole-buffer
"H-v" yank
"H-c" kill-ring-save
"H-s" save-buffer
"H-z" undo
"H-w" delete-window
"H-<backspace>" n/kill-line-0
;; Tab
"H-t" dashboard-refresh-buffer)
(:init
;; unset
(global-unset-key (kbd "<magnify-down>"))
(global-unset-key (kbd "<magnify-up>")))))
(add-hook 'emacs-startup-hook #'nasy/-cus-mac)
時用之
主勭使用。
;;; 風雨時用.el --- Nasy's emacs.d core file. -*- lexical-binding: t; -*-
(cl-eval-when (compile)
(add-to-list 'load-path (locate-user-emacs-file "桃夭/擊鼓"))
(add-to-list 'load-path (locate-user-emacs-file "桃夭/風雨"))
(require '擊鼓)
(require '風雨)
(require 'compile)
(require 'winner)
(sup 'avy t)
(sup 'expand-region t)
(sup 'flycheck t)
(sup 'org t)
(sup 'projectile t)
(sup 'smartparens t)
(sup 'treemacs t)
(with-no-warnings
(setq vterm-always-compile-module t))
(sup 'vterm t)
(sup '(vterm-toggle :build (:not native-compile)) t)
(sup `(彩 :local-repo ,(concat *nasy-site* "nasy/nasy-theme")
:files ("彩.el"))
t))
元
(defvar nasy-file-sym-t '((".config/nasy-emacs" . ".emacs.d")))
函數
;;;###autoload
(defun nasy/file-sym-t (file)
"Trans true file name to symlink file name."
(cl-loop for (from . to) in nasy-file-sym-t
do
(setq file (string-replace from to file))
return file))
;;;###autoload
(defun nasy/file-truename (file)
"Get the true name of FILE."
(if (or (file-remote-p file nil t)
(not (file-remote-p file)))
(file-truename file)
file))
;;;###autoload
(defun nasy/p-ignore-p (truename)
"Determine whether ignore the `TRUENAME' file or not."
(or (string-match-p "nix/store" truename)
nil))
;;;###autoload
(defun nasy/unquote (exp)
"Return EXP unquoted."
(declare (pure t) (side-effect-free t))
(while (memq (car-safe exp) '(quote function))
(setq exp (cadr exp)))
exp)
;;;###autoload
(defun posframe-poshandler-frame-top-center (info)
"Make posframe INFO top center."
(cons (/ (- (plist-get info :parent-frame-width)
(plist-get info :posframe-width))
2)
(round (* 0.02 (x-display-pixel-height)))))
;;;###autoload
(defun nasy/wfw1 (&rest _)
"Widget forward 1."
(interactive)
(widget-forward 1))
;;;###autoload
(defun nasy/fw2 (&rest _)
"Forward 2 chars."
(interactive "p")
(forward-char 2))
;;;###autoload
(defun nasy/閒置 ()
"閒置 Emacs."
(interactive)
(dashboard-refresh-buffer)
(delete-other-windows))
;;;###autoload
(defun nasy/-open-custom ()
"Open custom 芄蘭.el."
(interactive)
(find-file (concat *nasy-custom* "芄蘭.el")))
;;;###autoload
(defun nasy/-open-source-page ()
"Open source page."
(interactive)
(browse-url "https://github.com/nasyxx/emacs.d/"))
;;;###autoload
(defun nasy/-open-document ()
"Open document."
(interactive)
(browse-url "https://emacs.nasy.moe/"))
;;;###autoload
(defun nasy/clear-text-overlay ()
"Clear text overlay."
(interactive)
(let ((inhibit-read-only t))
(set-text-properties (point-min) (point-max) nil)))
;;;###autoload
(defun nasy/up-directory (arg)
"Move up a directory ARGth times."
(interactive "p")
(if minibuffer-completing-file-name
(if (string-match-p "/." (minibuffer-contents))
(zap-up-to-char (- arg) ?/)
(delete-minibuffer-contents))
(backward-kill-word arg)))
重新加載 user-init-file
文件
;;;###autoload
(defun nasy/reload-init ()
"Reload init.el."
(interactive)
(message "Reloading init.el...")
(load user-init-file nil 'nomessage)
(message "Reloading init.el... done."))
;;;###autoload
(defun nasy/eval-buffer-or-region (&optional start end)
"Evaluate the current region, or the whole buffer if no region is active.
In Lisp code, START and END denote the region to be evaluated;
they default to `point-min' and `point-max' respectively.
If evaluating a buffer visiting this file, then delegate instead
to `nasy/reload-init'."
(interactive)
(if (and buffer-file-name
(member (file-truename buffer-file-name)
(list
(when (bound-and-true-p early-init-file)
(file-truename early-init-file))
(file-truename user-init-file)))
(not (region-active-p)))
(nasy/reload-init)
(let ((name nil))
(if (region-active-p)
(progn
(setq start (region-beginning))
(setq end (region-end))
(setq name "region"))
(setq start (point-min))
(setq end (point-max))
(setq name (buffer-name)))
(let ((load-file-name (buffer-file-name)))
(message "Evaluating %s..." name)
(eval-region start end)
(message "Evaluating %s...done" name)))))
臿入時間
;;;###autoload
(defun nasy/insert-current-date ()
"Insert current date."
(interactive)
(insert (shell-command-to-string "echo -n $(date +'%b %d, %Y')")))
;;;###autoload
(defun nasy/insert-current-filename ()
"Insert current buffer filename."
(interactive)
(insert (file-relative-name buffer-file-name)))
buffer 相關
;;;###autoload
(defvar nasy/real-buffer-functions
'(nasy/dired-buffer-p)
"A list of predicate functions run to determine if a buffer is real, unlike
`nasy/unreal-buffer-functions'. They are passed one argument: the buffer to be
tested.
Should any of its function returns non-nil, the rest of the functions are
ignored and the buffer is considered real.
See `nasy/real-buffer-p' for more information.")
;;;###autoload
(defvar nasy/unreal-buffer-functions
'(minibufferp nasy/special-buffer-p nasy/non-file-visiting-buffer-p)
"A list of predicate functions run to determine if a buffer is *not* real,
unlike `nasy/real-buffer-functions'. They are passed one argument: the buffer to
be tested.
Should any of these functions return non-nil, the rest of the functions are
ignored and the buffer is considered unreal.
See `nasy/real-buffer-p' for more information.")
;;;###autoload
(defvar-local nasy/real-buffer-p nil
"If non-nil, this buffer should be considered real no matter what. See
`nasy/real-buffer-p' for more information.")
;;;###autoload
(defvar nasy/fallback-buffer-name "*scratch*"
"The name of the buffer to fall back to if no other buffers exist (will create
it if it doesn't exist).")
;;
;; Functions
;;;###autoload
(defun nasy/buffer-frame-predicate (buf)
"To be used as the default frame buffer-predicate parameter. Returns nil if
BUF should be skipped over by functions like `next-buffer' and `other-buffer'."
(or (nasy/real-buffer-p buf)
(eq buf (nasy/fallback-buffer))))
;;;###autoload
(defun nasy/fallback-buffer ()
"Returns the fallback buffer, creating it if necessary. By default this is the
scratch buffer. See `nasy/fallback-buffer-name' to change this."
(let (buffer-list-update-hook)
(get-buffer-create nasy/fallback-buffer-name)))
;;;###autoload
(defalias 'nasy/buffer-list #'buffer-list)
;;;###autoload
(defun nasy/project-root (&optional dir)
"Return the project root of DIR (defaults to `default-directory').
Returns nil if not in a project."
(let ((projectile-project-root
(unless dir (bound-and-true-p projectile-project-root)))
projectile-require-project-root)
(projectile-project-root dir)))
;;;###autoload
(defun nasy/project-buffer-list (&optional project)
"Return a list of buffers belonging to the specified PROJECT.
If PROJECT is nil, default to the current project.
If no project is active, return all buffers."
(let ((buffers (nasy/buffer-list)))
(if-let* ((project-root
(if project (expand-file-name project)
(nasy/project-root))))
(cl-loop for buf in buffers
if (projectile-project-buffer-p buf project-root)
collect buf)
buffers)))
;;;###autoload
(defun nasy/open-projects ()
"Return a list of projects with open buffers."
(cl-loop with projects = (make-hash-table :test 'equal :size 8)
for buffer in (nasy/buffer-list)
if (buffer-live-p buffer)
if (nasy/real-buffer-p buffer)
if (with-current-buffer buffer (nasy/project-root))
do (puthash (abbreviate-file-name it) t projects)
finally return (hash-table-keys projects)))
;;;###autoload
(defun nasy/dired-buffer-p (buf)
"Returns non-nil if BUF is a dired buffer."
(with-current-buffer buf (derived-mode-p 'dired-mode)))
;;;###autoload
(defun nasy/special-buffer-p (buf)
"Returns non-nil if BUF's name starts and ends with an *."
(equal (substring (buffer-name buf) 0 1) "*"))
;;;###autoload
(defun nasy/temp-buffer-p (buf)
"Returns non-nil if BUF is temporary."
(equal (substring (buffer-name buf) 0 1) " "))
;;;###autoload
(defun nasy/visible-buffer-p (buf)
"Return non-nil if BUF is visible."
(get-buffer-window buf))
;;;###autoload
(defun nasy/buried-buffer-p (buf)
"Return non-nil if BUF is not visible."
(not (nasy/visible-buffer-p buf)))
;;;###autoload
(defun nasy/non-file-visiting-buffer-p (buf)
"Returns non-nil if BUF does not have a value for `buffer-file-name'."
(not (buffer-file-name buf)))
;;;###autoload
(defun nasy/real-buffer-list (&optional buffer-list)
"Return a list of buffers that satify `nasy/real-buffer-p'."
(cl-remove-if-not #'nasy/real-buffer-p (or buffer-list (nasy/buffer-list))))
;;;###autoload
(defun nasy/real-buffer-p (buffer-or-name)
"Returns t if BUFFER-OR-NAME is a =real= buffer.
A real buffer is a useful buffer; a first class citizen in Doom. Real ones
should get special treatment, because we will be spending most of our time in
them. Unreal ones should be low-profile and easy to cast aside, so we can focus
on real ones.
The exact criteria for a real buffer is:
1. A non-nil value for the buffer-local value of the `nasy/real-buffer-p'
variable OR
2. Any function in `nasy/real-buffer-functions' returns non-nil OR
3. None of the functions in `nasy/unreal-buffer-functions' must return
non-nil.
If BUFFER-OR-NAME is omitted or nil, the current buffer is tested."
(or (bufferp buffer-or-name)
(stringp buffer-or-name)
(signal 'wrong-type-argument (list '(bufferp stringp) buffer-or-name)))
(when-let (buf (get-buffer buffer-or-name))
(and (buffer-live-p buf)
(not (nasy/temp-buffer-p buf))
(or (buffer-local-value 'nasy/real-buffer-p buf)
(run-hook-with-args-until-success 'nasy/real-buffer-functions buf)
(not (run-hook-with-args-until-success 'nasy/unreal-buffer-functions buf))))))
;;;###autoload
(defun nasy/unreal-buffer-p (buffer-or-name)
"Return t if BUFFER-OR-NAME is an =unreal= buffer.
See `nasy/real-buffer-p' for details on what that means."
(not (nasy/real-buffer-p buffer-or-name)))
;;;###autoload
(defun nasy/buffers-in-mode (modes &optional buffer-list derived-p)
"Return a list of buffers whose `major-mode' is `eq' to MODE(S).
If DERIVED-P, test with `derived-mode-p', otherwise use `eq'."
(let ((modes (nasy/enlist modes)))
(cl-remove-if-not (if derived-p
(lambda (buf)
(with-current-buffer buf
(apply #'derived-mode-p modes)))
(lambda (buf)
(memq (buffer-local-value 'major-mode buf) modes)))
(or buffer-list (nasy/buffer-list)))))
;;;###autoload
(defun nasy/visible-windows (&optional window-list)
"Return a list of the visible, non-popup (dedicated) windows."
(cl-loop for window in (or window-list (window-list))
when (or (window-parameter window 'visible)
(not (window-dedicated-p window)))
collect window))
;;;###autoload
(defun nasy/visible-buffers (&optional buffer-list)
"Return a list of visible buffers (i.e. not buried)."
(if buffer-list
(cl-remove-if-not #'get-buffer-window buffer-list)
(delete-dups (mapcar #'window-buffer (window-list)))))
;;;###autoload
(defun nasy/buried-buffers (&optional buffer-list)
"Get a list of buffers that are buried."
(cl-remove-if #'get-buffer-window (or buffer-list (nasy/buffer-list))))
;;;###autoload
(defun nasy/matching-buffers (pattern &optional buffer-list)
"Get a list of all buffers that match the regex PATTERN."
(cl-loop for buf in (or buffer-list (nasy/buffer-list))
when (string-match-p pattern (buffer-name buf))
collect buf))
;;;###autoload
(defun nasy/set-buffer-real (buffer flag)
"Forcibly mark BUFFER as FLAG (non-nil = real)."
(with-current-buffer buffer
(setq nasy/real-buffer-p flag)))
;;;###autoload
(defun nasy/kill-buffer-and-windows (buffer)
"Kill the buffer and delete all the windows it's displayed in."
(dolist (window (get-buffer-window-list buffer))
(unless (one-window-p t)
(delete-window window)))
(kill-buffer buffer))
;;;###autoload
(defun nasy/fixup-windows (windows)
"Ensure that each of WINDOWS is showing a real buffer or the fallback buffer."
(dolist (window windows)
(with-selected-window window
(when (nasy/unreal-buffer-p (window-buffer))
(previous-buffer)
(when (nasy/unreal-buffer-p (window-buffer))
(switch-to-buffer (nasy/fallback-buffer)))))))
;;;###autoload
(defun nasy/kill-buffer-fixup-windows (buffer)
"Kill the BUFFER and ensure all the windows it was displayed in have switched
to a real buffer or the fallback buffer."
(let ((windows (get-buffer-window-list buffer)))
(kill-buffer buffer)
(nasy/fixup-windows (cl-remove-if-not #'window-live-p windows))))
;;;###autoload
(defun nasy/kill-buffers-fixup-windows (buffers)
"Kill the BUFFERS and ensure all the windows they were displayed in have
switched to a real buffer or the fallback buffer."
(let ((seen-windows (make-hash-table :test 'eq :size 8)))
(dolist (buffer buffers)
(let ((windows (get-buffer-window-list buffer)))
(kill-buffer buffer)
(dolist (window (cl-remove-if-not #'window-live-p windows))
(puthash window t seen-windows))))
(nasy/fixup-windows (hash-table-keys seen-windows))))
;;;###autoload
(defun nasy/-kill-matching-buffers (pattern &optional buffer-list)
"Kill all buffers (in current workspace OR in BUFFER-LIST) that match the
regex PATTERN. Returns the number of killed buffers."
(let ((buffers (nasy/matching-buffers pattern buffer-list)))
(dolist (buf buffers (length buffers))
(kill-buffer buf))))
;;
;; Hooks
;;;###autoload
(defun nasy/mark-buffer-as-real-h ()
"Hook function that marks the current buffer as real."
(nasy/set-buffer-real (current-buffer) t))
;;
;; Interactive commands
;;;###autoload
(defun nasy/kill-this-buffer-in-all-windows (buffer &optional dont-save)
"Kill BUFFER globally and ensure all windows previously showing this buffer
have switched to a real buffer or the fallback buffer.
If DONT-SAVE, don't prompt to save modified buffers (discarding their changes)."
(interactive
(list (current-buffer) current-prefix-arg))
(cl-assert (bufferp buffer) t)
(when (and (buffer-modified-p buffer) dont-save)
(with-current-buffer buffer
(set-buffer-modified-p nil)))
(nasy/kill-buffer-fixup-windows buffer))
(defun nasy/message-or-count (interactive message count)
(if interactive
(message message count)
count))
;;;###autoload
(defun nasy/kill-all-buffers (&optional buffer-list interactive)
"Kill all buffers and closes their windows.
If the prefix arg is passed, doesn't close windows and only kill buffers that
belong to the current project."
(interactive
(list (if current-prefix-arg
(nasy/project-buffer-list)
(nasy/buffer-list))
t))
(if (null buffer-list)
(message "No buffers to kill")
(save-some-buffers)
(delete-other-windows)
(when (memq (current-buffer) buffer-list)
(switch-to-buffer (nasy/fallback-buffer)))
(mapc #'kill-buffer buffer-list)
(nasy/message-or-count
interactive "Killed %d buffers"
(- (length buffer-list)
(length (cl-remove-if-not #'buffer-live-p buffer-list))))))
;;;###autoload
(defun nasy/kill-other-buffers (&optional buffer-list interactive)
"Kill all other buffers (besides the current one).
If the prefix arg is passed, kill only buffers that belong to the current
project."
(interactive
(list (delq (current-buffer)
(if current-prefix-arg
(nasy/project-buffer-list)
(nasy/buffer-list)))
t))
(mapc #'nasy/kill-buffer-and-windows buffer-list)
(nasy/message-or-count
interactive "Killed %d other buffers"
(- (length buffer-list)
(length (cl-remove-if-not #'buffer-live-p buffer-list)))))
;;;###autoload
(defun nasy/kill-matching-buffers (pattern &optional buffer-list interactive)
"Kill buffers that match PATTERN in BUFFER-LIST.
If the prefix arg is passed, only kill matching buffers in the current project."
(interactive
(list (read-regexp "Buffer pattern: ")
(if current-prefix-arg
(nasy/project-buffer-list)
(nasy/buffer-list))
t))
(nasy/-kill-matching-buffers pattern buffer-list)
(when interactive
(message "Killed %d buffer(s)"
(- (length buffer-list)
(length (cl-remove-if-not #'buffer-live-p buffer-list))))))
;;;###autoload
(defun nasy/kill-buried-buffers (&optional buffer-list interactive)
"Kill buffers that are buried.
If PROJECT-P (universal argument), only kill buried buffers belonging to the
current project."
(interactive
(list (nasy/buried-buffers
(if current-prefix-arg (nasy/project-buffer-list)))
t))
(mapc #'kill-buffer buffer-list)
(nasy/message-or-count
interactive "Killed %d buried buffers"
(- (length buffer-list)
(length (cl-remove-if-not #'buffer-live-p buffer-list)))))
;;;###autoload
(defun nasy/kill-project-buffers (project &optional interactive)
"Kill buffers for the specified PROJECT."
(interactive
(list (if-let (open-projects (nasy/open-projects))
(completing-read
"Kill buffers for project: " open-projects
nil t nil nil
(if-let* ((project-root (nasy/project-root))
(project-root (abbreviate-file-name project-root))
((member project-root open-projects)))
project-root))
(message "No projects are open!")
nil)
t))
(when project
(let ((buffer-list (nasy/project-buffer-list project)))
(nasy/kill-buffers-fixup-windows buffer-list)
(nasy/message-or-count
interactive "Killed %d project buffers"
(- (length buffer-list)
(length (cl-remove-if-not #'buffer-live-p buffer-list)))))))
;;;###autoload
(defun nasy/kill-buffers-no-company-box ()
"Kill all buffers except company box buffers."
(interactive)
(nasy/kill-all-buffers
(cl-loop for buffer in (nasy/buffer-list)
when (not (string-match-p "company-box" (buffer-name buffer)))
collect buffer)))
;;;###autoload
(defun nasy/scratch ()
"Switch buffer to scratch."
(interactive)
(switch-to-buffer "*scratch*"))
布局相關
;; When splitting window, show (other-buffer) in the new window
(defun split-window-func-with-other-buffer (split-function)
"Split window with `SPLIT-FUNCTION'."
(lambda (&optional arg)
"Split this window and switch to the new window unless ARG is provided."
(interactive "P")
(funcall split-function)
(let ((target-window (next-window)))
(set-window-buffer target-window (other-buffer))
(unless arg
(select-window target-window)))))
(defun split-window--v ()
"Split window vertically."
(interactive)
(split-window-func-with-other-buffer 'split-window-vertically))
(defun split-window--h ()
"Split window horizontcally."
(interactive)
(split-window-func-with-other-buffer 'split-window-horizontally))
(defun toggle-delete-other-windows ()
"Delete other windows in frame if any, or restore previous window config."
(interactive)
(if (and winner-mode
(equal (selected-window) (next-window)))
(winner-undo)
(delete-other-windows)))
(defun split-window-horizontally-instead ()
"Kill any other windows and re-split such that the current window is on the top half of the frame."
(interactive)
(let ((other-buffer (and (next-window) (window-buffer (next-window)))))
(delete-other-windows)
(split-window-horizontally)
(when other-buffer
(set-window-buffer (next-window) other-buffer))))
(defun split-window-vertically-instead ()
"Kill any other windows and re-split such that the current window is on the left half of the frame."
(interactive)
(let ((other-buffer (and (next-window) (window-buffer (next-window)))))
(delete-other-windows)
(split-window-vertically)
(when other-buffer
(set-window-buffer (next-window) other-buffer))))
;; Borrowed from http://postmomentum.ch/blog/201304/blog-on-emacs
(defun nasy/split-window()
"Split the window to see the most recent buffer in the other window.
Call a second time to restore the original window configuration."
(interactive)
(if (eq last-command 'nasy-split-window)
(progn
(jump-to-register :nasy-split-window)
(setq this-command 'nasy-unsplit-window))
(window-configuration-to-register :nasy/split-window)
(switch-to-buffer-other-window nil)))
文字處理
;;;###autoload
(defun nasy/delete-backward-word (arg)
"Like `backward-kill-word', but doesn't affect the kill-ring."
(interactive "p")
(let (kill-ring)
(backward-kill-word arg)))
;;;###autoload
(defun nasy/region-active-p ()
"Return non-nil if selection is active."
(declare (side-effect-free t))
(use-region-p))
;;;###autoload
(defun nasy/region-beginning ()
"Return beginning position of selection."
(declare (side-effect-free t))
(region-beginning))
;;;###autoload
(defun nasy/region-end ()
"Return end position of selection."
(declare (side-effect-free t))
(region-end))
;;;###autoload
(defun nasy/thing-at-point-or-region (&optional thing prompt)
"Grab the current selection, THING at point, or xref identifier at point.
Returns THING if it is a string. Otherwise, if nothing is found at point and
PROMPT is non-nil, prompt for a string (if PROMPT is a string it'll be used as
the prompting string). Returns nil if all else fails.
NOTE: Don't use THING for grabbing symbol-at-point. The xref fallback is smarter
in some cases."
(declare (side-effect-free t))
(cond ((stringp thing)
thing)
((nasy/region-active-p)
(buffer-substring-no-properties
(nasy/region-beginning)
(nasy/region-end)))
(thing
(thing-at-point thing t))
((require 'xref nil t)
;; A little smarter than using `symbol-at-point', though in most cases,
;; xref ends up using `symbol-at-point' anyway.
(xref-backend-identifier-at-point (xref-find-backend)))
(prompt
(read-string (if (stringp prompt) prompt "")))))
;;;###autoload
(defalias 'default/newline #'newline)
;;;###autoload
(defun default/newline-above ()
"Insert an indented new line before the current one."
(interactive)
(beginning-of-line)
(save-excursion (newline))
(indent-according-to-mode))
;;;###autoload
(defun default/newline-below ()
"Insert an indented new line after the current one."
(interactive)
(end-of-line)
(newline-and-indent))
;;;###autoload
(defun default/yank-pop ()
"Interactively select what text to insert from the kill ring."
(interactive)
(call-interactively
(cond ((fboundp 'counsel-yank-pop) #'counsel-yank-pop)
((fboundp 'helm-show-kill-ring) #'helm-show-kill-ring)
((error "No kill-ring search backend available. Enable ivy or helm!")))))
;;;###autoload
(defun default/yank-buffer-filename ()
"Copy the current buffer's path to the kill ring."
(interactive)
(if-let* ((filename (or buffer-file-name (bound-and-true-p list-buffers-directory))))
(message (kill-new (abbreviate-file-name filename)))
(error "Couldn't find filename in current buffer")))
;;;###autoload
(defun default/insert-file-path (arg)
"Insert the file name (absolute path if prefix ARG).
If `buffer-file-name' isn't set, uses `default-directory'."
(interactive "P")
(let ((path (or buffer-file-name default-directory)))
(insert
(if arg
(abbreviate-file-name path)
(file-name-nondirectory path)))))
;;;###autoload
(defun default/newline-indent-and-continue-comments-a ()
"A replacement for `newline-and-indent'.
Continues comments if executed from a commented line, with special support for
languages with weak native comment continuation support (like C-family
languages)."
(interactive)
(if (and (sp-point-in-comment)
comment-line-break-function)
(funcall comment-line-break-function nil)
(delete-horizontal-space t)
(newline nil t)
(indent-according-to-mode)))
(defun nasy/insert-zero-width-space ()
"Insert a zero width space \u200b."
(interactive)
(insert "\u200b"))
挈壺 benchmark
(defmacro nasy/timer (&rest body)
"Measure and return the time it takes evaluating BODY."
`(let ((time (current-time)))
,@body
(float-time (time-since time))))
模式
激活區域
(defvar nasy/active-region--on nil)
(defun nasy/on--active-region ()
(nasy/active-region--mode 1))
(defun nasy/off--active-region ()
(nasy/active-region--mode -1))
(defvar nasy/active-region-map (make-sparse-keymap))
;;;###autoload
(define-minor-mode nasy/active-region--mode
"Actized region or not."
:keymap nasy/active-region-map)
;;;###autoload
(define-minor-mode nasy/active-region-mode
"Actived region or not."
:lighter "n/ar"
(if nasy/active-region-mode
(progn
(nasy/off--active-region)
(add-hook 'activate-mark-hook #'nasy/on--active-region)
(add-hook 'deactivate-mark-hook #'nasy/off--active-region))
(remove-hook 'activate-mark-hook #'nasy/on--active-region)
(remove-hook 'deactivate-mark-hook #'nasy/off--active-region)
(nasy/off--active-region)))
快捷鍵
(defun nasy/-set-key-map ()
"Nasy Set keymap for config."
(define-key global-map (kbd "s-SPC") #'nasy/insert-zero-width-space))
(defun nasy/-unset-key-map ()
"Nasy Unet keymap for config."
(define-key global-map (kbd "s-SPC") nil))
(defun nasy/-keymap ()
"Define nasy key map."
(define-keymap :parent mode-specific-map
"c" (define-keymap :prefix 'nasy-code-map
"c" #'compile
"C" #'recompile
"t" #'vterm-toggle
"x" #'flycheck-list-errors)
"e" (define-keymap :prefix 'nasy-edit-map
"a" #'avy-goto-char
"c" #'comment-line
"e" #'er/expand-region
"SPC" #'nasy/insert-zero-width-space)
"t" (define-keymap :prefix 'nasy-treemacs-map
"t" #'treemacs
"1" #'treemacs-delete-other-windows
"B" #'treemacs-bookmark
"f" #'treemacs-find-file)
"o" (define-keymap :prefix 'nasy-org-map
"b" #'org-tree-to-indirect-buffer)
"y" (define-keymap :prefix 'nasy-yas-map
"n" #'yas-new-snippet)))
(define-minor-mode nasy-keybinding-mode
"Nasy Keybinding Mode."
:init-value nil
:lighter "n/k"
(if nasy-keybinding-mode
(progn
(let ((keymap (nasy/-keymap)))
(define-key global-map "\C-c" keymap))
(nasy/-set-key-map))
(define-key global-map "\C-c" mode-specific-map)
(nasy/-unset-key-map)))
(setup nasy-keybinding
(:hook-into nasy-org-first-key-hook
prog-mode-hook
text-mode-hook))
光影
(defun beacon--shine-b ()
"Shine a beacon at point."
(let ((colors (beacon--color-range)))
(save-excursion
;; (backward-char 1)
(while colors
(if (looking-at "^")
(setq colors nil)
(beacon--colored-overlay (pop colors))
(backward-char 1))))))
(defun nasy/beacon-blink (&rest _)
"Blink the beacon at the position of the cursor."
(interactive)
(beacon--vanish)
(run-hooks 'beacon-before-blink-hook)
(beacon--shine-b)
(when (timerp beacon--timer)
(cancel-timer beacon--timer))
(setq beacon--timer
(run-at-time beacon-blink-delay
(/ beacon-blink-duration 1.0 beacon-size)
#'beacon--dec)))
(defun nasy/blink ()
(cond ((member this-command '(left-char
backward-char
backward-word
delete-char
delete-backward-char
backward-delete-char-untabify
move-beginning-of-line
org-beginning-of-line
org-beginning-of-item
org-beginning-of-block
org-delete-backward-char
org-metaleft))
(beacon-blink))
((member this-command '(right-char
forward-char
forward-word
self-insert-command
move-end-of-line
org-end-of-line
org-end-of-item
org-end-of-block
org-metaright))
(nasy/beacon-blink))))
(define-minor-mode nasy-beacon-cursor-mode
"Nasy beacon on moving cursor."
:lighter "n/bc"
:global t
:group 'nasy
(if nasy-beacon-cursor-mode
(add-hook 'pre-command-hook #'nasy/blink)
(remove-hook 'pre-command-hook #'nasy/blink)))
(nasy-beacon-cursor-mode 1)
末
(provide '風雨時用)
;;; 風雨時用.el ends here
緑衣
(add-to-list 'load-path (locate-user-emacs-file "桃夭/緑衣"))
(require '緑衣)
(require '補)
國風・邶風・緑衣
緑兮衣兮、緑衣黃裹
心之憂矣、曷維其已
緑兮衣兮、緑衣黃裳
心之憂矣、曷維其亡
緑兮絲兮、女所治兮
我恖古人、俾無訧兮
絺兮綌兮、淒其以風
我恖古人、實獲我心
永不弃者載入于初始之時也
Permanent configuration file.
You cannot disable anything here.
章
Anzu search tools
anzu.el is an Emacs port of anzu.vim. anzu.el provides a minor mode which displays current match and total matches information in the mode-line in various search modes.
https://github.com/emacsorphanage/anzu
(setup anzu
(:doc "anzu.el is an Emacs port of anzu.vim.")
(:url "https://github.com/emacsorphanage/anzu")
(:tag "search" "tools")
(:first-key global-anzu-mode)
(:global
[remap query-replace] anzu-query-replace
[remap query-replace-regexp] anzu-query-replace-regexp))
Avy point location
Jump to things in Emacs tree-style.
https://github.com/abo-abo/avy
(setup avy
(:doc "Jump to things in Emacs tree-style.")
(:url "https://github.com/abo-abo/avy")
(:tag "point" "location")
(:opt
avy-keys '(?a ?o ?e ?u ?i ?d ?h ?t ?n ?s)) ;; for dvorak
(:global
"C-;" avy-goto-char
"C-:" avy-goto-char-2
;; "C-'" avy-goto-char-2
;; "C-`" avy-goto-char-2
"M-g e" avy-goto-word-0
"M-g w" avy-goto-word-1
;; "C-~" avy-goto-word-1
"C-c C-j" avy-resume))
Beginend editing
Emacs package to redefine M-< and M-> for some modes
https://github.com/DamienCassou/beginend
(setup beginend
(:doc "Emacs package to redefine M-< and M-> for some modes")
(:url "https://github.com/DamienCassou/beginend")
(:tag "editing")
(:first-key beginend-global-mode))
Compile builtin
(defvar nasy/last-compilation-buffer nil
"The last buffer in which compilation took place.")
(defun nasy/save-compilation-buffer (&rest _)
"Save the compilation buffer to find it later."
(setq nasy/last-compilation-buffer next-error-last-buffer))
(defun alert-after-compilation-finish (buf result)
"Use `alert' to report compilation RESULT if BUF is hidden."
(when (buffer-live-p buf)
(unless (catch 'is-visible
(walk-windows (lambda (w)
(when (eq (window-buffer w) buf)
(throw 'is-visible t))))
nil)
(alert (concat "Compilation " result)
:buffer buf
:category 'compilation
:title "Emacs"))))
(setup compile
(:tag "builtin")
(:advice compilation-start :after nasy/save-compilation-buffer)
(:global [f6] recompile)
(:with-hook compilation-finish-functions (:hook alert-after-compilation-finish)))
Consult extensions
consult.el - Consulting completing-read.
https://github.com/minad/consult
Include consult & consult-flycheck.
consult
(defun nasy/consult-line-symbol-at-point ()
"Consult line with symbol at point."
(interactive)
(consult-line (thing-at-point 'symbol)))
(setup consult
(:doc "consult.el - Consulting completing-read")
(:url "https://github.com/minad/consult")
(:tag "extensions")
(:load-first vertico)
(:opt
consult-narrow-key "C-.")
(:with-hook completion-list-mode-hook
(:hook consult-preview-at-point-mode))
(:global
[remap switch-to-buffer] consult-buffer
[remap switch-to-buffer-other-window] consult-buffer-other-window
[remap switch-to-buffer-other-frame] consult-buffer-other-frame
[remap bookmark-jump] consult-bookmark
[remap goto-line] consult-goto-line
[remap imenu] consult-imenu
[remap multi-occur] consult-line-multi
[remap recentf-open-files] consult-recent-file
[remap yank-pop] consult-yank-replace
"C-s" consult-line
"C-S-s" nasy/consult-line-symbol-at-point)
(:when-loaded
(:require consult-xref)
(consult-customize
consult-theme
:preview-key '("M-."
:debounce 3 "<up>" "<down>"
:debounce 1 any)
consult-ripgrep consult-git-grep consult-grep
consult-bookmark consult-recent-file consult-xref
consult--source-recent-file consult--source-project-recent-file
consult--source-bookmark consult-buffer
:preview-key '("M-."
:debounce 5 "<up>" "<down>"
:debounce 5 any))))
consult-flycheck
(setup consult-flycheck
(:doc "consult.el - Consulting completing-read")
(:url "https://github.com/minad/consult")
(:tag "extensions")
(:load-first consult)
(:bind-into flycheck-command-map
"!" consult-flycheck))
consult-dir convenience
Consult-dir allows you to easily select and switch between “active” directories.
https://github.com/karthink/consult-dir
(setup consult-dir
(:doc "consult-dir: switch directories easily in Emacs")
(:url "https://github.com/karthink/consult-dir")
(:tag "convenience")
(:load-first consult)
(:global
"C-x C-d" consult-dir)
(:bind-into minibuffer-local-completion-map
"C-x C-d" consult-dir
"C-x C-j" consult-dir-jump-file)
(:after vertico
(:bind-into vertico-map
"C-x C-d" consult-dir
"C-x C-j" consult-dir-jump-file)))
Dired files
DiredMode is the mode of a Dired buffer. It shows a directory (folder) listing that you can use to perform various operations on files and subdirectories in the directory. The operations you can perform are numerous, from creating subdirectories to byte-compiling files, searching files, and of course visiting (editing) files.
https://www.emacswiki.org/emacs/DiredMode
(setup dired
(:doc "DiredMode is the mode of a Dired buffer.")
(:url "https://www.emacswiki.org/emacs/DiredMode")
(:tag "files")
(:bind-into dired-mode-map
[mouse-2] dired-find-file
"C-c C-p" wdired-change-to-wdired-mode)
(:opt
insert-directory-program (or (executable-find "gls")
(executable-find "ls"))
dired-recursive-deletes 'top))
Easy Kill killing convenience
Provide commands easy-kill and easy-mark to let users kill or mark things easily.
https://github.com/leoliu/easy-kill
(setup easy-kill
(:doc "Kill & Mark Things Easily in Emacs.")
(:url "https://github.com/leoliu/easy-kill")
(:tag "killing" "convenience")
(:global
[remap kill-ring-save] easy-kill
[remap mark-sexp] easy-mark))
Eldoc builtin docs help
(setup eldoc
(:opt eldoc-documentation-strategy #'eldoc-documentation-compose
eldoc-echo-area-use-multiline-p t))
embark convenience
Emacs Mini-Buffer Actions Rooted in Keymaps.
https://github.com/oantolin/embark/
(defun embark-act-noquit ()
"Run action but don't quit the minibuffer afterwards."
(interactive)
(let ((embark-quit-after-action nil))
(embark-act)))
(defun embark-which-key-indicator ()
"An embark indicator that displays keymaps using which-key.
The which-key help message will show the type and value of the
current target followed by an ellipsis if there are further
targets."
(lambda (&optional keymap targets prefix)
(if (null keymap)
(which-key--hide-popup-ignore-command)
(which-key--show-keymap
(if (eq (plist-get (car targets) :type) 'embark-become)
"Become"
(format "Act on %s '%s'%s"
(plist-get (car targets) :type)
(embark--truncate-target (plist-get (car targets) :target))
(if (cdr targets) "…" "")))
(if prefix
(pcase (lookup-key keymap prefix 'accept-default)
((and (pred keymapp) km) km)
(_ (key-binding prefix 'accept-default)))
keymap)
nil nil t (lambda (binding)
(not (string-suffix-p "-argument" (cdr binding))))))))
(defun embark-hide-which-key-indicator (fn &rest args)
"Hide the which-key indicator immediately when using the completing-read prompter."
(which-key--hide-popup-ignore-command)
(let ((embark-indicators
(remq #'embark-which-key-indicator embark-indicators)))
(apply fn args)))
(defun embark-live-vertico ()
"Shrink Vertico minibuffer when `embark-live' is active."
(when-let (win (and (string-prefix-p "*Embark Live" (buffer-name))
(active-minibuffer-window)))
(with-selected-window win
(when (and (bound-and-true-p vertico--input)
(fboundp 'vertico-multiform-unobtrusive))
(vertico-multiform-unobtrusive)))))
(setup embark
(:doc "Emacs Mini-Buffer Actions Rooted in Keymaps.")
(:url "https://github.com/oantolin/embark")
(:tag "convenience")
(:load-first vertico consult embark-consult)
(:global
[remap describe-bindings] embark-bindings
"C-," embark-dwim)
(:bind-into embark-file-map
"s" sudo-edit)
(:after vertico
(:bind-into vertico-map
"M-o" embark-act)
(add-to-list 'embark-indicators #'embark-which-key-indicator))
(:after 風雨時用
(:bind-into nasy/active-region-map
"M-o" embark-act))
(:with-mode embark-collect-mode
(:hook embark-live-vertico))
(:when-loaded
;; Hide the mode line of the Embark live/completions buffers
(add-to-list 'display-buffer-alist
'("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
nil
(window-parameters (mode-line-format . none))))))
(setup embark-consult
(:load-first consult)
(:with-mode embark-collect-mode
(:hook consult-preview-at-point-mode)))
Flycheck convenience languages tools
Modern on-the-fly syntax checking extension for GNU Emacs.
https://github.com/flycheck/flycheck
(setup flycheck
(:doc "On the fly syntax checking for GNU Emacs.")
(:url "https://github.com/flycheck/flycheck")
(:tag "convenience" "languages" "tools")
(:hook-into prog-mode)
(:opt
flycheck-display-errors-function #'flycheck-display-error-messages-unless-error-list
flycheck-check-syntax-automatically '(save idle-change mode-enabled)
flycheck-display-errors-delay 0.25)
(:bind-into flycheck-error-list-mode-map
"C-n" flycheck-error-list-next-error
"C-p" flycheck-error-list-previous-error
"RET" flycheck-error-list-goto-error
[return] flycheck-error-list-goto-error)
(:when-loaded
(add-to-list 'display-buffer-alist
`(,(rx bos "*Flycheck errors*" eos)
(display-buffer-reuse-window
display-buffer-in-side-window)
(side . bottom)
(reusable-frames . visible)
(window-height . 0.33)))
(defalias 'show-error-at-point-soon
'flycheck-show-error-at-point)
(add-to-list 'flycheck-emacs-lisp-checkdoc-variables 'sentence-end-double-space)))
GCMH internal
以 gcmh
管理汙薉
Use GCMH – the Garbage Collector Magic Hack – to adjust garbage collection.
(defun nasy/-start-gcmh (&rest _)
"Start GCMH."
(when (and (not noninteractive)
(not (and (boundp '*no-gcmh*)
*no-gcmh*)))
(customize-set-variable
'gcmh-verbose t
"Customized with leaf in `gcmh' block")
(customize-set-variable
'gcmh-low-cons-threshold #x2000000 ;; 32MB
"Customized with leaf in `gcmh' block")
(customize-set-variable
'gcmh-high-cons-threshold #x8000000 ;; 128MB
"Customized with leaf in `gcmh' block")
(customize-set-variable
'gcmh-idle-delay 360
"Customized with leaf in `gcmh' block")
(gcmh-mode 1)))
;; (use-package gcmh
;; :doc "Use GCMH -- the Garbage Collector Magic Hack -- to adjust garbage collection."
;; :url "https://gitlab.com/koral/gcmh"
;; :tag "internal"
;; :commands gcmh-mode
;; :hook (nasy-first-key . nasy/-start-gcmh))
(setup gcmh
(:doc "Use GCMH -- the Garbage Collector Magic Hack -- to adjust garbage collection.")
(:url "https://gitlab.com/koral/gcmh")
(:tag "internal")
(:first-key nasy/-start-gcmh))
Grep builtin
(setup grep
(:tag "builtin")
(:opt
grep-highlight-matches t
grep-scroll-output t))
Helpful help lisp
A better Emacs help buffer.
https://github.com/Wilfred/helpful
(setup helpful
(:doc "A better Emacs *help* buffer.")
(:url "https://github.com/Wilfred/helpful")
(:tag "help" "lisp")
(:global
"C-c d" helpful-at-point
[remap describe-function] helpful-callable
[remap describe-variable] helpful-variable
[remap describe-key] helpful-key))
elisp-demos
(setup elisp-demos
(:doc "Demonstrate Emacs Lisp APIs.")
(:url "https://github.com/xuchunyang/elisp-demos")
(:tag "lisp" "docs")
(:advice helpful-update :after elisp-demos-advice-helpful-update))
Keyfreq extensions utilities
Track Emacs commands frequency
https://github.com/dacap/keyfreq
(setup keyfreq
(:doc "Track Emacs commands frequency")
(:url "https://github.com/dacap/keyfreq")
(:tag "extensions" "utilities")
(:opt
keyfreq-file (concat *nasy-var* "keyfreq")
keyfreq-excluded-commands
'(backward-char
dap-tooltip-mouse-motion
delete-backward-char
execute-extended-command
forward-char
keyboard-quit
kill-buffer
left-char
minibuffer-keyboard-quit
mouse-drag-region
mouse-set-point
move-beginning-of-line
move-end-of-line
next-line
org-delete-backward-char
org-end-of-line
org-return
org-self-insert-command
pixel-scroll-precision
previous-line
previous-line
right-char
right-word
save-buffer
selectrum-next-candidate
selectrum-select-current-candidate
self-insert-command
yank))
(:hook-into nasy-first-key-hook)
(:mode-hook (keyfreq-autosave-mode 1)))
marginalia extensions
marginalia.el - Marginalia in the minibuffer
https://github.com/minad/marginalia
(setup marginalia
(:doc "marginalia.el - Marginalia in the minibuffer.")
(:url "https://github.com/minad/marginalia")
(:tag "extensions")
(:load-first vertico)
(:when-loaded (marginalia-mode 1))
(:bind-into minibuffer-local-map
"M-a" marginalia-cycle))
(setup all-the-icons-completion
(:with-mode marginalia-mode
(:hook all-the-icons-completion-marginalia-setup)))
Orderless extensions
This package provides an orderless completion style that divides the pattern into space-separated components, and matches candidates that match all of the components in any order. Each component can match in any one of several ways: literally, as a regexp, as an initialism, in the flex style, or as multiple word prefixes. By default, regexp and literal matches are enabled.
https://github.com/oantolin/orderless
(defun nasy/-orderless-dispatch (pattern _index _total)
"Orderless (PATTERN) dispatch.
Recognizes the following patterns:
* ~flex flex~
* =literal literal=
* `initialism initialism`
* !without-literal without-literal!
* .ext (file extension)
* regexp$ (regexp matching at end)"
(cond
;; Ensure that $ works with Consult commands, which add disambiguation suffixes
((string-suffix-p "$" pattern) `(orderless-regexp . ,(concat (substring pattern 0 -1) "[\x100000-\x10FFFD]*$")))
;; File extensions
((string-match-p "\\`\\.." pattern) `(orderless-regexp . ,(concat "\\." (substring pattern 1) "[\x100000-\x10FFFD]*$")))
;; Ignore single !
((string= "!" pattern) `(orderless-literal . ""))
;; Without literal
((string-prefix-p "!" pattern) `(orderless-without-literal . ,(substring pattern 1)))
((string-suffix-p "!" pattern) `(orderless-without-literal . ,(substring pattern 0 -1)))
;; Initialism matching
((string-prefix-p "`" pattern) `(orderless-initialism . ,(substring pattern 1)))
((string-suffix-p "`" pattern) `(orderless-initialism . ,(substring pattern 0 -1)))
;; Literal matching
((string-prefix-p "=" pattern) `(orderless-literal . ,(substring pattern 1)))
((string-suffix-p "=" pattern) `(orderless-literal . ,(substring pattern 0 -1)))
;; Flex matching
((string-prefix-p "~" pattern) `(orderless-flex . ,(substring pattern 1)))
((string-suffix-p "~" pattern) `(orderless-flex . ,(substring pattern 0 -1)))))
(setup orderless
(:doc "Emacs completion style that matches multiple regexps in any order.")
(:url "https://github.com/oantolin/orderless")
(:tag "extensions")
(:first-key* (require 'orderless))
(:opt
completion-styles '(orderless initials basic)
orderless-matching-styles '(orderless-regexp
orderless-initialism
orderless-literal)
orderless-style-dispatchers '(nasy/-orderless-dispatch)
orderless-component-separator "[ &·]"
completion-category-defaults nil
completion-category-overrides '((file (styles partial-completion)))))
Page Break Lines convenience faces
This Emacs library provides a global mode which displays ugly form feed characters as tidy horizontal rules.
https://github.com/purcell/page-break-lines
(setup page-break-lines
(:doc "Emacs: display ugly ^L page breaks as tidy horizontal lines")
(:url "https://github.com/purcell/page-break-lines")
(:tag "convenience" "faces")
(:with-hook nasy/font-change-hook
(:hook (lambda ()
(progn
(after-x 'page-break-lines
(nasy/change-char-width page-break-lines-char 2)
(nasy/set-symbol ?⊸ 18 nil))))))
(:opt page-break-lines-char ?⊸))
Parens faces languages parens builtin
(setup paren
(:tag "builtin")
(:opt show-paren-context-when-offscreen t)
(:first-key show-paren-mode))
Projectile convenience project
Projectile is a project interaction library for Emacs. Its goal is to provide a nice set of features operating on a project level without introducing external dependencies (when feasible). For instance - finding project files has a portable implementation written in pure Emacs Lisp without the use of GNU find (but for performance sake an indexing mechanism backed by external commands exists as well).
https://github.com/bbatsov/projectile
(setup projectile
(:doc "Projectile is a project interaction library for Emacs.")
(:url "https://github.com/bbatsov/projectile")
(:tag "project" "convenience")
(:global [remap find-tag] projectile-find-tag)
(:opt
projectile-known-projects-file (concat *nasy-var* "projectile/known-projects.el")
projectile-indexing-method 'hybrid
projectile-require-project-root 'prompt
projectile-ignored-project-function #'nasy/p-ignore-p)
(:when-loaded
(setq projectile-project-root-files-top-down-recurring
(append '("compile_commands.json"
".cquery")
projectile-project-root-files-top-down-recurring))))
Recentf files
Recentf is a minor mode that builds a list of recently opened files.
https://www.emacswiki.org/emacs/RecentFiles
(defvar nasy--recentf-cleaned nil)
(setup recentf
(:doc "Recentf is a minor mode that builds a list of recently opened files.")
(:url "https://www.emacswiki.org/emacs/RecentFiles")
(:tag "files")
(:global "C-c r" recentf-open-files)
(:first-key*
(recentf-mode))
(:mode-hook
(after-x '風雨時用
(unless nasy--recentf-cleaned
(setq nasy--recentf-cleaned t)
(recentf-cleanup))))
(:opt*
recentf-save-file (concat *nasy-var* "recentf-save.el")
recentf-filename-handlers
'(;; Text properties inflate the size of recentf's files, and there is
;; no purpose in persisting them, so we strip them out.
substring-no-properties
;; Resolve symlinks of local files. Otherwise we get duplicate
;; entries opening symlinks.
nasy/file-truename
;; Keep some symlinks
nasy/file-sym-t
;; Replace $HOME with ~, which is more portable, and reduces how much
;; horizontal space the recentf listing uses to list recent files.
abbreviate-file-name)
recentf-auto-cleanup 'never
recentf-max-saved-items 1000
recentf-exclude
`(,(abbreviate-file-name
(locate-user-emacs-file *nasy-var*))
"/tmp/" "/ssh:" "/nix/store" "~/.nix/store" "/private/var/folders"
,(locate-user-emacs-file "straight"))))
Savehist history
(setup savehist
(:hook-into nasy-first-key-hook)
(:opt
kill-ring-max 300
history-length 3000
history-delete-duplicates t
savehist-autosave-interval 3600
savehist-file (concat *nasy-var* "savehist.el")
savehist-additional-variables '(mark-ring
global-mark-ring
search-ring
regexp-search-ring
extended-command-history)))
Sessions history
(setup session
(:autoload session-initialize session-save-session)
(:with-hook aftre-init-hook
(:hook session-initialize))
(:with-hook after-save-hook
(:hook session-save-session))
(:opt* session-save-file (concat *nasy-var* "session"))
(:opt
session-name-disable-regexp "\\(?:\\`'/tmp\\|\\.git/[A-Z_]+\\'\\)"
session-save-file-coding-system 'utf-8
desktop-globals-to-save
'((comint-input-ring . 50)
(compile-history . 30)
desktop-missing-file-warning
(dired-regexp-history . 20)
(extended-command-history . 30)
(face-name-history . 20)
(file-name-history . 100)
(grep-find-history . 30)
(grep-history . 30)
(ivy-history . 100)
(magit-revision-history . 50)
(minibuffer-history . 50)
(org-clock-history . 50)
(org-refile-history . 50)
(org-tags-history . 50)
(query-replace-history . 60)
(read-expression-history . 60)
(regexp-history . 60)
(regexp-search-ring . 20)
register-alist
(search-ring . 20)
(shell-command-history . 50)
tags-file-name
tags-table-list
kill-ring)))
Subword builtin
(setup subword
(:tag "builtin")
(:hook-into prog-mode-hook))
Sudo Edit convenience
Utilities for opening files with sudo
https://github.com/nflath/sudo-edit
(setup sudo-edit
(:doc "Utilities for opening files with sudo.")
(:url "https://github.com/nflath/sudo-edit")
(:tag "convenience"))
switch-window convenience
Offer a visual way to choose a window to switch to.
https://github.com/dimitri/switch-window
(setup switch-window
(:doc "Offer a *visual* way to choose a window to switch to.")
(:url "https://github.com/dimitri/switch-window")
(:tag "convenience")
(:global
"C-c 1" toggle-delete-other-windows
"C-c 2" split-window--v
"C-c 3" split-window--h
"C-x |" split-window-horizontally-instead
"C-x _" split-window-vertically-instead
"C-x o" switch-window
"C-c x" nasy/split-window
"M-o" other-window)
(:opt
;; for dvorak layout
switch-window-qwerty-shortcuts
'("a" "o" "e" "u" "h" "t" "n" "s" "i" "d"
";" "," "." "p" "y" "f" "g" "c" "l"
"'" "q" "j" "k" "x" "b" "m")
switch-window-shortcut-style 'qwerty))
Tempo builtin
(setup tempo
(:tag "builtin")
(:autoload tempo-define-template))
transient bindings
Taking inspiration from prefix keys and prefix arguments, Transient implements a similar abstraction involving a prefix command, infix arguments and suffix commands. We could call this abstraction a "transient command", but because it always involves at least two commands (a prefix and a suffix) we prefer to call it just a "transient".
https://magit.vc/manual/transient
https://github.com/magit/transient
(setup transient
(:doc "Transient commands.")
(:url "https://github.com/magit/transient")
(:tag "bindings")
(:opt
transient-history-file (concat *nasy-var* "transient/history.el")
transient-levels-file (concat *nasy-etc* "transient/levels.el")
transient-values-file (concat *nasy-etc* "transient/values.el"))
(:init (add-to-list 'nasy--defer-loads 'transient)))
Treesit
(defun na/treesit-install-language-grammar (lang)
"Build and install the tree-sitter language grammar library for LANG.
Interactively, if `treesit-language-source-alist' doesn't already
have data for building the grammar for LANG, prompt for its
repository URL and the C/C++ compiler to use.
This command requires Git, a C compiler and (sometimes) a C++ compiler,
and the linker to be installed and on PATH. It also requires that the
recipe for LANG exists in `treesit-language-source-alist'.
See `exec-path' for the current path where Emacs looks for
executable programs, such as the C/C++ compiler and linker."
(interactive (list (intern
(completing-read
"Language: "
(mapcar #'car treesit-language-source-alist)))))
(when-let ((recipe
(or (assoc lang treesit-language-source-alist)
(treesit--install-language-grammar-build-recipe
lang))))
(condition-case err
(apply #'treesit--install-language-grammar-1
;; The nil is OUT-DIR.
(cons (car treesit-extra-load-path) recipe))
(error
(display-warning
'treesit
(format "Error encountered when installing language grammar: %s"
err)))))
;; Check that the installed language grammar is loadable.
(pcase-let ((`(,available . ,err)
(treesit-language-available-p lang t)))
(when (not available)
(display-warning
'treesit
(format "The installed language grammar for %s cannot be located or has problems (%s): %s"
lang (nth 0 err)
(string-join
(mapcar (lambda (x) (format "%s" x))
(cdr err))
" "))))))
(setup treesit
(:opt treesit-font-lock-level 4)
(:when-loaded
(add-to-list 'treesit-extra-load-path
(concat *nasy-var* "treesit")))
(:advice
treesit-install-language-grammar :override na/treesit-install-language-grammar))
(setup treesit-auto
(:opt treesit-auto-install 'prompt)
(:first-key*
(require 'treesit-auto)
(add-to-list 'treesit-auto-fallback-alist '(bash-ts-mode . sh-mode))
(add-to-list 'treesit-auto-fallback-alist '(toml-ts-mode . conf-toml-mode))
(global-treesit-auto-mode)))
Unfill convenience
Functions providing the inverse of Emacs' fill-paragraph and fill-region
https://github.com/purcell/unfill
(setup unfill
(:doc "Functions providing the inverse of Emacs' fill-paragraph and fill-region")
(:url "https://github.com/purcell/unfill")
(:tag "convenience")
(:global "M-q" unfill-toggle))
Uniquify builtin files
(setup uniquify
(:tag "builtin" "files")
(:opt
uniquify-buffer-name-style 'reverse
uniquify-separator " • "
uniquify-after-kill-buffer-p t
uniquify-ignore-buffers-re "^\\*"))
valign convenience table text
这个包能对齐 Org Mode、Markdown和table.el 的表格。它能对齐包含不等宽字体、中日韩字符、图片的表格。valign 不会影响 Org Mode(或 Markdown mode)基于等宽字符的对齐。 (注:目歬不在 org-mode 中启用)
This package provides visual alignment for Org Mode, Markdown and table.el tables on GUI Emacs. It can properly align tables containing variable-pitch font, CJK characters and images. Meanwhile, the text-based alignment generated by Org mode (or Markdown mode) is left untouched.
https://github.com/casouri/valign
(setup valign
(:doc "Pixel-perfect visual alignment for Org and Markdown tables.")
(:url "https://github.com/casouri/valign")
(:tag "convenience" "table" "text")
(:hook-into markdown-mode-hook))
vc-mode vc
(setup vc
(:first-key vc-mode))
Vertico completion extensions
Vertico provides a performant and minimalistic vertical completion UI based on the default completion system. The main focus of Vertico is to provide a UI which behaves correctly under all circumstances. By reusing the built-in facilities system, Vertico achieves full compatibility with built-in Emacs completion commands and completion tables. Vertico only provides the completion UI but aims to be highly flexible, extensible and modular. Additional enhancements are available as extensions or complementary packages. The code base is small and maintainable. The main vertico.el package is only about 600 lines of code without white space and comments.
https://github.com/minad/vertico
;; Add prompt indicator to `completing-read-multiple'.
;; We display [CRM<separator>], e.g., [CRM,] if the separator is a comma.
(defun crm-indicator (args)
(cons (format "[CRM%s] %s"
(replace-regexp-in-string
"\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" ""
crm-separator)
(car args))
(cdr args)))
(setup vertico
(:doc "Vertico provides a performant and minimalistic vertical completion UI based on the default completion system.")
(:url "https://github.com/minad/vertico")
(:tag "completion")
(:advice completing-read-multiple :filter-args crm-indicator)
(:bind-into vertico-map
"M-<DEL>" vertico-directory-delete-word)
(:first-key* (vertico-mode 1))
(:with-hook minibuffer-setup-hook
(:hook vertico-repeat-save))
(:mode-hook
(vertico-mouse-mode 1)
(after-x '風雨時用
(nasy/active-region-mode 1))))
View Large File files largefiles utilities
Emacs minor mode that allows viewing, editing, searching and comparing large files in batches, trading memory for processor time.
https://github.com/m00natic/vlfi
(defun ffap-vlf ()
"Find file at point with VLF."
(interactive)
(let ((file (ffap-file-at-point)))
(unless (file-exists-p file)
(error "File does not exist: %s" file))
(vlf file)))
(setup vlf
(:doc "View Large Files in Emacs")
(:url "https://github.com/m00natic/vlfi")
(:tag "files" "large files" "utilities")
(:autoload ffap-vlf))
wgrep editing extensions grep
wgrep allows you to edit a grep buffer and apply those changes to the file buffer like sed interactively. No need to learn sed script, just learn Emacs.
https://github.com/mhayashi1120/Emacs-wgrep
(setup wgrep
(:doc "Writable grep buffer and apply the changes to files.")
(:url "https://github.com/mhayashi1120/Emacs-wgrep")
(:tag "editing" "extensions" "grep"))
Which Function builtin
(setup which-func
(:tag "builtin")
(:first-key which-function-mode))
Whitespace convenience data wp
Visualize blanks (TAB, (HARD) SPACE and NEWLINE).
https://www.emacswiki.org/emacs/WhiteSpace
In Emacs, intelligently call whitespace-cleanup on save.
https://github.com/purcell/whitespace-cleanup-mode
(defun no-trailing-whitespace ()
"Turn off display of trailing whitespace in this buffer."
(setq show-trailing-whitespace nil))
(setup whitespace
(:tag "data" "wp")
(:with-function no-trailing-whitespace
(:hook-into
;; But don't show trailing whitespace in SQLi, inf-ruby etc.
artist-mode-hook
picture-mode-hook
special-mode-hook
Info-mode-hook
eww-mode-hook
term-mode-hook
vterm-mode-hook
comint-mode-hook
compilation-mode-hook
twittering-mode-hook
minibuffer-setup-hook
fundamental-mode-hook)))
(setup whitespace-cleanup-mode
(:doc "In Emacs, intelligently call whitespace-cleanup on save.")
(:url "https://github.com/purcell/whitespace-cleanup-mode")
(:tag "convonience")
(:opt
whitespace-cleanup-mode-only-if-initially-clean nil
whitespace-style
'(face trailing tabs spaces newline
missing-newline-at-eof empty indentation
space-after-tab space-before-tab
space-mark tab-mark newline-mark))
(:hook-into text-mode-hook prog-mode-hook)
(:global "<remap> <just-one-space>" cycle-spacing))
xref builtin
(setup xref
(:opts
((xref-show-xrefs-function
xref-show-definitions-function)
. #'xref-show-definitions-completing-read)))
文
;;;###autoload
(defvar nasy/company-backend-alist
'((text-mode company-dabbrev company-yasnippet company-ispell company-files)
(prog-mode company-capf company-yasnippet company-files)
(conf-mode company-capf company-dabbrev-code company-yasnippet company-files))
"An alist matching modes to company backends.
The backends for any mode is built from this.")
;;;###autoload
(defvar nasy-cape/company
;; '(company-tabnine company-yasnippet)
'(company-yasnippet))
術
;;;###autoload
(defun nasy/add-company-backend (modes &rest backends)
"Prepend BACKENDS (in order) to `company-backends' in MODES.
MODES should be one symbol or a list of them, representing major or minor modes.
This will overwrite backends for MODES on consecutive uses.
If the car of BACKENDS is nil, unset the backends for MODES.
Examples:
(nasy/add-company-backend 'js2-mode
'company-tide 'company-yasnippet)
(nasy/add-company-backend 'sh-mode
'(company-shell :with company-yasnippet))
(nasy/add-company-backend '(c-mode c++-mode)
'(:separate company-irony-c-headers company-irony))
(nasy/add-company-backend 'sh-mode nil) ; unsets backends for `sh-mode'"
(declare (indent defun))
(dolist (mode (nasy/enlist modes))
(if (null (car backends))
(setq nasy/company-backend-alist
(delq (assq mode nasy/company-backend-alist)
nasy/company-backend-alist))
(setf (alist-get mode nasy/company-backend-alist)
backends))))
;;;###autoload
(defun nasy/company-backends ()
"Get company backends."
(let (backends)
(let ((mode major-mode)
(modes (list major-mode)))
(while (setq mode (get mode 'derived-mode-parent))
(push mode modes))
(dolist (mode modes)
(dolist (backend (append (cdr (assq mode nasy/company-backend-alist))
(default-value 'company-backends)))
(push backend backends)))
(delete-dups
(append (cl-loop for (mode . backends) in nasy/company-backend-alist
if (or (eq major-mode mode) ; major modes
(and (boundp mode)
(symbol-value mode))) ; minor modes
append backends)
(nreverse backends))))))
;;;###autoload
(defun nasy/company-init-backends-h ()
"Set `company-backends' for the current buffer."
(or (memq major-mode '(fundamental-mode special-mode))
buffer-read-only
(nasy/temp-buffer-p (or (buffer-base-buffer) (current-buffer)))
(setq-local company-backends (nasy/company-backends))))
;; (put 'nasy/company-init-backends-h 'permanent-local-hook t)
;;;###autoload
(defun nasy/company-complete ()
"Bring up the completion popup. If only one result, complete it."
(interactive)
(require 'company)
(when (ignore-errors
(/= (point)
(cdr (bounds-of-thing-at-point 'symbol))))
(save-excursion (insert " ")))
(when (and (company-manual-begin)
(= company-candidates-length 1))
(company-complete-common)))
;;;###autoload
(defun nasy/company-has-completion-p ()
"Return non-nil if a completion candidate exists at point."
(and (company-manual-begin)
(= company-candidates-length 1)))
;;;###autoload
(defun nasy/company-toggle-auto-completion ()
"Toggle as-you-type code completion."
(interactive)
(require 'company)
(setq company-idle-delay (unless company-idle-delay 0.2))
(message "Auto completion %s"
(if company-idle-delay "enabled" "disabled")))
;;;###autoload
(defun nasy/company-dabbrev ()
"Invokes `company-dabbrev-code' in `prog-mode' buffers and `company-dabbrev' everywhere else."
(interactive)
(call-interactively
(if (derived-mode-p 'prog-mode)
#'company-dabbrev-code
#'company-dabbrev)))
;;;###autoload
(defun nasy/company-whole-lines (command &optional arg &rest ignored)
"`company-mode' completion backend that completes whole-lines, akin to vim's
C-x C-l."
(interactive (list 'interactive))
(require 'company)
(pcase command
(`interactive (company-begin-backend 'nasy/company-whole-lines))
(`prefix (company-grab-line "^[\t\s]*\\(.+\\)" 1))
(`candidates
(all-completions
arg
(delete-dups
(split-string
(replace-regexp-in-string
"^[\t\s]+" ""
(concat (buffer-substring-no-properties (point-min) (line-beginning-position))
(buffer-substring-no-properties (line-end-position) (point-max))))
"\\(\r\n\\|[\n\r]\\)" t))))))
;;;###autoload
(defun nasy/company-dict-or-keywords ()
"`company-mode' completion combining `company-dict' and `company-keywords'."
(interactive)
(require 'company-dict)
(require 'company-keywords)
(let ((company-backends '((company-keywords company-dict))))
(call-interactively #'company-complete)))
;;;###autoload
(defun nasy/company-dabbrev-code-previous ()
"TODO."
(interactive)
(require 'company-dabbrev)
(let ((company-selection-wrap-around t))
(call-interactively #'nasy/company-dabbrev)
(company-select-previous-or-abort)))
;;;###autoload
(defvar nasy/prev-whitespace-mode nil)
(make-variable-buffer-local 'nasy/prev-whitespace-mode)
;;;###autoload
(defvar nasy/show-trailing-whitespace nil)
(make-variable-buffer-local 'nasy/show-trailing-whitespace)
(defvar my-prev-whitespace-mode nil)
;;;###autoload
(defun nasy/-pre-popup-draw ()
"Turn off whitespace mode before showing company complete tooltip."
(if whitespace-mode
(progn
(setq my-prev-whitespace-mode t)
(whitespace-mode -1)))
(setq nasy/show-trailing-whitespace show-trailing-whitespace)
(setq show-trailing-whitespace nil))
;;;###autoload
(defun nasy/-post-popup-draw ()
"Restore previous whitespace mode after showing company tooltip."
(if nasy/prev-whitespace-mode
(progn
(whitespace-mode 1)
(setq nasy/prev-whitespace-mode nil)))
(setq show-trailing-whitespace nasy/show-trailing-whitespace))
;;;###autoload
(defun nasy/company-filter-c ()
(company-search-abort)
(company-filter-candidates))
;;;###autoload
(defun nasy/company-box-icons--elisp-fn (candidate)
(when (derived-mode-p 'emacs-lisp-mode)
(let ((sym (intern candidate)))
(cond ((fboundp sym) 'ElispFunction)
((boundp sym) 'ElispVariable)
((featurep sym) 'ElispFeature)
((facep sym) 'ElispFace)))))
;;;###autoload
(defun nasy/company-remove-scrollbar-a (orig-fn &rest args)
"This disables the company-box scrollbar, because:
https://github.com/sebastiencs/company-box/issues/44"
(cl-letf (((symbol-function #'display-buffer-in-side-window)
(symbol-function #'ignore)))
(apply orig-fn args)))
;;;###autoload
(defun nasy/merge-capf (c)
"Merge c into completion-at-point-functions."
(remove-hook 'completion-at-point-functions t t)
(add-hook 'completion-at-point-functions c 1 'local))
;; (setq completion-at-point-functions
;; (cape-capf-buster (apply #'cape-super-capf completion-at-point-functions))))
;;;###autoload
(defun nasy/-merge-capf ()
"Merge nasy capy."
(require 'cape)
(let ((nasy-capfs (cape-capf-buster (cape-company-to-capf
(apply-partially
#'company--multi-backend-adapter
nasy-cape/company)))))
(nasy/merge-capf nasy-capfs)))
;;;###autoload
(defun nasy/orderless-dispatch-flex-first (_pattern index _total)
"orderless-flex for corfu."
(and (eq index 0) 'orderless-flex))
;;;###autoload
(defun nasy/setup-corfu ()
"Setup corfu."
(corfu-mode 1)
(setq-local orderless-matching-styles '(orderless-flex)
orderless-style-dispatchers nil)
(add-hook 'orderless-style-dispatchers (function nasy/orderless-dispatch-flex-first) nil
'local))
章
cape editing extensions
Cape provides a bunch of Completion At Point Extensions which can be used in combination with my Corfu completion UI or the default completion UI. The completion backends used by completion-at-point are so called completion-at-point-functions (Capfs). In principle, the Capfs provided by Cape can also be used by Company.
(setup cape
(:doc "Completion At Point Extensions.")
(:url "https://github.com/minad/cape")
(:tag "editing" "extensions")
(:load-first corfu company)
(:with-map mode-specific-map
(:bind
"p p" completion-at-point ;; capf
"p t" complete-tag ;; etags
"p d" cape-dabbrev ;; or dabbrev-completion
"p f" cape-file
"p k" cape-keyword
"p s" cape-symbol
"p a" cape-abbrev
"p i" cape-ispell
"p l" cape-line
"p w" cape-dict
"p \\" cape-tex
"p A-¥" cape-tex
"p &" cape-sgml
"p r" cape-rfc1345))
(:with-hook corfu-mode-hook
(:hook nasy/-merge-capf))
(:when-loaded
(setq completion-at-point-functions
(cape-capf-buster (cape-company-to-capf
(apply-partially
#'company--multi-backend-adapter
nasy-cape/company))))))
company
company
(setup company
(:autoload company--multi-backend-adapter))
;; ;; (:global
;; ;; "C-;" nasy/company-complete
;; ;; "M-/" company-files
;; ;; "C-<tab>" nasy/company-complete
;; ;; [remap indent-for-tab-command] company-indent-or-complete-common)
;; (:company-mode-map
;; ([remap indent-for-tab-command]
;; . company-indent-or-complete-common)
;; ("M-/" . company-files))
;; (:company-active-map
;; ("C-o" . company-search-kill-others)
;; ("C-n" . company-select-next)
;; ("C-p" . company-select-previous)
;; ("C-h" . company-quickhelp-manual-begin)
;; ("C-S-h" . company-show-doc-buffer)
;; ("C-s" . company-search-candidates)
;; ("M-s" . company-filter-candidates)
;; ([C-tab] . nasy/company-complete)
;; ([tab] . company-complete-common-or-cycle)
;; ([backtab] . company-select-previous))
;; (:company-search-map
;; ("C-n" . company-search-repeat-forward)
;; ("C-p" . company-search-repeat-backward)
;; ("C-s" . nasy/company-filter-c))
;; :custom
;; ((company-tooltip-limit . 10)
;; (company-dabbrev-downcase . nil)
;; (company-dabbrev-ignore-case . t)
;; (company-global-modes
;; . '(not erc-mode message-mode help-mode gud-mode eshell-mode))
;; ;; `(company-frontends
;; ;; . ,(if *c-box*
;; ;; '(company-box-frontend)
;; ;; '(company-pseudo-tooltip-frontend company-echo-metadata-frontend)))
;; (company-dabbrev-other-buffers . 'all)
;; (company-tooltip-align-annotations . t)
;; (company-minimum-prefix-length . 2)
;; (company-idle-delay . 1)
;; (company-tooltip-idle-delay . .2)
;; (company-require-match . 'never)
;; (company-format-margin-function . #'company-vscode-dark-icons-margin))
;; :hook (nasy--defer-load-hook . (lambda () (require 'company)))
;; :config
;; ;; (add-hook 'after-change-major-mode-hook #'nasy/company-init-backends-h 'append)
;; :defer-config
;; ;; (add-to-list 'completion-styles 'initials t)
;; (setq company-backends '(company-capf))
;; :advice
;; (:before company-pseudo-tooltip-unhide nasy/-pre-popup-draw)
;; (:after company-pseudo-tooltip-hide nasy/-post-popup-draw))
Company Quickhelp
;; (leaf company-quickhelp
;; :after company
;; :bind
;; (:company-active-map
;; ("C-c h" . company-quickhelp-manual-begin))
;; :hook company-mode-hook
;; :custom
;; (pos-tip-use-relative-coordinates . t))
Company Tabnine
;; (leaf company-tabnine
;; :disabled t
;; :after company
;; :custom
;; `(company-tabnine-binaries-folder . ,(concat *nasy-var* "company/tabnine-binaries"))
;; `(company-tabnine-log-file-path
;; . ,(concat *nasy-var* "company/tabnine-binaries/log")))
Company Flx
;; (leaf company-flx
;; :after company
;; :disabled t
;; :hook company-mode-hook)
Company Box
;; (leaf company-box
;; :after company
;; :hook company-mode-hook
;; :custom
;; (company-box-show-single-candidate . t)
;; (company-box-max-candidates . 25)
;; (company-box-icons-alist . 'company-box-icons-all-the-icons)
;; :config
;; (setq
;; company-box-icons-functions
;; (cons #'nasy/company-box-icons--elisp-fn
;; (delq 'company-box-icons--elisp
;; company-box-icons-functions)))
;; (after-x 'all-the-icons
;; (setq
;; company-box-icons-all-the-icons
;; (let ((all-the-icons-scale-factor 0.8))
;; `((Unknown . ,(all-the-icons-material "find_in_page" :face 'all-the-icons-purple))
;; (Text . ,(all-the-icons-material "text_fields" :face 'all-the-icons-green))
;; (Method . ,(all-the-icons-material "functions" :face 'all-the-icons-yellow))
;; (Function . ,(all-the-icons-material "functions" :face 'all-the-icons-yellow))
;; (Constructor . ,(all-the-icons-material "functions" :face 'all-the-icons-yellow))
;; (Field . ,(all-the-icons-material "functions" :face 'all-the-icons-yellow))
;; (Variable . ,(all-the-icons-material "adjust" :face 'all-the-icons-blue))
;; (Class . ,(all-the-icons-material "class" :face 'all-the-icons-cyan))
;; (Interface . ,(all-the-icons-material "settings_input_component" :face 'all-the-icons-cyan))
;; (Module . ,(all-the-icons-material "view_module" :face 'all-the-icons-cyan))
;; (Property . ,(all-the-icons-material "settings" :face 'all-the-icons-lorange))
;; (Unit . ,(all-the-icons-material "straighten" :face 'all-the-icons-red))
;; (Value . ,(all-the-icons-material "filter_1" :face 'all-the-icons-red))
;; (Enum . ,(all-the-icons-material "plus_one" :face 'all-the-icons-lorange))
;; (Keyword . ,(all-the-icons-material "filter_center_focus" :face 'all-the-icons-lgreen))
;; (Snippet . ,(all-the-icons-material "short_text" :face 'all-the-icons-lblue))
;; (Color . ,(all-the-icons-material "color_lens" :face 'all-the-icons-green))
;; (File . ,(all-the-icons-material "insert_drive_file" :face 'all-the-icons-green))
;; (Reference . ,(all-the-icons-material "collections_bookmark" :face 'all-the-icons-silver))
;; (Folder . ,(all-the-icons-material "folder" :face 'all-the-icons-green))
;; (EnumMember . ,(all-the-icons-material "people" :face 'all-the-icons-lorange))
;; (Constant . ,(all-the-icons-material "pause_circle_filled" :face 'all-the-icons-blue))
;; (Struct . ,(all-the-icons-material "streetview" :face 'all-the-icons-blue))
;; (Event . ,(all-the-icons-material "event" :face 'all-the-icons-yellow))
;; (Operator . ,(all-the-icons-material "control_point" :face 'all-the-icons-red))
;; (TypeParameter . ,(all-the-icons-material "class" :face 'all-the-icons-red))
;; (Template . ,(all-the-icons-material "short_text" :face 'all-the-icons-green))
;; (ElispFunction . ,(all-the-icons-material "functions" :face 'all-the-icons-red))
;; (ElispVariable . ,(all-the-icons-material "check_circle" :face 'all-the-icons-blue))
;; (ElispFeature . ,(all-the-icons-material "stars" :face 'all-the-icons-orange))
;; (ElispFace . ,(all-the-icons-material "format_paint" :face 'all-the-icons-pink))))))
;; :advice (:around
;; company-box--update-scrollbar
;; nasy/company-remove-scrollbar-a))
copilot.el editing extensions
Copilot.el is an Emacs plugin for GitHub Copilot.
https://github.com/zerolfx/copilot.el
(defun nasy/copilot-complete ()
"Copilot complete."
(interactive)
(copilot-clear-overlay)
(copilot-complete))
(defun nasy/copilot-disable-p ()
"Disable copilot when at the end of the file and not changed."
(and (= (point-max) (point))
(not (buffer-modified-p))))
(setup copilot
(:doc "An unofficial Copilot plugin for Emacs.")
(:url "https://github.com/zerolfx/copilot.el")
(:tag "editing" "extensions")
(:advice keyboard-quit :after copilot-clear-overlay)
(:bind-into copilot-mode-map
"C-<tab>" copilot-accept-completion
"H-SPC" nasy/copilot-complete)
(:opt copilto-idle-delay 0.8)
(:when-loaded
(add-to-list 'copilot-disable-predicates #'nasy/copilot-disable-p))
(:hook-into prog-mode-hook text-mode org-mode-hook emacs-lisp-mode-hook)
(:mode-hook
(add-to-list 'copilot--indentation-alist '(python-ts-mode python-indent py-indent-offset python-indent-offset))
(setq copilot-idle-delay 0.8)))
corfu editing extensions
Corfu enhances the default completion in region function with a completion overlay.
https://github.com/minad/corfu
(defun nasy/corfu-commit-predicate ()
"Auto-commit candidates if:
1. A '.' is typed, except after a SPACE or text/org mode.
2. A selection was made, aside from entering SPACE.
3. Just one candidate exists, and we continue to non-symbol info.
4. The 1st match is exact."
(cond
((seq-contains-p (this-command-keys-vector) ?.)
(or (string-empty-p (car corfu--input))
(not
(or (string= (substring (car corfu--input) -1) " ")
(eq major-mode 'org-mode)
(eq major-mode 'text-mode)))))
((/= corfu--index corfu--preselect) ; a selection was made
(not (seq-contains-p (this-command-keys-vector) ?\s)))
((eq corfu--total 1) ;just one candidate
(seq-intersection (this-command-keys-vector) [?: ?, ?\) ?\] ?\( ?\s]))
((and corfu--input ; exact 1st match
(string-equal (substring (car corfu--input) corfu--base)
(car corfu--candidates)))
(seq-intersection (this-command-keys-vector) [?: ?\. ?, ?\) ?\] ?\" ?' ?\s]))))
(setup corfu
(:doc "Completion Overlay Region FUnction.")
(:url "https://github.com/minad/corfu")
(:tag "editing" "extensions")
(:bind-into corfu-map
"C-g" corfu-quit
"<backtab>" corfu-last)
(:opts
((corfu-cycle
corfu-auto)
. t)
((corfu-preselect-first
corfu-preview-current)
. nil))
(:opt
corfu-quit-no-match 'separator
corfu-separator #x00b7
corfu-auto-delay 0.4
corfu-auto-prefix 2
corfu-echo-documentation 1
corfu-commit-predicate #'nasy/corfu-commit-predicate)
(:with-function nasy/setup-corfu
(:hook-into
prog-mode-hook
org-mode-hook
shell-mode-hook
eshell-mode-hook
eval-expression-minibuffer-setup-hook))
;; Extensions
(:mode-hook
(corfu-history-mode)
(corfu-indexed-mode)
(:after savehist
(add-to-list 'savehist-additional-variables 'corfu-history))))
corfu-popupinfo convenience corfu documentation popup
Display a documentation popup for completion candidate when using Corfu. It can be re regarded as company-quickhelp for Corfu.
https://github.com/minad/corfu/blob/main/extensions/corfu-popupinfo.el
(setup corfu-popupinfo
(:doc "Documentation popup for Corfu.")
(:url "https://github.com/minad/corfu/blob/main/extensions/corfu-popupinfo.el")
(:tag "convenience" "corfu" "documentation" "popup")
(:hook-into corfu-mode-hook))
citre
Citre
月出
(add-to-list 'load-path (locate-user-emacs-file "桃夭/月出"))
(require '月出)
月出皎兮、佼人嫽兮
舒窈糾兮、勞心悄兮
月出晧兮、佼人懰兮
舒憂受兮、勞心慅兮
月出照兮、佼人尞兮
舒夭綤兮、勞心憯兮
非恆用者以 *no-xxx*
爲 t
弃用之
Selective packages. Disabled the package
by setting no-package in the custom file.
章
abridge-diff diffs tools magit
A simple Emacs package for abridging refined diff hunks (for example in magit). Why abridge a diff hunk? Most diffs are line based. If you are working on files with very long lines, for example LaTeX files, or text files with full paragraphs per line (often using visual-line-mode), line-based diffs can be very challenging to read, even with "hunk refining" enabled (highlighting the words which changed).
https://github.com/jdtsmith/abridge-diff
(setup abridge-diff
(:doc "Emacs package for refining diff hunks with very long lines (as in LaTeX files).")
(:url "https://github.com/jdtsmith/abridge-diff")
(:tag "diffs" "magit" "tools")
(:load-first magit)
(:when-loaded
(abridge-diff-mode 1)))
Ansi-Color comm processes terminals services
ansi-color.el translates ANSI SGR (Select Graphic Rendition) escape sequences like "Esc[30m" into EmacsOverlays, TextProperties, or XEmacsExtents with face colours, bold, etc.
https://www.emacswiki.org/emacs/AnsiColor
(defun colourise-compilation-buffer ()
(when (eq major-mode 'compilation-mode)
(ansi-color-apply-on-region compilation-filter-start
(point-max))))
(setup ansi-color
(:doc "ansi-color.el translates ANSI SGR (Select Graphic Rendition) escape sequences with face colours, bold, etc.")
(:url "https://www.emacswiki.org/emacs/AnsiColor")
(:tag "comm" "processes" "terminals" "services"