Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .emacs.d/lisp/code/editorconfig-c.el
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,28 @@ Debug warning is suppressed if SUPPRESS is non-nil."

(kotct/editorconfig-check-for-core kotct/editorconfig-suppress-core-not-found-warning)

(defvar kotct/warn-on-editorconfig-with-no-props
t
"If not false-y, warn when editing a file with no editorconfig properties
applying, indicating that the user is stuck with Emacs' default style for the
active buffer.")

(defun kotct/check-editorconfig-props (props)
"Warn the user if a file is being edited with EditorConfig active but no
properties were applied.

The argument PROPS is a property hash table provided by the EditorConfig
package, and contains key-value pairs corresponding to the user's configured
style for the current buffer. If this hash table is empty, no properties were
applied to the buffer, so the user is at the whims of Emacs' default style for
the active mode, which may not be desirable."

(if kotct/warn-on-editorconfig-with-no-props
(let ((fn (buffer-file-name))
(bn (buffer-name)))
(if (and fn (= 0 (hash-table-count props)))
(message(format "EditorConfig mode is active for buffer %s, but no properties were applied." bn))))))

(add-hook #'editorconfig-after-apply-functions #'kotct/check-editorconfig-props)

(provide 'editorconfig-c)
41 changes: 0 additions & 41 deletions .emacs.d/lisp/code/indentation.el
Original file line number Diff line number Diff line change
@@ -1,44 +1,3 @@
;; set the default tab width to 4 chars
;; this is the reference variable for the tab width
(setf global-tab-width 4)

;; define automated tab-setting system
(defvar kotct/tab-variable-setters
'((global-tab-width . setf))
"An alist of symbols representing variables and the method
used to set them to the tab width
(almost always either setf or setq-default).")

(defmacro kotct/setf-tab (var)
"Set the variable VAR to the tab width and keep it updated
if the tab width changes."
`(progn
(setf ,var global-tab-width)
(setf kotct/tab-variable-setters (cons '(,var . setf) kotct/tab-variable-setters))))

(defmacro kotct/setq-default-tab (var)
"Set default value of the variable VAR to the tab width
and keep it updated if the tab width changes."
`(progn
(setq-default ,var global-tab-width)
(setf kotct/tab-variable-setters (cons '(,var . setq-default) kotct/tab-variable-setters))))

(defmacro kotct/set-tab-width (width)
"Set `global-tab-width' and all other associated tab width
variables in `kotct/tab-variable-setters' to WIDTH."
(cons 'progn
(mapcar (lambda (pair) (list (cdr pair) (car pair) width))
kotct/tab-variable-setters)))

(kotct/setq-default-tab tab-width)
(kotct/setf-tab smie-indent-basic)

;; Set the base indent variable.
(kotct/setf-tab standard-indent)

;; by default, don't use tabs
(setq-default indent-tabs-mode nil)

;; when you hit DEL on a tab, delete the whole tab, don't convert to spaces
(setf backward-delete-char-untabify-method nil)

Expand Down
6 changes: 0 additions & 6 deletions .emacs.d/lisp/code/languages/c.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,4 @@
;; set style to linux
(setf c-default-style "linux")

;; use tab-width for indentation
(kotct/setf-tab c-basic-offset)

;; use smart tabs
(smart-tabs-insinuate 'c)

(provide 'c)
8 changes: 0 additions & 8 deletions .emacs.d/lisp/code/languages/fish.el
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
(require 'fish-mode)

(smart-tabs-add-language-support fish fish-mode-hook
((fish-indent-line . standard-indent)
(fish-indent-region . standard-indent)))

(smart-tabs-insinuate 'fish)

(add-hook 'fish-mode-hook (lambda () (setf indent-tabs-mode t)))

(provide 'fish)
2 changes: 0 additions & 2 deletions .emacs.d/lisp/code/languages/java.el
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
;; TODO: implement IDE-like java editing

(smart-tabs-insinuate 'java)

(provide 'java)
15 changes: 0 additions & 15 deletions .emacs.d/lisp/code/languages/ruby.el
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
(require 'indentation)

;; Set ruby-indent-level to global-tab-width
(kotct/setq-default-tab ruby-indent-level)

;; Add Smart Tabs language support for Ruby using the
;; `smart-tabs-add-language-support' macro.
(smart-tabs-add-language-support ruby ruby-mode-hook
((ruby-indent-line . ruby-indent-level)
(ruby-indent-level . ruby-indent-level)))

;; Apply Ruby language support to Smart Tabs.
(smart-tabs-insinuate 'ruby)

;; Use tabs mode in Ruby by default.
(setf ruby-indent-tabs-mode t)

;; Don't use SMIE because SMIE sucks.
(setf ruby-use-smie nil)

Expand Down
13 changes: 0 additions & 13 deletions .emacs.d/lisp/code/languages/rust.el
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
(require 'indentation)

;; Set `rust-indent-offset' to the `global-tab-width' value.
(kotct/setq-default-tab rust-indent-offset)

;; Add language support for Rust.
(smart-tabs-add-language-support rust rust-mode-hook
((rust-mode-indent-line . rust-indent-offset)))

;; Use `indent-tabs-mode' in `rust-mode'
(add-hook 'rust-mode-hook (lambda () (setf indent-tabs-mode t)))

;; Turn on Rust support in Smart Tabs.
(smart-tabs-insinuate 'rust)

;; Don't indent `where' clauses in Rust.
(setf rust-indent-where-clause nil)

Expand Down
7 changes: 0 additions & 7 deletions .emacs.d/lisp/code/languages/sh.el
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
(require 'indentation)

;; Synchronize `sh-basic-offset' and `sh-indentation' to the global tab size
(kotct/setf-tab sh-basic-offset)
(kotct/setf-tab sh-indentation)

;; Always use indent-tabs-mode in sh-mode
(add-hook 'sh-mode-hook (lambda () (setf indent-tabs-mode t)))

;; Indent case labels at the same level as the case statement
(setf sh-indent-for-case-label 0)

Expand Down
2 changes: 0 additions & 2 deletions .emacs.d/lisp/code/languages/web-c.el
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,4 @@
(setf web-mode-enable-control-block-indentation nil)
(setf web-mode-script-padding 0)

(add-hook 'web-mode-hook (lambda () (setf indent-tabs-mode t)))

(provide 'web-c)
4 changes: 0 additions & 4 deletions .emacs.d/test/lisp/code/languages/sh-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
(kotct/load-corresponding)

(describe "sh config"
(it "adds a tab variable setter for `sh-basic-offset'"
(expect (assoc 'sh-basic-offset kotct/tab-variable-setters) :to-be-truthy))
(it "adds a tab variable setter for `sh-indentation'"
(expect (assoc 'sh-indentation kotct/tab-variable-setters) :to-be-truthy))
(it "sets the indentation for case labels to 0"
(expect sh-indent-for-case-label :to-be 0))
(it "sets the indentation for case alts to be one level"
Expand Down