summary refs log tree commit diff
path: root/emacs
diff options
context:
space:
mode:
Diffstat (limited to 'emacs')
-rw-r--r--emacs/init.el21
1 files changed, 7 insertions, 14 deletions
diff --git a/emacs/init.el b/emacs/init.el
index 841d036..539da9c 100644
--- a/emacs/init.el
+++ b/emacs/init.el
@@ -596,21 +596,15 @@ targets."
 
 ;;; indentation: tabs and whitespace settings
 
-;; my rules for inserting tabs are that the tab key should insert tabs.  i personally prefer tabs.  spaces don't work for me because then people go trigger happy with alignment, which doesn't really work with proportional fonts.
+;; In general, my rules for inserting tabs are that the tab key should insert tabs.  I personally prefer tabs to spaces, because tabs work reasonably well whatever font or tab width one chooses to set, whereas spaces are the same width for everyone, except when someone uses a proportional font in which case they are narrower than expected.  Furthermore, people tend to use spaces for alignment, which looks bad when you can't rely on every character being the same width.
 
-;; todo: elastic tabstops
-;; https://nickgravgaard.com/elastic-tabstops/
-;; https://github.com/tenbillionwords/spaceship-mode
+;; However, i'm in the minority, and fighting with the very complicated emacs indentation systems is simply not fun.  That said, i refuse to use a monospaced font.  Luckily the minority is more than one and someone has already done the hard work for me of writing a mode to make spaces for indentation work reasonably well with a proportional font.  That mode is elastic-indent-mode, and it very simply makes leading whitespace characters the same width as the characters on the line above.  It's a simple solution but most of the time it does what i want.
+(require 'elastic-indent)
+(add-hook 'prog-mode-hook #'elastic-indent-mode)
 
-;; always insert \t for tab.
-(setopt electric-indent-mode nil
-        backward-delete-char-untabify-method nil
-        tab-width 8)
-
-;; do a naive duplicate whitespace on return, vi/nano style.
-(define-key global-map (kbd "TAB") 'self-insert-command)
-(defun naive-return-and-indent ()
-  "insert a newline and copy the indentation of the previous line"
+;; Previously i used a function to naïvely copy the whitespace from the line above.  This is the way that vi, nano, and acme all implement auto-indentation.  However, for now i'm experimenting with using the built-in indentation functions again.  I'm leaving this defun here for posterity.
+(defun noa/naive-return-and-indent ()
+  "Insert a newline and copy the indentation of the previous line, vi/nano style."
   (interactive)
   (open-line 1)
   (let* ((start (progn (beginning-of-line) (point)))
@@ -620,7 +614,6 @@ targets."
     (delete-trailing-whitespace start end)
     (beginning-of-line 2)
     (insert whitespace)))
-(define-key global-map (kbd "RET") 'naive-return-and-indent)
 
 ;;; Interface