Initial commit
This commit is contained in:
commit
99e3df82b7
28 changed files with 2639 additions and 0 deletions
28
configs/hooks.el
Normal file
28
configs/hooks.el
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
; Delete trailing whitespaces on save
|
||||
(add-hook 'write-file-hooks 'delete-trailing-whitespace)
|
||||
|
||||
;; Mode to collapse code block
|
||||
(add-hook 'c-mode-common-hook (lambda () (hs-minor-mode 1)))
|
||||
(add-hook 'lisp-mode-hooks (lambda () (hs-minor-mode 1)))
|
||||
(add-hook 'java-mode-hooks (lambda () (hs-minor-mode 1)))
|
||||
(add-hook 'python-mode-hooks (lambda () (hs-minor-mode 1)))
|
||||
|
||||
; Auto insert C/C++ header guard
|
||||
(add-hook 'find-file-hooks
|
||||
(lambda ()
|
||||
(when (and (memq major-mode '(c-mode c++-mode)) (equal (point-min) (point-max)) (string-match ".*\\.hh?" (buffer-file-name)))
|
||||
(insert-header-guard)
|
||||
(goto-line 3)
|
||||
(insert "\n"))))
|
||||
(add-hook 'find-file-hooks
|
||||
(lambda ()
|
||||
(when (and (memq major-mode '(c-mode c++-mode)) (equal (point-min) (point-max)) (string-match ".*\\.cc?" (buffer-file-name)))
|
||||
(insert-header-inclusion))))
|
||||
|
||||
(add-hook 'sh-mode-hook
|
||||
(lambda ()
|
||||
(insert-shebang-if-empty "/bin/sh")))
|
||||
|
||||
(add-hook 'ruby-mode-hook
|
||||
(lambda ()
|
||||
(insert-shebang-if-empty "/usr/bin/ruby")))
|
||||
Loading…
Add table
Add a link
Reference in a new issue