From 31ec3d89f40172edeb4f6a418a2124c7d0ecc601 Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Mon, 17 Apr 2023 16:04:46 +0700 Subject: [PATCH] Sql interactive history, fix centaur tabs, mu4e line nums, experiementing --- .config/emacs/init.org | 100 ++++++++++++++++++++++++++++++++--------- 1 file changed, 78 insertions(+), 22 deletions(-) diff --git a/.config/emacs/init.org b/.config/emacs/init.org index 0c21864..8ccf4fb 100644 --- a/.config/emacs/init.org +++ b/.config/emacs/init.org @@ -411,9 +411,13 @@ Setup other stuff (setq-default display-line-numbers 'relative) (make-variable-buffer-local 'global-hl-line-mode) -(dolist (mode '( dashboard-mode-hook org-mode-hook term-mode-hook eww-mode-hook vterm-mode-hook dirvish-directory-view-mode-hook - eshell-mode-hook dired-mode-hook shell-mode-hook magit-mode-hook compilation-mode-hook)) - (add-hook mode (lambda () (display-line-numbers-mode 0)))) +(defun joe/disable-line-numbers () (display-line-numbers-mode 0)) + +(dolist (mode '( dashboard-mode-hook org-mode-hook term-mode-hook eww-mode-hook + vterm-mode-hook dirvish-directory-view-mode-hook eshell-mode-hook + dired-mode-hook shell-mode-hook magit-mode-hook compilation-mode-hook + mu4e-main-mode-hook)) + (add-hook mode #'joe/disable-line-numbers)) (set-window-margins nil 0) (setq-default right-fringe-width 10) @@ -874,6 +878,30 @@ Ace Window will show a hint if there are more than 2 windows, but I don't really (global-set-key (kbd "C-x o") #'ace-window) (global-set-key (kbd "C-x C-o") #'ace-swap-window) +#+end_src +*** COMMENT Beframe +#+begin_src emacs-lisp +(defvar consult-buffer-sources) +(declare-function consult--buffer-state "consult") + +(with-eval-after-load 'consult + (defface beframe-buffer + '((t :inherit font-lock-string-face)) + "Face for `consult' framed buffers.") + + (defvar beframe-consult-source + `( :name "Frame-specific buffers (current frame)" + :narrow ?F + :category buffer + :face beframe-buffer + :history beframe-history + :items ,#'beframe-buffer-names + :action ,#'switch-to-buffer + :state ,#'consult--buffer-state)) + + (add-to-list 'consult-buffer-sources 'beframe-consult-source)) + +(require 'beframe) #+end_src *** Popper @@ -949,8 +977,16 @@ Ace Window will show a hint if there are more than 2 windows, but I don't really (body-function . ,#'select-window)))))) (setq popper-display-function #'joe/popper-display-func) +;; (setq popper-display-function nil) +;; (setq popper-display-function #'popper-select-popup-at-bottom) (popper-mode t) +#+end_src +*** COMMENT Tab-bar & Tab-line +#+begin_src emacs-lisp +(global-set-key (kbd "s-n") #'tab-line-switch-to-next-tab) +(global-set-key (kbd "s-p") #'tab-line-switch-to-prev-tab) + #+end_src *** Scrolling #+begin_src emacs-lisp :tangle no @@ -1032,6 +1068,11 @@ Ace Window will show a hint if there are more than 2 windows, but I don't really (add-hook mode 'centaur-tabs-local-mode)) (with-eval-after-load 'centaur-tabs + (defun joe/fix-centaur-tabs (THEME) + (centaur-tabs-mode -1) + (centaur-tabs-mode)) + + (advice-add 'consult-theme :after #'joe/fix-centaur-tabs) (defun centaur-tabs-buffer-groups () "`centaur-tabs-buffer-groups' control buffers' group rules. @@ -1682,26 +1723,41 @@ startup. Reason we have to call this is so the vterm fucntion can call `vterm--i #+end_src *** SQL #+begin_src emacs-lisp - (defun joe/mark-sql-defun () - "Mark the current SQL function definition." - (interactive) - (let ((beg (save-excursion - (re-search-backward "^create or replace function [^(]+" nil t) - (match-end 0))) - (end (save-excursion - (re-search-forward "\\(language\\)" nil t) - (line-end-position)))) - (when (and beg end) - (goto-char beg) - (set-mark end))) - (evil-visual-line) - (evil-visual-line)) - (with-eval-after-load 'sql-mode - (define-key sql-mode-map (kbd "C-M-h") #'joe/mark-sql-defun) - (define-key sql-mode-map (kbd "") #'sql-connect) - (define-key sql-mode-map (kbd "") #'sql-connect)) -#+end_src +(defun joe/mark-sql-defun () + "Mark the current SQL function definition." + (interactive) + (let ((beg (save-excursion + (re-search-backward "^create or replace function [^(]+" nil t) + (match-end 0))) + (end (save-excursion + (re-search-forward "\\(language\\)" nil t) + (line-end-position)))) + (when (and beg end) + (goto-char beg) + (set-mark end))) + (evil-visual-line) + (evil-visual-line)) +;; This is required so that .dir-locals that read env files for credentials works +(require 'dotenv) +(with-eval-after-load 'sql-mode + (define-key sql-mode-map (kbd "C-M-h") #'joe/mark-sql-defun) + (define-key sql-mode-map (kbd "") #'sql-connect)) +(defun joe/sql-save-history-hook () + (let ((lval 'sql-input-ring-file-name) + (rval 'sql-product)) + (if (symbol-value rval) + (let ((filename + (concat user-emacs-directory "sql/" + (symbol-name (symbol-value rval)) + "-history.sql"))) + (set (make-local-variable lval) filename)) + (error + (format "SQL history will not be saved because %s is nil" + (symbol-name rval)))))) + +(add-hook 'sql-interactive-mode-hook 'joe/sql-save-history-hook) +#+end_src *** C Design some basic functions for compiling. There's also a hook to close the popper window if there