summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAssaf Gordon <assafgordon@gmail.com>2017-04-06 18:20:31 (GMT)
committerAssaf Gordon <assafgordon@gmail.com>2017-04-06 18:20:31 (GMT)
commit338493a62023b490b23cd6bbb2648dbf0023b80e (patch)
tree16049a62a17fa35492e478ba707e426d1e79b6ce
parent48e3f68058a0002aee5f8c844f5710312d733e65 (diff)
downloaddot-files-dev/emacs.zip
dot-files-dev/emacs.tar.gz
dot-files-dev/emacs.tar.bz2
emacs: attempt at switching gnu/linux styles with C-c tdev/emacs
-rw-r--r--emacs60
1 files changed, 49 insertions, 11 deletions
diff --git a/emacs b/emacs
index 15d9b9b..723bba2 100644
--- a/emacs
+++ b/emacs
@@ -42,8 +42,10 @@
; Whitespace/80columns enforcing
; see http://www.emacswiki.org/emacs/EightyColumnRule
+; For 'Whitespace-style' see:
+; https://www.emacswiki.org/emacs/WhiteSpace#toc7
(require 'whitespace)
-(setq whitespace-style '(face empty lines-tail trailing))
+(setq whitespace-style '(face empty lines-tail trailing space-before-tab))
(global-whitespace-mode t)
; Get rid of the startup message
@@ -67,18 +69,54 @@
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
)
-; "Linux" C style by default
-; (setq c-default-style "linux")
-;
-; spaces instead of tABs
-; see http://www.emacswiki.org/emacs/NoTabs
-; use 't' to enable hard TABS, 'nil' to convert tabs to spaces
+; Set GNU style:
+; soft tabs (spaces instead of TAB), pressing TAB inserts 4 spaces.
+; mark tab.
+(defun set-gnu-style ()
+ (interactive)
+ (global-whitespace-mode 0)
+ (setq indent-tabs-mode nil)
+ (setq tab-width 4)
+ (setq c-default-style "gnu")
+ ; missing: tab-mark
+ (setq whitespace-style
+ '(face empty lines-tail trailing space-before-tab ))
+ (global-whitespace-mode 1)
+ (redraw-display)
+ (setq agn-style "gnu")
+ (message "setting 'gnu' style")
+ )
-; spaces-for-tabs
-(setq-default indent-tabs-mode nil)
+; Set linux style:
+; hard tabs (ASCII 0x09), each tab is 8 spaces,
+; mark spaces.
+(defun set-linux-style ()
+ (interactive)
+ (global-whitespace-mode 0)
+ (setq indent-tabs-mode t)
+ (setq c-default-style "linux")
+ (setq tab-width 8)
+ ; missing: space-mark
+ (setq whitespace-style
+ '(face empty lines-tail trailing space-before-tab ))
+ (global-whitespace-mode 1)
+ (redraw-display)
+ (setq agn-style "linux")
+ (message "setting 'linux' style")
+ )
-; real tables (ASCII 0x09)
-; (setq-default indent-tabs-mode t)
+; Default style
+(set-gnu-style)
+
+;;
+;; Toggle between the styles
+(defun agn-toggle-styles ()
+ (interactive)
+ (if (string= agn-style "linux")
+ (set-gnu-style)
+ (set-linux-style))
+ )
+(global-set-key (kbd "C-c t") 'agn-toggle-styles)
; From "Emacs" for Kernel Development:
; http://martinezjavier.blogspot.com/2011/07/emacs-configuration-for-linux-kernel.html