From: Ian Kelling Date: Wed, 16 Jul 2025 22:40:24 +0000 (-0400) Subject: dev snapshot before I delete an elisp experiment X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=dot-emacs dev snapshot before I delete an elisp experiment --- diff --git a/init.el b/init.el index 40ad4ad..3f65b8a 100644 --- a/init.el +++ b/init.el @@ -46,11 +46,11 @@ (setq file-name-handler-alist nil - message-log-max 16384 - gc-cons-threshold 100000000 ;; 100 mb - ;; package-enable-at-startup nil - gc-cons-percentage 0.6 - auto-window-vscroll nil) + message-log-max 16384 + gc-cons-threshold 100000000 ;; 100 mb + ;; package-enable-at-startup nil + gc-cons-percentage 0.6 + auto-window-vscroll nil) (add-hook 'after-init-hook #'(lambda () @@ -575,8 +575,10 @@ A non-nil CURRENT-ONLY argument means save only current buffer." (cond ((equal (car custom-enabled-themes) 'naquadah) (override-theme 'ef-light)) (t + (global-hide-mode-line-mode -1) (override-theme 'naquadah)))) + (setq ef-themes-mixed-fonts t ef-themes-variable-pitch-ui t) @@ -682,6 +684,8 @@ A non-nil CURRENT-ONLY argument means save only current buffer." savehist-file (concat user-emacs-directory ".savehist")) (savehist-mode 1)) + + ;;; vertico (setq read-file-name-completion-ignore-case t read-buffer-completion-ignore-case t @@ -692,12 +696,18 @@ A non-nil CURRENT-ONLY argument means save only current buffer." :custom ;; (vertico-scroll-margin 0) ;; Different scroll margin (vertico-count 20) ;; Show more candidates - ;;(vertico-resize t) ;; Grow and shrink the Vertico minibuffer (vertico-cycle t) ;; Enable cycling for `vertico-next/previous' + ;; default tab inserts current candidate. (keymap-set vertico-map "TAB" #'minibuffer-complete) + ;; just stumbled upon this searching for a solution. There might be + ;; some better way. + (keymap-set vertico-map "C-f" #'vertico-kill-line) :init (vertico-mode)) +;;(keymap-set vertico-map "C-f" 'vertico-kill-line) + + ;; Emacs minibuffer configurations. (use-package emacs :custom @@ -721,6 +731,12 @@ A non-nil CURRENT-ONLY argument means save only current buffer." (completion-category-overrides '((file (styles partial-completion))))) +(defun vertico-kill-line () + "Remove text from the echo area by killing backwards" + (interactive) + (kill-line 0)) + + ;;; dired @@ -884,7 +900,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer." ;;; modes with little configuration needed - +(setq sqlformat-command 'sqlfluff) (custom-set-variables '(css-indent-offset 2) @@ -1071,7 +1087,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer." ;; program to work partly and for an error that is not near the missing semicolon. ;; This works super well to find missing semicolons. (defun perl-iank-regex () - "Start regexp isearch forward with pre-populated search string." + "Start regexp isearch forward with pre-populated search string." (interactive) (let ((search-string "^[^#]*[^ {};,]$")) @@ -1340,11 +1356,44 @@ Go to the next directory based on where the cursor is." (setq global-mark-ring (nbutlast global-mark-ring)) (goto-char (marker-position (mark-marker))))) +(defun replace-regexp-in-buffer (regexp replace-string) + "Replace all matches of REGEXP with REPLACE-STRING in current buffer." + (save-excursion + (goto-char (point-min)) + (while (re-search-forward regexp nil t) + (replace-match replace-string nil nil)))) + +;; I have 2 sql formatters. I prefer the format of sqlfluff, but it is +;; very picky and will refuse to work sometimes. So, here is a function +;; to more easily use the other one. +;;(defun sqlformat-iank-alt ()) + (defun indent-buffer () "Indents the entire buffer." (interactive) (cond ((derived-mode-p 'org-mode) (org-indent-region (point-min) (point-max))) + ((derived-mode-p 'sql-mode) + ;;;; i dun think this is needed, but leaving it here just in case. + ;; (let ((err-buf (get-buffer "*sqlformat errors*"))) + ;; (when err-buf (kill-buffer err-buf))) + + ;; fixes parsing errors for the perl i've been writing. + (replace-regexp-in-buffer "?" "'?'") + (sqlformat-buffer) + (replace-regexp-in-buffer "'\\?'" "?") + (let ((err-buf (get-buffer "*sqlformat errors*")) + err-str) + (when err-buf + (with-current-buffer err-buf + (setq err-str (buffer-substring-no-properties (point-min) (point-max)))) + (when (not (string-empty-p err-str)) + (message "using alt formatter due to error: %s" err-str) + (setq sqlformat-command 'sqlformat + sqlformat-args (list "-k" "lower" "-r" "--wrap_after=80")) + (sqlformat-buffer) + (setq sqlformat-command 'sqlfluff + sqlformat-args nil))))) ((derived-mode-p 'python-mode) (py-autopep8)) (t @@ -1947,6 +1996,7 @@ or else the number of characters matched by `outline-regexp'." (?w (file . ,"/p/w.org")) (?k (file . ,"/a/bin/ds/Arduino/Model01-Firmware/Model01-Firmware.ino")) (?x (file . ,"/a/x.txt")) + (?q (file . ,"/a/x.sql")) )) (set-register (car r) (cadr r))) @@ -2463,7 +2513,7 @@ modes like org-mode which have their own yank function." (global-set-key (kbd "C-e") 'copy-line) -;;;;; M-e ?? unused +;;;;; M-e goto-line (global-set-key (kbd "M-e") 'goto-line) ;;;;; C-r isearch-backward @@ -2473,8 +2523,8 @@ modes like org-mode which have their own yank function." (lambda () (define-key comint-mode-map (kbd "C-r") 'comint-history-isearch-backward-regexp))) -;;;;; M-r ?? unused - +;;;;; M-r sql-up +(global-set-key (kbd "M-r") 'sqlformat-region) ;;;;; C-a copy buffer