From 5cec642a0bb8f260d4ecb3a99b44642d3460bf14 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Mon, 22 Feb 2021 06:52:51 -0600 Subject: [PATCH] Added fennel, window management, dired, and org enhancements --- README.org | 113 +++++++++++++++++++++++++++++++++++++++++++++++------ init.el | 78 +++++++++++++++++++++++++++++++----- 2 files changed, 168 insertions(+), 23 deletions(-) diff --git a/README.org b/README.org index ddd9e86f..251f0a27 100644 --- a/README.org +++ b/README.org @@ -14,12 +14,14 @@ - [[#completion][Completion]] - [[#help][Help]] - [[#format][Format]] + - [[#fennel][Fennel]] - [[#file-management][File Management]] - [[#org-mode][Org Mode]] - [[#calendar][Calendar]] - [[#magit][Magit]] - [[#eshell][Eshell]] - [[#pdf-tools][PDF-Tools]] + - [[#window-management][Window Management]] - [[#garbage-collection][Garbage Collection]] - [[#early-init][Early Init]] @@ -91,7 +93,8 @@ In order to have this config work on both my desktop with regular joe-schmoe mon Then let's make sure line-numbers are relative and on. And let's turn on visual-line-mode globally. #+begin_src emacs-lisp (setq display-line-numbers-type 'relative) -(display-line-numbers-mode +1) +(global-display-line-numbers-mode +1) +(add-hook 'prog-mode-hook (display-line-numbers-mode +1)) (global-visual-line-mode +1) #+end_src @@ -447,6 +450,13 @@ Marginalia makes for some great decoration to our minibuffer completion items. W :defer 1) #+end_src +** Fennel +I use fennel to build my awesomewm config. So, we'll need that downloaded. +#+begin_src emacs-lisp +(use-package fennel-mode + :mode ("\\.fnl\\'" . fennel-mode)) +#+end_src + ** File Management *** Dired @@ -458,21 +468,46 @@ Marginalia makes for some great decoration to our minibuffer completion items. W (chris/leader-keys "od" '(dired-jump :which-key "open dired here")) (general-def 'normal dired-mode-map - "h" 'dired-up-directory - "l" 'dired-find-file "q" 'kill-this-buffer)) #+end_src +#+begin_src emacs-lisp +(use-package all-the-icons-dired + :hook (dired-mode . all-the-icons-dired-mode)) +#+end_src + +#+begin_src emacs-lisp +(use-package dired-single + :after dired + :general + (general-def 'normal dired-mode-map + "h" 'dired-single-up-directory + "l" 'dired-single-buffer)) +#+end_src + +#+begin_src emacs-lisp :tangle no +(use-package dired-rainbow + :after dired) +#+end_src + +#+begin_src emacs-lisp +(use-package diredfl + :after dired + :config (diredfl-global-mode +1)) +#+end_src ** Org Mode Let's start by creating a self contained function of what I'd like started on every org buffer. #+begin_src emacs-lisp (defun chris/org-mode-setup () (org-indent-mode +1) (toc-org-mode +1) - (olivetti-mode +1)) + (olivetti-mode +1) + (display-line-numbers-mode -1)) #+end_src This is the use-package definition with a lot of customization. Need to setup auto tangle and make sure I have some structure templates for org-mode. + +Part of this config includes some special capture templates for my work as a youth minister. I create lessons through both org-mode and org-roam capture templates. The first part comes from org-roam, then the next is org-mode. #+begin_src emacs-lisp (use-package org :config @@ -545,10 +580,11 @@ This is the use-package definition with a lot of customization. Need to setup au (setq org-id-method 'ts) :general (chris/leader-keys "o a" 'org-agenda - "c" 'org-capture)) + "c" 'org-capture + "so" 'consult-imenu)) #+end_src -We need to create a lesson capture function to find our lesson files differently each time we run our TFC plan capture. +We need to create a lesson capture function to find our lesson files differently each time we run our TFC plan capture. This is the most unique part of my capture template. This function uses =org-roam-find-file= to pick the lesson file that I need to add my lesson plan to. This way the lesson itself is created before the plan. #+begin_src emacs-lisp (defun chris/org-roam-capture-lesson-file () "Function to return the lesson file that is needed for TFC plan capture and move to correct position for plan insertion" @@ -574,15 +610,44 @@ We are also going to make our config auto-tangle. This is so helpful on saving t (add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'chris/org-babel-tangle-config :append :local))) #+end_src + +We also need to add =evil-org= to make better keybindings. +#+begin_src emacs-lisp +(use-package evil-org + :after org) +#+end_src +*** Org-Super-Agenda +Super Agenda gives me a really nice way of making the agenda view look a lot better with some better information included. +#+begin_src emacs-lisp +(use-package org-super-agenda + :after org-agenda + :init + (setq org-super-agenda-groups '((:name "Today" + :time-grid t + :scheduled today) + (:name "Due Today" + :deadline today) + (:name "Important" + :priority "A") + (:name "Overdue" + :time-grid t + :scheduled today) + (:name "Due soon" + :deadline future))) + :config + (org-super-agenda-mode) + (setq org-super-agenda-header-map nil)) +#+end_src *** Org-Roam Here we are going to add org-roam. This is a note-takers paradise by adding an automatic backlinking function. -Basic Org-Roam setup. We select the directory and the basic width of the Org-Roam buffer so that it fits right. We also want to exclude certain files from Org-Roam. All files are synced between machines using syncthing and kept in a version history. I'd like to exclude the version history from Org-Roam using =org-roam-file-exclude-regexp=. +Basic Org-Roam setup. We select the directory and the basic width of the Org-Roam buffer so that it doesn't take too much space on my laptop. We also want to exclude certain files from Org-Roam. All files are synced between machines using syncthing and kept in a version history. I'd like to exclude the version history from Org-Roam using =org-roam-file-exclude-regexp=. We also need to setup some capture templates to use some specific setups with my journalling. These include a space for my [[file:../../org/homework_for_life.org][Homework For Life]], tasks for the day, and how I can love on my family. #+BEGIN_SRC emacs-lisp (use-package org-roam - :after org + :hook (org-load . org-roam-mode) + :commands (org-roam org-roam-find-file) :config (setq org-roam-directory "~/org") (setq org-roam-buffer-width 0.25) @@ -636,6 +701,14 @@ In order to use it, I need to go to http://localhost:8080 (add-hook 'org-roam-mode-hook org-roam-server-mode t) #+END_SRC +*** Org-Superstar +#+begin_src emacs-lisp +(use-package org-superstar + :after org + :config + (org-superstar-mode +1) + (setq org-superstar-headline-bullets-list '("\u25c9" "\u25c8" "\u25b8" "\u25ce" "\u272c" "\u25c7" "\u2749" "\u2719" "\u2756"))) +#+end_src ** Calendar #+begin_src emacs-lisp @@ -647,9 +720,12 @@ In order to use it, I need to go to http://localhost:8080 (cfw:open-calendar-buffer :contents-sources (list - (cfw:org-create-source "Cyan") ; org-agenda source - (cfw:ical-create-source "NV" "https://www.nvhuskies.org/vnews/display.v?ical" "Green") ; School Calendar - (cfw:ical-create-source "Outlook" "https://outlook.office365.com/owa/calendar/62a0d491bec4430e825822afd2fd1c01@tfcconnection.org/9acc5bc27ca24ce7a900c57284959f9d8242340735661296952/S-1-8-2197686000-2519837503-3687200543-3873966527/reachcalendar.ics" "Yellow") ; Outlook Calendar + (cfw:org-create-source + "Cyan") ; org-agenda source + (cfw:ical-create-source + "NV" "https://www.nvhuskies.org/vnews/display.v?ical" "Green") ; School Calendar + (cfw:ical-create-source + "Outlook" "https://outlook.office365.com/owa/calendar/62a0d491bec4430e825822afd2fd1c01@tfcconnection.org/9acc5bc27ca24ce7a900c57284959f9d8242340735661296952/S-1-8-2197686000-2519837503-3687200543-3873966527/reachcalendar.ics" "Yellow") ; Outlook Calendar ))) :general (chris/leader-keys @@ -657,7 +733,7 @@ In order to use it, I need to go to http://localhost:8080 (general-def cfw:calendar-mode-map "q" 'kill-this-buffer "RET" 'cfw:show-details-command) - (general-def cfw:details-mode-map + (general-def 'normal cfw:details-mode-map "q" 'cfw:details-kill-buffer-command)) #+end_src @@ -686,7 +762,7 @@ Use magit, because why wouldn't you? duh! #+end_src ** Eshell -Let's add our own eshell prompt. +Let's add our own eshell prompt. and set the password cache to a significantly higher time in order to not need to constantly reuse my password. #+begin_src emacs-lisp (use-package eshell :ensure nil @@ -756,6 +832,7 @@ Let's add our own eshell prompt. ;;; If the prompt spans over multiple lines, the regexp should match ;;; last line only. (setq-default eshell-prompt-regexp "^ ") + (setq eshell-destroy-buffer-when-process-dies t) :general (chris/leader-keys "oe" 'eshell) @@ -775,6 +852,16 @@ Let's use pdf-tools for a lot better interaction with pdfs. (pdf-tools-install)) #+end_src +** Window Management +#+begin_src emacs-lisp +(setq display-buffer-alist + '(("\\*e?shell\\*" + (display-buffer-in-side-window) + (window-width . 0.3) + (side . right)))) +(setq display-buffer-alist nil) +#+end_src + ** Garbage Collection We set the =gc-cons-threshold= variable to really high, now lets set it back low to make sure emacs performs properly. diff --git a/init.el b/init.el index 4e5b68c4..86746d7f 100644 --- a/init.el +++ b/init.el @@ -30,7 +30,8 @@ :height chris/default-font-size :weight 'regular) (setq display-line-numbers-type 'relative) -(display-line-numbers-mode +1) +(global-display-line-numbers-mode +1) +(add-hook 'prog-mode-hook (display-line-numbers-mode +1)) (global-visual-line-mode +1) (setq doc-view-resolution 192) @@ -246,6 +247,9 @@ (setq format-all-formatters '("Emacs Lisp" emacs-lisp)) :defer 1) +(use-package fennel-mode + :mode ("\\.fnl\\'" . fennel-mode)) + (use-package dired :ensure nil :straight nil @@ -253,14 +257,27 @@ (chris/leader-keys "od" '(dired-jump :which-key "open dired here")) (general-def 'normal dired-mode-map - "h" 'dired-up-directory - "l" 'dired-find-file "q" 'kill-this-buffer)) +(use-package all-the-icons-dired + :hook (dired-mode . all-the-icons-dired-mode)) + +(use-package dired-single + :after dired + :general + (general-def 'normal dired-mode-map + "h" 'dired-single-up-directory + "l" 'dired-single-buffer)) + +(use-package diredfl + :after dired + :config (diredfl-global-mode +1)) + (defun chris/org-mode-setup () (org-indent-mode +1) (toc-org-mode +1) - (olivetti-mode +1)) + (olivetti-mode +1) + (display-line-numbers-mode -1)) (use-package org :config @@ -333,7 +350,8 @@ (setq org-id-method 'ts) :general (chris/leader-keys "o a" 'org-agenda - "c" 'org-capture)) + "c" 'org-capture + "so" 'consult-imenu)) (defun chris/org-roam-capture-lesson-file () "Function to return the lesson file that is needed for TFC plan capture and move to correct position for plan insertion" @@ -356,8 +374,31 @@ (add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'chris/org-babel-tangle-config :append :local))) +(use-package evil-org + :after org) + +(use-package org-super-agenda + :after org-agenda + :init + (setq org-super-agenda-groups '((:name "Today" + :time-grid t + :scheduled today) + (:name "Due Today" + :deadline today) + (:name "Important" + :priority "A") + (:name "Overdue" + :time-grid t + :scheduled today) + (:name "Due soon" + :deadline future))) + :config + (org-super-agenda-mode) + (setq org-super-agenda-header-map nil)) + (use-package org-roam - :after org + :hook (org-load . org-roam-mode) + :commands (org-roam org-roam-find-file) :config (setq org-roam-directory "~/org") (setq org-roam-buffer-width 0.25) @@ -405,6 +446,12 @@ (add-hook 'org-roam-mode-hook org-roam-server-mode t) +(use-package org-superstar + :after org + :config + (org-superstar-mode +1) + (setq org-superstar-headline-bullets-list '("\u25c9" "\u25c8" "\u25b8" "\u25ce" "\u272c" "\u25c7" "\u2749" "\u2719" "\u2756"))) + (use-package calfw :commands chris/calfw-calendar-open :config @@ -413,9 +460,12 @@ (cfw:open-calendar-buffer :contents-sources (list - (cfw:org-create-source "Cyan") ; org-agenda source - (cfw:ical-create-source "NV" "https://www.nvhuskies.org/vnews/display.v?ical" "Green") ; School Calendar - (cfw:ical-create-source "Outlook" "https://outlook.office365.com/owa/calendar/62a0d491bec4430e825822afd2fd1c01@tfcconnection.org/9acc5bc27ca24ce7a900c57284959f9d8242340735661296952/S-1-8-2197686000-2519837503-3687200543-3873966527/reachcalendar.ics" "Yellow") ; Outlook Calendar + (cfw:org-create-source + "Cyan") ; org-agenda source + (cfw:ical-create-source + "NV" "https://www.nvhuskies.org/vnews/display.v?ical" "Green") ; School Calendar + (cfw:ical-create-source + "Outlook" "https://outlook.office365.com/owa/calendar/62a0d491bec4430e825822afd2fd1c01@tfcconnection.org/9acc5bc27ca24ce7a900c57284959f9d8242340735661296952/S-1-8-2197686000-2519837503-3687200543-3873966527/reachcalendar.ics" "Yellow") ; Outlook Calendar ))) :general (chris/leader-keys @@ -423,7 +473,7 @@ (general-def cfw:calendar-mode-map "q" 'kill-this-buffer "RET" 'cfw:show-details-command) - (general-def cfw:details-mode-map + (general-def 'normal cfw:details-mode-map "q" 'cfw:details-kill-buffer-command)) (use-package calfw-org @@ -507,6 +557,7 @@ ;;; If the prompt spans over multiple lines, the regexp should match ;;; last line only. (setq-default eshell-prompt-regexp "^ ") + (setq eshell-destroy-buffer-when-process-dies t) :general (chris/leader-keys "oe" 'eshell) @@ -521,4 +572,11 @@ :config (pdf-tools-install)) +(setq display-buffer-alist + '(("\\*e?shell\\*" + (display-buffer-in-side-window) + (window-width . 0.3) + (side . right)))) +(setq display-buffer-alist nil) + (setq gc-cons-threshold 2000000)