From c62ab7497f75273f8a6fe88c26aa0a99e13e153f Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Thu, 12 Sep 2024 18:01:06 -0700 Subject: [PATCH] Misc lisp editing changes --- init.el | 92 +++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 76 insertions(+), 16 deletions(-) diff --git a/init.el b/init.el index 6508c06..8e30296 100644 --- a/init.el +++ b/init.el @@ -135,7 +135,7 @@ ;; Some settings for programming (setq-default indent-tabs-mode nil - tab-width 4 + tab-width 4 fill-column 80 comment-multi-line t) @@ -209,8 +209,8 @@ Interactively, force the recompile if called with a prefix." (use-package flyspell :config (setq ispell-program-name "hunspell" - flyspell-issue-message-flag nil - flyspell-issue-welcome-flag nil) + flyspell-issue-message-flag nil + flyspell-issue-welcome-flag nil) (define-key flyspell-mode-map (kbd "C-;") nil t) (define-key flyspell-mode-map (kbd "C-,") nil t)) @@ -300,6 +300,15 @@ Interactively, force the recompile if called with a prefix." ("C-c C-+" . evil-numbers/inc-at-pt-incremental) ("C-c C--" . evil-numbers/dec-at-pt-incremental))) +(use-package aggressive-indent + :hook (prog-mode . aggressive-indent-mode) + :config + (add-to-list 'aggressive-indent-protected-commands + #'evil-undo)) + +(use-package adjust-parens + :hook (prog-mode . adjust-parens-mode)) + ;; for when the files are just too large (use-package vlf :demand t @@ -1398,17 +1407,17 @@ If no name is given, list all bookmarks instead." :hook ((emacs-lisp-mode . my/-helpful-setup-emacs-lisp-mode) (helpful-mode . my/-setup-helpful-mode)) :bind (:map help-map - ("f" . helpful-callable) - ("v" . helpful-variable) - ("k" . helpful-key) - ("o" . helpful-symbol) - ("x" . helpful-command) - ("F" . helpful-function) - :map helpful-mode-map - ("" . my/helpful-history-back) - ("" . my/helpful-history-forward) - ("<" . my/helpful-history-back) - (">" . my/helpful-history-forward)) + ("f" . helpful-callable) + ("v" . helpful-variable) + ("k" . helpful-key) + ("o" . helpful-symbol) + ("x" . helpful-command) + ("F" . helpful-function) + :map helpful-mode-map + ("" . my/helpful-history-back) + ("" . my/helpful-history-forward) + ("<" . my/helpful-history-back) + (">" . my/helpful-history-forward)) :init (defun my/-helpful-setup-emacs-lisp-mode () (setq-local evil-lookup-func #'helpful-at-point)) @@ -1484,9 +1493,60 @@ buffers `helpful--sym' to `my/helpful-symbol-history'." (setq helpful-switch-buffer-function 'my/-helpful-switch-buffer-function helpful-max-buffers 2)) +(defun my/greyify-color (color percent &optional frame) + "Make COLOR closer to black by PERCENT on FRAME. +Color can be any color which can be passed to `color-values'." + (cl-destructuring-bind (&optional r g b) + (color-name-to-rgb color frame) + (when (and r g b) + (let ((scale (- 1.0 (/ percent 100.0)))) + (color-rgb-to-hex (* r scale) + (* g scale) + (* b scale)))))) + ;; rainbow-delimiters (use-package rainbow-delimiters - :hook (prog-mode . rainbow-delimiters-mode)) + :hook (prog-mode . rainbow-delimiters-mode) + :config + ;; generate dark version of the rainbow delimiters faces + (defun my/-rainbow-delimiters-recalc-dark-faces (&optional frame) + (unless frame (setq frame (selected-frame))) + (dotimes (i 9) + (when-let ((old-face (intern-soft + (format "rainbow-delimiters-depth-%d-face" + (1+ i)))) + (new-face + (intern + (format "my/rainbow-delimiters-depth-%d-dark-face" + (1+ i)))) + (old-color (face-attribute old-face :foreground frame)) + (new-color (my/greyify-color old-color 50 frame))) + (set-face-attribute new-face frame :foreground new-color)))) + (add-hook 'after-make-frame-functions + #'my/-rainbow-delimiters-recalc-dark-faces) + (add-hook 'server-after-make-frame-hook + #'my/-rainbow-delimiters-recalc-dark-faces) + (defun my/rainbow-delimiters-parinfer-pick-face (depth match loc) + "Version of `rainbow-delimiters-default-pick-face' that colors closing +parenthesis darker than opening ones. This function defers to +`rainbow-delimiters-default-pick-face' and just changes the output if it returns +one of the normal rainbow-delimiters-depth-N-face faces." + (save-match-data + (let* ((base-face (rainbow-delimiters-default-pick-face depth match loc)) + (base-name (symbol-name base-face))) + (if (and adjust-parens-mode + (eq ?\) (char-syntax + (elt (buffer-substring-no-properties loc (1+ loc)) 0))) + (string-match (rx string-start "rainbow-delimiters-depth-" + (group (+ num)) + "-face" string-end) + base-name)) + (or (intern-soft (format "my/rainbow-delimiters-depth-%s-dark-face" + (match-string 1 base-name))) + base-face) + base-face)))) + (setopt rainbow-delimiters-pick-face-function + 'my/rainbow-delimiters-parinfer-pick-face)) ;; auto-highlight-symbol (use-package auto-highlight-symbol @@ -1576,4 +1636,4 @@ buffers `helpful--sym' to `my/helpful-symbol-history'." ;; fun! (use-package mines) -;;; init.el ends +;;; init.el ends here