Make chicken more ergonomic and remove dired previews

This commit is contained in:
BirDt_ 2026-03-27 12:53:26 +08:00
parent a75f9188f6
commit ebbe94030f
2 changed files with 104 additions and 35 deletions

View file

@ -89,36 +89,36 @@
;; Preview files ;; Preview files
(defun dired-preview-to-the-right () ;; (defun dired-preview-to-the-right ()
"My preferred `dired-preview-display-action-alist-function'." ;; "My preferred `dired-preview-display-action-alist-function'."
'((display-buffer-in-side-window) ;; '((display-buffer-in-side-window)
(side . right) ;; (side . right)
(slot . 0) ;; (slot . 0)
(window-width . 0.3))) ;; (window-width . 0.3)))
(use-package dired-preview ;; (use-package dired-preview
:after (ready-player) ;; :after (ready-player)
:config ;; :config
(setq dired-preview-display-action-alist #'dired-preview-to-the-right) ;; (setq dired-preview-display-action-alist #'dired-preview-to-the-right)
(setq dired-preview-buffer-name-indicator "[Preview]") ;; (setq dired-preview-buffer-name-indicator "[Preview]")
(setq dired-preview-ignored-extensions-regexp ;; (setq dired-preview-ignored-extensions-regexp
(concat "\\." ;; (concat "\\."
"\\(gz\\|" ;; "\\(gz\\|"
"zst\\|" ;; "zst\\|"
"tar\\|" ;; "tar\\|"
"xz\\|" ;; "xz\\|"
"rar\\|" ;; "rar\\|"
"zip\\|" ;; "zip\\|"
"iso\\|" ;; "iso\\|"
"epub" ;; "epub"
"\\)")) ;; "\\)"))
(unless (equal system-type 'android) (dired-preview-global-mode 1))) ;; (unless (equal system-type 'android) (dired-preview-global-mode 1)))
;; Automatically kill preview buffers when opening a file ;; ;; Automatically kill preview buffers when opening a file
(add-hook 'find-file-hook (lambda () ;; (add-hook 'find-file-hook (lambda ()
(dolist (buf (buffer-list)) ;; (dolist (buf (buffer-list))
(when (string-match-p "\\[Preview\\]" (buffer-name buf)) ;; (when (string-match-p "\\[Preview\\]" (buffer-name buf))
(kill-buffer buf))))) ;; (kill-buffer buf)))))
(use-package neotree (use-package neotree
:config :config

View file

@ -42,17 +42,86 @@
(setq inferior-lisp-program "sbcl")) (setq inferior-lisp-program "sbcl"))
;; Scheme (with Chickens) ;; Scheme (with Chickens)
(use-package geiser) (use-package geiser
:config
;; Auto-start the geiser repl
(setq geiser-mode-start-repl-p t)
(use-package geiser-chicken ;; Put geiser in the bottom
:after (geiser) (add-to-list 'display-buffer-alist
:config (add-to-list 'display-buffer-alist '("\\*Geiser .* REPL"
'("\\*Geiser"
(display-buffer-in-side-window) (display-buffer-in-side-window)
(side . bottom) (side . bottom)
(slot . 1) (slot . 1)
(window-height . 0.2)))
(add-to-list 'display-buffer-alist
`("\\*Geiser Documentation"
(display-buffer-in-side-window)
(side . ,(if (equal system-type 'android) 'bottom 'right))
(slot . ,(if (equal system-type 'android) 0 3))
(window-height . 0.2)))
(add-to-list 'display-buffer-alist
`("\\*Geiser Debug"
(display-buffer-in-side-window)
(side . ,(if (equal system-type 'android) 'bottom 'right))
(slot . ,(if (equal system-type 'android) 0 4))
(window-height . 0.2)))) (window-height . 0.2))))
(defcustom chicken-doc-repository ""
"Custom location for the chicken-doc repository."
:type 'string
:group 'scheme
:group 'geiser)
(use-package geiser-chicken
:after (geiser)
:config
(setenv "CHICKEN_DOC_REPOSITORY" chicken-doc-repository)
;; Annoying BS to prevent inline C code from fucking with the syntax table
;; This is really hacky and doesn't truly work properly especially with auto-indent
(defun scheme-propertize-chicken-comment (start)
"Find the matching <# for a #> at START and mark the whole region as a comment."
(save-excursion
(goto-char start)
(let ((pos (point)))
(if (re-search-forward "<#" nil t)
(progn
(put-text-property pos (point) 'syntax-table (string-to-syntax "< c"))
(put-text-property pos (1+ pos) 'syntax-table (string-to-syntax "<"))
(put-text-property (1- (point)) (point) 'syntax-table (string-to-syntax ">")))
;; no matching <# found maybe just mark the #> as invalid
(put-text-property pos (1+ pos) 'syntax-table (string-to-syntax "'"))))))
(defun chicken-scheme-syntax-propertize (start end)
"Extend scheme-syntax-propertize to also handle #> ... <#."
(goto-char start)
(funcall
(syntax-propertize-rules
("#>" (0 (ignore (scheme-propertize-chicken-comment (match-beginning 0)))))
("<#" (0 (ignore (scheme-propertize-chicken-comment (match-beginning 0)))))
)
start end))
;; Replace the default scheme-syntax-propertize when chicken is being used
(add-hook 'scheme-mode-hook
(lambda ()
(when (memq 'chicken geiser-active-implementations)
(setq-local syntax-propertize-function #'chicken-scheme-syntax-propertize)
(syntax-propertize (point-max)))))
;; Modifications for chicken
;; Indent module contents at column 0
(defun scheme-module-indent (state indent-point normal-indent) 0)
(put 'module 'scheme-indent-function 'scheme-module-indent)
(put 'and-let* 'scheme-indent-function 1)
(put 'parameterize 'scheme-indent-function 1)
(put 'handle-exceptions 'scheme-indent-function 1)
(put 'when 'scheme-indent-function 1)
(put 'unless 'scheme-indent-function 1)
(put 'match 'scheme-indent-function 1))
(use-package geiser-racket (use-package geiser-racket
:after (geiser)) :after (geiser))