From 9185384bcc4b894f0f662e00aceb2ec4fb9b5501 Mon Sep 17 00:00:00 2001 From: Matthew Gordon Date: Sat, 12 Mar 2022 11:44:31 -0500 Subject: [PATCH 1/4] Add org roam and org roam ui Why is this change needed? -------------------------- I want a better way of recording and organizing knowledge. I reviewed a bunch of tools in this space including, but not limited to, - roam - logseq - notion - obsidian I was surprised to find that Emacs provided the best tooling overall. I had a lot of requirements, but the key ones were - no writing style requirements - for example, Roam and Logseq require everything to be a node in a tree. I just want to start writing without any thought to format. Also, a tree is not always the best way to represent information. - stored in plain text - everything I write should be as portable as possible - stored in a place I can control or export - if I decide to switch tools or the tool I'm using goes away, that shouldn't make me start over - navigate by reference or tag - it should be easy to find linked or unlinked references to anything I write about, either because I'm implicitly mentioned it somewhere, I've explicitly linked it, or I've explicitly grouped the ideas together with a tag How does it address the issue? ------------------------------ Org Roam is the most popular zettelkasten package for Emacs and does the above once configured correctly. I also added Org Roam UI, a web interface for navigating your notes, to make it even easier to see knowledge relations and find notes I'm looking for. This implementation doesn't address all of my needs, but committing this is the last thing I need to do to switch laptops so it's happening anyway. In particular, I haven't - made sure that everything that's embedded in a note is stored in the note repository (e.g. adding an image should put the image in the repo) - actually turned the org roam directory into a repo for maximum storage safety - installed a flashcard solution - enabled transclusion - decided on a publishing feature (if I want one) Still, it should fire up and work just fine for anyone. I'm already using it fairly extensively. It might even eventually take the place of my tmp file. Any links to any relevant tickets, articles or other resources? --------------------------------------------------------------- --- .emacs.d/config.org | 108 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 107 insertions(+), 1 deletion(-) diff --git a/.emacs.d/config.org b/.emacs.d/config.org index 00b91fd..e39755a 100644 --- a/.emacs.d/config.org +++ b/.emacs.d/config.org @@ -3,6 +3,7 @@ #+EMAIL: matt@expectedbehavior.com #+OPTIONS: num:nil + * About This is the Expected Behavior Emacs configuation. It's intended to be used by the Emacsers of EB, but it should be a good starting place for @@ -309,7 +310,7 @@ https://www.gnu.org/software/emacs/manual/html_node/emacs/Registers.html TODO: Project navigation should depend on a function that determines where your code lives #+BEGIN_SRC emacs-lisp (global-set-key (kbd "C-c e") (lambda() (interactive)(find-file "~/.emacs.d/config.org"))) -(global-set-key (kbd "C-c t") (lambda() (interactive)(find-file "~/Dropbox/tmp.txt"))) +(global-set-key (kbd "C-c t") (lambda() (interactive)(find-file "~/Dropbox/tmp.org"))) (global-set-key (kbd "C-c p i w") (lambda() (interactive)(find-file "~/code/instrumental/web/README.md"))) (global-set-key (kbd "C-c p d w") (lambda() (interactive)(find-file "~/code/docraptor/web/README.md"))) #+END_SRC @@ -478,6 +479,21 @@ brew cask install font-fira-mono :init (doom-modeline-mode 1)) #+END_SRC +** Ensure Emacs Environment Variables Match User Shell +Depending on how you start Emacs, it may or may not have the same +environment variables as your normal shell environment. Some packages +depend on having access to shell commands or other environment +variables and it can be a very non-obvious kind of failure. + +In specific, this was installed in response to the +[[https://www.reddit.com/r/emacs/comments/sjstjx/how_can_i_get_orgroam_unlinked_references_working/][problem I was having with org-roam not displaying unlinked references.]] +#+BEGIN_SRC emacs-lisp + (use-package exec-path-from-shell + :init (exec-path-from-shell-initialize)) +#+END_SRC + +#+RESULTS: + * Per-Mode This section should contain changes that apply to just one mode or a @@ -512,6 +528,96 @@ blacklists a few modes, it belongs in Global. #+END_SRC +** Org + +#+BEGIN_SRC emacs-lisp + + (add-hook 'org-mode-hook 'auto-fill-mode) + + (let ((current-prefix-arg '(4))) + (setq org-startup-with-inline-images t)) + +#+END_SRC + +** Org Roam +Org Roam is a text based information management system using the +Zettelkasten Method. If you don't know what that is, the simplest way +to describe it is a personal wiki with tags that tracks and graphs +links between nodes. + +If you'd like to learn more, [[https://www.youtube.com/watch?v=AyhPmypHDEw&list=PLEoMzSkcN8oN3x3XaZQ-AXFKv52LZzjqD][System Crafters did a YouTube series]] that +starts with the absolute basics and builds from there. You could +always read the [[https://www.orgroam.com/manual.html][Org Roam Manual]], but it's a bit more of a technical +review and less of a user guide. + +#+BEGIN_SRC emacs-lisp + ;; -*- lexical-binding: t -*- + + + ;; If you're going to make files, they're going to need a directory. + ;; I chose a Dropbox folder as the default because it means your + ;; files will be backed up as soon as you start working on it. + ;; TODO: Dry up the directory. It's in three places, which is bad. + (if (file-exists-p (file-truename "~/Dropbox/OrgRoam")) + (display-message-or-buffer "Org Roam directory already exists") + (make-directory "~/Dropbox/OrgRoam") + ) + + (use-package org-roam + :custom + (org-roam-directory (file-truename "~/Dropbox/OrgRoam")) + (org-roam-completion-everywhere t) + (org-roam-mode-section-functions + (list #'org-roam-backlinks-section + #'org-roam-reflinks-section + #'org-roam-unlinked-references-section + )) + :bind ( + ("C-c n f" . org-roam-node-find) + ("C-c n i" . org-roam-node-insert) + ("C-c n I" . org-roam-node-insert-immediate) + ("C-c n l" . org-roam-buffer-toggle) + ("C-c n s" . org-roam-db-sync) ;; in case you delete a file outside emacs + ("C-c n t" . org-roam-tag-add) ;; in case you delete a file outside emacs + :map org-mode-map + ("C-M-i" . completion-at-point) + ) + :config + (org-roam-setup) + (org-roam-db-autosync-mode) + ) + + + (defun org-roam-node-insert-immediate (arg &rest args) + (interactive "P") + (let ((args (cons arg args)) + (org-roam-capture-templates (list (append (car org-roam-capture-templates) + '(:immediate-finish t))))) + (apply #'org-roam-node-insert args))) + +#+END_SRC + + +#+BEGIN_SRC emacs-lisp + + ;; https://github.com/org-roam/org-roam-ui + ;; localhost:35901 + ;; + (use-package org-roam-ui + :after org-roam ;; or :after org + ;; normally we'd recommend hooking orui after org-roam, but since org-roam does not have + ;; a hookable mode anymore, you're advised to pick something yourself + ;; if you don't care about startup time, use + :hook (after-init . org-roam-ui-mode) + :config + (setq org-roam-ui-sync-theme t + org-roam-ui-follow t + org-roam-ui-update-on-save t + org-roam-ui-open-on-start t)) + +#+END_SRC + + ** Rust #+BEGIN_SRC emacs-lisp From 249a86631bf96315bd86bc1ab150405c6fae0882 Mon Sep 17 00:00:00 2001 From: Matthew Gordon Date: Mon, 25 Apr 2022 11:56:18 -0400 Subject: [PATCH 2/4] Remove custom org roam method for immediate insertion Why is this change needed? -------------------------- It was recommended by several people while I was setting it up, but I never want it. How does it address the issue? ------------------------------ I'm deleting it because it's bad to have code you never use. Any links to any relevant tickets, articles or other resources? --------------------------------------------------------------- https://3.basecamp.com/3093825/buckets/14355728/todos/4853961505 --- .emacs.d/config.org | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/.emacs.d/config.org b/.emacs.d/config.org index e39755a..581a19c 100644 --- a/.emacs.d/config.org +++ b/.emacs.d/config.org @@ -541,9 +541,9 @@ blacklists a few modes, it belongs in Global. ** Org Roam Org Roam is a text based information management system using the -Zettelkasten Method. If you don't know what that is, the simplest way -to describe it is a personal wiki with tags that tracks and graphs -links between nodes. +Zettelkasten Method. If you haven't heard of it, think of it as a +personal wiki with tags that tracks and graphs links between +nodes. That's really underselling it. If you'd like to learn more, [[https://www.youtube.com/watch?v=AyhPmypHDEw&list=PLEoMzSkcN8oN3x3XaZQ-AXFKv52LZzjqD][System Crafters did a YouTube series]] that starts with the absolute basics and builds from there. You could @@ -575,7 +575,6 @@ review and less of a user guide. :bind ( ("C-c n f" . org-roam-node-find) ("C-c n i" . org-roam-node-insert) - ("C-c n I" . org-roam-node-insert-immediate) ("C-c n l" . org-roam-buffer-toggle) ("C-c n s" . org-roam-db-sync) ;; in case you delete a file outside emacs ("C-c n t" . org-roam-tag-add) ;; in case you delete a file outside emacs @@ -588,13 +587,6 @@ review and less of a user guide. ) - (defun org-roam-node-insert-immediate (arg &rest args) - (interactive "P") - (let ((args (cons arg args)) - (org-roam-capture-templates (list (append (car org-roam-capture-templates) - '(:immediate-finish t))))) - (apply #'org-roam-node-insert args))) - #+END_SRC From ba7c950f877b4d6b7ed5120ea82416fe55650ed6 Mon Sep 17 00:00:00 2001 From: Matthew Gordon Date: Tue, 28 Jun 2022 16:27:16 -0400 Subject: [PATCH 3/4] Add Silver Searcher as an option for projectile searching Why is this change needed? -------------------------- The second most common thing I do with Projectile after using it to find a file in a project is search the project for instances of a thing. I was using grep because it's easy, but I always use `ag` in my terminal so it makes sense to expand that option to Emacs. How does it address the issue? ------------------------------ Add the package Any links to any relevant tickets, articles or other resources? --------------------------------------------------------------- --- .emacs.d/config.org | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.emacs.d/config.org b/.emacs.d/config.org index 581a19c..a28d327 100644 --- a/.emacs.d/config.org +++ b/.emacs.d/config.org @@ -443,6 +443,11 @@ brew cask install font-fira-mono ) #+END_SRC +** Ag - The Silver Searcher +If you want to use Projectile's search functions with ag + +(use-package ag) + ** Projectile #+BEGIN_SRC emacs-lisp (use-package projectile From 5b3f6db4fd5cd8998232df17d96eba69dc58e9d2 Mon Sep 17 00:00:00 2001 From: Matthew Gordon Date: Tue, 28 Jun 2022 16:34:13 -0400 Subject: [PATCH 4/4] Add an alias that pushes a git branch and sets local to track the remote Why is this change needed? -------------------------- It's the most common thing in the world. You make a new branch, then you want to push those changes to the remote and you get that message about needing to set the tracking branch or specify more info when you push. Most documentation about this makes it sound like it's very straightforward to automate, but I kept running into cases where the simple solutions didn't work and I'd have to type things out the long way. How does it address the issue? ------------------------------ Add the alias 'gpu' that does all of the steps idempotently. If you haven't pushed and set tracking, it does it for you. If that's already done, it pushes. I left a link to the most relevant SO in case the best way of doing this changes in the future. Any links to any relevant tickets, articles or other resources? --------------------------------------------------------------- --- .common_files/lib/git.bash | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.common_files/lib/git.bash b/.common_files/lib/git.bash index b023088..7e4fe06 100644 --- a/.common_files/lib/git.bash +++ b/.common_files/lib/git.bash @@ -16,7 +16,11 @@ alias gst='git status' alias gco="git checkout" alias gu="git reset HEAD" alias ghr="git log -n1 --pretty=format:'%C(bold red)%h%Creset'" -alias gpp="git pull && git push" +# https://stackoverflow.com/questions/17847213/how-to-configure-git-push-to-automatically-set-upstream-without-u +alias gpu='[[ -z $(git config "branch.$(git symbolic-ref --short HEAD).merge") ]] && + git push -u origin $(git symbolic-ref --short HEAD) || + git push' +alias gpp="git pull && gpu" complete -o default -o nospace -F _git_checkout gco alias gpul="git pull" complete -o default -o nospace -F _git_pull gpull