Cleanup some TODOs in config

Move crafted config out of main config to actually encourage me to
sort through and take what I want to keep from it
This commit is contained in:
Evie Litherland-Smith 2024-02-15 05:52:46 +00:00
parent 18a0a07098
commit 77833632c3
2 changed files with 176 additions and 173 deletions

View file

@ -320,7 +320,7 @@ Loading this file is handled automatically on my [[https://git.xenia.me.uk/xenia
(keymap-global-set "C-c i n" #'nerd-icons-insert) (keymap-global-set "C-c i n" #'nerd-icons-insert)
#+end_src #+end_src
*** TODO Font ligatures *** Font ligatures
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package ligature (use-package ligature
:ensure t :ensure t
@ -647,26 +647,6 @@ For reference information, see [[https://orgmode.com][Org-mode website]]
(setq org-preview-latex-default-process 'dvisvgm) (setq org-preview-latex-default-process 'dvisvgm)
#+end_src #+end_src
** TODO Crafted config
#+begin_src emacs-lisp
;; Disable auto-pairing of "<" in org-mode with electric-pair-mode
(defun crafted-org-enhance-electric-pair-inhibit-predicate ()
"Disable auto-pairing of \"<\" in `org-mode' when using `electric-pair-mode'."
(when (and electric-pair-mode (eql major-mode #'org-mode))
(setq-local electric-pair-inhibit-predicate
`(lambda (c)
(if (char-equal c ?<)
t
(,electric-pair-inhibit-predicate c))))))
;; Add hook to both electric-pair-mode-hook and org-mode-hook
;; This ensures org-mode buffers don't behave weirdly,
;; no matter when electric-pair-mode is activated.
(add-hook 'electric-pair-mode-hook #'crafted-org-enhance-electric-pair-inhibit-predicate)
(add-hook 'org-mode-hook #'crafted-org-enhance-electric-pair-inhibit-predicate)
#+end_src
* Password Store * Password Store
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package password-store (use-package password-store
@ -1126,12 +1106,13 @@ Set fill column to 88 and enable display in python buffers
* Internet * Internet
** TODO Gnus ** Gnus
#+begin_src emacs-lisp :tangle yes #+begin_src emacs-lisp :tangle yes
(use-package gnus (use-package gnus
:config :config
(setq gnus-select-method '(nnnil))) (setq gnus-select-method '(nnnil)))
#+end_src #+end_src
** Email ** Email
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq sendmail-program (executable-find "msmtp") (setq sendmail-program (executable-find "msmtp")
@ -1488,154 +1469,3 @@ Set fill column to 88 and enable display in python buffers
(doc-view-scale-internally t) (doc-view-scale-internally t)
(doc-view-image-width 850)) (doc-view-image-width 850))
#+end_src #+end_src
** TODO Crafted Config
#+begin_src emacs-lisp
;;; Whitespace
(defun crafted-writing-configure-whitespace (use-tabs &optional use-globally &rest enabled-modes)
"Helper function to configure `whitespace' mode.
Enable using TAB characters if USE-TABS is non-nil. If
USE-GLOBALLY is non-nil, turn on `global-whitespace-mode'. If
ENABLED-MODES is non-nil, it will be a list of modes to activate
whitespace mode using hooks. The hooks will be the name of the
mode in the list with `-hook' appended. If USE-GLOBALLY is
non-nil, ENABLED-MODES is ignored.
Configuring whitespace mode is not buffer local. So calling this
function twice with different settings will not do what you
think. For example, if you wanted to use spaces instead of tabs
globally except for in Makefiles, doing the following won't work:
;; turns on global-whitespace-mode to use spaces instead of tabs
(crafted-writing-configure-whitespace nil t)
;; overwrites the above to turn to use tabs instead of spaces,
;; does not turn off global-whitespace-mode, adds a hook to
;; makefile-mode-hook
(crafted-writing-configure-whitespace t nil 'makefile-mode)
Instead, use a configuration like this:
;; turns on global-whitespace-mode to use spaces instead of tabs
(crafted-writing-configure-whitespace nil t)
;; turn on the buffer-local mode for using tabs instead of spaces.
(add-hook 'makefile-mode-hook #'indent-tabs-mode)
For more information on `indent-tabs-mode', See the info
node `(emacs)Just Spaces'
Example usage:
;; Configuring whitespace mode does not turn on whitespace mode
;; since we don't know which modes to turn it on for.
;; You will need to do that in your configuration by adding
;; whitespace mode to the appropriate mode hooks.
(crafted-writing-configure-whitespace nil)
;; Configure whitespace mode, but turn it on globally.
(crafted-writing-configure-whitespace nil t)
;; Configure whitespace mode and turn it on only for prog-mode
;; and derived modes.
(crafted-writing-configure-whitespace nil nil 'prog-mode)"
(if use-tabs
(customize-set-variable 'whitespace-style
'(face empty trailing indentation::tab
space-after-tab::tab
space-before-tab::tab))
;; use spaces instead of tabs
(customize-set-variable 'whitespace-style
'(face empty trailing tab-mark
indentation::space)))
(if use-globally
(global-whitespace-mode 1)
(when enabled-modes
(dolist (mode enabled-modes)
(add-hook (intern (format "%s-hook" mode)) #'whitespace-mode))))
;; cleanup whitespace
(customize-set-variable 'whitespace-action '(cleanup auto-cleanup)))
;;; parentheses
(electric-pair-mode 1) ; auto-insert matching bracket
(show-paren-mode 1) ; turn on paren match highlighting
;;; LaTeX configuration
(with-eval-after-load 'latex
(customize-set-variable 'TeX-auto-save t)
(customize-set-variable 'TeX-parse-self t)
(setq-default TeX-master nil)
;; compile to pdf
(tex-pdf-mode)
;; correlate the source and the output
(TeX-source-correlate-mode)
;; set a correct indentation in a few additional environments
(add-to-list 'LaTeX-indent-environment-list '("lstlisting" current-indentation))
(add-to-list 'LaTeX-indent-environment-list '("tikzcd" LaTeX-indent-tabular))
(add-to-list 'LaTeX-indent-environment-list '("tikzpicture" current-indentation))
;; add a few macros and environment as verbatim
(add-to-list 'LaTeX-verbatim-environments "lstlisting")
(add-to-list 'LaTeX-verbatim-environments "Verbatim")
(add-to-list 'LaTeX-verbatim-macros-with-braces "lstinline")
(add-to-list 'LaTeX-verbatim-macros-with-delims "lstinline")
;; electric pairs in auctex
(customize-set-variable 'TeX-electric-sub-and-superscript t)
(customize-set-variable 'LaTeX-electric-left-right-brace t)
(customize-set-variable 'TeX-electric-math (cons "$" "$"))
;; open all buffers with the math mode and auto-fill mode
(add-hook 'LaTeX-mode-hook #'auto-fill-mode)
(add-hook 'LaTeX-mode-hook #'LaTeX-math-mode)
;; add support for references
(add-hook 'LaTeX-mode-hook #'turn-on-reftex)
(customize-set-variable 'reftex-plug-into-AUCTeX t)
;; to have the buffer refresh after compilation
(add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer))
;; message the user if the latex executable is not found
(defun crafted-writing-tex-warning-if-no-latex-executable ()
"Print a message to the minibuffer if the \"latex\" executable cannot be found."
(unless (executable-find "latex")
(message "latex executable not found")))
(add-hook 'tex-mode-hook #'crafted-writing-tex-warning-if-no-latex-executable)
(when (and (executable-find "latex")
(executable-find "latexmk"))
(with-eval-after-load 'latex
(when (require 'auctex-latexmk nil 'noerror)
(with-eval-after-load 'auctex-latexmk
(auctex-latexmk-setup)
(customize-set-variable 'auctex-latexmk-inherit-TeX-PDF-mode t))
(defun crafted-writing-tex-make-latexmk-default-command ()
"Set `TeX-command-default' to \"LatexMk\"."
(setq TeX-command-default "LatexMk"))
(add-hook 'TeX-mode-hook #'crafted-writing-tex-make-latexmk-default-command))))
;;; Markdown
(when (fboundp 'markdown-mode)
;; because the markdown-command variable may not be loaded (yet),
;; check manually for the other markdown processors. If it is
;; loaded, the others are superfluous but `or' fails fast, so they
;; are not checked if `markdown-command' is set and the command is
;; indeed found.
(unless (or (and (boundp 'markdown-command)
(executable-find markdown-command))
(executable-find "markdown")
(executable-find "pandoc"))
(message "No markdown processor found, preview may not possible."))
(with-eval-after-load 'markdown-mode
(customize-set-variable 'markdown-enable-math t)
(customize-set-variable 'markdown-enable-html t)
(add-hook 'markdown-mode-hook #'conditionally-turn-on-pandoc)))
#+end_src

173
crafted_config.el Normal file
View file

@ -0,0 +1,173 @@
;;; crafted-config -- Old crafted-emacs config to sort
;;; Commentary:
;;; Code:
;; Disable auto-pairing of "<" in org-mode with electric-pair-mode
(defun crafted-org-enhance-electric-pair-inhibit-predicate ()
"Disable auto-pairing of \"<\" in `org-mode' when using `electric-pair-mode'."
(when (and electric-pair-mode (eql major-mode #'org-mode))
(setq-local electric-pair-inhibit-predicate
`(lambda (c)
(if (char-equal c ?<)
t
(,electric-pair-inhibit-predicate c))))))
;; Add hook to both electric-pair-mode-hook and org-mode-hook
;; This ensures org-mode buffers don't behave weirdly,
;; no matter when electric-pair-mode is activated.
(add-hook 'electric-pair-mode-hook #'crafted-org-enhance-electric-pair-inhibit-predicate)
(add-hook 'org-mode-hook #'crafted-org-enhance-electric-pair-inhibit-predicate)
;;; Whitespace
(defun crafted-writing-configure-whitespace (use-tabs &optional use-globally &rest enabled-modes)
"Helper function to configure `whitespace' mode.
Enable using TAB characters if USE-TABS is non-nil. If
USE-GLOBALLY is non-nil, turn on `global-whitespace-mode'. If
ENABLED-MODES is non-nil, it will be a list of modes to activate
whitespace mode using hooks. The hooks will be the name of the
mode in the list with `-hook' appended. If USE-GLOBALLY is
non-nil, ENABLED-MODES is ignored.
Configuring whitespace mode is not buffer local. So calling this
function twice with different settings will not do what you
think. For example, if you wanted to use spaces instead of tabs
globally except for in Makefiles, doing the following won't work:
;; turns on `global-whitespace-mode' to use spaces instead of tabs
(crafted-writing-configure-whitespace nil t)
;; overwrites the above to turn to use tabs instead of spaces,
;; does not turn off `global-whitespace-mode', adds a hook to
;; makefile-mode-hook
(crafted-writing-configure-whitespace t nil 'makefile-mode)
Instead, use a configuration like this:
;; turns on `global-whitespace-mode' to use spaces instead of tabs
(crafted-writing-configure-whitespace nil t)
;; turn on the buffer-local mode for using tabs instead of spaces.
(add-hook 'makefile-mode-hook #'indent-tabs-mode)
For more information on `indent-tabs-mode', See the info
node `(emacs)Just Spaces'
Example usage:
;; Configuring whitespace mode does not turn on whitespace mode
;; since we don't know which modes to turn it on for.
;; You will need to do that in your configuration by adding
;; whitespace mode to the appropriate mode hooks.
(crafted-writing-configure-whitespace nil)
;; Configure whitespace mode, but turn it on globally.
(crafted-writing-configure-whitespace nil t)
;; Configure whitespace mode and turn it on only for `prog-mode'
;; and derived modes.
(crafted-writing-configure-whitespace nil nil 'prog-mode)"
(if use-tabs
(customize-set-variable 'whitespace-style
'(face empty trailing indentation::tab
space-after-tab::tab
space-before-tab::tab))
;; use spaces instead of tabs
(customize-set-variable 'whitespace-style
'(face empty trailing tab-mark
indentation::space)))
(if use-globally
(global-whitespace-mode 1)
(when enabled-modes
(dolist (mode enabled-modes)
(add-hook (intern (format "%s-hook" mode)) #'whitespace-mode))))
;; cleanup whitespace
(customize-set-variable 'whitespace-action '(cleanup auto-cleanup)))
;;; parentheses
(electric-pair-mode 1) ; auto-insert matching bracket
(show-paren-mode 1) ; turn on paren match highlighting
;;; LaTeX configuration
(with-eval-after-load 'latex
(customize-set-variable 'TeX-auto-save t)
(customize-set-variable 'TeX-parse-self t)
(setq-default TeX-master nil)
;; compile to pdf
(tex-pdf-mode)
;; correlate the source and the output
(TeX-source-correlate-mode)
;; set a correct indentation in a few additional environments
(add-to-list 'LaTeX-indent-environment-list '("lstlisting" current-indentation))
(add-to-list 'LaTeX-indent-environment-list '("tikzcd" LaTeX-indent-tabular))
(add-to-list 'LaTeX-indent-environment-list '("tikzpicture" current-indentation))
;; add a few macros and environment as verbatim
(add-to-list 'LaTeX-verbatim-environments "lstlisting")
(add-to-list 'LaTeX-verbatim-environments "Verbatim")
(add-to-list 'LaTeX-verbatim-macros-with-braces "lstinline")
(add-to-list 'LaTeX-verbatim-macros-with-delims "lstinline")
;; electric pairs in auctex
(customize-set-variable 'TeX-electric-sub-and-superscript t)
(customize-set-variable 'LaTeX-electric-left-right-brace t)
(customize-set-variable 'TeX-electric-math (cons "$" "$"))
;; open all buffers with the math mode and auto-fill mode
(add-hook 'LaTeX-mode-hook #'auto-fill-mode)
(add-hook 'LaTeX-mode-hook #'LaTeX-math-mode)
;; add support for references
(add-hook 'LaTeX-mode-hook #'turn-on-reftex)
(customize-set-variable 'reftex-plug-into-AUCTeX t)
;; to have the buffer refresh after compilation
(add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer))
;; message the user if the latex executable is not found
(defun crafted-writing-tex-warning-if-no-latex-executable ()
"Print a message to the minibuffer if the \"latex\" executable cannot be found."
(unless (executable-find "latex")
(message "latex executable not found")))
(add-hook 'tex-mode-hook #'crafted-writing-tex-warning-if-no-latex-executable)
(when (and (executable-find "latex")
(executable-find "latexmk"))
(with-eval-after-load 'latex
(when (require 'auctex-latexmk nil 'noerror)
(with-eval-after-load 'auctex-latexmk
(auctex-latexmk-setup)
(customize-set-variable 'auctex-latexmk-inherit-TeX-PDF-mode t))
(defun crafted-writing-tex-make-latexmk-default-command ()
"Set `TeX-command-default' to \"LatexMk\"."
(setq TeX-command-default "LatexMk"))
(add-hook 'TeX-mode-hook #'crafted-writing-tex-make-latexmk-default-command))))
;;; Markdown
(when (fboundp 'markdown-mode)
;; because the markdown-command variable may not be loaded (yet),
;; check manually for the other markdown processors. If it is
;; loaded, the others are superfluous but `or' fails fast, so they
;; are not checked if `markdown-command' is set and the command is
;; indeed found.
(unless (or (and (boundp 'markdown-command)
(executable-find markdown-command))
(executable-find "markdown")
(executable-find "pandoc"))
(message "No markdown processor found, preview may not possible."))
(with-eval-after-load 'markdown-mode
(customize-set-variable 'markdown-enable-math t)
(customize-set-variable 'markdown-enable-html t)
(add-hook 'markdown-mode-hook #'conditionally-turn-on-pandoc)))
(provide 'crafted_config)
;;; crafted_config.el ends here