From 315fb0ef87fb5e3f5c30acaf234fa4f405b5e6d6 Mon Sep 17 00:00:00 2001 From: andsy10 Date: Sat, 27 Jun 2026 09:15:48 +0800 Subject: [PATCH] style: Rename custom functions from slash to dash convention --- lisp/fix-dirvish-preview.el | 8 +++--- lisp/init-base.el | 4 +-- lisp/init-completion.el | 8 ++---- lisp/init-exwm.el | 4 +-- lisp/init-kbd-func.el | 54 ++++++++++++++++++++++--------------- lisp/init-kbd.el | 2 +- lisp/init-org.el | 2 +- lisp/init-startup.el | 4 +-- 8 files changed, 45 insertions(+), 41 deletions(-) diff --git a/lisp/fix-dirvish-preview.el b/lisp/fix-dirvish-preview.el index 83b827a..f0e98ef 100644 --- a/lisp/fix-dirvish-preview.el +++ b/lisp/fix-dirvish-preview.el @@ -9,7 +9,7 @@ (with-eval-after-load 'dirvish ;; Function to find mtn output file for a given video file in cache directory - (defun my/dirvish-find-mtn-output (video-file cache-dir ext) + (defun my-dirvish-find-mtn-output (video-file cache-dir ext) "Find mtn-generated thumbnail for VIDEO-FILE in CACHE-DIR with extension EXT." (let* ((file-base (file-name-base video-file)) ;; mtn generates: [filename].[ext].jpg @@ -18,7 +18,7 @@ (car files))) ;; Advice to fix the sentinel after mtn generates the thumbnail - (defun my/dirvish-media--cache-sentinel-advice (orig-fun proc exit-code) + (defun my-dirvish-media--cache-sentinel-advice (orig-fun proc exit-code) "Advice to rename mtn output to MD5 format after generation." (let* ((video-path (process-get proc 'path)) (ext (downcase (or (file-name-extension video-path) ""))) @@ -30,14 +30,14 @@ (let* ((width (dirvish-media--img-size (dv-preview-window dv))) (cache (dirvish--img-thumb-name video-path width ".jpg")) (cache-dir (dirvish--get-parent-path cache)) - (mtn-file (my/dirvish-find-mtn-output video-path cache-dir ext))) + (mtn-file (my-dirvish-find-mtn-output video-path cache-dir ext))) (when (and mtn-file (file-exists-p mtn-file) (not (file-exists-p cache))) (rename-file mtn-file cache))))) ;; Call original function (funcall orig-fun proc exit-code)) ;; Apply advice - (advice-add 'dirvish-media--cache-sentinel :around #'my/dirvish-media--cache-sentinel-advice)) + (advice-add 'dirvish-media--cache-sentinel :around #'my-dirvish-media--cache-sentinel-advice)) (provide 'fix-dirvish-preview) diff --git a/lisp/init-base.el b/lisp/init-base.el index 8f2a5d9..07340f0 100644 --- a/lisp/init-base.el +++ b/lisp/init-base.el @@ -84,9 +84,7 @@ (use-package async :hook (after-init . dired-async-mode) - (after-init . async-bytecomp-package-mode) - :init - (setq async-bytecomp-allowed-packages '(all)))) + (after-init . async-bytecomp-package-mode))) ;; autorevert buffer (use-package autorevert diff --git a/lisp/init-completion.el b/lisp/init-completion.el index b50c718..81defd2 100644 --- a/lisp/init-completion.el +++ b/lisp/init-completion.el @@ -57,7 +57,7 @@ :init (setq prefix-help-command 'embark-prefix-help-command) :config - (defun my/embark-preview () + (defun my-embark-preview () "Previews candidate in vertico buffer, unless it's a consult command." (interactive) (unless (bound-and-true-p consult--preview-function) @@ -111,11 +111,7 @@ targets." :around #'embark-hide-which-key-indicator)))) ;; embark-consult -(use-package embark-consult - :config - (add-hook - 'embark-collect-mode-hook - #'consult-preview-at-point-mode)) +(use-package embark-consult) ;; eglot (use-package eglot diff --git a/lisp/init-exwm.el b/lisp/init-exwm.el index 936d275..f5c2907 100644 --- a/lisp/init-exwm.el +++ b/lisp/init-exwm.el @@ -105,9 +105,9 @@ (,(kbd "C-/") . [?\C-z]) (,(kbd "C-?") . ,(kbd "C-S-z")))) - (defun my/exwm-update-class () + (defun my-exwm-update-class () (exwm-workspace-rename-buffer exwm-class-name)) - (add-hook 'exwm-update-class-hook #'my/exwm-update-class) + (add-hook 'exwm-update-class-hook #'my-exwm-update-class) (require 'exwm-xim) (exwm-xim-mode) diff --git a/lisp/init-kbd-func.el b/lisp/init-kbd-func.el index 679f3e6..3f2edce 100644 --- a/lisp/init-kbd-func.el +++ b/lisp/init-kbd-func.el @@ -20,9 +20,10 @@ (defun disable-truncate-lines () (toggle-truncate-lines 1)) -(defun my/jinx-smart-toggle () +(defun my-jinx-smart-toggle () "Toggle jinx-mode smartly. -Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise toggle global-jinx-mode." +Disable jinx-mode if it's enable and global-jinx-mode is disable , +otherwise toggle global-jinx-mode." (interactive) (unless (featurep 'jinx) (require 'jinx)) @@ -52,9 +53,13 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog (interactive "fOpen externally: ") (if (and (eq system-type 'windows-nt) (fboundp 'w32-shell-execute)) - (shell-command-to-string (encode-coding-string (replace-regexp-in-string "/" "\\\\" - (format "explorer.exe %s" (file-name-directory (expand-file-name file)))) - 'gbk)) + (shell-command-to-string + (encode-coding-string + (replace-regexp-in-string "/" "\\\\" + (format "explorer.exe %s" + (file-name-directory + (expand-file-name file)))) + 'gbk)) (call-process (pcase system-type ('darwin "open") ('cygwin "cygstart") @@ -68,11 +73,11 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog (consult-directory-externally default-directory)) (defun consult-fd-home () - "Search for all files in home folder use fd." - (interactive) - (let ((consult-fd-args "fd -H -I -i -c never --full-path") - (default-directory "~/")) - (consult-fd))) + "Search for all files in home folder use fd." + (interactive) + (let ((consult-fd-args "fd -H -I -i -c never --full-path") + (default-directory "~/")) + (consult-fd))) (defun org-cycle-parent-subtree() "Cycle parent org subtree." @@ -87,7 +92,8 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog (defun my-denote-journal-path-to-existing-entry (&optional date interval) "Return the path of current denote journal if it exists, otherwise return nil." (require 'denote-journal) - (let* ((internal-date (denote-journal--date-in-interval-p (or date (current-time)) interval)) + (let* ((internal-date + (denote-journal--date-in-interval-p (or date (current-time)) interval)) (files (denote-journal--get-entry internal-date interval))) (if files (denote-journal-select-file-prompt files)))) @@ -100,9 +106,11 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog (message "No journal for today yet"))) (defun my-denote-open-metanote () - "Open denote metanote in `~/org/my-org-note/20260508T220745==metanote--all-my-metanotes__org.org'" + "Open denote metanote in +`~/org/my-org-note/20260508T220745==metanote--all-my-metanotes__org.org'" (interactive) - (find-file "~/org/my-org-note/20260508T220745==metanote--all-my-metanotes__org.org")) + (find-file + "~/org/my-org-note/20260508T220745==metanote--all-my-metanotes__org.org")) (defun org-table-align-all () "Ajust all table in current buffer." @@ -186,7 +194,8 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog (dired-move-to-filename)) (defun my-dirvish-layout-toggle () - "Toggle layout using first recipe in `dirvish-layout-recipes' instead of fallback." + "Toggle layout using first recipe in `dirvish-layout-recipes' instead of +fallback." (interactive) (let ((dv (dirvish-curr))) (unless dv (user-error "Not a dirvish buffer")) @@ -230,7 +239,8 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog (persp-set-buffer buf)))) (defun my-gptel-agent-project () - "Run `gptel-agent' in current project's root (by run it with prefix argument)." + "Run `gptel-agent' in current project's root (by run it with prefix +argument)." (interactive) (let ((current-prefix-arg '-)) (call-interactively 'gptel-agent))) @@ -284,13 +294,13 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog (start-process-shell-command "xinput" nil "xinput set-prop 12 'libinput Accel Speed' -0.45")) (defun restart-fcitx5 () - "Kill and restart fcitx5, to fix random issues in exwm." - (interactive) - (if (zerop (shell-command "pgrep fcitx5")) - (progn - (eshell-command "pkill fcitx5") - (eshell-command "fcitx5 -d")) - (eshell-command "fcitx5 -d")))) + "Kill and restart fcitx5, to fix random issues in exwm." + (interactive) + (if (zerop (shell-command "pgrep fcitx5")) + (progn + (eshell-command "pkill fcitx5") + (eshell-command "fcitx5 -d")) + (eshell-command "fcitx5 -d")))) (provide 'init-kbd-func) diff --git a/lisp/init-kbd.el b/lisp/init-kbd.el index ea54372..c876602 100644 --- a/lisp/init-kbd.el +++ b/lisp/init-kbd.el @@ -84,7 +84,7 @@ (general-def :prefix "C-c t" "f" 'flycheck-mode - "j" 'my/jinx-smart-toggle + "j" 'my-jinx-smart-toggle "g" 'gptel-mode "h" 'global-diff-hl-mode) diff --git a/lisp/init-org.el b/lisp/init-org.el index da191ef..bbf08b0 100644 --- a/lisp/init-org.el +++ b/lisp/init-org.el @@ -124,7 +124,7 @@ :after org :demand t :hook - (org-mode . org-display-inline-images) + (org-mode . org-link-preview-region) :config (setq-default org-download-image-dir "./images/" org-download-heading-lvl nil) diff --git a/lisp/init-startup.el b/lisp/init-startup.el index c9860b2..c729742 100644 --- a/lisp/init-startup.el +++ b/lisp/init-startup.el @@ -66,11 +66,11 @@ (setq initial-scratch-message "") -(defun my/scratch-set-mode (&rest _) +(defun my-scratch-set-mode (&rest _) (when (eq major-mode 'fundamental-mode) (funcall initial-major-mode))) -(advice-add 'scratch-buffer :after #'my/scratch-set-mode) +(advice-add 'scratch-buffer :after #'my-scratch-set-mode) ;; 窗口名 (setq-default frame-title-format '("%b - Emacs"))