Sql interactive history, fix centaur tabs, mu4e line nums, experiementing

This commit is contained in:
Joseph Ferano 2023-04-17 16:04:46 +07:00
parent 0fd3df7e34
commit 31ec3d89f4

View File

@ -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,7 +1723,7 @@ 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 ()
(defun joe/mark-sql-defun ()
"Mark the current SQL function definition."
(interactive)
(let ((beg (save-excursion
@ -1696,12 +1737,27 @@ startup. Reason we have to call this is so the vterm fucntion can call `vterm--i
(set-mark end)))
(evil-visual-line)
(evil-visual-line))
(with-eval-after-load 'sql-mode
;; 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 "<f8>") #'sql-connect)
(define-key sql-mode-map (kbd "<f8>") #'sql-connect))
#+end_src
(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