commit ccf4a678e01d5a00b36666dbe47bc0534933474f
parent 4aefd6295d3df52a9b5af4e10077e3b2062804b5
Author: Ethan Long <me@ethandl.dev>
Date: Fri, 24 Jul 2026 20:15:23 +1000
Added some new features and fixed some epic bugs
Python indentation is now usable :)
Diffstat:
| M | clean.sh | | | 2 | +- |
| M | config.org | | | 58 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++---- |
2 files changed, 55 insertions(+), 5 deletions(-)
diff --git a/clean.sh b/clean.sh
@@ -1,3 +1,3 @@
#!/bin/sh
-rm -rf config.el config.el~ eln-cache/ elpaca/ tree-sitter/ platform-config/
+rm -rf config.el config.el~ eln-cache/ elpaca/ tree-sitter/ platform-config/ tramp
diff --git a/config.org b/config.org
@@ -195,13 +195,16 @@ The scroll bar is unnecessary if you are navigating via keyboard, and takes up s
#+begin_src emacs-lisp
(scroll-bar-mode 0)
#+end_src
-** Relative line numbers
+** Line numbers
When working with modal editing and in general programming, it is useful to be able to see distances to previous or subsequent lines in the buffer.
Emacs comes with a nice built-in mode that displays line numbers on the left-hand side of a buffer, much like in ~vi~.
#+begin_src emacs-lisp
- (setq display-line-numbers-type 'relative)
(add-hook 'prog-mode-hook #'display-line-numbers-mode)
#+end_src
+Optionally, you can also set the line numbers to be relative to the cursor position.
+#+begin_src emacs-lisp :tangle no
+ (setq display-line-numbers-type 'relative)
+#+end_src
By default, the size of the line-numbers column is only big enough for small files and will grow and shrink to accomodate the line numbers as you scroll, leading to the jarring movement of code horizontally as a buffer is scrolled.
This can be fixed:
@@ -221,6 +224,24 @@ It can be very useful to know the current position of the cursor in a line so th
#+begin_src emacs-lisp
(column-number-mode 1)
#+end_src
+** Indentation indicators
+Programming languages that use indentation to control scope such as Python are greatly enhanced by the ability to see indentation more clearly.
+The ~indent-bars~ package by jdtsmith gives us the ability to see this indentation much more clearly.
+#+begin_src emacs-lisp
+ (elpaca indent-bars
+ (setq indent-bars-no-descend-lists 'skip) ; prevent extra bars in nested lists + skip intermediate bars
+ (setq indent-bars-treesit-support t))
+#+end_src
+
+Because I want all aspects of language configuration to be in [[The programming environment][the programming environment]] section, I don't want to set language-specific variables here.
+The plist ~indent-bars-treesit-scope~ is one such language-specific variable, if there are ever any more that I want to configure, I will also add them here:
+#+begin_src emacs-lisp
+ (defvar ethandl/indent-bars-treesit-scope nil)
+ (defun ethandl/set-indent-bars-treesit-scope ()
+ (require 'indent-bars)
+ (setq indent-bars-treesit-scope ethandl/indent-bars-treesit-scope))
+ (add-hook 'elpaca-after-init-hook #'ethandl/set-indent-bars-treesit-scope)
+#+end_src
** Fonts
*** Code fonts
These are the fonts used generally by the Emacs user interface, and in any buffer that doesn't use ~variable-pitch-mode~.
@@ -501,6 +522,13 @@ We add this to the ~elpaca-after-init-hook~ so that everything is compiled after
(add-hook 'elpaca-after-init-hook
#'ethandl/nativecomp-aot)
#+end_src
+** Indenting without tabs
+Tabs make your code unreadable on editors with different tab settings if used incorrectly.
+Unfortunately Emacs does this incorrectly by default, so I will disable this behaviour:
+#+begin_src emacs-lisp
+ (indent-tabs-mode -1)
+ (setq-default indent-tabs-mode -1)
+#+end_src
* Org mode
** Section numbering
I like my sections numbered:
@@ -592,8 +620,8 @@ Treesitter grammar installation is slow and blocks up the emacs process. The fol
"\\`treesit-language-source-alist\\'")))
#+end_src
** Markdown
-Emacs comes with ~markdown-ts-mode~, which utilises treesitter to provide highlighting for markdown.
-To use this mode, we just install the treesitter grammar(s):
+For markdown, I will use ~markdown-ts-mode~, which utilises treesitter to provide highlighting for markdown.
+To use this mode, we need to install the treesitter grammar(s):
#+begin_src emacs-lisp
(add-to-list 'treesit-language-source-alist
'(markdown "https://github.com/tree-sitter-grammars/tree-sitter-markdown"
@@ -627,6 +655,19 @@ From my (admittedly limited) experience, ~python-ts-mode~ tends to have better s
(add-to-list 'ethandl/org-babel-langs '(python . t))
#+end_src
+
+For python, I like to have indentation visible with ~indent-bars~,
+#+begin_src emacs-lisp
+ (add-hook 'python-mode-hook #'indent-bars-mode)
+ (add-hook 'python-ts-mode-hook #'indent-bars-mode)
+#+end_src
+A simple configuration for treesit-python is given on the github repo for ~indent-bars~:
+#+begin_src emacs-lisp
+ (setq indent-bars-treesit-ignore-blank-lines-types '("module"))
+ (add-to-list 'ethandl/indent-bars-treesit-scope
+ '(python function_definition class_definition for_statement
+ if_statement with_statement while_statement))
+#+end_src
** Powershell
I don't like or use Powershell, but seeing as I sometimes operate on Windows (and even have a sample in this config for TRAMP compatability), it /could/ be nice to have.
@@ -687,6 +728,15 @@ Firstly, there is no ~nativecomp~, so we have to redefine the function to be a n
(interactive)
(lwarn '(windows-is-shit) :debug "Nativecomp not supported on Windows NT. Use a real OS"))
#+end_src
+** Emacs <31
+There are a few assumptions that are made in this configuration that do not hold for versions of Emacs less than 31.
+*** ~markdown-ts-mode~
+~markdown-ts-mode~ is only shipped with Emacs31 and newer, so we need to install it on older versions:
+#+begin_src emacs-lisp :tangle (if (< (string-to-number emacs-version) 31) "platform-config/old-emacs.el" "no")
+ (elpaca markdown-ts-mode
+ (require 'markdown-ts-mode)
+ (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-ts-mode)))
+#+end_src
** Including the platforms
Finally, we include any tangled platforms:
#+begin_src emacs-lisp