From a2d1776e600418f80f190e4d7b9cba943c2ca383 Mon Sep 17 00:00:00 2001 From: Tim McCarthy Date: Sun, 9 Oct 2022 10:28:19 -0700 Subject: [PATCH] ThoomEmacs init changes - Move package management to top - Add exec-path-from-shell - Add server start - Move thoom/meow-negate macro out of use-package block - Add visual-line-mode to org - Set org src indentation to 0 (but don't actually reindent yet) - Add aspirational headings for modes to configure --- thoom-emacs/ThoomEmacs.org | 100 ++++++++++++++++++++++--------------- thoom-emacs/init.el | 58 +++++++++++++-------- 2 files changed, 97 insertions(+), 61 deletions(-) diff --git a/thoom-emacs/ThoomEmacs.org b/thoom-emacs/ThoomEmacs.org index e06001f..5e0cacb 100644 --- a/thoom-emacs/ThoomEmacs.org +++ b/thoom-emacs/ThoomEmacs.org @@ -2,29 +2,7 @@ #+PROPERTY: header-args:emacs-lisp :tangle ./init.el :mkdirp yes #+STARTUP: content * Prelude -** Utility constants for checking operating system -#+begin_src emacs-lisp - ;; Check the system used - (defconst ON-LINUX (eq system-type 'gnu/linux)) - (defconst ON-MAC (eq system-type 'darwin)) - (defconst ON-BSD (or ON-MAC (eq system-type 'berkeley-unix))) - (defconst ON-WINDOWS (memq system-type '(cygwin windows-nt ms-dos))) - #+end_src -** Auto-tangle this file -#+begin_src emacs-lisp - (defun thoom/org-babel-tangle-config () - (when (string-equal (file-truename (buffer-file-name)) - (expand-file-name "~/.dotfiles/thoom-emacs/ThoomEmacs.org")) - ;; Dynamic scoping to the rescue - (let ((org-confirm-babel-evaluate nil)) - (org-babel-tangle)))) - - (add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'thoom/org-babel-tangle-config))) -#+end_src -* Package Management - -** straight.el - +** Package Management #+BEGIN_SRC emacs-lisp (defvar bootstrap-version) (let ((bootstrap-file @@ -38,14 +16,41 @@ (goto-char (point-max)) (eval-print-last-sexp))) (load bootstrap-file nil 'nomessage)) -#+END_SRC -** use-package - -#+BEGIN_SRC emacs-lisp (straight-use-package 'use-package) #+END_SRC +** Utility constants for checking operating system +#+begin_src emacs-lisp + ;; Check the system used + (defconst ON-LINUX (eq system-type 'gnu/linux)) + (defconst ON-MAC (eq system-type 'darwin)) + (defconst ON-BSD (or ON-MAC (eq system-type 'berkeley-unix))) + (defconst ON-WINDOWS (memq system-type '(cygwin windows-nt ms-dos))) +#+end_src +** Fix PATH on macOS +Emacs on macOS doesn't naturally find shell variables like PATH, so to help it out we run a shell and load some variables from the env command. +#+begin_src emacs-lisp + (use-package exec-path-from-shell + :straight t + :if (and ON-MAC (memq window-system '(mac ns))) + :config + (dolist (var '("NIX_SSL_CERT_FILE" + "NIX_PATH" + "NIX_PROFILES")) + (add-to-list 'exec-path-from-shell-variables var)) + (exec-path-from-shell-initialize)) +#+end_src +** Auto-tangle this file +#+begin_src emacs-lisp + (defun thoom/org-babel-tangle-config () + (when (string-equal (file-truename (buffer-file-name)) + (expand-file-name "~/.dotfiles/thoom-emacs/ThoomEmacs.org")) + ;; Dynamic scoping to the rescue + (let ((org-confirm-babel-evaluate nil)) + (org-babel-tangle)))) + (add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'thoom/org-babel-tangle-config))) +#+end_src * Basic UI Tweaks ** Theme #+begin_src emacs-lisp @@ -63,7 +68,7 @@ (doom-themes-org-config)) #+end_src -** Hiding Stuff +** Hiding Clutter Disable a bunch of stuff we don't want to see. #+BEGIN_SRC emacs-lisp @@ -100,18 +105,14 @@ Set some common settings, like global-auto-revert-mode. ;; TODO - Decide whether to enable this ;; (defalias 'yes-or-no-p 'y-or-n-p) #+END_SRC - ** hl-todo - #+begin_src emacs-lisp (use-package hl-todo :straight t :init (global-hl-todo-mode)) #+end_src - ** Repeat Mode - #+begin_src emacs-lisp (repeat-mode 1) @@ -133,20 +134,22 @@ Set some common settings, like global-auto-revert-mode. #+end_src ** Tab Bar - #+begin_src emacs-lisp (tab-bar-mode) ;; TODO - keybindings #+end_src - ** Custom File - Set a location for the custom file so it doesn't pollute this file. #+BEGIN_SRC emacs-lisp (setq custom-file (locate-user-emacs-file "custom-vars.el")) #+END_SRC +* Emacs Server +#+begin_src emacs-lisp + (require 'server) + (unless (server-running-p) (server-start)) +#+end_src * Keybindings ** Which-key @@ -183,6 +186,7 @@ Set a location for the custom file so it doesn't pollute this file. ("C-c b b" . consult-buffer) ("C-c b p" . previous-buffer) ("C-c b n" . next-buffer) + ("C-c b C-c" . server-edit) ("C-o" . pop-global-mark) ("M-DEL" . backward-kill-word) @@ -202,16 +206,17 @@ When in indent-rigidly mode (=+= in normal state), use =H/L= to adjust indent by #+end_src ** Meow #+begin_src emacs-lisp + (defmacro thoom/meow-negate (meow-command) + `(lambda () + (interactive) + (let ((current-prefix-arg -1)) + (call-interactively ,meow-command)))) + (use-package meow :straight t :init ;; TODO - make this unnecessary (require 'meow) - (defmacro thoom/meow-negate (meow-command) - `(lambda () - (interactive) - (let ((current-prefix-arg -1)) - (call-interactively ,meow-command)))) ;; TODO - debug this. should make org headings into meow things (meow-thing-register 'heading 'heading 'heading) @@ -345,14 +350,18 @@ When in indent-rigidly mode (=+= in normal state), use =H/L= to adjust indent by (meow-global-mode 1)) #+end_src +** TODO Autocompletion * Org #+begin_src emacs-lisp (use-package org + :hook (org-mode . visual-line-mode) :config ;; Add structure templates (add-to-list 'org-modules 'org-tempo t) (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")) + (setq org-edit-src-content-indentation 0) + ;; Repeat map for previous/next heading (thoom/repeat-map thoom/org-previous-next-visible-heading-repeat-map ("n" . org-next-visible-heading) @@ -366,7 +375,6 @@ When in indent-rigidly mode (=+= in normal state), use =H/L= to adjust indent by #+end_src * VMOCE - ** Vertico #+begin_src emacs-lisp (use-package vertico @@ -548,3 +556,13 @@ When in indent-rigidly mode (=+= in normal state), use =H/L= to adjust indent by :hook (embark-collect-mode . consult-preview-at-point-mode)) #+end_src + +* TODO Git + +* TODO Direnv + +* Programming +** TODO LSP +** TODO Python +** TODO Web +** TODO Nix diff --git a/thoom-emacs/init.el b/thoom-emacs/init.el index 1740ce4..c2d1f72 100644 --- a/thoom-emacs/init.el +++ b/thoom-emacs/init.el @@ -1,18 +1,3 @@ -;; Check the system used -(defconst ON-LINUX (eq system-type 'gnu/linux)) -(defconst ON-MAC (eq system-type 'darwin)) -(defconst ON-BSD (or ON-MAC (eq system-type 'berkeley-unix))) -(defconst ON-WINDOWS (memq system-type '(cygwin windows-nt ms-dos))) - -(defun thoom/org-babel-tangle-config () - (when (string-equal (file-truename (buffer-file-name)) - (expand-file-name "~/.dotfiles/thoom-emacs/ThoomEmacs.org")) - ;; Dynamic scoping to the rescue - (let ((org-confirm-babel-evaluate nil)) - (org-babel-tangle)))) - -(add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'thoom/org-babel-tangle-config))) - (defvar bootstrap-version) (let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) @@ -28,6 +13,31 @@ (straight-use-package 'use-package) +;; Check the system used +(defconst ON-LINUX (eq system-type 'gnu/linux)) +(defconst ON-MAC (eq system-type 'darwin)) +(defconst ON-BSD (or ON-MAC (eq system-type 'berkeley-unix))) +(defconst ON-WINDOWS (memq system-type '(cygwin windows-nt ms-dos))) + +(use-package exec-path-from-shell + :straight t + :if (and ON-MAC (memq window-system '(mac ns))) + :config + (dolist (var '("NIX_SSL_CERT_FILE" + "NIX_PATH" + "NIX_PROFILES")) + (add-to-list 'exec-path-from-shell-variables var)) + (exec-path-from-shell-initialize)) + +(defun thoom/org-babel-tangle-config () + (when (string-equal (file-truename (buffer-file-name)) + (expand-file-name "~/.dotfiles/thoom-emacs/ThoomEmacs.org")) + ;; Dynamic scoping to the rescue + (let ((org-confirm-babel-evaluate nil)) + (org-babel-tangle)))) + +(add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'thoom/org-babel-tangle-config))) + (use-package doom-themes :straight t :config @@ -98,6 +108,9 @@ (setq custom-file (locate-user-emacs-file "custom-vars.el")) +(require 'server) +(unless (server-running-p) (server-start)) + (use-package which-key :straight t :init @@ -128,6 +141,7 @@ ("C-c b b" . consult-buffer) ("C-c b p" . previous-buffer) ("C-c b n" . next-buffer) + ("C-c b C-c" . server-edit) ("C-o" . pop-global-mark) ("M-DEL" . backward-kill-word) @@ -139,16 +153,17 @@ (define-key indent-rigidly-map (kbd "h") 'indent-rigidly-left-to-tab-stop) (define-key indent-rigidly-map (kbd "l") 'indent-rigidly-right-to-tab-stop) +(defmacro thoom/meow-negate (meow-command) + `(lambda () + (interactive) + (let ((current-prefix-arg -1)) + (call-interactively ,meow-command)))) + (use-package meow :straight t :init ;; TODO - make this unnecessary (require 'meow) - (defmacro thoom/meow-negate (meow-command) - `(lambda () - (interactive) - (let ((current-prefix-arg -1)) - (call-interactively ,meow-command)))) ;; TODO - debug this. should make org headings into meow things (meow-thing-register 'heading 'heading 'heading) @@ -283,11 +298,14 @@ (meow-global-mode 1)) (use-package org + :hook (org-mode . visual-line-mode) :config ;; Add structure templates (add-to-list 'org-modules 'org-tempo t) (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")) + (setq org-edit-src-content-indentation 0) + ;; Repeat map for previous/next heading (thoom/repeat-map thoom/org-previous-next-visible-heading-repeat-map ("n" . org-next-visible-heading)