style: Rename custom functions from slash to dash convention

This commit is contained in:
2026-06-27 09:15:48 +08:00
parent 33ced00fc4
commit 315fb0ef87
8 changed files with 45 additions and 41 deletions

View File

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

View File

@@ -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

View File

@@ -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

View File

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

View File

@@ -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,8 +53,12 @@ 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))))
(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")
@@ -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)))

View File

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

View File

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

View File

@@ -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"))