Reputation: 193
I want to have minor mode that, when enabled, changes the tab space from 4 to 2 (and when disabled returns the tab space back to 4). I haven't written a mode before so I'm not sure how to go about this.
Upvotes: 0
Views: 180
Reputation: 19747
No need to create a minor mode. tab-width is already a buffer-local variable:
(defvar my-tab-toggle-values '(2 4))
(defun my-toggle-tab-width ()
(interactive)
(setq tab-width
(if (= tab-width (first my-tab-toggle-values))
(second my-tab-toggle-values)
(first my-tab-toggle-values))))
Upvotes: 3