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-丁香     "#CCA4E3")
(defconst n-淡紫丁香 "#e6cfe6")
(defconst n-品红     "#F00056")
(defconst n-墨       "#50616D")
(defconst n-墨灰     "#758A99")
(defconst n-富春紡   "#FEF4B4")
(defconst n-春緑     "#E3EFD1")
(defconst n-松绿     "#057748")
(defconst n-松花     "#BCE672")
(defconst n-水黄     "#DDEEC4")
(defconst n-龍泉靑瓷 "#C8E6C6")
(defconst n-蛤粉     "#fdfff4")
(defconst n-湖藍     "#30DFF3")
(defconst n-漆       "#161823")
(defconst n-火红     "#FF2D51")
(defconst n-牙       "#EEDEB0")
(defconst n-珈琲椶   "#705438")
(defconst n-米灰     "#D3CBAF")
(defconst n-紙棕     "#D2B38C")
(defconst n-嬭油     "#fffdd0")
(defconst n-素       "#E0F0E9")
(defconst n-紫扇貝   "#923A60")
(defconst n-缟       "#F2ECDE")
(defconst n-胡粉     "#FFFAE8")
(defconst n-芽灰     "#E3DBBF")
(defconst n-茶       "#B35C44")
(defconst n-荼       "#F3F9F1")
(defconst n-蠟白     "#FEF8DE")
(defconst n-長萅蕐   "#FF47D1")
(defconst n-霜       "#E9F1F6")
(defconst n-青莲     "#801DAE")
(defconst n-靛青     "#177CB0")
(defconst n-鱼肚     "#FCEFE8")
(defconst n-鸭黄     "#FAFF72")
(defconst n-鹅黄     "#FFF143")
(defconst n-黛       "#4A4266")
(defconst n-向日黃   "#FFC34D")
(defconst n-鳳仙粉   "#FF9393")
(defconst n-露玫瑰   "#ffe4e1")

(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)
  "Nasy theme uses underline on list.

 Should be one or more in `comment', `hl-line'."
  :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 patch font."
  :group 'nasy-theme
  :type 'string)

(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 89)))
       (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))))
   `(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/墨缟 :foreground ,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))))
   `(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
   `(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-builtin-face
     ((,class (:background ,n-春緑 :foreground ,n-珈琲椶 :slant italic))))
   `(font-lock-comment-delimiter-face
     ((,class (:inherit font-lock-comment-face :weight bold))))
   `(font-lock-comment-face
     ((,class (:foreground ,n/墨灰素
                           :slant italic
                           :underline ,(--u? 'comment)))))
   `(font-lock-constant-face
     ((,class (:inherit font-lock-variable-name-face :weight bold))))
   `(font-lock-doc-face
     ((,class (:background ,n-水黄 :foreground ,n/靛青湖藍 :extend t))))
   `(font-lock-function-name-face
     ((,class (:foreground ,n-松绿 :underline t))))
   `(font-lock-keyword-face
     ((,class (:foreground ,n/墨缟 :weight bold))))
   `(font-lock-negation-char-face
     ((,class (:foreground ,n-珈琲椶))))
   `(font-lock-string-face
     ((,class (:foreground ,n/靛青湖藍))))
   `(font-lock-type-face
     ((,class (:foreground ,n-松绿 :slant italic :weight bold))))
   `(font-lock-variable-name-face
     ((,class (:foreground ,n-茶))))
   `(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 (:background ,n-芽灰
                                   :distant-foreground ,n-墨
                                   :extend t
                                   :underline ,(--u? 'hl-line)
                                   :weight bold))))

   ;;; mode line
   `(doom-modeline-buffer-minor-mode
     ((,class (:inherit mode-line))))
   `(doom-modeline-buffer-modified
     ((,class (:foreground ,n-火红
                           :inherit mode-line
                           :weight bold))))
   `(doom-modeline-info
     ((,class (:foreground ,n-靛青
                           :inherit mode-line
                           :weight bold))))
   `(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-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-胡粉))))
   `(mode-line-inactive ((,class (:background ,n-素))))

   ;;; 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))))
   `(org-block-begin-line
     ((,class (:background ,n-嬭油
                           :box (:line-width 1 :style released-button)
                           :extend t
                           :foreground ,n/墨缟
                           :weight bold
                           :slant italic))))
   `(org-code ((,class (:background ,n-米灰
                                    :foreground ,n-墨
                                    :inheit fixed-pitch))))
   `(org-document-title
     ((,class (:background ,n-富春紡
                           :extend nil
                           :foreground ,n/墨缟
                           :height ,(--s? 1.7)
                           :weight bold))))
   `(org-document-info
     ((,class (:background ,n/素墨
                           :extend t
                           :foreground ,n/墨缟
                           :height ,(--s? 1.2)
                           :slant italic))))
   `(org-document-info-keyword
     ((,class (:background ,n/素墨
                           :extend t
                           :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-level-1
     ((,class (:background ,n-霜
                           :extend t
                           :foreground ,n-靛青
                           :height ,(--s? 1.4)
                           :overline t
                           :weight bold))))
   `(org-level-2
     ((,class (:background ,n-露玫瑰
                           :extend t
                           :foreground ,n-紫扇貝
                           :height ,(--s? 1.2)
                           :overline t
                           :weight bold))))
   `(org-level-3
     ((,class (:background ,n-春緑
                           :extend t
                           :foreground ,n-松绿
                           :height ,(--s? 1.1)
                           :overline t
                           :weight bold))))
   `(org-level-4
     ((,class (:background ,n-淡紫丁香
                           :extend t
                           :foreground ,n/青莲丁香
                           :height ,(--s? 1.1)
                           :overline t
                           :weight bold))))
   `(org-level-5
     ((,class (:extend t
                       :foreground ,n-靛青
                       :height ,(--s? 1.1)
                       :slant italic
                       :weight normal))))
   `(org-level-6
     ((,class (:extend t
                       :foreground ,n-茶
                       :height ,(--s? 1.1)
                       :slant italic
                       :weight normal))))
   `(org-level-7
     ((,class (:extend t
                       :foreground ,n-松绿
                       :height ,(--s? 1.1)
                       :slant italic
                       :weight normal))))
   `(org-level-8
     ((,class (:extend t
                       :foreground ,n/青莲丁香
                       :height ,(--s? 1.1)
                       :slant italic
                       :weight normal))))
   `(org-list-dt ((,class (:height ,(--s? 1.1) :weight bold))))
   `(org-meta-line
     ((,class (:inherit font-lock-comment-face
                        :underline nil))))
   `(org-roam-link
     ((,class (:inherit org-link
                        :overline  t
                        :underline t))))
   `(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))))

   ;;; 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-墨))))

   ;;; tree sitter
   `(tree-sitter-hl-face:constructor
     ((,class (:inherit tree-sitter-hl-face:type :bold nil))))
   `(tree-sitter-hl-face:property
     ((,class (:inherit font-lock-constant-face :bold nil))))
   `(tree-sitter-hl-face:operator
     ((,class (:background ,n-蠟白 :bold t :inherit font-lock-negation-char-face))))))

;;;###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))))))

配置

國風・鄭風・蔓艸

埜有蔓艸、霝露漙兮
有美一人、淸揚婉兮
邂逅相遇、冟我願兮

埜有蔓艸、霝路瀼瀼
有美一人、婉如淸揚
邂逅相遇、與子偕臧

吾學埶不精所述設定必有遺屚朢恕

篇者聚章而成試以詩之名名設定之篇不求其意但求其魂

擊鼓

(add-to-list 'load-path (locate-user-emacs-file  "桃夭/擊鼓" ))
(require '擊鼓)

國風・邶風・擊鼓

擊鼓其鏜、踊躍用兵
土國城漕、我獨南行

從孫子仲、平陳與宋
不我以歸、憂心有忡

爰居爰處、爰喪其馬
于以求之、于林之下

死生契闊、與子成說
執子之手、與子偕老

于嗟闊兮、不我活兮
于嗟洵兮、不我信兮

必要組件之于 Emacs 啓勭

以 raxod502 之 straight.el 載入包以 conao3 之 leaf.el 引用包

early-init

(eval-and-compile
  (unless (boundp '*nasy*)
    (load (locate-user-emacs-file"early-init.el") nil 'nomessage)))

開始之歬 加載之初 所用

;;; early-init.el --- Nasy's early-init.el  -*- lexical-binding: t; -*-

;;; Commentary:
;; Nasy's early-init.el

;;; Code:

(setq
 ad-redefinition-action            'accept
 auto-mode-case-fold               nil
 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     32
 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))))

  (add-hook 'emacs-startup-hook #'nasy/restore-default))


(set-language-environment "UTF-8")
(setq selection-coding-system 'utf-8)


(defconst *nasy* "20220409")

(defconst *is-a-mac* (eq system-type 'darwin))

(defconst *nasy-custom* (concat user-emacs-directory "芄蘭/"))
(defconst *nasy-site*   (concat user-emacs-directory "木瓜/"))
(defconst *nasy-dir*    (concat 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))

(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

straight

(eval-and-compile
  (with-no-warnings
    (setq straight-vc-git-default-clone-depth     1
          straight-repository-branch              "develop"
          straight-enable-use-package-integration nil
          straight-check-for-modifications        nil))
  (defvar bootstrap-version)

  (let ((bootstrap-file
         (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
        (bootstrap-version 5))
    (unless (file-exists-p bootstrap-file)
      (with-current-buffer
          (url-retrieve-synchronously
           "https://raw.githubusercontent.com/raxod502/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 "???"))))))


(cl-eval-when (compile eval load)
  (defmacro sup (&rest body)
    `(progn
       (cl-eval-when (compile eval load)
         (straight-use-package ,@body))
       (if nasy--require
           (cl-eval-when (compile eval load)
             (if (symbolp ,@body)
                 (require ,@body nil t)
               (require (car ,@body) nil t)))
         (cl-eval-when (compile)
           (if (symbolp ,@body)
               (require ,@body nil t)
             (require (car ,@body) nil t)))))))


;; (eval-and-compile
;;   (defmacro sup (&rest body)
;;     `(progn
;;        (eval-and-compile
;;          (straight-use-package ,@body))
;;        (if nasy--require
;;            (eval-when-compile
;;              (if (symbolp ,@body)
;;                  (require ,@body nil t)
;;                (require (car ,@body) nil t)))
;;          (eval-when-compile
;;            (if (symbolp ,@body)
;;                (require ,@body nil t)
;;              (require (car ,@body) nil t)))))))

leaf

(eval-and-compile
  (straight-use-package 'leaf)
  (straight-use-package 'leaf-keywords)
  (require 'leaf)
  (require 'leaf-keywords)
  (leaf-keywords-init)
  (setq leaf-defaults '(:leaf-autoload nil :leaf-defun nil)))

(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)))

(advice-add 'leaf :before-while #'nasy/-package-filter)

(defmacro n/leaf-nv (name &rest body)
  "Nasy wrap leaf no defvar BODY with a default require and NAME."
  (declare (indent 1))
  `(leaf ,name
     :require ,(or nasy--require nasy-pdump)
     ,@body))

(defmacro n/leaf-nr (name &rest body)
  "Nasy wrap leaf no require BODY with a default defvar and NAME."
  (declare (indent 1))
  (let ((namesym (intern (format "*no-%s*" name))))
    `(leaf ,name
       :defvar ,namesym
       :disabled (and (boundp ',namesym)
                     ,namesym)
       ,@body)))

(defmacro n/leaf (name &rest body)
  "Nasy wrap leaf BODY with a default defvar and require and NAME."
  (declare (indent 1))
  (let ((namesym (intern (format "*no-%s*" name))))
    `(leaf ,name
       :defvar ,namesym
       :disabled (and (boundp ',namesym)
                     ,namesym)
       :require ,(or nasy--require nasy-pdump)
       ,@body)))

包之墬阯 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 之外

(cl-eval-when (compile eval load)
  (straight-register-package
   '(keytar :type git
            :host github
            :repo "emacs-grammarly/keytar"))

  (straight-register-package
   '(parinfer-rust-mode :type git
                        :host github
                        :repo "justinbarclay/parinfer-rust-mode"))

  (straight-register-package
   '(point-history :type git
                   :host github
                   :repo "blue0513/point-history"))

  (straight-register-package
   '(vundo :type git
           :host github
           :repo "casouri/vundo")))

載入 org

(sup 'org)
(sup 'org-contrib)

自定義

例子~芄蘭之例~、个人配置~芄蘭~與自定義~custom-file~

肰定義 custom-file 于此並無載入之意苟欲載入置 (load custom-file) 于个人配置 芄蘭 之內。

載入
(cl-eval-when (compile eval load)
  (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))

(provide '芄蘭之例)

清汙薉   internal

gcmh 管理汙薉

GCMH   internal

Use GCMH – the Garbage Collector Magic Hack – to adjust garbage collection.

https://gitlab.com/koral/gcmh

(leaf gcmh
  :doc "Use GCMH --  the Garbage Collector Magic Hack -- to adjust garbage collection."
  :url "https://gitlab.com/koral/gcmh"
  :tag "internal"
  :defun gcmh-mode
  :hook (nasy-first-key-hook . nasy/-start-gcmh)
  :init (sup 'gcmh))

(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)))

整置文件   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 '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."))

風雨

(leaf 風雨
  :load-path* "桃夭/風雨"
  :require t
  :config (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))))
    (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)
(leaf
  :init
  (sup `(:local-repo ,(concat *nasy-site* "nasy/nasy-theme")
            :files ("彩.el")))
  (require '))
(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)))))
Font
(defvar nasy/font-change-hook nil
  "Hooks to run after font changed.")

(defvar nasy--cus-font nil)
(defvar nasy--set-font nil)


(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))


(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 *font-symbol-family*)
        (set-fontset-font (frame-parameter nil 'font)
                          charset
                          (font-spec :family "Apple Color Emoji")
                          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 "Apple Color Emoji"))
      ;; For NS/Cocoa
      (set-fontset-font (frame-parameter nil 'font)
                        'symbol
                        (font-spec :family "Apple Color Emoji")
                        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))

    (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 _)
  "Font."
  (setq nasy--set-font t)
  (leaf nasy-font
    :doc "一些默訒値。"
    :custom
    (*font-main-family*   . "OperatorMonoSSmLig Nerd Font")
    (*font-symbol-family* . "Symbola")
    (*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-mode-line-family*
      *font-header-line-family*
      *font-tab-line-family*)
     . "Recursive Mono Casual Static")

    ((*font-main-size*
      *font-mode-line-size*)
     . 14)
    (*font-tab-line-size* . 13)
    (*font-symbol-size* . 17)
    ((*font-cjk-size*
      *font-cjk-2-size*
      *font-cjk-3-size*
      *font-cjk-4-size*
      *font-cjk-5-size*)
     . nil)
    (*font-header-line-size* . 12)

    ((*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*)
     . 'normal)

    (*font-main-weight* . 'medium)

    ((*font-cjk-weight*
      *font-cjk-2-weight*
      *font-cjk-3-weight*)
     . 'medium)


    ((*font-cjk-4-weight*
      *font-cjk-5-weight*) . 'bold))

  (require '芄蘭 nil t))


(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)

(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 '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 ()
  (leaf mac
    :when *is-a-mac*
    :bind
    ("C-z"   . stop-minimizing-window)
    ("M-¥"   . nasy/-insert-backslash)
    ("A-¥"   . nasy/-insert-backslash)
    ("A-C-¥" . toggle-input-method)

    ;; 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)

    :custom
    (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                   . (90 . 75))
          (vertical-scroll-bars    . nil)
          (border-width            . 5)
          (internal-border-width   . 24)))

    :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)
  (setq nasy--require t)
  (add-to-list 'load-path (locate-user-emacs-file  "桃夭/擊鼓"))
  (add-to-list 'load-path (locate-user-emacs-file  "桃夭/風雨"))
  (require '擊鼓)
  (require '風雨)

  (sup 'avy)
  (sup 'beacon)
  (sup 'dashboard)
  (sup 'flycheck)
  (sup 'projectile)
  (sup 'smartparens)
  (sup 'treemacs)

  (require 'winner)
  (require 'xref)
  (setq nasy--require nil))


(cl-eval-when (compile eval load)
  (require '風雨))
(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 stop-minimizing-window ()
  "Stop minimizing window under macOS."
  (interactive)
  (unless (and *is-a-mac*
               window-system)
    (suspend-frame)))


;;;###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)))
重新加載 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
              "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)))


(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)))


(leaf nasy-keybinding
  :hook (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

緑衣

(leaf 緑衣
  :load-path* "桃夭/緑衣"
  :require t)

(leaf
  :load-path* "桃夭/緑衣"
  :require t)

國風・邶風・緑衣

緑兮衣兮、緑衣黃裹
心之憂矣、曷維其已

緑兮衣兮、緑衣黃裳
心之憂矣、曷維其亡

緑兮絲兮、女所治兮
我恖古人、俾無訧兮

絺兮綌兮、淒其以風
我恖古人、實獲我心

永不弃者載入于初始之旹也

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

(leaf anzu
  :doc "anzu.el is an Emacs port of anzu.vim."
  :url "https://github.com/emacsorphanage/anzu"
  :tag "search" "tools"
  :hook ((nasy-first-key-hook . global-anzu-mode))
  :bind (([remap query-replace]        . anzu-query-replace)
         ([remap query-replace-regexp] . anzu-query-replace-regexp))
  :init (sup 'anzu))
Avy   point location

Jump to things in Emacs tree-style.

https://github.com/abo-abo/avy

(leaf avy
  :doc "Jump to things in Emacs tree-style."
  :url "https://github.com/abo-abo/avy"
  :tag "point" "location"
  :custom
  (avy-keys . '(?a ?o ?e ?u ?i ?d ?h ?t ?n ?s)) ;; for dvorak
  :bind
  ("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)
  :init (sup 'avy))
Beginend   editing

Emacs package to redefine M-< and M-> for some modes

https://github.com/DamienCassou/beginend

(leaf beginend
  :doc "Emacs package to redefine M-< and M-> for some modes"
  :url "https://github.com/DamienCassou/beginend"
  :tag "editing"
  :hook ((emacs-startup-hook . beginend-global-mode))
  :init (sup 'beginend))
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"))))

(leaf compile
  :tag "builtin"
  :advice (:after compilation-start nasy/save-compilation-buffer)
  :bind (([f6] . recompile))
  :hook ((compilation-finish-functions . alert-after-compilation-finish)))
Consult   extensions

consult.el - Consulting completing-read.

https://github.com/minad/consult

Include consult, consult-selectrum & consult-flycheck.

consult
(leaf consult
  :doc "consult.el - Consulting completing-read"
  :url "https://github.com/minad/consult"
  :tag "extensions"
  :after selectrum
  :require t recentf
  :custom
  `(consult-narrow-key . ,(kbd "C-."))
  :bind
  (([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 apropos]            . consult-apropos)
   ([remap bookmark-jump]      . consult-bookmark)
   ([remap goto-line]          . consult-goto-line)
   ([remap imenu]              . consult-imenu)
   ([remap multi-occur]        . consult-multi-occur)
   ([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))
  :init (sup 'consult)
  :defer-config
  (consult-customize
   consult-theme
   :preview-key (list (kbd "M-.")
                      :debounce 3 (kbd "<up>") (kbd "<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 (list (kbd "M-.")
                      :debounce 5 (kbd "<up>") (kbd "<down>")
                      :debounce 5 'any))
  (defun nasy/consult-line-symbol-at-point ()
    (interactive)
    (consult-line (thing-at-point 'symbol))))
consult-selectrum
(leaf consult-selectrum
  :doc "consult.el - Consulting completing-read"
  :url "https://github.com/minad/consult"
  :tag "extensions"
  :after consult selectrum
  :require t)
consult-flycheck
(leaf consult-flycheck
  :doc "consult.el - Consulting completing-read"
  :url "https://github.com/minad/consult"
  :tag "extensions"
  :after consult
  :bind (:flycheck-command-map
         ("!" . consult-flycheck))
  :init (sup 'consult-flycheck))
consult-dir   convenience

Consult-dir allows you to easily select and switch between “active” directories.

https://github.com/karthink/consult-dir

(leaf consult-dir
  :doc "consult-dir: switch directories easily in Emacs"
  :url "https://github.com/karthink/consult-dir"
  :tag "convenience"
  :after consult selectrum
  :bind
  ("C-x C-d" . consult-dir)
  (:minibuffer-local-completion-map
   ("C-x C-d" . consult-dir)
   ("C-x C-j" . consult-dir-jump-file))
  (:selectrum-minibuffer-map
   ("C-x C-d" . consult-dir)
   ("C-x C-j" . consult-dir-jump-file))
  :init (sup 'consult-dir))
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

(leaf dired
  :doc "DiredMode is the mode of a Dired buffer."
  :url "https://www.emacswiki.org/emacs/DiredMode"
  :tag "files"
  :bind
  (:dired-mode-map
   ([mouse-2] . dired-find-file)
   ("C-c C-p" . wdired-change-to-wdired-mode))
  :custom
  `(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

(leaf easy-kill
  :doc "Kill & Mark Things Easily in Emacs."
  :url "https://github.com/leoliu/easy-kill"
  :tag "killing" "convenience"
  :init (sup 'easy-kill)
  :bind (([remap kill-ring-save] . easy-kill)
         ([remap mark-sexp]      . easy-mark)))
Emacs Spatial Navigate   editing

Spatial navigation in Emacs.

https://gitlab.com/ideasman42/emacs-spatial-navigate

(leaf spatial-navigate
  :doc "Spatial navigation in Emacs."
  :url "https://gitlab.com/ideasman42/emacs-spatial-navigate"
  :tag "editing"
  :bind (("<C-p>" . spatial-navigate-backward-vertical-bar)
         ("<C-n>" . spatial-navigate-forward-vertical-bar)
         ("<M-b>" . spatial-navigate-backward-horizontal-bar)
         ("<M-f>" . spatial-navigate-forward-horizontal-bar)
         ("<M-up>" . spatial-navigate-backward-vertical-box)
         ("<M-down>" . spatial-navigate-forward-vertical-box)
         ("<H-left>" . spatial-navigate-backward-horizontal-box)
         ("<H-right>" . spatial-navigate-forward-horizontal-box))
  :init (sup 'spatial-navigate))
embark   convenience

Emacs Mini-Buffer Actions Rooted in Keymaps.

https://github.com/oantolin/embark/

(defun refresh-selectrum ()
  (setq selectrum--previous-input-string nil))


;; (defun nasy/-resize-embark-collect-window (&rest _)
;;   "Automatically resizing auto-updating Embark Collect buffers to fit their contents."
;;   (when (memq embark-collect--kind '(:live :completions))
;;     (fit-window-to-buffer (get-buffer-window)
;;                           (floor (frame-height) 2) 1)))

;; (defun shrink-selectrum ()
;;   "Shrink Selectrum to a single line while using embark-collect-live."
;;   (when (eq embark-collect--kind :live)
;;     (with-selected-window (active-minibuffer-window)
;;       (setq-local selectrum-num-candidates-displayed 1)
;;       (setq-local selectrum-display-style
;;                   '(horizontal :before-candidates "[" :after-candidates "]"
;;                                :more-candidates "" :candidates-separator "")))))

(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)))

(leaf embark
  :doc "Emacs Mini-Buffer Actions Rooted in Keymaps."
  :url "https://github.com/oantolin/embark"
  :tag "convenience"
  :after selectrum
  :require t
  :advice
  (:around embark-completiing-read-prompter embark-hide-which-key-indicator)
  :bind
  ([remap describe-bindings] . embark-bindings)
  ("C-," . embark-dwim)
  (:embark-file-map
   ("s" . sudo-edit))
  (:selectrum-minibuffer-map
   ("M-o" . embark-act))
  (:nasy/active-region-map
   :package 風雨旹用
   ("M-o" . embark-act))
  :custom
  (embark-indicators
   . '(embark-which-key-indicator
       embark-highlight-indicator
       embark-isearch-highlight-indicator))
  :hook
  ;; icomplete
  ;; (embark-pre-action-hook . completion--flush-all-sorted-completions)
  ;; selectrum
  ;; (embark-pre-action-hook   . refresh-selectrum)
  ;; (embark-collect-mode-hook . shrink-selectrum)
  ;; Embark Collect
  ;; (embark-post-action-hook . embark-collect--update-linked)

  ;; misc
  ;; (embark-collect-post-revert-hook . nasy/-resize-embark-collect-window)

  :init (sup 'embark)
  :config
  ;; 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)))))


(leaf embark-consult
  :after embark consult
  :require t
  :hook (embark-collect-mode-hook . consult-preview-at-point-mode)
  :init (sup 'embark-consult))
Flycheck   convenience languages tools

Modern on-the-fly syntax checking extension for GNU Emacs.

flycheck.org

https://github.com/flycheck/flycheck

(leaf flycheck
  :doc "On the fly syntax checking for GNU Emacs."
  :url "https://github.com/flycheck/flycheck"
  :tag "convenience" "languages" "tools"
  :hook prog-mode-hook
  :custom
  (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
  (: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))
  :init
  (sup 'flycheck)
  (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)))
  :defer-config
  (defalias 'show-error-at-point-soon
    'flycheck-show-error-at-point)
  (add-to-list 'flycheck-emacs-lisp-checkdoc-variables 'sentence-end-double-space))
Grep   builtin
(leaf grep
  :tag "builtin"
  :custom
  ((grep-highlight-matches grep-scroll-output) . t))
Helpful   help lisp

A better Emacs help buffer.

https://github.com/Wilfred/helpful

(leaf helpful
  :doc "A better Emacs *help* buffer."
  :url "https://github.com/Wilfred/helpful"
  :tag "help" "lisp"
  :bind (("C-c d" . helpful-at-point)
         ([remap describe-function]   . helpful-callable)
         ([remap describe-variable]   . helpful-variable)
         ([remap describe-key]        . helpful-key))
  :init (sup 'helpful))
elisp-demos
(leaf elisp-demos
  :doc "Demonstrate Emacs Lisp APIs."
  :url "https://github.com/xuchunyang/elisp-demos"
  :tag "lisp" "docs"
  :init (sup 'elisp-demos)
  :advice (:after helpful-update elisp-demos-advice-helpful-update))
Keyfreq   extensions utilities

Track Emacs commands frequency

https://github.com/dacap/keyfreq

(leaf keyfreq
  :doc "Track Emacs commands frequency"
  :url "https://github.com/dacap/keyfreq"
  :tag "extensions" "utilities"
  :custom
  `(keyfreq-file . ,(concat *nasy-var* "keyfreq"))
  (keyfreq-excluded-commands
   . '(
       backward-char
       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
       previous-line
       previous-line
       right-char
       right-word
       save-buffer
       selectrum-next-candidate
       selectrum-select-current-candidate
       self-insert-command
       yank))
  :hook (nasy-first-key-hook)
  :mode-hook (keyfreq-autosave-mode 1)
  :init (sup 'keyfreq))
marginalia   extensions

marginalia.el - Marginalia in the minibuffer

https://github.com/minad/marginalia

(leaf marginalia
  :doc "marginalia.el - Marginalia in the minibuffer."
  :url "https://github.com/minad/marginalia"
  :tag "extensions"
  :after selectrum
  :bind (:minibuffer-local-map
         ("M-a" . marginalia-cycle))
  :init
  (sup 'marginalia)
  (marginalia-mode 1)
  :advice (:after marginalia-cycle
                  (lambda ()
                    (when (bound-and-true-p selectrum-mode)
                      (selectrum-exhibit)))))
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

(leaf orderless
  :doc "Emacs completion style that matches multiple regexps in any order."
  :url "https://github.com/oantolin/orderless"
  :tag "extensions"
  :leaf-autoload t
  :leaf-defun t
  :commands (n/first-initialism n/flex-if-twiddle
             n/strict-if-hash n/without-if-bang)
  :custom
  (completion-styles . '(orderless))
  (orderless-skip-highlighting . (lambda () selectrum-is-active))
  (orderless-matching-styles
   . '(orderless-regexp
       orderless-initialism
       orderless-literal))
  (selectrum-highlight-candidates-function . #'orderless-highlight-matches)
  (orderless-style-dispatchers   . '(nasy/-orderless-dispatch))
  (orderless-component-separator . "[ &·]")
  (completion-category-overrides . '((file (styles . (partial-completion)))))

  :init
  (sup '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)))))
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

(leaf 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"
  :hook
  (nasy-first-key-hook . global-page-break-lines-mode)
  (nasy/font-change-hook
   . (lambda ()
       (progn
         (nasy/change-char-width page-break-lines-char 2)
         (nasy/set-symbol ?⊸ 18 nil))))
  :custom
  (page-break-lines-char . ?⊸)
  :init (sup 'page-break-lines))
Parens   faces languages parens builtin
(leaf paren
  :tag "builtin"
  :custom (show-paren-context-when-offscreen . t)
  :hook (nasy-first-key-hook . 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

(leaf projectile
  :doc "Projectile is a project interaction library for Emacs."
  :url "https://github.com/bbatsov/projectile"
  :tag "project" "convenience"
  :bind ([remap find-tag] . projectile-find-tag)
  :custom
  `(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)
  :init (sup 'projectile)
  :config
  (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)

(leaf recentf
  :doc "Recentf is a minor mode that builds a list of recently opened files."
  :url "https://www.emacswiki.org/emacs/RecentFiles"
  :tag "files"
  :bind ("C-c r" . recentf-open-files)
  :hook nasy-first-key-hook
  :mode-hook
  (after-x '風雨旹用
    (unless nasy--recentf-cleaned
      (setq nasy--recentf-cleaned t)
      (recentf-cleanup)))
  :custom
  `(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-etc*))
       ,(abbreviate-file-name
         (locate-user-emacs-file *nasy-var*))
       "/tmp/" "/ssh:" "/nix/store" "~/.nix/store" ,(locate-user-emacs-file "straight"))))
Savehist   history
(leaf savehist
  :hook emacs-startup-hook
  :custom
  (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)))
Selectrum   extensions

Better solution for incremental narrowing in Emacs.

https://github.com/raxod502/selectrum

(leaf selectrum
  :doc "Better solution for incremental narrowing in Emacs."
  :url "https://github.com/raxod502/selectrum"
  :tag "extensions"
  :hook
  (nasy-first-key-hook)
  (nasy--defer-load-hook . (lambda () (require 'selectrum)))
  :mode-hook
  (after-x '風雨旹用
    (nasy/active-region-mode 1))
  :init
  (sup 'selectrum))
Sessions   history
(leaf session
  :hook
  (nasy-first-key-hook . session-initialize)
  (after-save-hook     . session-save-session)
  :custom
  `(session-save-file              . ,(concat *nasy-var* "session"))
  (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))
  :init (sup 'session))
Subword   builtin
(leaf subword
  :tag "builtin"
  :hook prog-mode-hook)
Sudo Edit   convenience

Utilities for opening files with sudo

https://github.com/nflath/sudo-edit

(leaf sudo-edit
  :doc "Utilities for opening files with sudo."
  :url "https://github.com/nflath/sudo-edit"
  :tag "convenience"
  :init (sup 'sudo-edit))
switch-window   convenience

Offer a visual way to choose a window to switch to.

https://github.com/dimitri/switch-window

(leaf switch-window
  :doc "Offer a *visual* way to choose a window to switch to."
  :url "https://github.com/dimitri/switch-window"
  :tag "convenience"
  :after transient
  :bind
  ("C-c o" . transient-dwim--nasy/switch-window)
  ("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)
  :custom
  (switch-window-shortcut-style . 'alphabet)
  (switch-window-timeout        . nil)
  :hook (nasy--defer-load-hook . (lambda () (require 'switch-window)))
  :transient
  (transient-dwim--nasy/switch-window nil
    "Transient-dwim for `switch-window'."
    [["Switch Window"
      ("o" "Other window" other-window)
      ("s" "Switch mindow" switch-window)
      ("1" "Delete other window" toggle-delete-other-windows)
      ("r" "Split window right" split-window-right)
      ("b" "Split window below" split-window-below)
      ("|" "Split window horizontally" split-window-horizontally-instead)
      ("_" "Split window vertically" split-window-vertically-instead)
      ("x" "Split window show recently" nasy/split-window)]])
  :init (sup 'switch-window))
Tempo   builtin
(leaf tempo
  :tag "builtin"
  :leaf-autoload t
  :leaf-defun t
  :commands 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

(leaf transient
  :doc "Transient commands."
  :url "https://github.com/magit/transient"
  :tag "bindings"
  :custom
  `((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")))
  :hook (nasy--defer-load-hook . (lambda () (require 'transient)))
  :init (add-to-list 'nasy--defer-loads 'transient))
Unfill   convenience

Functions providing the inverse of Emacs' fill-paragraph and fill-region

https://github.com/purcell/unfill

(leaf unfill
  :doc "Functions providing the inverse of Emacs' fill-paragraph and fill-region"
  :url "https://github.com/purcell/unfill"
  :tag "convenience"
  :bind (("M-q" . unfill-toggle))
  :init (sup 'unfill))
Uniquify   builtin files
(leaf uniquify
  :tag "builtin" "files"
  :custom
  (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)基于等宽字符的对齐。

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

(leaf valign
  :doc "Pixel-perfect visual alignment for Org and Markdown tables."
  :url "https://github.com/casouri/valign"
  :tag "convenience" "table" "text"
  :hook (org-mode-hook)
  :init (sup 'valign))
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

(leaf vlf
  :doc "View Large Files in Emacs"
  :url "https://github.com/m00natic/vlfi"
  :tag "files" "large files" "utilities"
  :leaf-autoload t
  :leaf-defun t
  :commands ffap-vlf
  :init
  (sup 'vlf)
  (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))))
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

(leaf wgrep
  :doc "Writable grep buffer and apply the changes to files."
  :url "https://github.com/mhayashi1120/Emacs-wgrep"
  :tag "editing" "extensions" "grep"
  :init (sup 'wgrep))
Which Function   builtin
(leaf which-func
  :tag "builtin"
  :hook (nasy-first-key-hook . 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))

(leaf whitespace
  :tag "data" "wp"
  :init
  :hook
  ;; 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) . no-trailing-whitespace))

(leaf whitespace-cleanup-mode
  :doc "In Emacs, intelligently call whitespace-cleanup on save."
  :url "https://github.com/purcell/whitespace-cleanup-mode"
  :tag "convonience"
  :custom
  (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 (text-mode-hook prog-mode-hook)
  :bind (("<remap> <just-one-space>" . cycle-spacing))
  :init (sup 'whitespace-cleanup-mode))
xref   builtin
(leaf xref
  :custom
  ((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))

;;;###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.

https://github.com/minad/cape

(leaf cape
  :doc "Completion At Point Extensions."
  :url "https://github.com/minad/cape"
  :tag "editing" "extensions"
  :after corfu
  :require t corfu company company-tabnine
  :bind (:mode-specific-map
         ("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))
  :hook ((corfu-mode-hook)
         . nasy/-merge-capf)
  :init (sup 'cape)
  :config
  (setq completion-at-point-functions
        (cape-capf-buster (cape-company-to-capf
                           (apply-partially
                            #'company--multi-backend-adapter
                            nasy-cape/company)))))
company
company
(leaf company
  ;; :hook (prog-mode-hook org-mode-hook)
  :bind
  ;; ("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))
  :init (sup '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)
  :init (sup 'company-quickhelp))
Company Tabnine
(leaf company-tabnine
  :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"))
  :init (sup 'company-tabnine))
Company Flx
(leaf company-flx
  :after company
  :hook company-mode-hook
  :init (sup 'company-flx))
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)
  :init
  (sup 'company-box)
  :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))

(leaf copilot
  :doc "An unofficial Copilot plugin for Emacs."
  :url "https://github.com/zerolfx/copilot.el"
  :tag "editing" "extensions"
  :advice (:after keyboard-quit copilot-clear-overlay)
  :bind
  (("C-<tab>" . copilot-accept-completion)
   ("H-SPC"   . nasy/copilot-complete))
  :custom
  (copilto-idle-delay . 3)
  :hook (prog-mode-hook python-mode-hook)
  :init
  (sup '(copilot :host github :repo "zerolfx/copilot.el"
                 :files ("dist" "copilot.el"))))
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) " ")
             org-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]))))

(leaf corfu
  :doc "Completion Overlay Region FUnction."
  :url "https://github.com/minad/corfu"
  :tag "editing" "extensions"
  :bind
  (:corfu-map
   ("C-g"       . corfu-quit)
   ("<backtab>" . corfu-last))
  :custom
  ((corfu-cycle
    corfu-auto)
   . t)
  (corfu-quit-no-match . 'separator)
  (corfu-separator . #x00b7)
  ((corfu-preselect-first
    corfu-preview-current)
   . nil)
  (corfu-auto-delay  . 0.4)
  (corfu-auto-prefix . 2)
  (corfu-echo-documentation . 1)
  (corfu-commit-predicate . #'nasy/corfu-commit-predicate)
  :hook
  ((prog-mode-hook
    org-mode-hook
    shell-mode-hook
    eshell-mode-hook)
   . nasy/setup-corfu)
  :init (sup 'corfu))
corfu-doc   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/galeo/corfu-doc

(leaf corfu-doc
  :doc "Documentation popup for Corfu."
  :url "https://github.com/galeo/corfu-doc"
  :tag "convenience" "corfu" "documentation" "popup"
  :bind (:corfu-map
         ("M-d" . corfu-doc-toggle)
         ("M-p" . corfu-doc-scroll-down)
         ("M-n" . corfu-doc-scroll-up))
  :hook (corfu-mode-hook . corfu-doc-mode)
  :init (sup 'corfu-doc))
citre

Citre

月出

(leaf 月出
  :load-path* "桃夭/月出"
  :require t)

月出皎兮、佼人嫽兮
舒窈糾兮、勞心悄兮

月出晧兮、佼人懰兮
舒憂受兮、勞心慅兮

月出照兮、佼人尞兮
舒夭綤兮、勞心憯兮

非恆用者以 *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

(leaf 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"
  :after magit
  :init
  (sup 'abridge-diff)
  (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

(leaf 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"
  :leaf-autoload t
  :leaf-defun t
  :commands colourise-compilation-buffer
  :after compile
  :hook ((compilation-filter-hook . colourise-compilation-buffer))
  :init
  (sup 'ansi-color)
  :defer-config
  (defun colourise-compilation-buffer ()
    (when (eq major-mode 'compilation-mode)
      (ansi-color-apply-on-region compilation-filter-start
                                  (point-max)))))
beacon   convenience

A light that follows your cursor around so you don't lose it!

https://github.com/Malabarba/beacon

(leaf beacon
  :doc "Never lose your cursor again."
  :url "https://github.com/Malabarba/beacon"
  :tag "convenience"
  :custom
  (beacon-size . 8)
  (beacon-blink-delay . 0.1)
  ((beacon-blink-when-point-moves-vertically
    beacon-blink-when-point-moves-horizontally)
   . 1)
  (blink-cursor-interval . 1)
  (beacon-dont-blink-commands . nil)
  :hook
  (nasy-first-key-hook . (lambda () (require 'beacon)))
  :init (sup 'beacon))
Color Identifiers Mode   faces languages

Emacs minor mode to highlight each source code identifier uniquely based on its name.

https://github.com/ankurdave/color-identifiers-mode

(leaf color-identifiers-mode
  :doc "Emacs minor mode to highlight each source code identifier uniquely based
on its name."
  :url "https://github.com/ankurdave/color-identifiers-mode"
  :tag "faces" "languages"
  :hook prog-mode-hook
  :init (sup 'color-identifiers-mode))
Default Text Scale   text
(leaf default-text-scale
  :leaf-autoload t
  :leaf-defun t
  :commands default-text-scale-mode
  :hook nasy-first-key-hook
  :init (sup 'default-text-scale))
dired-async   dired async network

Simple library for asynchronous processing in Emacs.

https://github.com/jwiegley/emacs-async

(leaf dired-async
  :doc "Simple library for asynchronous processing in Emacs."
  :url "https://github.com/jwiegley/emacs-async"
  :tag "dired" "async" "network"
  :leaf-autoload t
  :leaf-defun t
  :commands dired-async-mode
  :hook dired-mode-hook
  :init (sup 'async))
Dired Hack   files

Collection of useful dired additions

https://github.com/Fuco1/dired-hacks

(leaf dired-hacks
  :doc "Collection of useful dired additions"
  :url "https://github.com/Fuco1/dired-hacks"
  :tag "files"
  :init
  (sup 'f)
  (sup 'dired-hacks))
Dired Filter
(leaf dired-filter
  :after dash
  :bind
  (:dired-filter-map
   ("p" . dired-filter-pop-all))
  :hook (dired-mode-hook
         (dired-mode-hook . dired-filter-group-mode))
  :custom
  (dired-filter-revert . 'never)
  (dired-filter-group-saved-groups
   . '(("default"
        ("Git"
         (directory . ".git")
         (file . ".gitignore"))
        ("Directory"
         (directory))
        ("PDF"
         (extension . "pdf"))
        ("LaTeX"
         (extension "tex" "bib"))
        ("Source"
         (extension "c" "cpp" "hs" "rb" "py" "r" "cs" "el" "lisp" "html" "js" "css"))
        ("Doc"
         (extension "md" "rst" "txt"))
        ("Org"
         (extension . "org"))
        ("Archives"
         (extension "zip" "rar" "gz" "bz2" "tar"))
        ("Images"
         (extension "jpg" "JPG" "webp" "png" "PNG" "jpeg" "JPEG" "bmp" "BMP" "TIFF" "tiff" "gif" "GIF")))))
  :init (sup 'dired-filter)
  :defer-config
  (define-key dired-filter-map (kbd "/") dired-filter-mark-map))


(leaf dired-filter
  :leaf-autoload t
  :leaf-defun t
  :commands dired-filter-group-mode)
Dired Rainbow
(leaf dired-rainbow
  :leaf-autoload t
  :leaf-defun t
  :commands (dired nasy/-init-dired-rainbow dired-rainbow-define dired-rainbow-define-chmod)
  :defun nasy/-init-dired-rainbow
  :after dired
  :require t
  :hook (dired-mode-hook . nasy/-init-dired-rainbow)
  :init
  (sup 'dired-rainbow)
  (defun nasy/-init-dired-rainbow ()
    "Nasy init dired-rainbow."
    (require 'dired-rainbow)
    (dired-rainbow-define html "#eb5286"
                          ("css" "less" "sass" "scss" "htm" "html" "jhtm" "mht" "eml" "mustache" "xhtml"))
    (dired-rainbow-define xml "#f2d024"
                          ("xml" "xsd" "xsl" "xslt" "wsdl" "bib" "json" "msg" "pgn" "rss" "yaml" "yml" "rdata"))
    (dired-rainbow-define document "#9561e2"
                          ("docm" "doc" "docx" "odb" "odt" "pdb" "pdf" "ps" "rtf" "djvu" "epub" "odp" "ppt" "pptx"))
    (dired-rainbow-define markdown "#705438"
                          ("org" "etx" "info" "markdown" "md" "mkd" "nfo" "pod" "rst" "tex" "textfile" "txt"))
    (dired-rainbow-define database "#6574cd"
                          ("xlsx" "xls" "csv" "accdb" "db" "mdb" "sqlite" "nc"))
    (dired-rainbow-define media "#de751f"
                          ("mp3" "mp4" "MP3" "MP4" "avi" "mpeg" "mpg" "flv" "ogg" "mov" "mid" "midi" "wav" "aiff" "flac"))
    (dired-rainbow-define image "#f66d9b"
                          ("tiff" "tif" "cdr" "gif" "ico" "jpeg" "jpg" "png" "psd" "eps" "svg"))
    (dired-rainbow-define log "#c17d11"
                          ("log"))
    (dired-rainbow-define shell "#f6993f"
                          ("awk" "bash" "bat" "sed" "sh" "zsh" "vim"))
    (dired-rainbow-define interpreted "#38c172"
                          ("py" "ipynb" "rb" "pl" "t" "msql" "mysql" "pgsql" "sql" "r" "clj" "cljs" "scala" "js"))
    (dired-rainbow-define compiled "#4dc0b5"
                          ("asm" "cl" "lisp" "el" "c" "h" "c++" "h++" "hpp" "hxx" "m" "cc" "cs" "cp" "cpp" "go" "f" "for" "ftn" "f90" "f95" "f03" "f08" "s" "rs" "hi" "h
s" "pyc" ".java"))
    (dired-rainbow-define executable "#8cc4ff"
                          ("exe" "msi"))
    (dired-rainbow-define compressed "#51d88a"
                          ("7z" "zip" "bz2" "tgz" "txz" "gz" "xz" "z" "Z" "jar" "war" "ear" "rar" "sar" "xpi" "apk" "xz" "tar"))
    (dired-rainbow-define packaged "#faad63"
                          ("deb" "rpm" "apk" "jad" "jar" "cab" "pak" "pk3" "vdf" "vpk" "bsp"))
    (dired-rainbow-define encrypted "#ffed4a"
                          ("gpg" "pgp" "asc" "bfe" "enc" "signature" "sig" "p12" "pem"))
    (dired-rainbow-define fonts "#6cb2eb"
                          ("afm" "fon" "fnt" "pfb" "pfm" "ttf" "otf"))
    (dired-rainbow-define partition "#e3342f"
                          ("dmg" "iso" "bin" "nrg" "qcow" "toast" "vcd" "vmdk" "bak"))
    (dired-rainbow-define vc "#0074d9"
                          ("git" "gitignore" "gitattributes" "gitmodules"))
    (dired-rainbow-define-chmod directory "#6cb2eb" "d.*")
    (dired-rainbow-define-chmod executable-unix "#38c172" "-.*x.*")
    (font-lock-flush)
    (font-lock-ensure)))
Dired Narrow
(leaf dired-narrow
  :after dired
  :init (sup 'dired-narrow))
Dired Collapse
(leaf dired-collapse
  :after dired
  :hook dired-mode-hook
  :init (sup 'dired-collapse))
Diff-hl (only for dired)   vc diffs

Emacs package for highlighting uncommitted changes

https://github.com/dgutov/diff-hl

(leaf diff-hl
  :doc "Emacs package for highlighting uncommitted changes"
  :url "https://github.com/dgutov/diff-hl"
  :tag "vc" "diffs"
  :hook ((dired-mode-hook         . diff-hl-dired-mode)
         (magit-pre-refresh-hook  . diff-hl-magit-pre-refresh)
         (magit-post-refresh-hook . diff-hl-magit-post-refresh)
         (nasy-first-key-hook     . global-diff-hl-mode)
         (nasy-first-key-hook     . global-diff-hl-show-hunk-mouse-mode)
         (nasy-first-key-hook     . diff-hl-margin-mode))
  :init (sup 'diff-hl))
eldoc box   docs extensions help

This package displays ElDoc documentations in a childframe.

https://github.com/casouri/eldoc-box

(leaf eldoc-box
  :doc "This package displays ElDoc documentations in a childframe."
  :url "https://github.com/casouri/eldoc-box"
  :tag "docs" "extensions" "help"
  :custom
  (eldoc-box-position-function . #'eldoc-box--default-at-point-position-function)
  :hook ((eldoc-mode-hook . eldoc-box-hover-mode)
         (eldoc-mode-hook . eldoc-box-hover-at-point-mode))
  :init (sup 'eldoc-box))
eldoc-overlay   extensions

Display eldoc doc with contextual documentation overlay for easy to look.

https://github.com/stardiviner/eldoc-overlay

(leaf eldoc-overlay
  :doc "Display eldoc doc with contextual documentation overlay for easy to look."
  :url "https://github.com/stardiviner/eldoc-overlay"
  :tag "extensions"
  :hook eldoc-mode-hook
  :init (sup 'eldoc-overlay))
Expand Region   marking region

Emacs extension to increase selected region by semantic units.

https://github.com/magnars/expand-region.el

(leaf expand-region
  :doc "Emacs extension to increase selected region by semantic units."
  :url "https://github.com/magnars/expand-region.el"
  :tag "marking" "region"
  :bind ("C-=" . er/expand-region)
  :init (sup 'expand-region))
Find File in Project   project convenience

Find file/directory and review Diff/Patch/Commit quickly everywhere.

https://github.com/technomancy/find-file-in-project

(leaf find-file-in-project
  :doc "Find file/directory and review Diff/Patch/Commit quickly everywhere."
  :url "https://github.com/technomancy/find-file-in-project"
  :tag "project" "convenience"
  :custom (ffip-use-rust-fd . t)
  :init (sup 'find-file-in-project))
ftables   convenience table text

This package provides some convenient commands for filling a table, i.e., adjusting the layout of the table so it can fit in n columns.

https://github.com/casouri/ftable

(leaf ftable
  :doc "Fill (auto-layout) tables."
  :url "https://github.com/casouri/ftable"
  :tag "convenience" "table" "text"
  :init (sup 'ftable))
Git Gutter   vc git

Disabled. Now use diff-hl

Emacs port of GitGutter which is Sublime Text Plugin GitGutter.

https://github.com/emacsorphanage/git-gutter

(leaf git-gutter
  :doc "Emacs port of GitGutter which is Sublime Text Plugin."
  :url "https://github.com/emacsorphanage/git-gutter"
  :tag "vc" "git"
  :hook (after-init-hook . global-git-gutter-mode)
  :custom ((git-gutter:visual-line    . t)
           (git-gutter:disabled-modes . '(asm-mode image-mode))
           (git-gutter:modified-sign  . "❚")
           (git-gutter:added-sign     . "✚")
           (git-gutter:deleted-sign   . "✘"))
  :bind (("C-x v =" . git-gutter:popup-hunk)
         ("C-x p"   . git-gutter:previous-hunk)
         ("C-x n"   . git-gutter:next-hunk))
  :init (sup 'git-gutter))
Highlight Indent Guides   faces

Emacs minor mode to highlight indentation.

https://github.com/DarthFennec/highlight-indent-guides

(leaf highlight-indent-guides
  :doc "Emacs minor mode to highlight indentation."
  :url "https://github.com/DarthFennec/highlight-indent-guides"
  :tag "faces"
  :hook (prog-mode-hook text-mode-hook org-mode-hook)
  :custom
  (highlight-indent-guides-delay . 0.5)
  :init (sup 'highlight-indent-guides))
Highlight Tail   color effect highlight visual

This minor-mode draws a tail in real time, when you write.

https://www.emacswiki.org/emacs/highlight-tail.el

(leaf highlight-tail
  :doc "This minor-mode draws a tail in real time, when you write."
  :url "https://www.emacswiki.org/emacs/highlight-tail.el"
  :tag "color" "effect" "highlight" "visual"
  :disabled t
  :init (sup 'highlight-tail))
hl-line   faces frame emulations

Highlight the current line of characters.

https://www.emacswiki.org/emacs/HighlightCurrentLine

(leaf hl-line
  :doc "Highlight the current line of characters."
  :url "https://www.emacswiki.org/emacs/HighlightCurrentLine"
  :tag "faces" "frames" "emulations"
  :hook ((after-init-hook . global-hl-line-mode)))
imenu list   tools convenience

Emacs plugin to show the current buffer's imenu entries in a seperate buffer.

https://github.com/bmag/imenu-list

(leaf imenu-list
  :doc "Emacs plugin to show the current buffer's imenu entries in a seperate buffer"
  :url "https://github.com/bmag/imenu-list"
  :tag "tools" "convenience"
  :bind (("C-." . imenu-list-smart-toggle))
  :custom (imenu-list-auto-resize . t)
  :init (sup 'imenu-list))
kind-icon   completion

kind-icon — colorful icons for completion in Emacs

This emacs package adds configurable icon or text-based completion prefixes based on the :company-kind property that many completion backends (such as lsp-mode and Emacs 28's elisp-mode) provide.

https://github.com/jdtsmith/kind-icon

(leaf kind-icon
  :doc "Completion kind text/icon prefix labelling for emacs in-region completion."
  :url "https://github.com/jdtsmith/kind-icon"
  :tag "completion"
  :after corfu
  :require t
  :init (sup 'kind-icon)
  :defer-config (add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter))
mixed-pitch   faces

Mixed pitch is a minor mode that enables mixing fixed-pitch (also known as fixed-width or monospace) and variable-pitch (AKA “proportional”) fonts. It tries to be smart about which fonts get which face. Fonts that look like code, org-tables, and such remain fixed-pitch and everything else becomes variable-pitch.

https://gitlab.com/jabranham/mixed-pitch

(leaf mixed-pitch
  :doc "Mix fixed-pitch and variable-pitch fonts in Emacs."
  :url "https://gitlab.com/jabranham/mixed-pitch"
  :tag "faces"
  :custom (mixed-pitch-variable-pitch-cursor . '(hbar . 3))
  :hook (org-mode-hook)
  :mode-hook
  (progn
    (after-x 'hl-line
      (unless (boundp 'nasy--hl-line-bold)
        (setq nasy--hl-line-bold (face-attribute 'hl-line :weight)))
      (if mixed-pitch-mode
          (set-face-attribute 'hl-line nil :weight 'unspecified)
        (set-face-attribute 'hl-line nil :weight nasy--hl-line-bold))))
  :init (sup 'mixed-pitch)
  (eval-when-compile
    (defvar nasy--hl-line-bold nil))
  :config
  (setq mixed-pitch-fixed-pitch-faces
        (append mixed-pitch-fixed-pitch-faces
                org-level-faces
                '(whitespace-hspace whitespace-space))))
mmm-mode   convenience faces languages tools

MMM Mode is a minor mode for Emacs that allows Multiple Major Modes to coexist in one buffer.

https://github.com/purcell/mmm-mode

(leaf mmm-auto
  :doc "MMM Mode is a minor mode for Emacs that allows Multiple Major Modes
to coexist in one buffer."
  :url "https://github.com/purcell/mmm-mode"
  :tag "convenience" "faces" "languages" "tools"
  :require t
  :custom
  (mmm-global-mode              . 'maybe)
  (mmm-submode-decoration-level . 2)
  :init
  (sup 'mmm-mode)
  (when (or nasy--require nasy-pdump)
    (require 'mmm-mode)))
Multiple Cursors   cursors editing

Multiple cursors for Emacs.

https://github.com/magnars/multiple-cursors.el

(leaf multiple-cursors
  :doc "Multiple cursors for Emacs."
  :url "https://github.com/magnars/multiple-cursors.el"
  :tag "editing" "cursors"
  :bind
  (("C-<"     . mc/mark-previous-like-this)
   ("C->"     . mc/mark-next-like-this)
   ("C-+"     . mc/mark-next-like-this)
   ("C-c C-<" . mc/mark-all-like-this)
   ("C-c m r" . set=rectangular-region-anchor)
   ("C-c m c" . mc/edit-lines)
   ("C-c m e" . mc/edit-ends-of-lines)
   ("C-c m a" . mc/edit-beginnings-of-lines))
  :custom `(mc/list-file . ,(concat *nasy-var* "mc-list.el"))
  :init
  (sup 'multiple-cursors))
Persistent Scratch   convenience history

persistent-scratch is an Emacs package that preserves the state of scratch buffers accross Emacs sessions by saving the state to and restoring it from a file.

https://github.com/Fanael/persistent-scratch

(leaf persistent-scratch
  :doc "Preserve the scratch buffer across Emacs sessions."
  :url "https://github.com/Fanael/persistent-scratch"
  :tag "convenience" "history"
  :custom `((persistent-scratch-save-file
             . ,(concat *nasy-var* "persistent-scratch.el"))
            (persistent-scratch-backup-directory
             . ,(concat *nasy-var* "persistent-scratch/")))
  :init (sup 'persistent-scratch)
  :advice (:after persistent-scratch-restore nasy/scratch))
Point History   editing history

Show the history of points you visited before.

https://github.com/blue0513/point-history

(leaf point-history
  :doc "Show the history of points you visited before."
  :url "https://github.com/blue0513/point-history"
  :tag "editing"
  :hook after-init-hook
  :bind (("C-c C-/" . point-history-show))
  :custom (point-history-ignore-buffer . "^ \\*Minibuf\\|^ \\*point-history-show*")
  :init (sup 'point-history))
Rainbow-Mode   faces

This minor mode sets background color to strings that match color names, e.g. #0000ff is displayed in white with a blue background.

https://elpa.gnu.org/packages/rainbow-mode.html

(leaf rainbow-mode
  :doc "Colorize color names in buffers."
  :url "https://elpa.gnu.org/packages/rainbow-mode.html"
  :tag "faces"
  :leaf-autoload t
  :leaf-defun t
  :commands nasy/rainbow-colorize-match
  :advice (:override rainbow-colorize-match nasy/rainbow-colorize-match)
  :hook (after-init-hook
         text-mode-hook
         org-mode-hook
         css-mode-hook
         html-mode-hook
         prog-mode-hook)
  :init (sup 'rainbow-mode)
  :defer-config
  (eval-when-compile
    (defvar *font-main-family*))
  (defun nasy/rainbow-colorize-match (color &optional match)
    "Return a matched string propertized with a face whose
background is COLOR. The foreground is computed using
`rainbow-color-luminance', and is either white or black."
    (let ((match (or match 0)))
      (put-text-property
       (match-beginning match) (match-end match)
       'face `((:foreground ,(if (> 0.5 (rainbow-x-color-luminance color))
                                 "white" "black"))
               (:background ,color)
               (:family ,*font-main-family*)))))
  (when (fboundp 'diminish)
    (diminish 'rainbow-mode)))
Rainbow Delimiters   convenience faces lisp tools parens

rainbow-delimiters is a "rainbow parentheses"-like mode which highlights delimiters such as parentheses, brackets or braces according to their depth. Each successive level is highlighted in a different color. This makes it easy to spot matching delimiters, orient yourself in the code, and tell which statements are at a given depth.

https://github.com/Fanael/rainbow-delimiters

(leaf rainbow-delimiters
  :doc "Emacs rainbow delimiters mode"
  :url "https://github.com/Fanael/rainbow-delimiters"
  :tag "convenience" "faces" "lisp" "tools"
  :hook prog-mode-hook org-src-mode-hook
  :init (sup 'rainbow-delimiters))
Shellcop   tools unix

Analyze errors reported in Emacs builtin shell

https://github.com/redguardtoo/shellcop

(leaf shellcop
  :disabled t
  :doc "Analyze errors reported in Emacs builtin shell."
  :url "https://github.com/redguardtoo/shellcop"
  :tag "unix" "tools"
  :hook (shell-mode-hook . shellcop-start)
  :init (sup 'shellcop))
Smartparens   abbrev convenience editing parens

Minor mode for Emacs that deals with parens pairs and tries to be smart about it.

https://github.com/Fuco1/smartparens

(leaf smartparens-config
  :doc "Minor mode for Emacs that deals with parens pairs and tries to be smart about it."
  :url "https://github.com/Fuco1/smartparens"
  :tag "abbrev" "convenience" "editing"
  :hook (after-init-hook . smartparens-global-mode)
  :custom ((sp-hybrid-kill-entire-symbol . nil))
  :init (sup 'smartparens))
Symbol Overlay   faces matching

Highlight symbols with overlays while providing a keymap for various operations about highlighted symbols. It was originally inspired by the package highlight-symbol. The fundamental difference is that in symbol-overlay every symbol is highlighted by the Emacs built-in function overlay-put rather than the font-lock mechanism used in highlight-symbol.

https://github.com/wolray/symbol-overlay

(leaf symbol-overlay
  :doc "Highlight symbols with keymap-enabled overlays."
  :url "https://github.com/wolray/symbol-overlay"
  :tag "faces" "matching"
  :bind (("M-i"  . symbol-overlay-put)
         ("M-n"  . symbol-overlay-switch-forward)
         ("M-p"  . symbol-overlay-switch-backward)
         ("<f8>" . symbol-overlay-remove-all)
         ("<f7>" . symbol-overlay-mode))
  :init (sup 'symbol-overlay))
Treemacs   convenience files

Treemacs is a file and project explorer similar to NeoTree or vim’s NerdTree, but largely inspired by the Project Explorer in Eclipse. It shows the file system outlines of your projects in a simple tree layout allowing quick navigation and exploration, while also possessing basic file management utilities.

https://github.com/Alexander-Miller/treemacs

(leaf treemacs
  :doc "A tree layout file explorer for Emacs"
  :url "https://github.com/Alexander-Miller/treemacs"
  :tag "convenience" "files"
  :init
  (sup 'treemacs)
  :defer-config
  (after-x 'winum
    (define-key winum-keymap (kbd "M-0") #'treemacs-select-window))
  (setq treemacs-collapse-dirs                 (if treemacs-python-executable 3 0)
         treemacs-deferred-git-apply-delay      0.5
         treemacs-directory-name-transformer    #'identity
         treemacs-display-in-side-window        t
         treemacs-eldoc-display                 t
         treemacs-file-event-delay              5000
         treemacs-file-extension-regex          treemacs-last-period-regex-value
         treemacs-file-follow-delay             0.2
         treemacs-file-name-transformer         #'identity
         treemacs-follow-after-init             t
         treemacs-git-command-pipe              ""
         treemacs-goto-tag-strategy             'refetch-index
         treemacs-indentation                   2
         treemacs-indentation-string            " "
         treemacs-is-never-other-window         nil
         treemacs-max-git-entries               5000
         treemacs-missing-project-action        'ask
         treemacs-move-forward-on-expand        t
         treemacs-no-png-images                 nil
         treemacs-no-delete-other-windows       t
         treemacs-project-follow-cleanup        nil
         treemacs-persist-file                  (concat *nasy-var* "treemacs-persist")
         treemacs-position                      'left
         treemacs-recenter-distance             0.1
         treemacs-recenter-after-file-follow    nil
         treemacs-recenter-after-tag-follow     nil
         treemacs-recenter-after-project-jump   'always
         treemacs-recenter-after-project-expand 'on-distance
         treemacs-show-cursor                   nil
         treemacs-show-hidden-files             t
         treemacs-silent-filewatch              nil
         treemacs-silent-refresh                nil
         treemacs-sorting                       'alphabetic-asc
         treemacs-space-between-root-nodes      t
         treemacs-tag-follow-cleanup            t
         treemacs-tag-follow-delay              1.5
         treemacs-user-mode-line-format         nil
         treemacs-user-header-line-format       nil
         treemacs-width                         35
         treemacs-workspace-switch-cleanup      nil)

  ;; The default width and height of the icons is 22 pixels. If you are
  ;; using a Hi-DPI display, uncomment this to double the icon size.
  ;; (treemacs-resize-icons 44)
  (treemacs-follow-mode t)
  (treemacs-filewatch-mode t)
  (treemacs-fringe-indicator-mode t)
  (pcase (cons (not (null (executable-find "git")))
               (not (null treemacs-python-executable)))
    (`(t . t)
     (treemacs-git-mode 'deferred))
    (`(t . _)
     (treemacs-git-mode 'simple))))


(leaf treemacs-icons-dired
  :after treemacs dired
  :init (sup 'treemacs-icons-dired)
  :config (treemacs-icons-dired-mode))

(leaf treemacs-magit
  :after treemacs magit
  :init (sup 'treemacs-magit))

(leaf treemacs-projectile
  :after treemacs projectile
  :init (sup 'treemacs-projectile))
Tree Sitter   languages parsers tools

emacs-tree-sitter is an Emacs binding for tree-sitter, an incremental parsing system.

https://ubolonton.github.io/emacs-tree-sitter/

(leaf tree-sitter
  :doc "emacs-tree-sitter is an Emacs binding for tree-sitter, an incremental parsing
 system."
  :url "https://github.com/ubolonton/emacs-tree-sitter"
  :tag "languagues" "parsers" "tools"
  :hook (agda-mode-hook
         c-mode-hook
         c++-mode-hook
         css-mode-hook
         emacs-lisp-mode-hook
         html-mode-hook
         js-mode-hook
         js2-mode-hook
         son-mode-hook
         python-mode-hook
         ruby-mode-hook
         rust-mode-hook
         typescript-mode-hook)
  :init
  (sup 'tsc)
  (sup 'tree-sitter)
  (sup 'tree-sitter-langs)
  ;; (nasy/extra-repo tree-sitter-langs
  ;;                  "emacs-tree-sitter/tree-sitter-langs"
  ;;                  :files ("*"))
  :defer-config
  (require 'tree-sitter-langs)
  (add-to-list 'tree-sitter-major-mode-language-alist '(mhtml-mode . html))
  (add-to-list 'tree-sitter-major-mode-language-alist '(emacs-lisp-mode . elisp)))


(leaf tree-sitter-hl
  :after tree-sitter tree-sitter-langs
  :hook (css-mode-hook python-mode-hook))
Tree Sitter Indent   convenience internal

https://codeberg.org/FelipeLema/tree-sitter-indent.el.git

(leaf tree-sitter-indent
  :doc "Use Tree-sitter as backend to source code indentation."
  :url "https://codeberg.org/FelipeLema/tree-sitter-indent.el"
  :tag "convenience" "internal"
  :hook (tree-sitter-mode-hook)
  :init (sup 'tree-sitter-indent))

(leaf tree-sitter-indent
  :after tree-sitter-indent
  :custom (c-indent-offset . tree-sitter-indent-offset))
Undo Propose   convenience files undo redo history

Navigate the emacs undo history by staging undo's in a temporary buffer.

https://github.com/jackkamm/undo-propose-el

(leaf undo-propose
  :doc "Navigate the emacs undo history by staging undo's in a temporary buffer."
  :url "https://github.com/jackkamm/undo-propose-el"
  :tag "convenience" "files" "undo" "redo" "history"
  :bind (("C-c u" . undo-propose))
  :init (sup 'undo-propose))
Visual-fill-column   convenience

Emacs mode for wrapping visual-line-mode buffers at fill-column.

https://github.com/joostkremers/visual-fill-column

(leaf visual-fill-column
  :doc "Emacs mode for wrapping visual-line-mode buffers at fill-column."
  :url "https://github.com/joostkremers/visual-fill-column"
  :tag "convenience"
  :leaf-autoload t
  :leaf-defun t
  :commands maybe-adjust-visual-fill-column
  :hook (visual-line-mode-hook
         (visual-fill-column-mode-hook . maybe-adjust-visual-fill-column))
  :init (sup 'visual-fill-column)
  :config
  (defun maybe-adjust-visual-fill-column ()
    "Readjust visual fill column when the global font size is modified.
This is helpful for writeroom-mode, in particular."
    (if visual-fill-column-mode
        (add-hook 'after-setting-font-hook 'visual-fill-column--adjust-window nil t)
      (remove-hook 'after-setting-font-hook 'visual-fill-column--adjust-window t))))
vundo   undo redo

Visual undo tree.

https://archive.casouri.cat/note/2021/visual-undo-tree/index.html

https://github.com/casouri/vundo

(leaf vundo
  :doc "Visual undo tree."
  :url "https://github.com/casouri/vundo"
  :tag "undo" "redo"
  :custom
  (vundo-window-side        . 'top)
  (vundo--window-max-height . 5)
  ;; :custom-face
  ;; `(vundo-default   . '((t (:font ,(font-spec
  ;;                                   :family "PT Mono"
  ;;                                   :size 22)))))
  ;; `(vundo-highlight . '((t (:foreground "#057748"
  ;;                                       :inherit 'vundo-default))))
  ;; `(vundo-node      . '((t (:foreground "#50616D"
  ;;                                       :inherit 'vundo-default))))
  ;; `(vundo-stem      . '((t (:foreground "#50616D"
  ;;                                       :inherit 'vundo-default))))
  :bind
  ("s-/" . vundo)
  :init (sup 'vundo))
Which Key   help

Emacs package that displays available keybindings in popup.

https://github.com/justbur/emacs-which-key

(leaf which-key
  :doc "Emacs package that displays available keybindings in popup."
  :url "https://github.com/justbur/emacs-which-key"
  :tag "help"
  :custom (which-key-allow-imprecise-window-fit . nil)
  :hook after-init-hook
  :init (sup 'which-key))
Writeroom   text

writeroom-mode is a minor mode for Emacs that implements a distraction-free writing mode similar to the famous Writeroom editor for macOS.

https://github.com/joostkremers/writeroom-mode

(leaf writeroom-mode
  :doc "Writeroom-mode: distraction-free writing for Emacs."
  :url "https://github.com/joostkremers/writeroom-mode"
  :tag "text"
  :custom
  (writeroom-global-effects
   . '(;; writeroom effects
       ;; writeroom-set-fullscreen
       writeroom-set-alpha
       writeroom-set-menu-bar-lines
       ;; writeroom-set-tool-bar-lines
       writeroom-set-vertical-scroll-bars
       writeroom-set-bottom-divider-width))
  (writeroom-fullscreen-effect . 'maximized)
  (writeroom-maximize-window   . nil)
  (writeroom-width             . 1.0)
  :init (sup 'writeroom-mode))
yank-pulse   text
;; From https://christiantietze.de/posts/2020/12/emacs-pulse-highlight-yanked-text/
(defun nasy/-yank-pulse-advice (orig-fn &rest args)
  ;; Define the variables first
  (let (begin end)
    ;; Initialize `begin` to the current point before pasting
    (setq begin (point))
    ;; Forward to the decorated function (i.e. `yank`)
    (apply orig-fn args)
    ;; Initialize `end` to the current point after pasting
    (setq end (point))
    ;; Pulse to highlight!
    (pulse-momentary-highlight-region begin end)))

(leaf pulse
  :advice (:around yank nasy/-yank-pulse-advice))
Yasnipeet   convenience emulation

YASnippet is a template system for Emacs. It allows you to type an abbreviation and automatically expand it into function templates. Bundled language templates include: C, C++, C#, Perl, Python, Ruby, SQL, LaTeX, HTML, CSS and more. The snippet syntax is inspired from TextMate's syntax, you can even import most TextMate templates to YASnippet. Watch a demo on YouTube.

https://github.com/joaotavora/yasnippet

https://github.com/sei40kr/license-snippets

https://github.com/AndreaCrotti/yasnippet-snippets

(leaf yasnippet
  :doc "A template system for Emacs"
  :url "https://github.com/joaotavora/yasnippet"
  :tag "convenience" "enmulation"
  :leaf-autoload t
  :leaf-defun t
  :after company
  :commands (yas-minor-mode
             yas-reload-all)
  :custom (yas-snippet-dirs . `(,(concat *nasy-etc* "yasnippet/snippets/")))
  :hook (((prog-mode-hook text-mode-hook) . yas-minor-mode))
  :init
  (sup 'yasnippet)
  (sup 'license-snippets)
  (sup 'yasnippet-snippets)
  :defer-config
  (license-snippets-init)
  (yas-reload-all))

庭尞

(leaf 庭尞
  :load-path* "桃夭/庭尞"
  :require t)

小雅・彤弓之什・庭尞

夜如何其、夜未央、庭尞之光
君子至止、鸞聲將將

夜如何其、夜未艾、庭尞皙皙
君子至止、鸞聲噦噦

夜如何其、夜郷晨、庭尞有煇
君子至止、言觀其旂

容皃也

UI

cal-china-x

This extension mainly adds the following extra features:

  • Chinese localizations
  • Display holiday, lunar(农历), horoscope(星座), zodiac(属相、十二生肖), solar term(节气) info on mode line
  • Define holidays using holiday-lunar, holiday-solar-term
  • Highlight holidays based on different priorities
  • Add cal-china-x-chinese-holidays, cal-china-x-japanese-holidays.
  • Custom week diary (like weeks in school)

https://github.com/xwl/cal-china-x

(leaf cal-china-x
  :doc "chinese localization, prioritized holiday highlight, lunar, horoscope, zodiac, etc."
  :url "https://github.com/xwl/cal-china-x"
  :tag "calendar" "date"
  :after calendar
  :custom
  (cal-china-x-force-chinese-week-day . t)
  (cal-china-x-always-show-jieqi      . t)
  :hook (nasy-first-key-hook . (lambda ()
                                 (require 'cal-china-x)
                                 (nasy/init-chinese-calendar)))
  :init (sup 'cal-china-x))

(defun nasy/init-chinese-calendar ()
  "Initial Chinese calendar."
  (setq calendar-date-display-form
        '((cal-china-x-calendar-display-form
           (mapcar (lambda (el) (string-to-number el))
                   (list month day year)))))

  (setq diary-date-forms chinese-date-diary-pattern)

  (setq calendar-chinese-celestial-stem cal-china-x-celestial-stem
        calendar-chinese-terrestrial-branch cal-china-x-terrestrial-branch)

  (setq calendar-month-header '(propertize (format "%d年%2d月" year month)
                                           'font-lock-face
                                           'calendar-month-header))
  (when cal-china-x-force-chinese-week-day
    (setq calendar-day-header-array cal-china-x-days))

  (setq calendar-mode-line-format
        (list
         (calendar-mode-line-entry 'calendar-scroll-right "previous month" "<")
         "日曆"

         '(cal-china-x-get-holiday date)

         '(concat " " (calendar-date-string date t)
                  (format " 第%d周"
                          (funcall (if cal-china-x-custom-week-start-date
                                       'cal-china-x-custom-week-of-date
                                     'cal-china-x-week-of-date)
                                   date)))

         '(cal-china-x-chinese-date-string date)


         (concat
          (calendar-mode-line-entry 'calendar-goto-info-node "read Info on Calendar"
                                    nil "info")
          " / "
          (calendar-mode-line-entry 'calendar-other-month "choose another month"
                                    nil "other")
          " / "
          (calendar-mode-line-entry 'calendar-goto-today "go to today's date"
                                    nil "today"))

         (calendar-mode-line-entry 'calendar-scroll-left "next month" ">")))

  (add-hook 'calendar-move-hook 'calendar-update-mode-line)
  (add-hook 'calendar-initial-window-hook 'calendar-update-mode-line)

  (add-hook 'calendar-mode-hook
            (lambda ()
              (set (make-local-variable 'font-lock-defaults)
                   ;; chinese month and year
                   '((("[0-9]+年\\ *[0-9]+月" . font-lock-function-name-face)) t))))


  (advice-add 'calendar-mark-holidays :around 'cal-china-x-mark-holidays)
  (advice-add 'mouse-set-point :after 'cal-china-x-mouse-set-point))
Centaur Tab

This projects aims to become an aesthetic, functional and efficient tabs plugin for Emacs with a lot of customization options.

https://github.com/ema2159/centaur-tabs

(leaf centaur-tabs
  :custom
  (centaur-tabs-style . "wave")
  :hook
  ;; (nasy-first-key-hook   . (lambda () (require 'tab-line) (centaur-tabs-mode)))
  (nasy/font-change-hook . (lambda () (nasy/set-symbol ?⏺ 14)))
  :init (sup 'centaur-tabs))


(defun nasy/-enable-centaur-tabs-local-mode ()
  (unless centaur-tabs-mode
    (centaur-tabs-mode 1))
  (centaur-tabs-local-mode 1))

(defun nasy/-disable-centaur-tabs-local-mode ()
  (unless centaur-tabs-mode
    (centaur-tabs-mode 1))
  (centaur-tabs-local-mode -1))


(defvar nasy--centaur-text-modes
  '(org-mode org-agenda-mode org-agenda-clockreport-mode
             org-agenda-log-mode org-beamer-mode
             org-bullets-mode org-cdlatex-mode
             org-indent-mode org-src-mode diary-mode
             text-mode markdown-mode))

(defvar nasy--centaur-vc-modes
  '(magit-blame-mode magit-blob-mode magit-diff-mode
                     magit-file-mode magit-log-mode
                     magit-process-mode magit-status-mode))


(defun nasy/-centaur-tabs-buffer-groups ()
  "Nasy's centaur tabs groups."
  (let ((bn (buffer-name)))
    (list
     (cond
      ;; org, markdown & text
      ((or (memq major-mode nasy--centaur-text-modes)
           (string-prefix-p "*Org Src" bn)
           (string-prefix-p "*Org Export" bn))
       "書寫")

      ;; VC
      ((memq major-mode nasy--centaur-vc-modes)
       "Magit")

      ;; Shell
      ((memq major-mode '(eshell-mode shell-mode vterm-mode))
       "Shell")

      ;; Info & Help
      ((memq major-mode '(help-mode info-mode helpful-mode))
       "注")

      ;; programming
      ((derived-mode-p 'prog-mode)
       "編程")

      ;; Web Page
      ((or (memq major-mode '(eww-mode xwidget-webkit-mode))
           (string-prefix-p "*xwidget webkit" bn))
       "網頁")

      ;; Emacs
      ((string-prefix-p "*" bn)
       "虛")

      ;; 
      (t (centaur-tabs-get-group-name (current-buffer)))))))


(leaf centaur-tabs
  :after centaur-tabs
  :custom
  (centaur-tabs-set-modified-marker . t)
  (centaur-tabs-height     . 28)
  (centaur-tabs-bar-height . 30)
  ((centaur-tabs-set-close-button
    centaur-tabs-enable-ido-completion) . nil)
  :hook (nasy-magit-first-key-hook
         . nasy/-disable-centaur-tabs-local-mode)
  :mode-hook
  ;; (centaur-tabs-headline-match)

  (customize-set-variable 'centaur-tabs-set-icons t
                          "Customized by Nasy in `centaur-tabs' block")
  (customize-set-variable 'centaur-tabs-show-navigation-buttons t
                          "Customized by Nasy in `centaur-tabs' block")
  (setq centaur-tabs-active-bar
        (centaur-tabs--make-xpm 'centaur-tabs-active-bar-face
         4
         centaur-tabs-bar-height))
  :advice (:override centaur-tabs-buffer-groups nasy/-centaur-tabs-buffer-groups))
Dashboard
(leaf dashboard
  :leaf-autoload t
  :leaf-defun t
  :commands (dashboard-refresh-buffer
             dashboard-setup-startup-hook)
  :init (sup 'dashboard))


(defun nasy/-set-dashboard-init-info (&rest _)
  (setq dashboard-init-info
        (let ((package-count 0) (time (emacs-init-time)))
          (setq package-count (+ (hash-table-size straight--profile-cache) package-count))
          (if (zerop package-count)
              (format "Emacs started in %s" time)
            (format "%d packages loaded in %s" package-count time)))))


(defun nasy/-dashboard-items (_)
  (insert "\n")
  (widget-create 'item
                 :tag "近期 (r)"
                 :action #'consult-recent-file
                 :mouse-face 'highlight
                 :button-face 'dashboard-heading
                 :button-prefix "🌓 "
                 :button-suffix ""
                 :format "%[%t%]"
                 :help-echo "open recent files")
  (insert "\t")
  (widget-create 'item
                 :tag "書籤 (b)"
                 :action #'consult-bookmark
                 :mouse-face 'highlight
                 :button-face 'dashboard-heading
                 :button-prefix "🔖 "
                 :button-suffix ""
                 :format "%[%t%]"
                 :help-echo "open bookmarks")
  (insert "\t")
  (widget-create 'item
                 :tag "項目 (p)"
                 :action #'projectile-switch-project
                 :mouse-face 'highlight
                 :button-face 'dashboard-heading
                 :button-prefix "🚀 "
                 :button-suffix ""
                 :format "%[%t%]"
                 :help-echo "open projects")
  (insert "               \n\n")
  (widget-create 'item
                 :tag "草稿 (c)"
                 :action #'persistent-scratch-restore
                 :mouse-face 'highlight
                 :button-face 'dashboard-heading
                 :button-prefix "📝 "
                 :button-suffix ""
                 :format "%[%t%]"
                 :help-echo "restore scratch buffer")
  (insert "\t")
  (widget-create 'item
                 :tag "議程 (a)"
                 :action #'org-agenda
                 :mouse-face 'highlight
                 :button-face 'dashboard-heading
                 :button-prefix "🗓 "
                 :button-suffix ""
                 :format "%[%t%]"
                 :help-echo "Org Agenda")
  (insert "\t")
  (widget-create 'item
                 :tag "日曆 (d)"
                 :action #'calendar
                 :mouse-face 'highlight
                 :button-face 'dashboard-heading
                 :button-prefix "📅 "
                 :button-suffix ""
                 :format "%[%t%]"
                 :help-echo "open calendar")
  (insert "               \n\n")
  (widget-create 'item
                 :tag "芄蘭 (C)"
                 :action #'nasy/-open-custom
                 :mouse-face 'highlight
                 :button-face 'dashboard-heading
                 :button-prefix "⚙ "
                 :button-suffix ""
                 :format "%[%t%]"
                 :help-echo "open custom file")
  (insert "\t")
  (widget-create 'item
                 :tag "源碼 (s)"
                 :action #'nasy/-open-source-page
                 :mouse-face 'highlight
                 :button-face 'dashboard-heading
                 :button-prefix "🍭 "
                 :button-suffix ""
                 :format "%[%t%]"
                 :help-echo "open https://github.com/nasyxx/emacs.d/")
  (insert "\t")
  (widget-create 'item
                 :tag "文檔 (D)"
                 :action #'nasy/-open-document
                 :mouse-face 'highlight
                 :button-face 'dashboard-heading
                 :button-prefix "📖 "
                 :button-suffix ""
                 :format "%[%t%]"
                 :help-echo "open https://emacs.nasy.moe")
  (insert "               \n\n"))


(defun nasy/dashboard-refresh ()
  "Refresh dashboard buffer."
  (interactive)
  (unless (get-buffer dashboard-buffer-name)
    (generate-new-buffer "*dashboard*"))
  (dashboard-refresh-buffer))


(declare-function persistent-scratch-restore "persistent-scratch")


(leaf dashboard
  :bind
  ("<f5>" . dashboard-refresh-buffer)
  (:dashboard-mode-map
   ("r"              . consult-recent-file)
   ("b"              . consult-bookmark)
   ("p"              . projectile-switch-project)
   ("c"              . persistent-scratch-restore)
   ("a"              . org-agenda)
   ("d"              . calendar)
   ("C"              . nasy/-open-custom)
   ("s"              . nasy/-open-source-page)
   ("D"              . nasy/-open-document)
   ("g"              . dashboard-refresh-buffer)
   ("<down-mouse-1>" . nil)
   ("H-p"            . dashboard-previous-line)
   ("H-n"            . dashboard-next-line)
   ("H-b"            . widget-backward)
   ("H-f"            . widget-forward)
   ("<mouse-1>"      . widget-button-click)
   ("<mouse-2>"      . widget-button-click)
   ("<up>"           . widget-backward)
   ("<down>"         . nasy/wfw1))
  :hook
  ((dashboard-mode-hook . (lambda () (setq-local tab-width 1)))
   (after-init-hook     . dashboard-setup-startup-hook)
   (after-init-hook     . dashboard-refresh-buffer))
  (nasy/font-change-hook
   . (lambda ()
       (progn
         (nasy/set-apple-symbol ?🌓)
         (nasy/set-apple-symbol ?🔖)
         (nasy/set-apple-symbol ?🚀)
         (nasy/set-apple-symbol ?📝)
         (nasy/set-apple-symbol ?🗓)
         (nasy/set-apple-symbol ?📅)
         (nasy/set-apple-symbol ?⚙)
         (nasy/set-apple-symbol ?🍭)
         (nasy/set-apple-symbol ?📖))))
  :custom
  (dashboard-items . '((n-items . t)))
                       ;; (bookmarks . t)))
                       ;; (registers . 5)
                       ;; (agenda    . 5)
                       ;; (projects  . 7)))
  (dashboard-item-generators . '((n-items . nasy/-dashboard-items)))
  ((dashboard-center-content
    dashboard-set-heading-icons
    dashboard-set-init-info) . t)
  `(dashboard-startup-banner
    . ,(concat *nasy-etc* "n_icon.png"))
  :advice (:before dashboard-refresh-buffer nasy/-set-dashboard-init-info))
doom Theme
(leaf doom-themes
  :after all-the-icons
  :custom
  ((doom-dracula-brighter-comments
    doom-dracula-colorful-headers
    doom-dracula-comment-bg) . t)
  (doom-themes-treemacs-theme . "doom-colors")
  (doom-themes-org-fontify-special-tags . nil)
  :init (sup 'doom-themes)
  :config
  (after-x 'treemacs
    (doom-themes-treemacs-config))
  ;; (doom-themes-visual-bell-config)
  (after-x 'org
    (doom-themes-org-config)))
Pretty Mode   pretty
;; https://github.com/tonsky/FiraCode/wiki/Emacs-instructions
(defun nasy/adjust-fira-code-symbol (charset &optional size)
  (let ((size (or size 14)))
    (set-fontset-font (frame-parameter nil 'font)
                      charset
                      (font-spec :family "Fira Code Symbol"
                                 :weight 'normal
                                 :size   size))))
;; I haven't found one statement that makes both of the above situations work, so I use both for now
(defun pretty-fonts-set-fontsets (CODE-FONT-ALIST)
  "Utility to associate many unicode points with specified `CODE-FONT-ALIST'."
  (--each CODE-FONT-ALIST
    (-let (((font . codes) it))
      (--each codes
        (set-fontset-font nil `(,it . ,it) font)
        (set-fontset-font t `(,it . ,it) font)))))

(defun pretty-fonts--add-kwds (FONT-LOCK-ALIST)
  "Exploits `font-lock-add-keywords'(`FONT-LOCK-ALIST') to apply regex-unicode replacements."
  (font-lock-add-keywords
   nil (--map (-let (((rgx uni-point) it))
               `(,rgx (0 (progn
                           (compose-region
                            (match-beginning 1) (match-end 1)
                            ,(concat "\t" (list uni-point)))
                           nil))))
             FONT-LOCK-ALIST)))

(defmacro pretty-fonts-set-kwds (FONT-LOCK-HOOKS-ALIST)
  "Set regex-unicode replacements to many modes(`FONT-LOCK-HOOKS-ALIST')."
  `(--each ,FONT-LOCK-HOOKS-ALIST
     (-let (((font-locks . mode-hooks) it))
       (--each mode-hooks
         (add-hook it (-partial 'pretty-fonts--add-kwds
                                (symbol-value font-locks)))))))

(defconst pretty-fonts-fira-font
  '(;; OPERATORS
    ;; Pipes
    ("\\(<|\\)" #Xe14d) ("\\(<>\\)" #Xe15b) ("\\(<|>\\)" #Xe14e) ("\\(|>\\)" #Xe135)

    ;; Brackets
    ("\\(<\\*\\)" #Xe14b) ("\\(<\\*>\\)" #Xe14c) ("\\(\\*>\\)" #Xe104)
    ("\\(<\\$\\)" #Xe14f) ("\\(<\\$>\\)" #Xe150) ("\\(\\$>\\)" #Xe137)
    ("\\(<\\+\\)" #Xe155) ("\\(<\\+>\\)" #Xe156) ("\\(\\+>\\)" #Xe13a)

    ;; Equality
    ("\\(!=\\)" #Xe10e) ("\\(!==\\)"         #Xe10f) ("\\(=/=\\)" #Xe143)
    ("\\(/=\\)" #Xe12c) ("\\(/==\\)"         #Xe12d)
    ("\\(===\\)" #Xe13d) ("[^!/]\\(==\\)[^>]" #Xe13c)

    ;; Equality Special
    ("\\(||=\\)"  #Xe133) ("[^|]\\(|=\\)" #Xe134)
    ("\\(~=\\)"   #Xe166)
    ("\\(\\^=\\)" #Xe136)
    ("\\(=:=\\)"  #Xe13b)

    ;; Comparisons
    ("\\(<=\\)" #Xe141) ("\\(>=\\)" #Xe145)
    ("\\(</\\)" #Xe162) ("\\(</>\\)" #Xe163)

    ;; Shifts
    ("[^-=]\\(>>\\)" #Xe147) ("\\(>>>\\)" #Xe14a)
    ("[^-=]\\(<<\\)" #Xe15c) ("\\(<<<\\)" #Xe15f)

    ;; Dots
    ("\\(\\.-\\)"    #Xe122) ("\\(\\.=\\)" #Xe123)
    ("\\(\\.\\.<\\)" #Xe125)

    ;; Hashes
    ("\\(#{\\)"  #Xe119) ("\\(#(\\)"   #Xe11e) ("\\(#_\\)"   #Xe120)
    ("\\(#_(\\)" #Xe121) ("\\(#\\?\\)" #Xe11f) ("\\(#\\[\\)" #Xe11a)

    ;; REPEATED CHARACTERS
    ;; 2-Repeats
    ("\\(||\\)" #Xe132)
    ("\\(!!\\)" #Xe10d)
    ("\\(%%\\)" #Xe16a)
    ("\\(&&\\)" #Xe131)