From 8bbddaf1988c54503f2e4310665e7d8fd02e34d4 Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Tue, 10 Sep 2024 11:51:11 +0200 Subject: [PATCH] just some cleanup... --- emacs/custom.el | 35 ++- emacs/init.el | 244 ++++++++++-------- .../org-mode/.yas-compiled-snippets.el | 8 +- 3 files changed, 170 insertions(+), 117 deletions(-) diff --git a/emacs/custom.el b/emacs/custom.el index 4ecc044..b8518da 100644 --- a/emacs/custom.el +++ b/emacs/custom.el @@ -1,4 +1,33 @@ -;; settings from customize +;;; custom.el --- Contains settings generated by customize -*- lexical-binding: t; -*- + +;; Copyright (C) 2024 Levi Neely + +;; Author: Levi Neely +;; Version: 0.1 +;; Package-Requires: ((emacs "29.4")) +;; Keywords: custom +;; URL: https://github.com/USERNAME/REPOSITORY + +;; This file is not part of GNU Emacs. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; This file contains settings generated by customize. + +;;; Code: (custom-set-variables ;; custom-set-variables was added by Custom. @@ -19,3 +48,7 @@ ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(default ((t (:weight regular :height 150 :width normal :foundry " " :family "Go Mono" :slant normal))))) + +(provide 'custom) + +;;; custom.el ends here. diff --git a/emacs/init.el b/emacs/init.el index db696d7..3cac4db 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -66,10 +66,10 @@ (get-text-property 0 'org-hd-marker item))) (line (when marker (org-with-point-at marker - (buffer-substring (line-beginning-position) (line-end-position))))) + (buffer-substring (line-beginning-position) (line-end-position))))) (todo-keyword (when marker (org-with-point-at marker - (org-get-todo-state)))) + (org-get-todo-state)))) (truncated-line (when line (replace-regexp-in-string "^\\[#[A-Z]\\] " "" line)))) (if truncated-line @@ -91,11 +91,11 @@ (message "Closed all org-agenda-related buffers.")) (defun my/org-config () + "Setup personal 'org-mode' configuration." (setq org-agenda-inhibit-startup t org-adapt-indentation nil - org-todo-keywords - '((sequence "HOLD(h)" "TODO(t)" "WAIT(w)" "|" - "DONE(d)" "CNCL(x)")) + org-todo-keywords '((sequence "HOLD(h)" "TODO(t)" "|" + "DONE(d)" "CNCL(x)")) org-todo-keyword-faces '(("HOLD" . (:foreground "orange" :weight bold)) ("TODO" . (:foreground "red" :weight bold)) @@ -118,6 +118,11 @@ :filter-return #'my-org-agenda-format-item)) (defun my/org-refile-config () + "Setup org-refile targets." + (defvar org-refile-targets) + (defvar org-refile-use-outline-path) + (defvar org-outline-path-complete-in-steps) + (defvar org-refile-allow-creating-parent-nodes) (setq org-refile-targets '((nil :maxlevel . 9) ("/ssh:lkn@alioth.uberspace.de:/home/lkn/TODO.org" :maxlevel . 9)) @@ -126,18 +131,25 @@ org-refile-allow-creating-parent-nodes 'confirm)) (defun my/org-capture-config () + "Setup org-capture." (setq org-capture-templates '(("t" "TODO" entry (file "/ssh:lkn@alioth.uberspace.de:/home/lkn/TODO.org") - "* TODO %?\n %i" :prepend t)))) - -(defun my/add-remote-todo-file () - "Add remote TODO.org file to org-agenda-files." - (interactive) - (unless org-agenda-files - (setq org-agenda-files - (list "/ssh:lkn@alioth.uberspace.de:/home/lkn/TODO.org")))) - -(advice-add 'org-agenda :before #'my/add-remote-todo-file) + "* TODO %?\n %i" :prepend t))) + (with-eval-after-load 'denote + (defvar denote-org-capture-specifiers) + (setq denote-org-capture-specifiers "%l\n%i\n%?") + (add-to-list 'org-capture-templates + '("n" "New note (with denote.el)" plain + (file denote-last-path) + #'denote-org-capture + :no-save t + :immediate-finish nil + :kill-buffer t + :jump-to-captured t))) + (advice-add 'org-agenda-format-item-line + :filter-return #'my-org-agenda-format-item) + (advice-add 'org-agenda-format-item + :filter-return #'my-org-agenda-format-item)) (use-package emacs :init @@ -148,26 +160,26 @@ (setq tramp-inline-compress-start-size 1000) (setq backup-by-copying t - completion-cycle-threshold 3 - create-lockfiles nil - custom-file (concat user-emacs-directory "custom.el") - delete-old-versions t - enable-recursive-minibuffers t - focus-follows-mouse t + completion-cycle-threshold 3 + create-lockfiles nil + custom-file (concat user-emacs-directory "custom.el") + delete-old-versions t + enable-recursive-minibuffers t + focus-follows-mouse t indent-tabs-mode nil - inhibit-startup-screen t - kept-new-versions 20 - kept-old-versions 2 - minibuffer-prompt-properties '(read-only t cursor-intangible t face minibuffer-prompt) - mouse-autoselect-window t - read-extended-command-predicate #'command-completion-default-include-p - read-process-output-max (* 1024 1024) - tab-always-indent 'complete + inhibit-startup-screen t + kept-new-versions 20 + kept-old-versions 2 + minibuffer-prompt-properties '(read-only t cursor-intangible t face minibuffer-prompt) + mouse-autoselect-window t + read-extended-command-predicate #'command-completion-default-include-p + read-process-output-max (* 1024 1024) + tab-always-indent 'complete tab-width 4 - text-mode-ispell-word-completion nil + text-mode-ispell-word-completion nil use-short-answers t - version-control t - warning-minimum-level :emergency + version-control t + warning-minimum-level :emergency backup-directory-alist `((".*" . ,(concat user-emacs-directory "backup"))) read-extended-command-predicate #'command-completion-default-include-p text-mode-ispell-word-completion nil @@ -221,9 +233,9 @@ (use-package multiple-cursors :ensure t :defer t :init (multiple-cursors-mode 1) :bind (("C-x C-<" . 'mc/edit-lines) - ("C->" . 'mc/mark-next-like-this) - ("C-<" . 'mc/mark-previous-like-this) - ("C-x C->" . 'mc/mark-all-like-this))) + ("C->" . 'mc/mark-next-like-this) + ("C-<" . 'mc/mark-previous-like-this) + ("C-x C->" . 'mc/mark-all-like-this))) ;; minibuffer ;; === @@ -254,20 +266,24 @@ (my/org-config) (my/org-refile-config) (my/org-capture-config) - (org-babel-do-load-languages - 'org-babel-load-languages - '((shell . t)))) + + (defun my/add-remote-todo-file () + "Add remote TODO.org file to org-agenda-files." + (interactive) + (unless org-agenda-files + (setq org-agenda-files + (list "/ssh:lkn@alioth.uberspace.de:/home/lkn/TODO.org")))) + + (advice-add 'org-agenda :before #'my/add-remote-todo-file) + (org-babel-do-load-languages 'org-babel-load-languages + '((shell . t)))) ;; knowledge management ;; === -(defun my/search-denote-notes () - "Use ripgrep to search denote notes." - (interactive) - (let ((default-directory "/ssh:lkn@alioth.uberspace.de:/home/lkn/notes/")) - (consult-ripgrep))) (use-package denote :ensure t + :commands (my/search-denote-notes) :bind (("C-x n f" . #'denote-open-or-create) ("C-x n n" . #'denote) ("C-x n c" . #'denote-region) @@ -281,11 +297,17 @@ ("C-x n l f" . #'denote-find-link) ("C-x n b l" . #'denote-backlinks) ("C-x n b f" . #'denote-find-backlink) - ("C-x n /" . #'my/search-denote-notes) + ("C-x n /" . #'my/search-denote-notes) ("C-x n r r" . #'denote-rename-file) ("C-x n r f" . #'denote-rename-file-using-front-matter)) :config + (defun my/search-denote-notes () + "Use ripgrep to search denote notes." + (interactive) + (let ((default-directory "/ssh:lkn@alioth.uberspace.de:/home/lkn/notes/")) + (consult-ripgrep))) + (let ((map dired-mode-map)) (define-key map (kbd "C-x n d") #'denote-dired-mode) (define-key map (kbd "C-x n i") #'denote-link-dired-marked-notes) @@ -299,7 +321,7 @@ denote-infer-keywords t denote-sort-keywords t denote-file-type nil - denote-history-completion-in-prompts nil + denote-history-completion-in-prompts nil denote-prompts '(title keywords) denote-excluded-directories-regexp nil denote-excluded-keywords-regexp nil @@ -307,39 +329,63 @@ denote-date-prompt-use-org-read-date t denote-date-format nil denote-backlinks-show-context t) - (denote-rename-buffer-mode 1) - (with-eval-after-load 'org-capture - (setq denote-org-capture-specifiers "%l\n%i\n%?") - (add-to-list 'org-capture-templates - '("n" "New note (with denote.el)" plain - (file denote-last-path) - #'denote-org-capture - :no-save t - :immediate-finish nil - :kill-buffer t - :jump-to-captured t)))) + (denote-rename-buffer-mode 1)) ;; version control ;; === (use-package magit :ensure t :defer t + :commands (magit-status-here + magit-get-current-branch + magit-get-upstream-branch + magit-read-branch + magit-git-string + magit-reset-to-merge-base + magit-reset-to-upstream) + :custom (magit-display-buffer-function + #'magit-display-buffer-same-window-except-diff-v1) :bind (("C-x g g" . #'magit-status) - ("C-x g l l" . #'magit-log) - ("C-x g l a" . #'magit-log-all) - ("C-x g l f" . #'magit-log-buffer-file) - ("C-x g R s" . #'magit-reset-soft) - ("C-x g R h" . #'magit-reset-hard) - ("C-x g !" . #'magit-run) - ("C-x g b b" . #'magit-branch) + ("C-x g r b" . #'magit-reset-to-merge-base) + ("C-x g r u" . #'magit-reset-to-upstream) + ("C-x g l l" . #'magit-log) + ("C-x g l a" . #'magit-log-all) + ("C-x g l f" . #'magit-log-buffer-file) + ("C-x g R s" . #'magit-reset-soft) + ("C-x g R h" . #'magit-reset-hard) + ("C-x g !" . #'magit-run) + ("C-x g b b" . #'magit-branch) ("C-x g b c" . #'magit-branch-create) ("C-x g b s" . #'magit-branch-checkout) ("C-x g m m" . #'magit-merge) ("C-x g d d" . #'magit-diff)) - - :commands (magit-status-here magit-get-current-branch) - :custom (magit-display-buffer-function - #'magit-display-buffer-same-window-except-diff-v1)) + :config + (defun magit-reset-to-merge-base () + "Reset to merge-base of two branches using Magit's branch selection." + (interactive) + (require 'magit) + (let* ((branch1 (magit-read-branch "Select first branch: ")) + (branch2 (magit-read-branch "Select second branch: ")) + (merge-base (magit-git-string "merge-base" branch1 branch2))) + (if merge-base + (progn + (magit-reset-internal "--soft" merge-base) + (message "Reset to merge-base of %s and %s" branch1 branch2)) + (user-error "No merge-base found between %s and %s" branch1 branch2)))) + + (defun magit-reset-to-upstream () + "Reset to upstream of the current branch using Magit." + (interactive) + (require 'magit) + (let ((current-branch (magit-get-current-branch))) + (if current-branch + (let ((upstream (magit-get-upstream-branch current-branch))) + (if upstream + (progn + (magit-reset-internal "--soft" "@{u}") + (message "Reset to upstream of %s (%s)" current-branch upstream)) + (user-error "No upstream branch set for %s" current-branch))) + (user-error "Not on a branch"))))) ;; diagramming ;; === @@ -350,10 +396,12 @@ 'org-babel-load-languages '((dot . t))))) (use-package plantuml-mode :ensure t + :custom + (plantuml-default-exec-mode 'jar) + (plantuml-jar-path "/usr/share/plantuml/plantuml.jar") + (org-plantuml-jar-path + (expand-file-name "/usr/share/plantuml/plantuml.jar")) :config - (setq plantuml-default-exec-mode 'jar - plantuml-jar-path "/usr/share/plantuml/plantuml.jar" - org-plantuml-jar-path (expand-file-name "/usr/share/plantuml/plantuml.jar")) (with-eval-after-load 'org (org-babel-do-load-languages 'org-babel-load-languages '((plantuml . t))))) @@ -651,11 +699,11 @@ (interactive "p") (let ((filename (dired-get-filename))) (setq target (concat (file-name-sans-extension filename) - "-old" - (if (> arg 1) (number-to-string arg)) - (file-name-extension filename t))) + "-old" + (if (> arg 1) (number-to-string arg)) + (file-name-extension filename t))) (if (file-directory-p filename) - (copy-file filename target)) + (copy-file filename target)) ) ) @@ -694,10 +742,10 @@ (setopt ellama-language "English") (require 'llm-ollama) (setopt ellama-provider - (make-llm-ollama - :chat-model "codellama:latest" - :embedding-model "nomic-embed-text" - :default-chat-non-standard-params '(("num_ctx" . 8192))))) + (make-llm-ollama + :chat-model "codellama:latest" + :embedding-model "nomic-embed-text" + :default-chat-non-standard-params '(("num_ctx" . 8192))))) (use-package lmtf :ensure t :defer t :straight (lmtf :type git :host github :repo "lneely/lmtf") @@ -720,10 +768,12 @@ (use-package websocket :ensure t) + (use-package org-ai :load-path (lambda () "~/.config/emacs/elisp/org-ai") :commands (org-ai-mode - org-ai-global-mode) + org-ai-global-mode + org-ai-install-yasnippets) :init (add-hook 'org-mode-hook #'org-ai-mode) (org-ai-global-mode) @@ -734,38 +784,6 @@ (setq org-ai-default-chat-model "claude-3-5-sonnet-20240620")) - -(defun magit-reset-to-merge-base () - "Reset to merge-base of two branches using Magit's branch selection." - (interactive) - (require 'magit) - (let* ((branch1 (magit-read-branch "Select first branch: ")) - (branch2 (magit-read-branch "Select second branch: ")) - (merge-base (magit-git-string "merge-base" branch1 branch2))) - (if merge-base - (progn - (magit-reset-internal "--soft" merge-base) - (message "Reset to merge-base of %s and %s" branch1 branch2)) - (user-error "No merge-base found between %s and %s" branch1 branch2)))) - -(defun magit-reset-to-upstream () - "Reset to upstream of the current branch using Magit." - (interactive) - (require 'magit) - (let ((current-branch (magit-get-current-branch))) - (if current-branch - (let ((upstream (magit-get-upstream-branch current-branch))) - (if upstream - (progn - (magit-reset-internal "--soft" "@{u}") - (message "Reset to upstream of %s (%s)" current-branch upstream)) - (user-error "No upstream branch set for %s" current-branch))) - (user-error "Not on a branch")))) - - -(global-set-key (kbd "C-x g r b") 'magit-reset-to-merge-base) -(global-set-key (kbd "C-x g r u") 'magit-reset-to-upstream) - (use-package yasnippet :ensure t :config @@ -780,6 +798,8 @@ :ensure t :after yasnippet) +(use-package wgrep :ensure t) + ;; web browsing ;; === (require 'eww) @@ -787,7 +807,7 @@ (setq shr-image-animate nil) (setq browse-url-browser-function 'eww-browse-url) - ; for pages that require JS for some stupid reason... +;; for pages that require JS for some stupid reason... (defun browse-url-xdg-open (url &optional _new-window) "Open URL using the default browser via `xdg-open'." (interactive (browse-url-interactive-arg "URL: ")) diff --git a/emacs/snippets/org-mode/.yas-compiled-snippets.el b/emacs/snippets/org-mode/.yas-compiled-snippets.el index 76c4cfe..2b559fe 100644 --- a/emacs/snippets/org-mode/.yas-compiled-snippets.el +++ b/emacs/snippets/org-mode/.yas-compiled-snippets.el @@ -2,9 +2,9 @@ ;;; Snippet definitions: ;;; (yas-define-snippets 'org-mode - '(("aippx" "* ${1:What}\n\n#+begin_ai :service perplexity.ai :model llama-3.1-sonar-small-128k-online\n[SYS]: ${2:You are a helpful assistant.}\n\n[ME]: ${0}\n#+end_ai\n" "aippx" nil nil nil "/home/lneely/.config/emacs/snippets/org-mode/aippx" nil nil) - ("aigpt" "* ${1:What}\n\n#+begin_ai :service openai :model gpt-3.5-turbo\n[SYS]: ${2:You are a helpful assistant.}\n\n[ME]: ${0}\n#+end_ai\n" "aigpt" nil nil nil "/home/lneely/.config/emacs/snippets/org-mode/aigpt" nil nil) - ("aicld" "* ${1:What}\n\n#+begin_ai :service anthropic :model claude-3-5-sonnet-20240620\n[SYS]: ${2:You are a helpful assistant.}\n\n[ME]: ${0}\n#+end_ai\n" "aicld" nil nil nil "/home/lneely/.config/emacs/snippets/org-mode/aicld" nil nil))) + '(("aippx" "* ${1:What}\n\n#+begin_ai :service perplexity.ai :model llama-3.1-sonar-small-128k-online\n[SYS]: ${2:You are a helpful assistant.}\n\n[ME]: ${0}\n#+end_ai\n" "aippx" nil nil nil "/home/lkn/.config/emacs/snippets/org-mode/aippx" nil nil) + ("aigpt" "* ${1:What}\n\n#+begin_ai :service openai :model gpt-3.5-turbo\n[SYS]: ${2:You are a helpful assistant.}\n\n[ME]: ${0}\n#+end_ai\n" "aigpt" nil nil nil "/home/lkn/.config/emacs/snippets/org-mode/aigpt" nil nil) + ("aicld" "* ${1:What}\n\n#+begin_ai :service anthropic :model claude-3-5-sonnet-20240620\n[SYS]: ${2:You are a helpful assistant.}\n\n[ME]: ${0}\n#+end_ai\n" "aicld" nil nil nil "/home/lkn/.config/emacs/snippets/org-mode/aicld" nil nil))) -;;; Do not edit! File generated at Mon Sep 9 09:15:20 2024 +;;; Do not edit! File generated at Sun Sep 8 23:48:43 2024