- 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
6.7 KiB
6.7 KiB
Reading and Writing Configuration
- Text and Case
- Reading and Writing
- Move correctly over camelCased words
- Understand the more common sentence with double space
- Join lines into paragraph
- Expand some words with auto-correct
- ediff
- tramp
- Clean up space
- Transform <a href> links into org links
- Count words per minute
- Enable dict mode
- Pick out passive voice and weasel words
- Org-babel docker
- Spelling and syntax
Text and Case
Convert DOuble capitals to single capitals
(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)
)
)
)
)
Then, let’s define a minor mode for it to be activated.
(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)))
Finally, let’s add a hook so that it is on for all the text files Emacs opens.
(add-hook 'text-mode-hook #'my-dubcaps-mode)
Also, since we add a minor mode string (it might be useful sometimes), currently I prefer to diminish it.
(defun my/diminish-dubcaps ()
(interactive)
(diminish 'my-dubcaps-mode ""))
(add-hook 'my-dubcaps-mode-hook 'my/diminish-dubcaps)
Reading and Writing
Move correctly over camelCased words
(subword-mode)
Understand the more common sentence with double space
(setq sentence-end-double-space nil)
Join lines into paragraph
(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)
Expand some words with auto-correct
(setq save-abbrevs 'silently)
(setq-default abbrev-mode t)
ediff
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
(setq ediff-split-window-function 'split-window-horizontally)
tramp
(setq tramp-default-method "ssh"
tramp-backup-directory-alist backup-directory-alist
tramp-ssh-controlmaster-options "ssh")
Clean up space
(bind-key "M-SPC" 'cycle-spacing)
Transform <a href> links into org links
(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)))))
Count words per minute
(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))
)
)
)
)
Enable dict mode
(setq dictionary-server "automatic")
Pick out passive voice and weasel words
(use-package writegood-mode
:diminish writegood-mode
:config
(progn (add-hook 'text-mode-hook 'writegood-mode))
)
Org-babel docker
(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)
)
Spelling and syntax
Spell checking
This requires installation of hunspell
sudo apt install hunspell
(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)
)
)
Flyspell correct
(use-package flyspell-correct
:after flyspell
:bind (:map flyspell-mode-map ("C-;" . flyspell-correct-wrapper))
)
Flycheck
Needs external checkers installed
(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")))
Flycheck bash
sudo apt install devscripts
(use-package flycheck-checkbashisms
:config
(flycheck-checkbashisms-setup)
)
Yaml
(use-package yaml-mode
:config
(add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode))
(add-to-list 'auto-mode-alist '("\\.yaml\\'" . yaml-mode))
)
Docker
(use-package docker-compose-mode)