Emacs: AI, eat instead of vterm, unfill region, auto mu4e, speedup eglot
This commit is contained in:
parent
fe27bc2388
commit
fc5def267a
@ -204,7 +204,8 @@ Finish up
|
|||||||
consult-eglot
|
consult-eglot
|
||||||
all-the-icons-completion
|
all-the-icons-completion
|
||||||
helpful
|
helpful
|
||||||
vterm
|
;; vterm
|
||||||
|
eat
|
||||||
;; Enhancements
|
;; Enhancements
|
||||||
olivetti
|
olivetti
|
||||||
doom-modeline
|
doom-modeline
|
||||||
@ -215,11 +216,11 @@ Finish up
|
|||||||
mono-complete
|
mono-complete
|
||||||
beframe
|
beframe
|
||||||
harpoon
|
harpoon
|
||||||
|
format-all
|
||||||
;; company
|
;; company
|
||||||
;; lsp-mode
|
;; lsp-mode
|
||||||
;; lsp-ui
|
;; lsp-ui
|
||||||
;; flycheck
|
;; flycheck
|
||||||
;; dap-mode
|
|
||||||
;; Org
|
;; Org
|
||||||
org-bullets
|
org-bullets
|
||||||
org-kanban
|
org-kanban
|
||||||
@ -252,7 +253,6 @@ Finish up
|
|||||||
'((dotenv :url "https://github.com/pkulev/dotenv.el")
|
'((dotenv :url "https://github.com/pkulev/dotenv.el")
|
||||||
(indent-bars :url "https://github.com/jdtsmith/indent-bars")
|
(indent-bars :url "https://github.com/jdtsmith/indent-bars")
|
||||||
(doom-themes :url "https://github.com/JosephFerano/doom-themes")
|
(doom-themes :url "https://github.com/JosephFerano/doom-themes")
|
||||||
(pico8-mode :url "https://github.com/Kaali/pico8-mode")
|
|
||||||
(org-timeblock :url "https://github.com/ichernyshovvv/org-timeblock")
|
(org-timeblock :url "https://github.com/ichernyshovvv/org-timeblock")
|
||||||
(dape :url "https://github.com/svaante/dape")
|
(dape :url "https://github.com/svaante/dape")
|
||||||
(app-launcher :url "https://github.com/SebastienWae/app-launcher")))
|
(app-launcher :url "https://github.com/SebastienWae/app-launcher")))
|
||||||
@ -441,7 +441,7 @@ Setup other stuff
|
|||||||
|
|
||||||
(defun joe/disable-line-numbers () (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
|
(dolist (mode '( dashboard-mode-hook org-mode-hook term-mode-hook eww-mode-hook eat-mode-hook
|
||||||
vterm-mode-hook dirvish-directory-view-mode-hook eshell-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
|
dired-mode-hook shell-mode-hook magit-mode-hook compilation-mode-hook
|
||||||
mu4e-headers-mode-hook mu4e-main-mode-hook))
|
mu4e-headers-mode-hook mu4e-main-mode-hook))
|
||||||
@ -557,6 +557,7 @@ Emacs is an great operating system, if only it had a good text editor...
|
|||||||
(comment-line 1)
|
(comment-line 1)
|
||||||
(move-to-column col)))
|
(move-to-column col)))
|
||||||
|
|
||||||
|
(global-set-key (kbd "C-w") #'backward-kill-word)
|
||||||
(global-set-key (kbd "C-c d") 'duplicate-line)
|
(global-set-key (kbd "C-c d") 'duplicate-line)
|
||||||
(global-set-key (kbd "C-c C-;") 'joe/duplicate-line-comment)
|
(global-set-key (kbd "C-c C-;") 'joe/duplicate-line-comment)
|
||||||
|
|
||||||
@ -646,6 +647,20 @@ Simple function more quickly align text
|
|||||||
(lambda ()
|
(lambda ()
|
||||||
(define-key csv-mode-map (kbd "C-c C-a") 'csv-align-mode)))
|
(define-key csv-mode-map (kbd "C-c C-a") 'csv-align-mode)))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
Fill region is great, except when you don't need it...
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(defun unfill-region (beg end)
|
||||||
|
"Unfill the region, joining text paragraphs into a single
|
||||||
|
logical line. This is useful, e.g., for use with
|
||||||
|
`visual-line-mode'."
|
||||||
|
(interactive "*r")
|
||||||
|
(let ((fill-column (point-max)))
|
||||||
|
(fill-region beg end)))
|
||||||
|
|
||||||
|
;; Handy key definition
|
||||||
|
(define-key global-map (kbd "C-M-q") #'unfill-region)
|
||||||
|
#+end_src
|
||||||
*** COMMENT Hydra
|
*** COMMENT Hydra
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(require 'hydra)
|
(require 'hydra)
|
||||||
@ -819,7 +834,7 @@ Simple function more quickly align text
|
|||||||
(require 'evil)
|
(require 'evil)
|
||||||
(evil-mode t)
|
(evil-mode t)
|
||||||
|
|
||||||
(evil-global-set-key 'insert (kbd "C-w") #'evil-delete-backward-word)
|
;; (evil-global-set-key 'insert (kbd "C-w") #'evil-delete-backward-word)
|
||||||
|
|
||||||
;; vv to expand selection to line
|
;; vv to expand selection to line
|
||||||
(evil-global-set-key 'visual
|
(evil-global-set-key 'visual
|
||||||
@ -872,8 +887,8 @@ Simple function more quickly align text
|
|||||||
(kbd "SPC br") 'joe/revert-buffer-no-confirm
|
(kbd "SPC br") 'joe/revert-buffer-no-confirm
|
||||||
(kbd "SPC gg") 'magit-status
|
(kbd "SPC gg") 'magit-status
|
||||||
(kbd "SPC gc") 'magit-clone
|
(kbd "SPC gc") 'magit-clone
|
||||||
(kbd "SPC ss") 'joe/vterm-here
|
(kbd "SPC ss") 'eat
|
||||||
(kbd "SPC sv") 'vterm
|
(kbd "SPC sv") 'eat-other-window
|
||||||
(kbd "SPC Ba") 'joe/bookmark-set-and-save
|
(kbd "SPC Ba") 'joe/bookmark-set-and-save
|
||||||
(kbd "SPC Bd") 'bookmark-delete
|
(kbd "SPC Bd") 'bookmark-delete
|
||||||
(kbd "SPC mr") 'joe/compile-run
|
(kbd "SPC mr") 'joe/compile-run
|
||||||
@ -995,7 +1010,6 @@ Harpoon lets you quickly switch between bookmarked buffers
|
|||||||
(global-set-key (kbd "C-c h 8") 'harpoon-go-to-8)
|
(global-set-key (kbd "C-c h 8") 'harpoon-go-to-8)
|
||||||
(global-set-key (kbd "C-c h 9") 'harpoon-go-to-9)
|
(global-set-key (kbd "C-c h 9") 'harpoon-go-to-9)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** Windows
|
** Windows
|
||||||
*** Window Management
|
*** Window Management
|
||||||
|
|
||||||
@ -1503,6 +1517,8 @@ These are functions to load a project specific file given the conventions I use.
|
|||||||
(define-key project-prefix-map "n" #'joe/project-open-project-notes)
|
(define-key project-prefix-map "n" #'joe/project-open-project-notes)
|
||||||
(define-key project-prefix-map "r" #'joe/project-open-project-readme)
|
(define-key project-prefix-map "r" #'joe/project-open-project-readme)
|
||||||
(define-key project-prefix-map "l" #'joe/project-open-project-license)
|
(define-key project-prefix-map "l" #'joe/project-open-project-license)
|
||||||
|
(define-key project-prefix-map "s" #'eat-project)
|
||||||
|
(define-key project-prefix-map "S" #'eat-project-other-window)
|
||||||
;; Remape this
|
;; Remape this
|
||||||
(define-key project-prefix-map "C-r" #'project-query-replace-regexp)
|
(define-key project-prefix-map "C-r" #'project-query-replace-regexp)
|
||||||
#+end_src
|
#+end_src
|
||||||
@ -1836,16 +1852,15 @@ odd looking ~'(t .t)~ is for specifying a default for all other actions.
|
|||||||
(require 'sendmail)
|
(require 'sendmail)
|
||||||
(setq send-mail-function 'smtpmail-send-it)
|
(setq send-mail-function 'smtpmail-send-it)
|
||||||
|
|
||||||
(setq message-kill-buffer-on-exit nil)
|
(setq mu4e-update-interval 30)
|
||||||
|
(setq mu4e-hide-index-messages t)
|
||||||
(setq mu4e-update-interval 10)
|
|
||||||
(setq mu4e-hide-index-messages 't)
|
|
||||||
(setq mu4e-completing-read-function 'completing-read)
|
(setq mu4e-completing-read-function 'completing-read)
|
||||||
(setq mu4e-sent-messages-behavior 'sent)
|
|
||||||
(setq mu4e-context-policy 'pick-first)
|
(setq mu4e-context-policy 'pick-first)
|
||||||
(setq mu4e-compose-context-policy 'ask)
|
(setq mu4e-compose-context-policy 'ask)
|
||||||
(setq mu4e-view-auto-mark-as-read nil)
|
(setq mu4e-view-auto-mark-as-read nil)
|
||||||
|
|
||||||
|
;; (setq mu4e-sent-messages-behavior 'sent)
|
||||||
|
|
||||||
(setq message-kill-buffer-on-exit t)
|
(setq message-kill-buffer-on-exit t)
|
||||||
|
|
||||||
(require 'age)
|
(require 'age)
|
||||||
@ -1863,6 +1878,8 @@ odd looking ~'(t .t)~ is for specifying a default for all other actions.
|
|||||||
|
|
||||||
(setq auth-sources '("~/.local/credentials/authinfo.age"))
|
(setq auth-sources '("~/.local/credentials/authinfo.age"))
|
||||||
|
|
||||||
|
(setq mu4e-change-filenames-when-moving t)
|
||||||
|
|
||||||
(age-file-enable)
|
(age-file-enable)
|
||||||
(age-encryption-mode +1)
|
(age-encryption-mode +1)
|
||||||
(setq mu4e-bookmarks nil)
|
(setq mu4e-bookmarks nil)
|
||||||
@ -1963,6 +1980,7 @@ be kept here commented out in case we want to try it again.
|
|||||||
(global-set-key (kbd "C-h C") #'helpful-command)
|
(global-set-key (kbd "C-h C") #'helpful-command)
|
||||||
#+end_src
|
#+end_src
|
||||||
** Terminals/Shells
|
** Terminals/Shells
|
||||||
|
*** COMMENT vterm
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(require 'vterm)
|
(require 'vterm)
|
||||||
(setq vterm-shell "/bin/fish")
|
(setq vterm-shell "/bin/fish")
|
||||||
@ -2047,6 +2065,20 @@ the right frame, I'm going to use the frame's name to close and remove the hook
|
|||||||
(add-hook 'delete-frame-functions #'joe/kill-vterm-scratch)
|
(add-hook 'delete-frame-functions #'joe/kill-vterm-scratch)
|
||||||
(add-hook 'kill-buffer-hook #'joe/kill-frame))))
|
(add-hook 'kill-buffer-hook #'joe/kill-frame))))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
*** eat
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(defun joe/eat-mode-hook ()
|
||||||
|
(setq-local global-hl-line-mode nil)
|
||||||
|
(setq buffer-face-mode-face '(:family "Fira Code Nerd Font"))
|
||||||
|
(buffer-face-mode))
|
||||||
|
(add-hook 'eat-mode-hook #'joe/eat-mode-hook)
|
||||||
|
|
||||||
|
(evil-define-key 'insert eat-semi-char-mode-map (kbd "C-f") #'eat-self-input)
|
||||||
|
(evil-set-initial-state 'eat-mode 'normal)
|
||||||
|
(setq eat-kill-buffer-on-exit 't)
|
||||||
|
(eat-eshell-mode)
|
||||||
|
(eat-eshell-visual-command-mode)
|
||||||
|
#+end_src
|
||||||
** Undo Fu
|
** Undo Fu
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(require 'undo-fu)
|
(require 'undo-fu)
|
||||||
@ -2142,6 +2174,14 @@ the right frame, I'm going to use the frame's name to close and remove the hook
|
|||||||
;; (setq flymake-start-on-save-buffer nil)
|
;; (setq flymake-start-on-save-buffer nil)
|
||||||
;; (setq flymake-start-on-flymake-mode nil)
|
;; (setq flymake-start-on-flymake-mode nil)
|
||||||
|
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
These help speed eglot up apparently [[https://www.reddit.com/r/emacs/comments/1b25904/is_there_anything_i_can_do_to_make_eglots/][Reddit Link]]
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(fset #'jsonrpc--log-event #'ignore)
|
||||||
|
(setq eglot-events-buffer-size 0)
|
||||||
|
|
||||||
#+end_src
|
#+end_src
|
||||||
*** COMMENT LSP
|
*** COMMENT LSP
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
@ -2265,6 +2305,65 @@ the right frame, I'm going to use the frame's name to close and remove the hook
|
|||||||
(add-to-list 'auto-mode-alist '("\\.vert\\'" . shader-mode))
|
(add-to-list 'auto-mode-alist '("\\.vert\\'" . shader-mode))
|
||||||
(add-to-list 'auto-mode-alist '("\\.frag\\'" . shader-mode))
|
(add-to-list 'auto-mode-alist '("\\.frag\\'" . shader-mode))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
** AI
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(setq gptel-default-mode #'org-mode)
|
||||||
|
(setq gptel-model "gpt-4")
|
||||||
|
(add-hook 'gptel-post-response-functions #'font-lock-ensure)
|
||||||
|
|
||||||
|
(defun gptel--save-state ()
|
||||||
|
"Write the gptel state to the buffer.
|
||||||
|
|
||||||
|
This saves chat metadata when writing the buffer to disk. To
|
||||||
|
restore a chat session, turn on `gptel-mode' after opening the
|
||||||
|
file."
|
||||||
|
(pcase major-mode
|
||||||
|
('org-mode
|
||||||
|
(org-with-wide-buffer
|
||||||
|
(goto-char (point-min))
|
||||||
|
(when (org-at-heading-p)
|
||||||
|
(org-open-line 1))
|
||||||
|
(org-entry-put (point-min) "GPTEL_MODEL" gptel-model)
|
||||||
|
(org-entry-put (point-min) "GPTEL_BACKEND" (gptel-backend-name gptel-backend))
|
||||||
|
(unless (equal (default-value 'gptel-temperature) gptel-temperature)
|
||||||
|
(org-entry-put (point-min) "GPTEL_TEMPERATURE"
|
||||||
|
(number-to-string gptel-temperature)))
|
||||||
|
(unless (string= (default-value 'gptel--system-message)
|
||||||
|
gptel--system-message)
|
||||||
|
(org-entry-put (point-min) "GPTEL_SYSTEM"
|
||||||
|
gptel--system-message))
|
||||||
|
(when gptel-max-tokens
|
||||||
|
(org-entry-put
|
||||||
|
(point-min) "GPTEL_MAX_TOKENS" gptel-max-tokens))
|
||||||
|
;; Save response boundaries
|
||||||
|
(letrec ((write-bounds
|
||||||
|
(lambda (attempts)
|
||||||
|
(let* ((bounds (gptel--get-bounds))
|
||||||
|
(offset (caar bounds))
|
||||||
|
(offset-marker (set-marker (make-marker) offset)))
|
||||||
|
(org-entry-put (point-min) "GPTEL_BOUNDS"
|
||||||
|
(prin1-to-string (gptel--get-bounds)))
|
||||||
|
(when (and (not (= (marker-position offset-marker) offset))
|
||||||
|
(> attempts 0))
|
||||||
|
(funcall write-bounds (1- attempts)))))))
|
||||||
|
(funcall write-bounds 6))))
|
||||||
|
(_ (save-excursion
|
||||||
|
(save-restriction
|
||||||
|
(add-file-local-variable 'gptel-model gptel-model)
|
||||||
|
(add-file-local-variable 'gptel--backend-name
|
||||||
|
(gptel-backend-name gptel-backend))
|
||||||
|
(unless (equal (default-value 'gptel-temperature) gptel-temperature)
|
||||||
|
(add-file-local-variable 'gptel-temperature gptel-temperature))
|
||||||
|
(unless (string= (default-value 'gptel--system-message)
|
||||||
|
gptel--system-message)
|
||||||
|
(add-file-local-variable 'gptel--system-message gptel--system-message))
|
||||||
|
(when gptel-max-tokens
|
||||||
|
(add-file-local-variable 'gptel-max-tokens gptel-max-tokens))
|
||||||
|
(add-file-local-variable 'gptel--bounds (gptel--get-bounds)))))))
|
||||||
|
|
||||||
|
;; together.ai key
|
||||||
|
;; faef0e42e0d1be4e41127aeccd419f520e3abb5e75d84f769512f9b3ed5822da
|
||||||
|
#+end_src
|
||||||
** Programming Languages
|
** Programming Languages
|
||||||
*** Python
|
*** Python
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
@ -2600,8 +2699,6 @@ process the clocks in that buffer as before. We find open clocks in the current
|
|||||||
buffer's associated file using =(buffer-file-name buffer)=. It's assumed that all
|
buffer's associated file using =(buffer-file-name buffer)=. It's assumed that all
|
||||||
Org mode buffers have associated files.
|
Org mode buffers have associated files.
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
|
||||||
*** Visuals
|
*** Visuals
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
|
|
||||||
@ -2697,12 +2794,16 @@ Org mode buffers have associated files.
|
|||||||
|
|
||||||
(defun joe/capture-daily ()
|
(defun joe/capture-daily ()
|
||||||
(concat
|
(concat
|
||||||
"* %^t\n"
|
"** %^t\n"
|
||||||
"** Schedule\n"
|
"*** Schedule\n"
|
||||||
"** Resources\n"
|
"*** Resources\n"
|
||||||
"** Notes"))
|
"*** Notes"))
|
||||||
(setq org-capture-templates
|
(setq org-capture-templates
|
||||||
`(
|
`(
|
||||||
|
("e" "Emacs Improvement" entry
|
||||||
|
(file+headline "Emacs.org" "Quick Wins")
|
||||||
|
"** TODO ")
|
||||||
|
|
||||||
("l" "Leetcode Solution" plain
|
("l" "Leetcode Solution" plain
|
||||||
(function ,(lambda () (find-file (joe/capture-leetcode-newfile))))
|
(function ,(lambda () (find-file (joe/capture-leetcode-newfile))))
|
||||||
#'joe/capture-leetcode-template)
|
#'joe/capture-leetcode-template)
|
||||||
@ -2716,6 +2817,7 @@ Org mode buffers have associated files.
|
|||||||
"** %^{Book Title}%^{AUTHOR}p" :prepend t)))
|
"** %^{Book Title}%^{AUTHOR}p" :prepend t)))
|
||||||
|
|
||||||
(define-key global-map (kbd "C-c c") #'org-capture)
|
(define-key global-map (kbd "C-c c") #'org-capture)
|
||||||
|
|
||||||
#+end_src
|
#+end_src
|
||||||
*** org-babel
|
*** org-babel
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
|
Loading…
x
Reference in New Issue
Block a user