refactor: Move Emacs config from system/ to projects/dotemacs/

- Delete deprecated system/ configuration files
- Update projects/dotemacs/modules/ with reorganized config
- Add .opencode/ directory for agent state
- Clean up attachments and unused documentation files
This commit is contained in:
2026-04-25 18:41:20 -04:00
parent 43c225a4b5
commit cc6c552d5a
75 changed files with 3263 additions and 5545 deletions

View File

@@ -0,0 +1,91 @@
;; YOU DON'T NEED NONE OF THIS CODE FOR SIMPLE INSTALL
;; IT IS AN EXAMPLE OF CUSTOMIZATION.
(use-package ellama
:init
(require 'llm-openai)
;; setup key bindings
(setq ellama-keymap-prefix "C-c e")
)
(setopt ellama-providers
'(
;; Ollama Provider (added here with a name)
("ollama" . (make-llm-ollama
;; Consider a dedicated embedding model if gemma isn't ideal for it.
:chat-model "gemma3:latest"
:embedding-model "gemma3:latest" ; Or e.g., "nomic-embed-text"
:default-chat-non-standard-params '(("num_ctx" . 8192))))
("openai" . (make-llm-openai
:key (auth-source-pass-get "api-key" "www/openai.com/amr@gharbeia.net")
:chat-model "gpt-4o"
:embedding-model "text-embedding-3-large"))
("groq" . (make-llm-openai-compatible
:url "https://api.groq.com/openai/v1"
:key (auth-source-pass-get "api-key" "www/console.groq.com/groq@amr.gharbeia.net")
;; Check Groq console for available models, these might change
:chat-model "llama3-70b-8192" ; Example, verify on Groq
:embedding-model "llama3-70b-8192")) ; Groq might not offer dedicated embedding models via this API
))
;; --- Set Active Providers ---
;; Choose your default provider from the list above by its name
(setopt ellama-provider "ollama") ; Or "ollama", "openai", "groq"
;; You can specify different providers for different tasks if needed
(setopt ellama-translation-provider "ollama")
(setopt ellama-naming-provider "ollama")
(setopt ellama-naming-scheme 'ellama-generate-name-by-llm)
(setq llm-debug t)
(use-package ellama
:ensure t
:bind ("C-c e" . ellama)
;; send last message in chat buffer with C-c C-c
:hook (org-ctrl-c-ctrl-c-final . ellama-chat-send-last-message)
:init (setopt ellama-auto-scroll t)
:config
;; show ellama context in header line in all buffers
(ellama-context-header-line-global-mode +1)
;; show ellama session id in header line in all buffers
(ellama-session-header-line-global-mode +1))
(use-package gptel)
(setq gptel-api-key (auth-source-pass-get "api-key" "www/console.groq.com/groq@amr.gharbeia.net"))
(gptel-make-openai "Groq" ;Any name you want
:host "api.groq.com"
:endpoint "/openai/v1/chat/completions"
:stream t
:key (auth-source-pass-get "api-key" "www/console.groq.com/groq@amr.gharbeia.net") ;can be a function that returns the key
:models '(llama-3.1-70b-versatile
llama-3.1-8b-instant
llama3-70b-8192
llama3-8b-8192
mixtral-8x7b-32768
gemma-7b-it))
(use-package elisa
:defer t
:init
(setopt elisa-limit 5)
(require 'llm-ollama)
(setopt elisa-embeddings-provider (make-llm-ollama :embedding-model "nomic-embed-text"))
(setopt elisa-chat-provider (make-llm-ollama
:chat-model "sskostyaev/openchat:8k-rag"
:embedding-model "nomic-embed-text"))
)
(use-package opencortex
:straight nil
:load-path "~/.local/share/opencortex/src"
:commands (opencortex-connect opencortex-disconnect)
:init
(setq opencortex-host "127.0.0.1")
(setq opencortex-port 9105)
(setq opencortex-executable-path "~/.local/share/opencortex/bin/opencortex-server")
:config
(message "opencortex: Local brain configured at %s" opencortex-executable-path))

View File

@@ -1,21 +1,120 @@
#+TITLE: Emacs AI Configuration
#+property: header-args :tangle ~/.emacs.d/modules/ai.el
#+TITLE: AI Configuration
#+PROPERTY: header-args :tangle yes
* ellama
#+begin_src elisp
* AI Settings
** Ellama
#+begin_src elisp :tangle yes
;; YOU DON'T NEED NONE OF THIS CODE FOR SIMPLE INSTALL
;; IT IS AN EXAMPLE OF CUSTOMIZATION.
(use-package ellama
:ensure t
:bind ("C-c e" . ellama)
:hook (org-ctrl-c-ctrl-c-final . ellama-chat-send-last-message)
:init (setopt ellama-auto-scroll t)
:config
(ellama-context-header-line-global-mode +1)
(ellama-session-header-line-global-mode +1)
:init
(require 'llm-openai)
;; setup key bindings
(setq ellama-keymap-prefix "C-c e")
)
#+end_src
* Providers
#+begin_src elisp
#+begin_src elisp :tangle yes
(setopt ellama-providers
'(
;; Ollama Provider (added here with a name)
("ollama" . (make-llm-ollama
;; Consider a dedicated embedding model if gemma isn't ideal for it.
:chat-model "gemma3:latest"
:embedding-model "gemma3:latest" ; Or e.g., "nomic-embed-text"
:default-chat-non-standard-params '(("num_ctx" . 8192))))
("openai" . (make-llm-openai
:key (auth-source-pass-get "api-key" "www/openai.com/amr@gharbeia.net")
:chat-model "gpt-4o"
:embedding-model "text-embedding-3-large"))
("groq" . (make-llm-openai-compatible
:url "https://api.groq.com/openai/v1"
:key (auth-source-pass-get "api-key" "www/console.groq.com/groq@amr.gharbeia.net")
;; Check Groq console for available models, these might change
:chat-model "llama3-70b-8192" ; Example, verify on Groq
:embedding-model "llama3-70b-8192")) ; Groq might not offer dedicated embedding models via this API
))
;; --- Set Active Providers ---
;; Choose your default provider from the list above by its name
(setopt ellama-provider "ollama") ; Or "ollama", "openai", "groq"
;; You can specify different providers for different tasks if needed
(setopt ellama-translation-provider "ollama")
(setopt ellama-naming-provider "ollama")
(setopt ellama-naming-scheme 'ellama-generate-name-by-llm)
(setq llm-debug t)
;; Note: API keys should be handled via auth-source as seen in original config
#+end_src
#+begin_src elisp
(use-package ellama
:ensure t
:bind ("C-c e" . ellama)
;; send last message in chat buffer with C-c C-c
:hook (org-ctrl-c-ctrl-c-final . ellama-chat-send-last-message)
:init (setopt ellama-auto-scroll t)
:config
;; show ellama context in header line in all buffers
(ellama-context-header-line-global-mode +1)
;; show ellama session id in header line in all buffers
(ellama-session-header-line-global-mode +1))
#+end_src
** GPTel
#+begin_src elisp :tangle yes
(use-package gptel)
#+end_src
#+begin_src elisp :tangle yes
(setq gptel-api-key (auth-source-pass-get "api-key" "www/console.groq.com/groq@amr.gharbeia.net"))
#+end_src
#+begin_src elisp :tangle yes
(gptel-make-openai "Groq" ;Any name you want
:host "api.groq.com"
:endpoint "/openai/v1/chat/completions"
:stream t
:key (auth-source-pass-get "api-key" "www/console.groq.com/groq@amr.gharbeia.net") ;can be a function that returns the key
:models '(llama-3.1-70b-versatile
llama-3.1-8b-instant
llama3-70b-8192
llama3-8b-8192
mixtral-8x7b-32768
gemma-7b-it))
#+end_src
** Elisa
#+begin_src elisp :tangle yes
(use-package elisa
:defer t
:init
(setopt elisa-limit 5)
(require 'llm-ollama)
(setopt elisa-embeddings-provider (make-llm-ollama :embedding-model "nomic-embed-text"))
(setopt elisa-chat-provider (make-llm-ollama
:chat-model "sskostyaev/openchat:8k-rag"
:embedding-model "nomic-embed-text"))
)
#+end_src
** OpenCortex (Local Foundry)
#+begin_src elisp :tangle yes
(use-package opencortex
:straight nil
:load-path "~/.local/share/opencortex/src"
:commands (opencortex-connect opencortex-disconnect)
:init
(setq opencortex-host "127.0.0.1")
(setq opencortex-port 9105)
(setq opencortex-executable-path "~/.local/share/opencortex/bin/opencortex-server")
:config
(message "opencortex: Local brain configured at %s" opencortex-executable-path))
#+end_src

View File

@@ -0,0 +1,91 @@
;;; emacs-core.el --- Summary
;;; Commentary:
;;; Code:
;; -*- lexical-binding: t; -*-
(setq gc-cons-threshold (* 500 1024 1024))
(add-hook 'after-init-hook (lambda () (setq gc-cons-threshold (* 5 1024 1024))))
(setq straight-use-package-by-default t)
(require 'use-package)
(straight-use-package 'diminish)
(require 'diminish)
(unless (file-directory-p (expand-file-name "~/.emacs.d/straight/versions")) (make-directory (expand-file-name "~/.emacs.d/straight/versions") t))
(use-package org)
(use-package ef-themes
:config
;; If you like two specific themes and want to switch between them, you
;; can specify them in `ef-themes-to-toggle' and then invoke the command
;; `ef-themes-toggle'. All the themes are included in the variable
;; `ef-themes-collection'.
(setq ef-themes-to-toggle '(ef-summer ef-winter))
(setq ef-themes-headings ; read the manual's entry or the doc string
'((0 variable-pitch light 1.9)
(1 variable-pitch light 1.8)
(2 variable-pitch regular 1.7)
(3 variable-pitch regular 1.6)
(4 variable-pitch regular 1.5)
(5 variable-pitch 1.4) ; absence of weight means `bold'
(6 variable-pitch 1.3)
(7 variable-pitch 1.2)
(t variable-pitch 1.1)))
;; They are nil by default...
(setq ef-themes-mixed-fonts t)
(setq ef-themes-variable-pitch-ui t)
;; Disable all other themes to avoid awkward blending:
(mapc #'disable-theme custom-enabled-themes)
;; Load the theme of choice:
(load-theme 'ef-winter :no-confirm)
)
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(when (file-exists-p custom-file) (load custom-file))
(defvar my-laptop-p (equal (system-name) "lilitop"))
(defvar my-server-p (and (equal (system-name) "localhost") (equal user-login-name "root")))
(defvar my-phone-p (not (null (getenv "ANDROID_ROOT")))
"If non-nil, GNU Emacs is running on Termux.")
(when my-phone-p (defvar gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
(global-auto-revert-mode) ; simplifies syncing
(savehist-mode)
(when (fboundp 'flycheck-mode)
(setq flycheck-global-modes nil)
(global-flycheck-mode -1))
(when (fboundp 'flymake-mode)
(setq help-at-pt-display-when-idle t)
;; Disable flymake in all buffers
(add-hook 'find-file-hook (lambda () (flymake-mode -1))))
(use-package magit)
(setq user-full-name "Amr Gharbeia")
(defvar email-address "amr@gharbeia.net")
(defvar calendar-latitude 39.0)
(defvar calendar-longitude -77.1)
(defvar calendar-location-name "Washington, DC")
(defvar calendar-time-zone -300)
(defvar calendar-standard-time-zone-name "EST")
(defvar calendar-daylight-time-zone-name "EDT")
(add-hook 'server-done-hook (lambda () (delete-frame)))
;; (desktop-save-mode t)
(use-package password-store)
(use-package auth-source
:config (auth-source-pass-enable)
)
(provide 'emacs-core)
;;; emacs-core.el ends here

View File

@@ -1,55 +1,199 @@
#+TITLE: Emacs Core Configuration
#+property: header-args :tangle ~/.emacs.d/modules/core.el
#+TITLE: Core Emacs Configuration
#+PROPERTY: header-args :tangle yes
* early-init.el
For straight.el to pick up before package.el
* Initialization Bootstrap
#+begin_src elisp :tangle ~/.emacs.d/early-init.el
(setq package-enable-at-startup nil)
#+end_src
This section tangles directly to ~/.emacs to bootstrap the entire system.
* Straight.el Bootstrap
#+begin_src elisp :tangle ~/.emacs
;;; .emacs --- Global settings -*- lexical-binding: t; -*-
(setq gc-cons-threshold (* 500 1024 1024))
(add-hook 'after-init-hook (lambda () (setq gc-cons-threshold (* 5 1024 1024))))
(setq straight-repository-branch "develop")
(eval-and-compile
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el"
(or (bound-and-true-p straight-base-dir)
user-emacs-directory)))
(bootstrap-version 7))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el" 'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
)
(eval-and-compile
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el"
(or (bound-and-true-p straight-base-dir)
user-emacs-directory)))
(bootstrap-version 7))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el" 'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(straight-use-package 'org))
(setq straight-use-package-by-default t)
(require 'ob-tangle)
;; Load the modular configuration starting from dotemacs.org
(org-babel-load-file (expand-file-name "~/memex/projects/dotemacs/dotemacs.org"))
(provide '.emacs)
#+end_src
* Server and Performance
#+begin_src elisp :tangle ~/.emacs.d/early-init.el
(require 'server)
(unless (server-running-p) (server-start))
(defvar server-max-buffers 100)
#+end_src
* Front matter
#+begin_src elisp
;;; emacs-core.el --- Summary
;;; Commentary:
;;; Code:
;; -*- lexical-binding: t; -*-
#+end_src
* Garbage collector
Increase threshold to 500 MB to ease startup
#+begin_src elisp
(setq gc-cons-threshold (* 500 1024 1024))
#+end_src
Decrease threshold to 5 MB after init
#+begin_src elisp
(add-hook 'after-init-hook (lambda () (setq gc-cons-threshold (* 5 1024 1024))))
#+end_src
* System Information
#+begin_src elisp :tangle ~/.emacs.d/custom.el
* Straight.el and use-package
Integrate use-package and straight
#+begin_src elisp
(setq straight-use-package-by-default t)
(require 'use-package)
(straight-use-package 'diminish)
(require 'diminish)
#+end_src
Make sure Org is installed (straight.el)
#+begin_src elisp
(unless (file-directory-p (expand-file-name "~/.emacs.d/straight/versions")) (make-directory (expand-file-name "~/.emacs.d/straight/versions") t))
(use-package org)
#+end_src
* UI and Themes
#+begin_src elisp
(use-package ef-themes
:config
;; If you like two specific themes and want to switch between them, you
;; can specify them in `ef-themes-to-toggle' and then invoke the command
;; `ef-themes-toggle'. All the themes are included in the variable
;; `ef-themes-collection'.
(setq ef-themes-to-toggle '(ef-summer ef-winter))
(setq ef-themes-headings ; read the manual's entry or the doc string
'((0 variable-pitch light 1.9)
(1 variable-pitch light 1.8)
(2 variable-pitch regular 1.7)
(3 variable-pitch regular 1.6)
(4 variable-pitch regular 1.5)
(5 variable-pitch 1.4) ; absence of weight means `bold'
(6 variable-pitch 1.3)
(7 variable-pitch 1.2)
(t variable-pitch 1.1)))
;; They are nil by default...
(setq ef-themes-mixed-fonts t)
(setq ef-themes-variable-pitch-ui t)
;; Disable all other themes to avoid awkward blending:
(mapc #'disable-theme custom-enabled-themes)
;; Load the theme of choice:
(load-theme 'ef-winter :no-confirm)
)
#+end_src
* Custom file
#+begin_src elisp
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(when (file-exists-p custom-file) (load custom-file))
#+end_src
* System information
#+begin_src elisp
(defvar my-laptop-p (equal (system-name) "lilitop"))
(defvar my-server-p (and (equal (system-name) "localhost") (equal user-login-name "root")))
(defvar my-phone-p (not (null (getenv "ANDROID_ROOT")))
"If non-nil, GNU Emacs is running on Termux.")
(when my-phone-p (defvar gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
(global-auto-revert-mode)
(savehist-mode)
(desktop-save-mode t)
(global-auto-revert-mode) ; simplifies syncing
#+end_src
* Persistent history
#+begin_src elisp
(savehist-mode)
#+end_src
* Disable Syntax Checkers (Diagnostic)
#+begin_src elisp
(when (fboundp 'flycheck-mode)
(setq flycheck-global-modes nil)
(global-flycheck-mode -1))
(when (fboundp 'flymake-mode)
(setq help-at-pt-display-when-idle t)
;; Disable flymake in all buffers
(add-hook 'find-file-hook (lambda () (flymake-mode -1))))
#+end_src
* Backup and versioning
#+begin_src emacs-lisp
(use-package magit)
#+end_src
* Personal information
#+begin_src elisp
(setq user-full-name "Amr Gharbeia")
(defvar email-address "amr@gharbeia.net")
(defvar calendar-latitude 39.0)
(defvar calendar-longitude -77.1)
(defvar calendar-location-name "Washington, DC")
(defvar calendar-time-zone -300)
(defvar calendar-standard-time-zone-name "EST")
(defvar calendar-daylight-time-zone-name "EDT")
#+end_src
* Saving Emacs Sessions
Close frame when done
#+begin_src elisp
(add-hook 'server-done-hook (lambda () (delete-frame)))
#+end_src
Save desktop session
#+begin_src elisp
;; (desktop-save-mode t)
#+end_src
* Security
#+begin_src elisp
(use-package password-store)
#+end_src
#+begin_src elisp
(use-package auth-source
:config (auth-source-pass-enable)
)
#+end_src
* End matter
#+begin_src elisp
(provide 'emacs-core)
;;; emacs-core.el ends here
#+end_src

View File

@@ -0,0 +1,18 @@
#+TITLE: Early Init Configuration
#+PROPERTY: header-args :tangle ~/.emacs.d/early-init.el
* early-init.el
For straight.el to pick up before package.el
#+begin_src elisp
(setq package-enable-at-startup nil)
#+end_src
* Run Emacs as a server
#+begin_src elisp
(require 'server)
(unless (server-running-p) (server-start))
(defvar server-max-buffers 100)
#+end_src

View File

@@ -0,0 +1,117 @@
(setq org-deadline-warning-days 7)
(setq org-agenda-skip-additional-timestamps-same-entry t)
(setq org-agenda-span 'fortnight)
(setq org-agenda-tags-column 'auto)
(setq org-agenda-skip-scheduled-if-deadline-is-shown t)
(setq org-agenda-files (list
(concat org-directory "/inbox.org")
(concat org-directory "/gtd.org")
(concat org-directory "/org-gtd-tasks.org")
)
)
(use-package org-super-agenda)
(setq org-todo-keywords
'(
(sequence "TODO(t)" "NEXT(n)" "WAIT(w@/!)" "|" "DONE(d!)" "CNCL(c@)")
)
)
(setq org-todo-keyword-faces
'(
("TODO" :foreground "red" :weight bold)
("NEXT" :foreground "red" :weight bold)
("WAIT" :foreground "yellow" :weight bold)
("DONE" :foreground "green" :weight bold)
("CNCL" :foreground "blue" :weight bold)
)
)
(setq org-enforce-todo-dependencies t)
(setq org-tags-exclude-from-inheritance '("crypt" "!private"))
(defun org-summary-todo (n-done n-not-done)
"Switch entry to 'DONE' when all subentries are done, to 'TODO' otherwise.
Uses N-DONE and N-NOT-DONE"
(let (org-log-done org-log-states) ; turn off logging
(org-todo (if (= n-not-done 0) "DONE" "TODO")
)
)
)
;; (add-hook 'org-after-todo-statistics-hook #'org-summary-todo)
(use-package f)
(use-package dash)
(use-package s)
(use-package org-edna
:config
(setq org-edna-use-inheritance t)
(org-edna-mode))
(use-package org-gtd
:straight (org-gtd :type git :host github :repo "Trevoke/org-gtd.el")
:demand t
:init (setq org-gtd-update-ack "4.0.0")
:config
(setq org-gtd-keyword-mapping
'((todo . "TODO")
(next . "NEXT")
(wait . "WAIT")
(done . "DONE")
(canceled . "CNCL")))
(setq org-gtd-custom-node-paths
(list (list "Actionable" (expand-file-name "~/memex/gtd.org") "Actions")
(list "Legacy" (expand-file-name "~/memex/org-gtd-tasks.org") "Actions")
(list "Projects" (expand-file-name "~/memex/gtd.org") "Projects")
(list "Incubate" (expand-file-name "~/memex/gtd.org") "Incubate")))
(org-gtd-mode)
)
(global-set-key (kbd "C-c d c") #'org-gtd-capture)
(global-set-key (kbd "C-c d e") #'org-gtd-engage)
(global-set-key (kbd "C-c d p") #'org-gtd-process-inbox)
(with-eval-after-load 'org-gtd
(define-key org-gtd-clarify-map (kbd "C-c c") #'org-gtd-organize))
(setq org-gtd-directory org-directory)
(setq org-gtd-organize-hooks '(org-gtd-set-area-of-focus))
(setq org-gtd-areas-of-focus '(
"Atoms"
"Bits"
"Cells"
"Flags"
"Business"
"Wealth"
"Learning"
"Skills"
"Privacy"
"Archive"
"Library"
"Writing"
"Health"
"Home"
"Family"
"Social"
"Egypt"
)
)
(setq org-gtd-clarify-show-horizons 'right)
(setq org-log-into-drawer "LOGBOOK")
(setq org-clock-into-drawer t)
(setq org-habit-graph-column 80)
(setq org-habit-show-habits-only-for-today nil)
(setq org-refile-targets '((nil :maxlevel . 9)
(org-agenda-files :maxlevel . 9)
)
)
(setq org-outline-path-complete-in-steps nil)
(setq org-refile-allow-creating-parent-nodes 'confirm)

View File

@@ -1,30 +1,112 @@
#+TITLE: Emacs GTD Configuration
#+property: header-args :tangle ~/.emacs.d/modules/gtd.el
#+TITLE: GTD & Agenda Configuration
#+PROPERTY: header-args :tangle yes
* org-gtd
* Agenda
Basic agenda settings
#+begin_src elisp
(use-package org-gtd
:defer t
:init (setq org-gtd-update-ack "3.0.0")
:after org
:config
(setq org-edna-use-inheritance t)
(org-edna-mode)
:bind (
("C-c d c" . org-gtd-capture)
("C-c d e" . org-gtd-engage)
("C-c d p" . org-gtd-process-inbox)
:map org-gtd-clarify-map
("C-c c" . org-gtd-organize)
)
)
(setq org-deadline-warning-days 7)
(setq org-agenda-skip-additional-timestamps-same-entry t)
(setq org-agenda-span 'fortnight)
(setq org-agenda-tags-column 'auto)
(setq org-agenda-skip-scheduled-if-deadline-is-shown t)
#+end_src
* GTD Directory and Areas
Agenda files
#+begin_src elisp
(defvar org-gtd-directory org-directory)
(defvar org-gtd-organize-hooks '(org-gtd-set-area-of-focus))
(defvar org-gtd-areas-of-focus '(
(setq org-agenda-files (list
(concat org-directory "/inbox.org")
(concat org-directory "/gtd.org")
(concat org-directory "/org-gtd-tasks.org")
)
)
#+end_src
Better agenda views
#+begin_src elisp :tangle yes
(use-package org-super-agenda)
#+end_src
* To-do
Basic todo
#+begin_src elisp
(setq org-todo-keywords
'(
(sequence "TODO(t)" "NEXT(n)" "WAIT(w@/!)" "|" "DONE(d!)" "CNCL(c@)")
)
)
(setq org-todo-keyword-faces
'(
("TODO" :foreground "red" :weight bold)
("NEXT" :foreground "red" :weight bold)
("WAIT" :foreground "yellow" :weight bold)
("DONE" :foreground "green" :weight bold)
("CNCL" :foreground "blue" :weight bold)
)
)
(setq org-enforce-todo-dependencies t)
(setq org-tags-exclude-from-inheritance '("crypt" "!private"))
#+end_src
Switch entry to 'DONE' when all subentries are done
#+begin_src elisp
(defun org-summary-todo (n-done n-not-done)
"Switch entry to 'DONE' when all subentries are done, to 'TODO' otherwise.
Uses N-DONE and N-NOT-DONE"
(let (org-log-done org-log-states) ; turn off logging
(org-todo (if (= n-not-done 0) "DONE" "TODO")
)
)
)
;; (add-hook 'org-after-todo-statistics-hook #'org-summary-todo)
#+end_src
* Getting Things Done (GTD)
#+begin_src elisp
(use-package f)
(use-package dash)
(use-package s)
(use-package org-edna
:config
(setq org-edna-use-inheritance t)
(org-edna-mode))
(use-package org-gtd
:straight (org-gtd :type git :host github :repo "Trevoke/org-gtd.el")
:demand t
:init (setq org-gtd-update-ack "4.0.0")
:config
(setq org-gtd-keyword-mapping
'((todo . "TODO")
(next . "NEXT")
(wait . "WAIT")
(done . "DONE")
(canceled . "CNCL")))
(setq org-gtd-custom-node-paths
(list (list "Actionable" (expand-file-name "~/memex/gtd.org") "Actions")
(list "Legacy" (expand-file-name "~/memex/org-gtd-tasks.org") "Actions")
(list "Projects" (expand-file-name "~/memex/gtd.org") "Projects")
(list "Incubate" (expand-file-name "~/memex/gtd.org") "Incubate")))
(org-gtd-mode)
)
(global-set-key (kbd "C-c d c") #'org-gtd-capture)
(global-set-key (kbd "C-c d e") #'org-gtd-engage)
(global-set-key (kbd "C-c d p") #'org-gtd-process-inbox)
(with-eval-after-load 'org-gtd
(define-key org-gtd-clarify-map (kbd "C-c c") #'org-gtd-organize))
#+end_src
#+begin_src elisp
(setq org-gtd-directory org-directory)
(setq org-gtd-organize-hooks '(org-gtd-set-area-of-focus))
(setq org-gtd-areas-of-focus '(
"Atoms"
"Bits"
"Cells"
@@ -44,5 +126,41 @@
"Egypt"
)
)
(defvar org-gtd-clarify-show-horizons 'right)
(setq org-gtd-clarify-show-horizons 'right)
#+end_src
Logging
#+begin_src elisp
(setq org-log-into-drawer "LOGBOOK")
#+end_src
Clocking work in drawer
#+begin_src elisp :tangle yes
(setq org-clock-into-drawer t)
#+end_src
Habits
#+begin_src elisp :tangle yes
(setq org-habit-graph-column 80)
(setq org-habit-show-habits-only-for-today nil)
#+end_src
* Refile
org-refile targets
#+begin_src elisp
(setq org-refile-targets '((nil :maxlevel . 9)
(org-agenda-files :maxlevel . 9)
)
)
#+end_src
Set type of refile targets completion
#+begin_src elisp
(setq org-outline-path-complete-in-steps nil)
#+end_src
Allow refiling to new parents created on the go after confirmation
#+begin_src elisp
(setq org-refile-allow-creating-parent-nodes 'confirm)
#+end_src

View File

@@ -0,0 +1,69 @@
(use-package calibredb
:defer t
:config
(setq calibredb-format-all-the-icons t)
(setq calibredb-format-icons-in-terminal t))
(defvar calibredb-root-dir (expand-file-name "~/memex/library/books"))
(defvar calibredb-db-dir (expand-file-name "metadata.db" calibredb-root-dir))
(defvar calibredb-id-width 6)
(defvar calibredb-title-width 100)
(use-package pdf-tools
:mode ("\\.pdf\\'" . pdf-view-mode)
:config
(pdf-tools-install :no-query)
(setq-default pdf-view-display-size 'fit-page)
(setq pdf-annot-activate-created-annotations t))
(use-package org-noter
:config
(setq org-noter-notes-search-path (list (expand-file-name "~/memex/library/books")))
(setq org-noter-default-notes-file-names '("books.org")))
(setq org-noter-notes-search-path (list (concat org-directory "/library/books")))
(setq org-noter-default-notes-file-names '("books.org"))
(use-package org-noter-pdftools
:after org-noter
:config
;; Add a function to ensure precise note is inserted
(defun org-noter-pdftools-insert-precise-note (&optional toggle-no-questions)
(interactive "P")
(org-noter--with-valid-session
(let ((org-noter-insert-note-no-questions (if toggle-no-questions
(not org-noter-insert-note-no-questions)
org-noter-insert-note-no-questions))
(org-pdftools-use-isearch-link t)
(org-pdftools-use-freepointer-annot t))
(org-noter-insert-note (org-noter--get-precise-info)))))
;; fix https://github.com/weirdNox/org-noter/pull/93/commits/f8349ae7575e599f375de1be6be2d0d5de4e6cbf
(defun org-noter-set-start-location (&optional arg)
"When opening a session with this document, go to the current location.
With a prefix ARG, remove start location."
(interactive "P")
(org-noter--with-valid-session
(let ((inhibit-read-only t)
(ast (org-noter--parse-root))
(location (org-noter--doc-approx-location (when (called-interactively-p 'any) 'interactive))))
(with-current-buffer (org-noter--session-notes-buffer session)
(org-with-wide-buffer
(goto-char (org-element-property :begin ast))
(if arg
(org-entry-delete nil org-noter-property-note-location)
(org-entry-put nil org-noter-property-note-location
(org-noter--pretty-print-location location))))))))
(with-eval-after-load 'pdf-annot
(add-hook 'pdf-annot-activate-handler-functions #'org-noter-pdftools-jump-to-note)
)
)
(use-package nov
:config
(add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))
)
(use-package helm-bibtex)
(setq bibtex-completion-bibliography '("~/bibliography/zotero.bib"))

View File

@@ -1,39 +1,101 @@
#+TITLE: Emacs Media and E-books Configuration
#+property: header-args :tangle ~/.emacs.d/modules/media.el
#+TITLE: Media and Books Configuration
#+PROPERTY: header-args :tangle yes
* Read ebooks (calibredb)
* calibredb
#+begin_src elisp
(use-package calibredb
:defer t
:config
(setq calibredb-format-all-the-icons t)
(setq calibredb-format-icons-in-terminal t)
)
(setq calibredb-format-all-the-icons t)
(setq calibredb-format-icons-in-terminal t))
#+end_src
(defvar calibredb-root-dir (concat (getenv "HOME") "/library/books"))
#+begin_src elisp
(defvar calibredb-root-dir (expand-file-name "~/memex/library/books"))
(defvar calibredb-db-dir (expand-file-name "metadata.db" calibredb-root-dir))
(defvar calibredb-id-width 6)
(defvar calibredb-title-width 100)
(defvar calibredb-author-width 20)
#+end_src
* nov.el (EPUB Viewer)
* PDF Tools
#+begin_src elisp
(use-package pdf-tools
:mode ("\\.pdf\\'" . pdf-view-mode)
:config
(pdf-tools-install :no-query)
(setq-default pdf-view-display-size 'fit-page)
(setq pdf-annot-activate-created-annotations t))
#+end_src
* Annotate PDFs and EPUBs (org-noter)
#+begin_src elisp
(use-package org-noter
:config
(setq org-noter-notes-search-path (list (expand-file-name "~/memex/library/books")))
(setq org-noter-default-notes-file-names '("books.org")))
#+end_src
#+begin_src elisp :tangle yes
(setq org-noter-notes-search-path (list (concat org-directory "/library/books")))
(setq org-noter-default-notes-file-names '("books.org"))
#+end_src
* Link PDFs (org-noter-pdftools)
#+begin_src elisp
(use-package org-noter-pdftools
:after org-noter
:config
;; Add a function to ensure precise note is inserted
(defun org-noter-pdftools-insert-precise-note (&optional toggle-no-questions)
(interactive "P")
(org-noter--with-valid-session
(let ((org-noter-insert-note-no-questions (if toggle-no-questions
(not org-noter-insert-note-no-questions)
org-noter-insert-note-no-questions))
(org-pdftools-use-isearch-link t)
(org-pdftools-use-freepointer-annot t))
(org-noter-insert-note (org-noter--get-precise-info)))))
;; fix https://github.com/weirdNox/org-noter/pull/93/commits/f8349ae7575e599f375de1be6be2d0d5de4e6cbf
(defun org-noter-set-start-location (&optional arg)
"When opening a session with this document, go to the current location.
With a prefix ARG, remove start location."
(interactive "P")
(org-noter--with-valid-session
(let ((inhibit-read-only t)
(ast (org-noter--parse-root))
(location (org-noter--doc-approx-location (when (called-interactively-p 'any) 'interactive))))
(with-current-buffer (org-noter--session-notes-buffer session)
(org-with-wide-buffer
(goto-char (org-element-property :begin ast))
(if arg
(org-entry-delete nil org-noter-property-note-location)
(org-entry-put nil org-noter-property-note-location
(org-noter--pretty-print-location location))))))))
(with-eval-after-load 'pdf-annot
(add-hook 'pdf-annot-activate-handler-functions #'org-noter-pdftools-jump-to-note)
)
)
#+end_src
* View EPUBs (nov.el)
#+begin_src elisp :tangle yes
(use-package nov
:config
(add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))
)
#+end_src
* org-noter and PDF Tools
#+begin_src elisp
(use-package org-noter)
(use-package org-noter-pdftools
:after org-noter
:config
(with-eval-after-load 'pdf-annot
(add-hook 'pdf-annot-activate-handler-functions #'org-noter-pdftools-jump-to-note)
)
)
* Zotero (helm-bibtex)
#+begin_src elisp :tangle yes
(use-package helm-bibtex)
#+end_src
#+begin_src elisp :tangle yes
(setq bibtex-completion-bibliography '("~/bibliography/zotero.bib"))
#+end_src

View File

@@ -0,0 +1,27 @@
(use-package eww
:bind* (("M-m g x" . eww)
("M-m g :" . eww-browse-with-external-browser)
("M-m g #" . eww-list-histories)
("M-m g {" . eww-back-url)
("M-m g }" . eww-forward-url))
:config
(progn
(add-hook 'eww-mode-hook 'visual-line-mode)
)
)
(use-package docker
:bind ("C-c d" . docker)
)
(use-package chemtable)
(use-package beancount
:straight (beancount :type git :host github :repo "beancount/beancount-mode")
:config
(add-to-list 'auto-mode-alist '("\\.beancount\\'" . beancount-mode))
(add-hook 'beancount-mode-hook #'outline-minor-mode)
(define-key beancount-mode-map (kbd "C-c C-n") #'outline-next-visible-heading)
(define-key beancount-mode-map (kbd "C-c C-p") #'outline-previous-visible-heading)
;; (add-hook 'beancount-mode-hook #'flymake-bean-check-enable)
)

View File

@@ -0,0 +1,46 @@
#+TITLE: Miscellaneous Configuration
#+PROPERTY: header-args :tangle yes
* Browser (eww)
#+begin_src elisp
(use-package eww
:bind* (("M-m g x" . eww)
("M-m g :" . eww-browse-with-external-browser)
("M-m g #" . eww-list-histories)
("M-m g {" . eww-back-url)
("M-m g }" . eww-forward-url))
:config
(progn
(add-hook 'eww-mode-hook 'visual-line-mode)
)
)
#+end_src
* Manage Docker in Emacs
#+begin_src elisp
(use-package docker
:bind ("C-c d" . docker)
)
#+end_src
* Periodic table of the elements
#+begin_src elisp :tangle yes
(use-package chemtable)
#+end_src
* Accounting (beancount)
#+begin_src elisp :tangle yes
(use-package beancount
:straight (beancount :type git :host github :repo "beancount/beancount-mode")
:config
(add-to-list 'auto-mode-alist '("\\.beancount\\'" . beancount-mode))
(add-hook 'beancount-mode-hook #'outline-minor-mode)
(define-key beancount-mode-map (kbd "C-c C-n") #'outline-next-visible-heading)
(define-key beancount-mode-map (kbd "C-c C-p") #'outline-previous-visible-heading)
;; (add-hook 'beancount-mode-hook #'flymake-bean-check-enable)
)
#+end_src

View File

@@ -0,0 +1,13 @@
[Desktop Entry]
Name=org-protocol
Comment=Intercept calls from emacsclient to trigger custom actions
Categories=Other;
Keywords=org-protocol;
Icon=emacs
Type=Application
Exec=emacsclient -- %u
Terminal=false
StartupWMClass=Emacs
MimeType=x-scheme-handler/org-protocol;
update-desktop-database ~/.local/share/applications/

View File

@@ -0,0 +1,145 @@
(use-package org
:config
(defvar org-outline-path-complete-in-steps nil)
:bind (("C-c l" . org-store-link)
("C-c a" . org-agenda)
("C-c c" . org-capture)
:map org-mode-map)
)
(setq org-directory (expand-file-name "~/memex/"))
(defvar org-pretty-entities t) ; Improve org mode looks
(defvar org-hide-emphasis-markers t) ; Hide emphasis markup
(defvar org-num-mode nil)
(defvar org-startup-folded 'shw2levels)
(defvar org-startup-indented t) ; Indent org heirarchy
(defvar org-adapt-indentation t)
(defvar org-hide-leading-stars t) ; Minimal Outline
(defvar org-odd-levels-only nil)
(setq org-list-demote-modify-bullet t)
(use-package org-modern
:ensure t
:config
;; Choose some fonts
(set-face-attribute 'default nil :family "sans-serif")
(set-face-attribute 'variable-pitch nil :family "sans-serif")
(set-face-attribute 'org-modern-symbol nil :family "Iosevka")
;; Edit settings
(defvar org-auto-align-tags nil)
(defvar org-tags-column 0)
(defvar org-catch-invisible-edits 'show-and-error)
(defvar org-special-ctrl-a/e t)
(defvar org-insert-heading-respect-content t)
;; Org styling, hide markup etc.
(defvar org-hide-emphasis-markers t)
(defvar org-pretty-entities t)
;; Agenda styling
(defvar org-agenda-tags-column 0)
(defvar org-agenda-block-separator ?─)
(defvar org-agenda-time-grid
'((daily today require-timed)
(800 1000 1200 1400 1600 1800 2000)
" ┄┄┄┄┄ " "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄"))
(defvar org-agenda-current-time-string
"◀── now ─────────────────────────────────────────────────")
;; Ellipsis styling
(defvar org-ellipsis "")
(set-face-attribute 'org-ellipsis nil :inherit 'default :box nil)
(global-org-modern-mode)
)
(setq org-src-fontify-natively t)
(setq org-src-tab-acts-natively t)
(setq org-startup-with-inline-images t)
(setq org-image-actual-width '(300))
(defvar org-default-notes-file (concat org-directory "inbox.org"))
(require 'org-protocol)
(setq org-protocol-default-buffer-for-file-links "*scratch*") ; fixes 'no buffers remain to edit error for org-protocol capturer
(setq org-capture-templates '(
("p" "Protocol"
entry
(file "inbox.org")
"* %^{Title}\nSource: %u, %c\n #+BEGIN_QUOTE\n%i\n#+END_QUOTE\n\n\n%?"
)
("L" "Protocol Link"
entry
(file "inbox.org")
"* %? [[%:link][%:description]]\n:PROPERTIES:\n:TITLE: %:description\n:URI: %:link\n:CREATED: %U\n:END:"
:prepend nil
:empty-lines 1
:created t
:kill-buffer t
)
)
)
(setq org-protocol-default-template-key "L")
(defun my/org-convert-orgzly-to-org-protocol ()
"Reformat Orgzly bookmark at point to org-protocol bookmark."
(interactive)
(when (org-at-heading-p)
(let ((headline (nth 4 (org-heading-components))))
;; Find and store the link. Delete the link line.
(search-forward-regexp "^https?://\\S-*" nil t)
(let ((link (match-string 0)))
(beginning-of-line)
(kill-line)
;; Delete any trailing blank spaces
(org-back-to-heading)
(end-of-line)
(when (not (org-on-heading-p))
(delete-char 1)
)
;; Set new headline
(goto-char (org-entry-beginning-position))
(org-edit-headline (format "[[%s][%s]]" link headline))
;; Set new properties
(org-set-property "TITLE" headline)
(org-set-property "URI" link)
(message "Reformatted Orgzly bookmark at point to org-protocol bookmark")
)
)
)
)
(setq org-export-with-smart-quotes t)
(setq org-export-backends '(beamer html latex md))
(use-package ox-epub)
(setq org-attach-id-dir (concat org-directory "/library"))
(defvar org-babel-do-load-languages 'org-babel-load-languages '((shell . t)))
(use-package org-cliplink
:bind
(("C-x p i" . org-cliplink))
)
(use-package deft
:commands (deft)
:init
(defvar deft-extensions '("org"))
(defvar deft-recursive nil)
(defvar deft-use-filename-as-title t)
:config
(defvar deft-directory org-directory)
(defvar deft-recursive t)
(defvar deft-strip-summary-regexp ":PROPERTIES:\n\\(.+\n\\)+:END:\n")
(defvar deft-use-filename-as-title t)
:bind ("C-c n d" . deft)
)

View File

@@ -1,7 +1,10 @@
#+TITLE: Emacs Org-mode Configuration
#+property: header-args :tangle ~/.emacs.d/modules/org.el
#+TITLE: Org Mode Configuration
#+PROPERTY: header-args :tangle yes
* Org Mode
** Basic setup
* Core Org Setup
#+begin_src elisp
(use-package org
:config
@@ -11,41 +14,130 @@
("C-c c" . org-capture)
:map org-mode-map)
)
(defvar org-directory (concat (getenv "HOME") "/org/"))
#+end_src
* Agenda
#+begin_src elisp
(setq org-deadline-warning-days 7)
(setq org-agenda-skip-additional-timestamps-same-entry t)
(setq org-agenda-span 'fortnight)
(setq org-agenda-tags-column 'auto)
(setq org-agenda-skip-scheduled-if-deadline-is-shown t)
(setq org-agenda-files (list
(concat org-directory "/0_inbox/inbox.org")
(concat org-directory "/0_inbox/org-gtd-tasks.org")
)
)
(setq org-directory (expand-file-name "~/memex/"))
#+end_src
* Capture and Protocol
** Looks
Basic
#+begin_src elisp
(defvar org-pretty-entities t) ; Improve org mode looks
(defvar org-hide-emphasis-markers t) ; Hide emphasis markup
(defvar org-num-mode nil)
(defvar org-startup-folded 'shw2levels)
#+end_src
Indentation of headers
#+begin_src elisp
(defvar org-startup-indented t) ; Indent org heirarchy
(defvar org-adapt-indentation t)
(defvar org-hide-leading-stars t) ; Minimal Outline
(defvar org-odd-levels-only nil)
#+end_src
Indentation of lists
#+begin_src elisp
(setq org-list-demote-modify-bullet t)
#+end_src
Org-modern
#+begin_src elisp
(use-package org-modern
:ensure t
:config
;; Choose some fonts
(set-face-attribute 'default nil :family "sans-serif")
(set-face-attribute 'variable-pitch nil :family "sans-serif")
(set-face-attribute 'org-modern-symbol nil :family "Iosevka")
;; Edit settings
(defvar org-auto-align-tags nil)
(defvar org-tags-column 0)
(defvar org-catch-invisible-edits 'show-and-error)
(defvar org-special-ctrl-a/e t)
(defvar org-insert-heading-respect-content t)
;; Org styling, hide markup etc.
(defvar org-hide-emphasis-markers t)
(defvar org-pretty-entities t)
;; Agenda styling
(defvar org-agenda-tags-column 0)
(defvar org-agenda-block-separator ?─)
(defvar org-agenda-time-grid
'((daily today require-timed)
(800 1000 1200 1400 1600 1800 2000)
" ┄┄┄┄┄ " "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄"))
(defvar org-agenda-current-time-string
"◀── now ─────────────────────────────────────────────────")
;; Ellipsis styling
(defvar org-ellipsis "")
(set-face-attribute 'org-ellipsis nil :inherit 'default :box nil)
(global-org-modern-mode)
)
#+end_src
Highlight Sourcecode Syntax
#+begin_src elisp
(setq org-src-fontify-natively t)
(setq org-src-tab-acts-natively t)
#+end_src
Images
#+begin_src elisp
(setq org-startup-with-inline-images t)
(setq org-image-actual-width '(300))
#+end_src
** Capture
#+begin_src elisp
(defvar org-default-notes-file (concat org-directory "inbox.org"))
#+end_src
*** Org-protocol
Linux configuration
#+begin_src bash :tangle yes
[Desktop Entry]
Name=org-protocol
Comment=Intercept calls from emacsclient to trigger custom actions
Categories=Other;
Keywords=org-protocol;
Icon=emacs
Type=Application
Exec=emacsclient -- %u
Terminal=false
StartupWMClass=Emacs
MimeType=x-scheme-handler/org-protocol;
#+end_src
#+begin_src bash :tangle yes
update-desktop-database ~/.local/share/applications/
#+end_src
Basic configuration
#+begin_src elisp
(require 'org-protocol)
(setq org-protocol-default-buffer-for-file-links "*scratch*")
(defvar org-default-notes-file (concat org-directory "/0_inbox/inbox.org"))
(setq org-protocol-default-template-key "L")
(setq org-protocol-default-buffer-for-file-links "*scratch*") ; fixes 'no buffers remain to edit error for org-protocol capturer
#+end_src
#+begin_src elisp :tangle ~/.emacs.d/custom.el
(defvar org-capture-templates '(
Org-protocol templates
#+begin_src elisp :tangle yes
(setq org-capture-templates '(
("p" "Protocol"
entry
(file "0_inbox/inbox.org")
(file "inbox.org")
"* %^{Title}\nSource: %u, %c\n #+BEGIN_QUOTE\n%i\n#+END_QUOTE\n\n\n%?"
)
("L" "Protocol Link"
entry
(file "0_inbox/inbox.org")
(file "inbox.org")
"* %? [[%:link][%:description]]\n:PROPERTIES:\n:TITLE: %:description\n:URI: %:link\n:CREATED: %U\n:END:"
:prepend nil
:empty-lines 1
@@ -56,14 +148,86 @@
)
#+end_src
* TODO Settings
#+begin_src elisp
(setq org-todo-keywords
'(
(sequence "TODO(t)" "NEXT(n)" "|" "DONE(d!)")
(sequence "WAIT(w@/!)" "|" "CNCL(c@)")
)
)
(setq org-enforce-todo-dependencies t)
(setq org-log-into-drawer "LOGBOOK")
(setq org-protocol-default-template-key "L")
#+end_src
Convert Orgzly captures to org-protocol captures standard
#+begin_src elisp
(defun my/org-convert-orgzly-to-org-protocol ()
"Reformat Orgzly bookmark at point to org-protocol bookmark."
(interactive)
(when (org-at-heading-p)
(let ((headline (nth 4 (org-heading-components))))
;; Find and store the link. Delete the link line.
(search-forward-regexp "^https?://\\S-*" nil t)
(let ((link (match-string 0)))
(beginning-of-line)
(kill-line)
;; Delete any trailing blank spaces
(org-back-to-heading)
(end-of-line)
(when (not (org-on-heading-p))
(delete-char 1)
)
;; Set new headline
(goto-char (org-entry-beginning-position))
(org-edit-headline (format "[[%s][%s]]" link headline))
;; Set new properties
(org-set-property "TITLE" headline)
(org-set-property "URI" link)
(message "Reformatted Orgzly bookmark at point to org-protocol bookmark")
)
)
)
)
#+end_src
** Exporting
#+begin_src elisp :tangle yes
(setq org-export-with-smart-quotes t)
(setq org-export-backends '(beamer html latex md))
#+end_src
Export to EPUB
#+begin_src elisp :tangle yes
(use-package ox-epub)
#+end_src
** org-attach
#+begin_src elisp
(setq org-attach-id-dir (concat org-directory "/library"))
#+end_src
** Enable shell scripting support in org-babel
#+begin_src elisp
(defvar org-babel-do-load-languages 'org-babel-load-languages '((shell . t)))
#+end_src
** Insert org-mode links from clipboard
#+begin_src elisp :tangle yes
(use-package org-cliplink
:bind
(("C-x p i" . org-cliplink))
)
#+end_src
** Deft
#+begin_src elisp :tangle yes
(use-package deft
:commands (deft)
:init
(defvar deft-extensions '("org"))
(defvar deft-recursive nil)
(defvar deft-use-filename-as-title t)
:config
(defvar deft-directory org-directory)
(defvar deft-recursive t)
(defvar deft-strip-summary-regexp ":PROPERTIES:\n\\(.+\n\\)+:END:\n")
(defvar deft-use-filename-as-title t)
:bind ("C-c n d" . deft)
)
#+end_src

View File

@@ -0,0 +1,108 @@
(use-package org-roam
:init (setq org-roam-v2-ack t) ;; Acknowledge V2 upgrade
:after org
:config
(org-roam-db-autosync-enable)
(require 'org-roam-dailies)
:bind (
("C-c n f" . org-roam-node-find)
("C-c n g" . org-roam-graph)
("C-c n r" . org-roam-node-random)
("C-c n h" . org-roam-node-convert-headline)
("C-c n i" . org-roam-node-insert)
("C-c n o" . org-id-get-create)
("C-c n t" . org-roam-tag-add)
("C-c n a" . org-roam-alias-add)
("C-c n l" . org-roam-buffer-display-dedicated)
)
)
(setq org-roam-directory (expand-file-name (concat org-directory "notes")))
(setq org-roam-dailies-directory (expand-file-name (concat org-directory "daily")))
(use-package sqlite3)
(require 'sqlite3)
(setq org-roam-file-exclude-regexp "^[.][.]?/")
(setq org-roam-mode-sections
(list #'org-roam-backlinks-section
#'org-roam-reflinks-section
#'org-roam-unlinked-references-section
)
)
(defun my/org-roam-node-has-tag (node tag)
"Filter function to check if the given NODE has the specified TAG."
(member tag (org-roam-node-tags node))
)
(defun my/org-roam-node-find-by-tag ()
"Find and open an Org-roam node based on a specified tag."
(interactive)
(let ((tag (read-string "Enter tag: ")))
(org-roam-node-find nil nil (lambda (node) (my/org-roam-node-has-tag node tag))))
)
(setq org-roam-capture-templates
'(
("L" "link" plain
(function org-roam--capture-get-point)
"%?"
:file-name "web/%<%Y-%m-%dT%H%M%S>.org"
:head "#+TITLE: ${title}\n#+CREATED: %<%Y-%m-%dT%H%M%S>"
:immediate-finish t
:unnarrowed t
)
("h" "hugo post" plain
"%?"
:target (file+head "posts/${slug}.org"
"#+TITLE: ${title}\n#+DATE: %U\n#+HUGO_BASE_DIR: ~/gharbeia.net\n#+HUGO_SECTION: ./posts\n#+HUGO_AUTO_SET_LASTMOD: t\n#+HUGO_TAGS: article\n#+HUGO_DRAFT: true\n")
:immediate-finish t
:unnarrowed t
)
("p" "person" plain
"%?"
:if-new (file+head "people/${slug}.org"
"#+TITLE: ${title}")
:immediate-finish t
:unnarrowed t
)
)
)
(setq org-roam-dailies-capture-templates
'(
("d" "daily" plain
""
:target ("file+heaed %<%Y-%m-%d>.org" "#+title: %<%Y-%m-%d>\n\n")
:immediate-finish t
)
)
)
(defun my/org-move-entry-to-daily-notes ()
"Move the current org-mode headline to the daily notes file based on its :CREATED: property."
(interactive)
(let*
(
(created-prop (org-entry-get nil "CREATED"))
(created-date (when created-prop
(org-parse-time-string created-prop)))
(year (nth 5 created-date)) ; Extract year (6th element)
(month (nth 4 created-date)) ; Extract month (5th element)
(day (nth 3 created-date)) ; Extract day (4th element)
(target-date (format "%04d-%02d-%02d" year month day)) ; Format date string
(target-file (org-roam-dailies-goto target-date))
)
(when target-file
(org-cut-subtree)
(find-file target-file)
(goto-char (point-max))
(unless (bolp) (newline))
(org-paste-subtree)
)
)
)

View File

@@ -1,42 +1,73 @@
#+TITLE: Emacs Org-roam Configuration
#+property: header-args :tangle ~/.emacs.d/modules/roam.el
#+TITLE: Org-Roam Configuration
#+PROPERTY: header-args :tangle yes
* Org-roam
** Basic org-roam setup
* org-roam Setup
#+begin_src elisp
(use-package org-roam
:init (setq org-roam-v2-ack t)
:after org
:config
(org-roam-db-autosync-enable)
(require 'org-roam-dailies)
(setq org-roam-mode-sections
(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 g" . org-roam-graph)
("C-c n r" . org-roam-node-random)
("C-c n h" . org-roam-node-convert-headline)
("C-c n i" . org-roam-node-insert)
("C-c n o" . org-id-get-create)
("C-c n t" . org-roam-tag-add)
("C-c n a" . org-roam-alias-add)
("C-c n l" . org-roam-buffer-display-dedicated)
)
)
(use-package org-roam
:init (setq org-roam-v2-ack t) ;; Acknowledge V2 upgrade
:after org
:config
(org-roam-db-autosync-enable)
(require 'org-roam-dailies)
:bind (
("C-c n f" . org-roam-node-find)
("C-c n g" . org-roam-graph)
("C-c n r" . org-roam-node-random)
("C-c n h" . org-roam-node-convert-headline)
("C-c n i" . org-roam-node-insert)
("C-c n o" . org-id-get-create)
("C-c n t" . org-roam-tag-add)
("C-c n a" . org-roam-alias-add)
("C-c n l" . org-roam-buffer-display-dedicated)
)
)
#+end_src
* Directories
#+begin_src elisp
(setq org-roam-directory (concat org-directory "/1_thinking"))
(setq org-roam-dailies-directory (concat org-directory "/0_inbox/daily"))
(setq org-roam-directory (expand-file-name (concat org-directory "notes")))
(setq org-roam-dailies-directory (expand-file-name (concat org-directory "daily")))
#+end_src
#+begin_src elisp :tangle yes
(use-package sqlite3)
(require 'sqlite3)
#+end_src
Include subdirectories in org-roam
#+begin_src elisp
(setq org-roam-file-exclude-regexp "^[.][.]?/")
#+end_src
* Capture Templates
** Display in org-roam-buffer
#+begin_src elisp :tangle yes
(setq org-roam-mode-sections
(list #'org-roam-backlinks-section
#'org-roam-reflinks-section
#'org-roam-unlinked-references-section
)
)
#+end_src
** Filter org-roam nodes find by tag
#+begin_src elisp :tangle yes
(defun my/org-roam-node-has-tag (node tag)
"Filter function to check if the given NODE has the specified TAG."
(member tag (org-roam-node-tags node))
)
(defun my/org-roam-node-find-by-tag ()
"Find and open an Org-roam node based on a specified tag."
(interactive)
(let ((tag (read-string "Enter tag: ")))
(org-roam-node-find nil nil (lambda (node) (my/org-roam-node-has-tag node tag))))
)
#+end_src
** org-roam-capture templates
#+begin_src elisp
(setq org-roam-capture-templates
'(
@@ -48,6 +79,7 @@
:immediate-finish t
:unnarrowed t
)
("h" "hugo post" plain
"%?"
:target (file+head "posts/${slug}.org"
@@ -55,6 +87,7 @@
:immediate-finish t
:unnarrowed t
)
("p" "person" plain
"%?"
:if-new (file+head "people/${slug}.org"
@@ -64,7 +97,9 @@
)
)
)
#+end_src
#+begin_src elisp
(setq org-roam-dailies-capture-templates
'(
("d" "daily" plain
@@ -75,3 +110,31 @@
)
)
#+end_src
** Move org header to org-roam-daily
#+begin_src elisp :tangle yes
(defun my/org-move-entry-to-daily-notes ()
"Move the current org-mode headline to the daily notes file based on its :CREATED: property."
(interactive)
(let*
(
(created-prop (org-entry-get nil "CREATED"))
(created-date (when created-prop
(org-parse-time-string created-prop)))
(year (nth 5 created-date)) ; Extract year (6th element)
(month (nth 4 created-date)) ; Extract month (5th element)
(day (nth 3 created-date)) ; Extract day (4th element)
(target-date (format "%04d-%02d-%02d" year month day)) ; Format date string
(target-file (org-roam-dailies-goto target-date))
)
(when target-file
(org-cut-subtree)
(find-file target-file)
(goto-char (point-max))
(unless (bolp) (newline))
(org-paste-subtree)
)
)
)
#+end_src

View File

@@ -0,0 +1,48 @@
(use-package bash-completion
:config
(require 'bash-completion)
(bash-completion-setup)
)
(defvar shell-dynamic-complete-functions t)
(require 'bash-completion)
(add-hook 'eshell-mode-hook
(lambda ()
(add-hook 'completion-at-point-functions
'bash-completion-capf-nonexclusive nil t
)
)
)
(use-package xterm-color
:commands (xterm-color-filter)
)
(use-package eshell
:after xterm-color
:config
(define-key eshell-hist-mode-map (kbd "M-r") #'consult-history)
(add-hook 'eshell-mode-hook
(lambda ()
(setenv "TERM" "xterm-256color")))
(add-hook 'eshell-before-prompt-hook (setq xterm-color-preserve-properties t))
(add-to-list 'eshell-preoutput-filter-functions 'xterm-color-filter)
(setq eshell-output-filter-functions
(remove 'eshell-handle-ansi-color eshell-output-filter-functions)
)
)
(add-hook 'eshell-mode-hook
(lambda ()
(add-hook 'completion-at-point-functions
'bash-completion-capf-nonexclusive nil t)))
(use-package eat
:config
;; For `eat-eshell-mode'.
(add-hook 'eshell-load-hook #'eat-eshell-mode)
;; For `eat-eshell-visual-command-mode'.
(add-hook 'eshell-load-hook #'eat-eshell-visual-command-mode)
)

View File

@@ -1,18 +1,86 @@
#+TITLE: Emacs Shell Configuration
#+property: header-args :tangle ~/.emacs.d/modules/shell.el
#+TITLE: Shell Configuration
#+PROPERTY: header-args :tangle yes
* Shell
** Bash completion
* Bash Completion
#+begin_src elisp
(use-package bash-completion
:config
(require 'bash-completion)
(bash-completion-setup)
)
(defvar shell-dynamic-complete-functions t)
#+end_src
* Frame Management
#+begin_src elisp
(add-hook 'server-done-hook (lambda () (delete-frame)))
(defvar shell-dynamic-complete-functions t)
#+end_src
** Eshell
Add programmable bash completion to Emacs shell-mode
#+begin_src elisp :tangle yes
(require 'bash-completion)
(add-hook 'eshell-mode-hook
(lambda ()
(add-hook 'completion-at-point-functions
'bash-completion-capf-nonexclusive nil t
)
)
)
#+end_src
Use colors in eshell
#+begin_src elisp :tangle yes
(use-package xterm-color
:commands (xterm-color-filter)
)
(use-package eshell
:after xterm-color
:config
(define-key eshell-hist-mode-map (kbd "M-r") #'consult-history)
(add-hook 'eshell-mode-hook
(lambda ()
(setenv "TERM" "xterm-256color")))
(add-hook 'eshell-before-prompt-hook (setq xterm-color-preserve-properties t))
(add-to-list 'eshell-preoutput-filter-functions 'xterm-color-filter)
(setq eshell-output-filter-functions
(remove 'eshell-handle-ansi-color eshell-output-filter-functions)
)
)
#+end_src
Eshell completion
#+begin_src elisp :tangle yes
(add-hook 'eshell-mode-hook
(lambda ()
(add-hook 'completion-at-point-functions
'bash-completion-capf-nonexclusive nil t)))
#+end_src
Emulate A Terminal (EAT)
#+begin_src elisp :tangle yes
(use-package eat
:config
;; For `eat-eshell-mode'.
(add-hook 'eshell-load-hook #'eat-eshell-mode)
;; For `eat-eshell-visual-command-mode'.
(add-hook 'eshell-load-hook #'eat-eshell-visual-command-mode)
)
#+end_src
* Server Actuation (Bash Integration)
Ensure that emacsclient always opens in a GUI frame by default when called from the shell.
#+begin_src bash :tangle ~/.bash_aliases
# Use emacsclient to open files in the GUI, starting daemon if needed
alias em="emacsclient -c -a ''"
# Set emacsclient as the default editor
export EDITOR="emacsclient -c -a ''"
export VISUAL="emacsclient -c -a ''"
#+end_src

View File

@@ -0,0 +1,16 @@
(when (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(when (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(when (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(setq inhibit-startup-screen t)
(setq initial-scratch-message nil)
(set-face-attribute 'default nil :family "sans-serif" :height 120)
(set-face-attribute 'variable-pitch nil :family "sans-serif")
(use-package org-modern
:ensure t
:config
(set-face-attribute 'org-modern-symbol nil :family "Iosevka")
(global-org-modern-mode)
)

View File

@@ -1,59 +1,32 @@
#+TITLE: Emacs UI Configuration
#+property: header-args :tangle ~/.emacs.d/modules/ui.el
#+PROPERTY: header-args :tangle yes
* Appearance
Basic UI settings for a cleaner look.
#+begin_src elisp
(defvar org-pretty-entities t) ; Improve org mode looks
(defvar org-hide-emphasis-markers t) ; Hide emphasis markup
(defvar org-num-mode nil)
(defvar org-startup-folded 'shw2levels)
(defvar org-startup-indented t) ; Indent org heirarchy
(defvar org-adapt-indentation t)
(defvar org-hide-leading-stars t) ; Minimal Outline
(defvar org-odd-levels-only nil)
(when (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(when (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(when (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(setq inhibit-startup-screen t)
(setq initial-scratch-message nil)
#+end_src
* Org-modern
* Fonts
#+begin_src elisp
(set-face-attribute 'default nil :family "sans-serif" :height 120)
(set-face-attribute 'variable-pitch nil :family "sans-serif")
#+end_src
* Org-modern (UI elements)
#+begin_src elisp
(use-package org-modern
:ensure t
:config
;; Choose some fonts
(set-face-attribute 'default nil :family "sans-serif")
(set-face-attribute 'variable-pitch nil :family "sans-serif")
(set-face-attribute 'org-modern-symbol nil :family "Iosevka")
;; Edit settings
(defvar org-auto-align-tags nil)
(defvar org-tags-column 0)
(defvar org-catch-invisible-edits 'show-and-error)
(defvar org-special-ctrl-a/e t)
(defvar org-insert-heading-respect-content t)
;; Org styling, hide markup etc.
(defvar org-hide-emphasis-markers t)
(defvar org-pretty-entities t)
;; Agenda styling
(defvar org-agenda-tags-column 0)
(defvar org-agenda-block-separator ?─)
(defvar org-agenda-time-grid
'((daily today require-timed)
(800 1000 1200 1400 1600 1800 2000)
" ┄┄┄┄┄ " "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄"))
(defvar org-agenda-current-time-string
"◀── now ─────────────────────────────────────────────────")
;; Ellipsis styling
(defvar org-ellipsis "")
(set-face-attribute 'org-ellipsis nil :inherit 'default :box nil)
(global-org-modern-mode)
(global-org-modern-mode)
)
#+end_src
* Syntax Highlighting
#+begin_src elisp
(setq org-src-fontify-natively t)
(setq org-src-tab-acts-natively t)
#+end_src

View File

@@ -0,0 +1,3 @@
sudo apt install hunspell
sudo apt install devscripts

View File

@@ -0,0 +1,153 @@
(defun my/dcaps-to-scaps ()
"Convert word in DOuble CApitals to Single Capitals."
(interactive)
(and (= ?w (char-syntax (char-before)))
(save-excursion
(and (if (called-interactively-p)
(skip-syntax-backward "w")
(= -3 (skip-syntax-backward "w"))
)
(let (case-fold-search)
(looking-at "\\b[[:upper:]]\\{2\\}[[:lower:]]")
)
(capitalize-word 1)
)
)
)
)
(define-minor-mode my-dubcaps-mode
"Toggle 'my-dubcaps-mode' and convert words in DOuble CApitals to Single Capitals as you type."
:init-value nil
:lighter (" DC")
(if my-dubcaps-mode
(add-hook 'post-self-insert-hook #'my/dcaps-to-scaps nil 'local)
(remove-hook 'post-self-insert-hook #'my/dcaps-to-scaps 'local)))
(add-hook 'text-mode-hook #'my-dubcaps-mode)
(defun my/diminish-dubcaps ()
(interactive)
(diminish 'my-dubcaps-mode ""))
(add-hook 'my-dubcaps-mode-hook 'my/diminish-dubcaps)
(subword-mode)
(setq sentence-end-double-space nil)
(defun my/fill-or-unfill-paragraph (&optional unfill region)
"Fill paragraph (or REGION). With the prefix argument UNFILL, fill it instead."
(interactive (progn
(barf-if-buffer-read-only)
(list (if current-prefix-arg 'fill) t)))
(let ((fill-column (if unfill fill-column (point-max))))
(fill-paragraph nil region)))
(bind-key "M-q" 'my/fill-or-unfill-paragraph)
(defun my/fill-or-unfill-all-paragraphs (&optional unfill)
"Fill or unfill all paragraphs in the current buffer.
With the prefix argument UNFILL, fill them instead."
(interactive (list (if current-prefix-arg 'fill)))
(let ((fill-column (if unfill fill-column (point-max))))
(save-excursion
(goto-char (point-min))
(while (not (eobp))
(fill-paragraph nil t)
(forward-paragraph)))))
(bind-key "M-Q" 'my/fill-or-unfill-all-paragraphs)
(remove-hook 'text-mode-hook #'turn-on-auto-fill)
(add-hook 'text-mode-hook 'turn-on-visual-line-mode)
(setq save-abbrevs 'silently)
(setq-default abbrev-mode t)
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
(setq ediff-split-window-function 'split-window-horizontally)
(setq tramp-default-method "ssh"
tramp-backup-directory-alist backup-directory-alist
tramp-ssh-controlmaster-options "ssh")
(bind-key "M-SPC" 'cycle-spacing)
(defun my/transform-html-links-to-org ()
"Transform all HTML <a> links in the current buffer into 'org-mode' links."
(interactive)
(goto-char (point-min))
(while (re-search-forward "<a href=\"\\(.*?\\)\">\\(.*?\\)</a>" nil t)
(replace-match (org-make-link-string (match-string 1) (match-string 2)))))
(require 'org-clock)
(defun my/org-entry-wpm ()
(interactive)
(save-restriction
(save-excursion
(org-narrow-to-subtree)
(goto-char (point-min))
(let* ((words (count-words-region (point-min) (point-max)))
(minutes (org-clock-sum-current-item))
(wpm (/ words minutes)))
(message "WPM: %d (words: %d, minutes: %d)" wpm words minutes)
(kill-new (number-to-string wpm))
)
)
)
)
(setq dictionary-server "automatic")
(use-package writegood-mode
:diminish writegood-mode
:config
(progn (add-hook 'text-mode-hook 'writegood-mode))
)
(use-package ob-docker-build
:straight (ob-docker-build :type git :host github :repo "ifitzpat/ob-docker-build")
:defer t
:config
(add-to-list 'org-babel-load-languages '(docker-build . t))
(org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages)
)
(use-package flyspell
:config (setq ispell-program-name "hunspell"
ispell-default-dictionary "en_US"
)
:diminish (flyspell-mode . "φ")
:hook (text-mode . flyspell-mode)
:bind (
("M-<f7>" . flyspell-buffer)
("<f7>" . flyspell-word)
("C-;" . flyspell-auto-correct-previous-word)
)
)
(use-package flyspell-correct
:after flyspell
:bind (:map flyspell-mode-map ("C-;" . flyspell-correct-wrapper))
)
(use-package flycheck
:defer t
:diminish (flycheck-mode . "")
:config
(setq flycheck-emacs-lisp-load-path 'inherit)
(setq flycheck-emacs-lisp-load-path (concat user-emacs-directory "straight/build")))
(use-package flycheck-checkbashisms
:config
(flycheck-checkbashisms-setup)
)
(use-package yaml-mode
:config
(add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode))
(add-to-list 'auto-mode-alist '("\\.yaml\\'" . yaml-mode))
)
(use-package docker-compose-mode)

View File

@@ -1,7 +1,195 @@
#+TITLE: Emacs Writing Configuration
#+property: header-args :tangle ~/.emacs.d/modules/writing.el
#+TITLE: Reading and Writing Configuration
#+PROPERTY: header-args :tangle yes
* Text and Case
** Convert DOuble capitals to single capitals
#+begin_src elisp :tangle yes
(defun my/dcaps-to-scaps ()
"Convert word in DOuble CApitals to Single Capitals."
(interactive)
(and (= ?w (char-syntax (char-before)))
(save-excursion
(and (if (called-interactively-p)
(skip-syntax-backward "w")
(= -3 (skip-syntax-backward "w"))
)
(let (case-fold-search)
(looking-at "\\b[[:upper:]]\\{2\\}[[:lower:]]")
)
(capitalize-word 1)
)
)
)
)
#+end_src
Then, lets define a minor mode for it to be activated.
#+begin_src elisp :tangle yes
(define-minor-mode my-dubcaps-mode
"Toggle 'my-dubcaps-mode' and convert words in DOuble CApitals to Single Capitals as you type."
:init-value nil
:lighter (" DC")
(if my-dubcaps-mode
(add-hook 'post-self-insert-hook #'my/dcaps-to-scaps nil 'local)
(remove-hook 'post-self-insert-hook #'my/dcaps-to-scaps 'local)))
#+end_src
Finally, lets add a hook so that it is on for all the text files Emacs opens.
#+begin_src elisp :tangle yes
(add-hook 'text-mode-hook #'my-dubcaps-mode)
#+end_src
Also, since we add a minor mode string (it might be useful sometimes), currently I prefer to diminish it.
#+begin_src elisp :tangle yes
(defun my/diminish-dubcaps ()
(interactive)
(diminish 'my-dubcaps-mode ""))
(add-hook 'my-dubcaps-mode-hook 'my/diminish-dubcaps)
#+end_src
* Reading and Writing
** Move correctly over camelCased words
#+begin_src elisp
(subword-mode)
#+end_src
** Understand the more common sentence with double space
#+begin_src elisp
(setq sentence-end-double-space nil)
#+end_src
** Join lines into paragraph
#+begin_src elisp
(defun my/fill-or-unfill-paragraph (&optional unfill region)
"Fill paragraph (or REGION). With the prefix argument UNFILL, fill it instead."
(interactive (progn
(barf-if-buffer-read-only)
(list (if current-prefix-arg 'fill) t)))
(let ((fill-column (if unfill fill-column (point-max))))
(fill-paragraph nil region)))
(bind-key "M-q" 'my/fill-or-unfill-paragraph)
#+end_src
#+begin_src elisp
(defun my/fill-or-unfill-all-paragraphs (&optional unfill)
"Fill or unfill all paragraphs in the current buffer.
With the prefix argument UNFILL, fill them instead."
(interactive (list (if current-prefix-arg 'fill)))
(let ((fill-column (if unfill fill-column (point-max))))
(save-excursion
(goto-char (point-min))
(while (not (eobp))
(fill-paragraph nil t)
(forward-paragraph)))))
(bind-key "M-Q" 'my/fill-or-unfill-all-paragraphs)
#+end_src
#+begin_src elisp
(remove-hook 'text-mode-hook #'turn-on-auto-fill)
(add-hook 'text-mode-hook 'turn-on-visual-line-mode)
#+end_src
** Expand some words with auto-correct
#+begin_src elisp :tangle yes
(setq save-abbrevs 'silently)
(setq-default abbrev-mode t)
#+end_src
** ediff
#+begin_src elisp :tangle yes
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
(setq ediff-split-window-function 'split-window-horizontally)
#+end_src
** tramp
#+begin_src elisp :tangle yes
(setq tramp-default-method "ssh"
tramp-backup-directory-alist backup-directory-alist
tramp-ssh-controlmaster-options "ssh")
#+end_src
** Clean up space
#+begin_src elisp :tangle yes
(bind-key "M-SPC" 'cycle-spacing)
#+end_src
** Transform <a href> links into org links
#+begin_src elisp :tangle yes
(defun my/transform-html-links-to-org ()
"Transform all HTML <a> links in the current buffer into 'org-mode' links."
(interactive)
(goto-char (point-min))
(while (re-search-forward "<a href=\"\\(.*?\\)\">\\(.*?\\)</a>" nil t)
(replace-match (org-make-link-string (match-string 1) (match-string 2)))))
#+end_src
** Count words per minute
#+begin_src elisp :tangle yes
(require 'org-clock)
(defun my/org-entry-wpm ()
(interactive)
(save-restriction
(save-excursion
(org-narrow-to-subtree)
(goto-char (point-min))
(let* ((words (count-words-region (point-min) (point-max)))
(minutes (org-clock-sum-current-item))
(wpm (/ words minutes)))
(message "WPM: %d (words: %d, minutes: %d)" wpm words minutes)
(kill-new (number-to-string wpm))
)
)
)
)
#+end_src
** Enable dict mode
#+begin_src elisp :tangle yes
(setq dictionary-server "automatic")
#+end_src
** Pick out passive voice and weasel words
#+begin_src elisp :tangle yes
(use-package writegood-mode
:diminish writegood-mode
:config
(progn (add-hook 'text-mode-hook 'writegood-mode))
)
#+end_src
** Org-babel docker
#+begin_src elisp :tangle yes
(use-package ob-docker-build
:straight (ob-docker-build :type git :host github :repo "ifitzpat/ob-docker-build")
:defer t
:config
(add-to-list 'org-babel-load-languages '(docker-build . t))
(org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages)
)
#+end_src
* Spelling and syntax
** Spell checking
This requires installation of hunspell
#+begin_src bash :tangle yes
sudo apt install hunspell
#+end_src
* Spell Checking
#+begin_src elisp
(use-package flyspell
:config (setq ispell-program-name "hunspell"
@@ -17,32 +205,50 @@
)
#+end_src
* Syntax Checking
** Flyspell correct
#+begin_src elisp :tangle yes
(use-package flyspell-correct
:after flyspell
:bind (:map flyspell-mode-map ("C-;" . flyspell-correct-wrapper))
)
#+end_src
** Flycheck
Needs external checkers installed
#+begin_src elisp
(use-package flycheck
:init (global-flycheck-mode)
:defer t
:diminish (flycheck-mode . "")
:config
(add-hook 'after-init-hook #'global-flycheck-mode)
(setq flycheck-emacs-lisp-load-path 'inherit)
(setq flycheck-emacs-lisp-load-path (concat user-emacs-directory "straight/build"))
(setq flycheck-emacs-lisp-load-path (concat user-emacs-directory "straight/build")))
#+end_src
** Flycheck bash
#+begin_src bash :tangle yes
sudo apt install devscripts
#+end_src
#+begin_src elisp :tangle yes
(use-package flycheck-checkbashisms
:config
(flycheck-checkbashisms-setup)
)
#+end_src
** Yaml
#+begin_src elisp :tangle yes
(use-package yaml-mode
:config
(add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode))
(add-to-list 'auto-mode-alist '("\\.yaml\\'" . yaml-mode))
)
#+end_src
* Text Manipulation
#+begin_src elisp
(subword-mode)
(setq sentence-end-double-space nil)
(defun my/fill-or-unfill-paragraph (&optional unfill region)
"Fill paragraph (or REGION). With the prefix argument UNFILL, fill it instead."
(interactive (progn
(barf-if-buffer-read-only)
(list (if current-prefix-arg 'fill) t)))
(let ((fill-column (if unfill fill-column (point-max))))
(fill-paragraph nil region)))
(bind-key "M-q" 'my/fill-or-unfill-paragraph)
(add-hook 'text-mode-hook 'turn-on-visual-line-mode)
#+end_src
** Docker
#+begin_src elisp :tangle yes
(use-package docker-compose-mode)
#+end_src