summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-09-04 13:52:03 -0400
committerDavid Robillard <d@drobilla.net>2024-09-04 13:52:03 -0400
commit3c300111d4bffb3bcadcbc6846f541165ab89a14 (patch)
treed64f4f383b8538d3f03178db5238636c3e16d8cc
parentfa60f82126d250257068db3bb36bafcba0769ace (diff)
downloaddotfiles-3c300111d4bffb3bcadcbc6846f541165ab89a14.tar.gz
dotfiles-3c300111d4bffb3bcadcbc6846f541165ab89a14.tar.bz2
dotfiles-3c300111d4bffb3bcadcbc6846f541165ab89a14.zip
Organize emacs configuration more sensibly
-rw-r--r--emacs/.emacs.d/init.el100
1 files changed, 51 insertions, 49 deletions
diff --git a/emacs/.emacs.d/init.el b/emacs/.emacs.d/init.el
index bb64142..817f60b 100644
--- a/emacs/.emacs.d/init.el
+++ b/emacs/.emacs.d/init.el
@@ -14,6 +14,7 @@
(setq dired-listing-switches "-al --time-style=long-iso")
(scroll-bar-mode (quote right))))
+;; Set basic emacs variables
(setq-default
gc-cons-threshold 100000000
backup-by-copying t
@@ -23,56 +24,9 @@
browse-url-generic-program (executable-find "sensible-browser")
browse-url-browser-function 'browse-url-generic)
+;; Hide dired details by default for a shiner experience
(add-hook 'dired-mode-hook (lambda () (dired-hide-details-mode)))
-;;; Code formatting
-
-(require 'clang-format)
-
-(defun get-clang-format-option (config-str field is-num)
- "Retrieve a config option from a clang-format config."
- (cond (is-num
- (let ((primary-match (s-match (concat "^" field ":[ \t]*[0-9]+") config-str)))
- (if primary-match
- (string-to-number (car (s-match "[0-9]+" (car primary-match))))
- 0)))
- (t
- (let ((primary-match (s-match (concat "^" field ":[ \t]*[A-Za-z]+") config-str)))
- (if primary-match
- (car (s-match "[A-Za-z]+$" (car primary-match)))
- "")))))
-
-(defun clang-format-c-mode-hook ()
- "Load C family configuration from clang-format configuration."
- (let* ((clang-format-config
- (shell-command-to-string "clang-format -dump-config"))
- (c-offset (get-clang-format-option clang-format-config "IndentWidth" t))
- (tabs-str (get-clang-format-option clang-format-config "UseTab" nil))
- (base-style
- (get-clang-format-option clang-format-config "BasedOnStyle" nil)))
- (progn
- (if (> c-offset 0)
- (setq-local c-basic-offset c-offset)
- (if (not (equal "" base-style))
- (cond ((or (equal "LLVM" base-style)
- (equal "Google" base-style)
- (equal "Chromium" base-style)
- (equal "Mozilla" base-style))
- (setq-local c-basic-offset 2))
- ((equal "WebKit" base-style)
- (setq-local c-basic-offset 4)))))
- (if (not (equal "" tabs-str))
- (if (not (string-equal "Never" tabs-str))
- (setq-local indent-tabs-mode t)
- (setq-local indent-tabs-mode nil))
- (if (not (equal "" base-style))
- (cond ((or (equal "LLVM" base-style)
- (equal "Google" base-style)
- (equal "Chromium" base-style)
- (equal "Mozilla" base-style)
- (equal "WebKit" base-style))
- (setq-local indent-tabs-mode nil))))))))
-
;;; Packages
(require 'package)
@@ -137,7 +91,7 @@
(require 'spaceline-config)
(require 'turtle-mode "turtle-mode/turtle-mode.el")
-;;; Basic editor configuration
+;;; Basic editor and modeline configuration
(defalias 'yes-or-no-p 'y-or-n-p)
(setq-default tab-width 4)
@@ -513,6 +467,54 @@
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
(add-hook 'c++-mode-common-hook 'my-c-mode-common-hook)
+;;; Code formatting
+
+(require 'clang-format)
+
+(defun get-clang-format-option (config-str field is-num)
+ "Retrieve a config option from a clang-format config."
+ (cond (is-num
+ (let ((primary-match (s-match (concat "^" field ":[ \t]*[0-9]+") config-str)))
+ (if primary-match
+ (string-to-number (car (s-match "[0-9]+" (car primary-match))))
+ 0)))
+ (t
+ (let ((primary-match (s-match (concat "^" field ":[ \t]*[A-Za-z]+") config-str)))
+ (if primary-match
+ (car (s-match "[A-Za-z]+$" (car primary-match)))
+ "")))))
+
+(defun clang-format-c-mode-hook ()
+ "Load C family configuration from clang-format configuration."
+ (let* ((clang-format-config
+ (shell-command-to-string "clang-format -dump-config"))
+ (c-offset (get-clang-format-option clang-format-config "IndentWidth" t))
+ (tabs-str (get-clang-format-option clang-format-config "UseTab" nil))
+ (base-style
+ (get-clang-format-option clang-format-config "BasedOnStyle" nil)))
+ (progn
+ (if (> c-offset 0)
+ (setq-local c-basic-offset c-offset)
+ (if (not (equal "" base-style))
+ (cond ((or (equal "LLVM" base-style)
+ (equal "Google" base-style)
+ (equal "Chromium" base-style)
+ (equal "Mozilla" base-style))
+ (setq-local c-basic-offset 2))
+ ((equal "WebKit" base-style)
+ (setq-local c-basic-offset 4)))))
+ (if (not (equal "" tabs-str))
+ (if (not (string-equal "Never" tabs-str))
+ (setq-local indent-tabs-mode t)
+ (setq-local indent-tabs-mode nil))
+ (if (not (equal "" base-style))
+ (cond ((or (equal "LLVM" base-style)
+ (equal "Google" base-style)
+ (equal "Chromium" base-style)
+ (equal "Mozilla" base-style)
+ (equal "WebKit" base-style))
+ (setq-local indent-tabs-mode nil))))))))
+
;; Python
(add-hook 'python-mode-hook