From c64cd7ffd222e3a31d5abcf0ebdba9bd70ead3f7 Mon Sep 17 00:00:00 2001 From: Derek Taylor Date: Fri, 19 Sep 2025 11:40:08 -0500 Subject: [PATCH] Markdown headers and 'toggle' bindings. --- .config/doom/config.el | 132 ++++++++++++++-------------------------- .config/doom/config.org | 106 ++++++++++++++++++++++++++------ 2 files changed, 131 insertions(+), 107 deletions(-) diff --git a/.config/doom/config.el b/.config/doom/config.el index 9f24ae9..53af2e9 100644 --- a/.config/doom/config.el +++ b/.config/doom/config.el @@ -1,36 +1,47 @@ -;;; $DOOMDIR/config.el -*- lexical-binding: t; -*- - -;; Place your private configuration here! Remember, you do not need to run 'doom -;; sync' after modifying this file! - - -;; Some functionality uses this to identify you, e.g. GPG configuration, email -;; clients, file templates and snippets. It is optional. -;; (setq user-full-name "John Doe" -;; user-mail-address "john@doe.com") - -;; Doom exposes five (optional) variables for controlling fonts in Doom: -;; -;; - `doom-font' -- the primary font to use -;; - `doom-variable-pitch-font' -- a non-monospace font (where applicable) -;; - `doom-big-font' -- used for `doom-big-font-mode'; use this for -;; presentations or streaming. -;; - `doom-symbol-font' -- for symbols -;; - `doom-serif-font' -- for the `fixed-pitch-serif' face -;; -;; See 'C-h v doom-font' for documentation and more examples of what they -;; accept. For example: -;; -;;(setq doom-font (font-spec :family "Fira Code" :size 12 :weight 'semi-light) -;; doom-variable-pitch-font (font-spec :family "Fira Sans" :size 13)) -;; -;; If you or Emacs can't find your font, use 'M-x describe-font' to look them -;; up, `M-x eval-region' to execute elisp code, and 'M-x doom/reload-font' to -;; refresh your font settings. If Emacs still can't find your font, it likely -;; wasn't installed correctly. Font issues are rarely Doom issues! - +(setq doom-theme 'doom-one) (setq doom-font (font-spec :family "JetBrains Mono" :size 15)) +(map! :leader + :desc "Comment line" "-" #'comment-line) + +(map! :leader + (:prefix ("t" . "toggle") + :desc "Toggle line numbers" "l" #'doom/toggle-line-numbers + :desc "Toggle eshell split" "e" #'+eshell/toggle + :desc "Toggle line highlight in frame" "h" #'hl-line-mode + :desc "Toggle line highlight globally" "H" #'global-hl-line-mode + :desc "Toggle markdown-view-mode" "m" #'dt/toggle-markdown-view-mode + :desc "Toggle truncate lines" "t" #'toggle-truncate-lines + :desc "Toggle treemacs" "T" #'+treemacs/toggle + :desc "Toggle vterm split" "v" #'+vterm/toggle)) + +(setq display-line-numbers-type t) +(map! :leader + (:prefix ("T" . "toggle here") + :desc "Toggle eshell split" "e" #'+eshell/here + :desc "Toggle vterm split" "v" #'+vterm/here)) + +(custom-set-faces + '(markdown-header-face ((t (:inherit font-lock-function-name-face :weight bold :family "variable-pitch")))) + '(markdown-header-face-1 ((t (:inherit markdown-header-face :height 1.6)))) + '(markdown-header-face-2 ((t (:inherit markdown-header-face :height 1.5)))) + '(markdown-header-face-3 ((t (:inherit markdown-header-face :height 1.4)))) + '(markdown-header-face-4 ((t (:inherit markdown-header-face :height 1.3)))) + '(markdown-header-face-5 ((t (:inherit markdown-header-face :height 1.2)))) + '(markdown-header-face-6 ((t (:inherit markdown-header-face :height 1.1))))) + +(defun dt/toggle-markdown-view-mode () + "Toggle between `markdown-mode' and `markdown-view-mode'." + (interactive) + (if (eq major-mode 'markdown-view-mode) + (markdown-mode) + (markdown-view-mode))) + +(setq org-directory "~/nc/Org/") +(setq org-modern-table-vertical 1) +(setq org-modern-table t) +(add-hook 'org-mode-hook #'hl-todo-mode) + (custom-theme-set-faces! 'doom-one '(org-level-8 :inherit outline-3 :height 1.0) @@ -43,59 +54,6 @@ '(org-level-1 :inherit outline-1 :height 1.6) '(org-document-title :height 1.8 :bold t :underline nil)) -;; There are two ways to load a theme. Both assume the theme is installed and -;; available. You can either set `doom-theme' or manually load a theme with the -;; `load-theme' function. This is the default: -(setq doom-theme 'doom-one) - -;; This determines the style of line numbers in effect. If set to `nil', line -;; numbers are disabled. For relative line numbers, set this to `relative'. -(setq display-line-numbers-type t) - -(map! :leader - :desc "Comment line" "-" #'comment-line) - -;; If you use `org' and don't want your org files in the default location below, -;; change `org-directory'. It must be set before org loads! - -(setq org-directory "~/nc/Org/") -(setq org-modern-table-vertical 1) -(setq org-modern-table t) -(add-hook 'org-mode-hook #'hl-todo-mode) - - -;; Whenever you reconfigure a package, make sure to wrap your config in an -;; `after!' block, otherwise Doom's defaults may override your settings. E.g. -;; -;; (after! PACKAGE -;; (setq x y)) -;; -;; The exceptions to this rule: -;; -;; - Setting file/directory variables (like `org-directory') -;; - Setting variables which explicitly tell you to set them before their -;; package is loaded (see 'C-h v VARIABLE' to look up their documentation). -;; - Setting doom variables (which start with 'doom-' or '+'). -;; -;; Here are some additional functions/macros that will help you configure Doom. -;; -;; - `load!' for loading external *.el files relative to this one -;; - `use-package!' for configuring packages -;; - `after!' for running code after a package has loaded -;; - `add-load-path!' for adding directories to the `load-path', relative to -;; this file. Emacs searches the `load-path' when you load packages with -;; `require' or `use-package'. -;; - `map!' for binding new keys -;; -;; To get information about any of these functions/macros, move the cursor over -;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k'). -;; This will open documentation for it, including demos of how they are used. -;; Alternatively, use `C-h o' to look up a symbol (functions, variables, faces, -;; etc). -;; -;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how -;; they are implemented. - -(setq confirm-kill-emacs nil) - -(setq initial-buffer-choice 'eshell) +(setq display-line-numbers-type t) ;; Turn line numbers on +(setq confirm-kill-emacs nil) ;; Don't confirm on exit +(setq initial-buffer-choice 'eshell) ;; Eshell is initial buffer diff --git a/.config/doom/config.org b/.config/doom/config.org index f4923c2..01a45f4 100644 --- a/.config/doom/config.org +++ b/.config/doom/config.org @@ -2,8 +2,16 @@ * Table of Contents :toc: - [[#doom-settings][Doom Settings]] +- [[#keybindings][Keybindings]] + - [[#comment-line][Comment Line]] + - [[#toggle-bindings][Toggle bindings]] +- [[#markdown][Markdown]] + - [[#headers][Headers]] + - [[#toggle-markdown-view][Toggle Markdown View]] - [[#org][Org]] -- [[#other-stuff][Other Stuff]] + - [[#basic-settings][Basic Settings]] + - [[#headers-1][Headers]] +- [[#sensible-defaults][Sensible Defaults]] * Doom Settings #+begin_src emacs-lisp @@ -12,7 +20,80 @@ #+end_src +* Keybindings + +** Comment Line +#+begin_src emacs-lisp +(map! :leader + :desc "Comment line" "-" #'comment-line) + +#+end_src + +** Toggle bindings +#+begin_src emacs-lisp +(map! :leader + (:prefix ("t" . "toggle") + :desc "Toggle line numbers" "l" #'doom/toggle-line-numbers + :desc "Toggle eshell split" "e" #'+eshell/toggle + :desc "Toggle line highlight in frame" "h" #'hl-line-mode + :desc "Toggle line highlight globally" "H" #'global-hl-line-mode + :desc "Toggle markdown-view-mode" "m" #'dt/toggle-markdown-view-mode + :desc "Toggle truncate lines" "t" #'toggle-truncate-lines + :desc "Toggle treemacs" "T" #'+treemacs/toggle + :desc "Toggle vterm split" "v" #'+vterm/toggle)) + +(setq display-line-numbers-type t) +(map! :leader + (:prefix ("T" . "toggle here") + :desc "Toggle eshell split" "e" #'+eshell/here + :desc "Toggle vterm split" "v" #'+vterm/here)) + + +#+end_src + +* Markdown +This sets the font size for each markdown header level. Having variable font sizes in a markdown outline makes it visually appealing and more readable. + + +** Headers +#+begin_src emacs-lisp +(custom-set-faces + '(markdown-header-face ((t (:inherit font-lock-function-name-face :weight bold :family "variable-pitch")))) + '(markdown-header-face-1 ((t (:inherit markdown-header-face :height 1.6)))) + '(markdown-header-face-2 ((t (:inherit markdown-header-face :height 1.5)))) + '(markdown-header-face-3 ((t (:inherit markdown-header-face :height 1.4)))) + '(markdown-header-face-4 ((t (:inherit markdown-header-face :height 1.3)))) + '(markdown-header-face-5 ((t (:inherit markdown-header-face :height 1.2)))) + '(markdown-header-face-6 ((t (:inherit markdown-header-face :height 1.1))))) + +#+end_src + +** Toggle Markdown View +A custom function to toggle between standard 'markdown-mode' and 'markdown-view-mode'. Custom functions in Emacs should be named as "prefix/name-of-function" to make it clear that the function is custom and not a standard Emacs function. In my case, I begin all my custom functions with 'dt'. + +#+begin_src emacs-lisp +(defun dt/toggle-markdown-view-mode () + "Toggle between `markdown-mode' and `markdown-view-mode'." + (interactive) + (if (eq major-mode 'markdown-view-mode) + (markdown-mode) + (markdown-view-mode))) + +#+end_src + * Org +** Basic Settings +#+begin_src emacs-lisp + +(setq org-directory "~/nc/Org/") +(setq org-modern-table-vertical 1) +(setq org-modern-table t) +(add-hook 'org-mode-hook #'hl-todo-mode) + +#+end_src + +** Headers +This sets the font size for each Org header level. Having variable font sizes in an Org outline makes it visually appealing and more readable. #+begin_src emacs-lisp (custom-theme-set-faces! 'doom-one @@ -26,27 +107,12 @@ '(org-level-1 :inherit outline-1 :height 1.6) '(org-document-title :height 1.8 :bold t :underline nil)) -(setq org-directory "~/nc/Org/") -(setq org-modern-table-vertical 1) -(setq org-modern-table t) -(add-hook 'org-mode-hook #'hl-todo-mode) - #+end_src -* Other Stuff +* Sensible Defaults #+begin_src emacs-lisp -(setq display-line-numbers-type t) - -(map! :leader - :desc "Comment line" "-" #'comment-line) - -;; If you use `org' and don't want your org files in the default location below, -;; change `org-directory'. It must be set before org loads! - - - -(setq confirm-kill-emacs nil) - -(setq initial-buffer-choice 'eshell) +(setq display-line-numbers-type t) ;; Turn line numbers on +(setq confirm-kill-emacs nil) ;; Don't confirm on exit +(setq initial-buffer-choice 'eshell) ;; Eshell is initial buffer #+end_src