You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

code.el 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. ;;; code.el --- Settings for editing source code
  2. ;; Generic hook run in most programming modes
  3. (defun usk-programming-mode-hook ()
  4. (require 'align)
  5. (setq save-place t)
  6. (set (make-local-variable 'comment-auto-fill-only-comments) t)
  7. (flyspell-prog-mode)
  8. (electric-pair-mode 1)
  9. (whitespace-mode t)
  10. (font-lock-add-keywords nil '(("\\<\\(FIXME:\\|TODO:\\|NOTE:\\|WARN:\\)"
  11. 1 devalot-fixme-face t)))
  12. (local-set-key (kbd "RET") 'reindent-then-newline-and-indent))
  13. (add-hook 'prog-mode-hook 'usk-programming-mode-hook)
  14. ;; Ruby
  15. (add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
  16. (add-to-list 'auto-mode-alist '("\\.irbrc$" . ruby-mode))
  17. (add-to-list 'auto-mode-alist '("\\.gemspec$" . ruby-mode))
  18. (add-to-list 'auto-mode-alist '("\\.ru$" . ruby-mode))
  19. (add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
  20. (add-to-list 'auto-mode-alist '("Gemfile$" . ruby-mode))
  21. (add-to-list 'auto-mode-alist '("Capfile$" . ruby-mode))
  22. (add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
  23. (autoload 'yaml-mode "yaml-mode" "YAML Mode" t)
  24. (add-hook 'ruby-mode-hook 'inf-ruby-keys)
  25. (add-hook 'ruby-mode-hook 'flymake-ruby-load)
  26. (add-hook 'ruby-mode-hook 'ruby-end-mode)
  27. (add-hook 'yaml-mode-hook 'usk-programming-mode-hook)
  28. ;; Ruby embedded in HTML
  29. (add-to-list 'load-path (concat user-emacs-directory "rhtml"))
  30. (autoload 'rhtml-mode "rhtml-mode" "Mode for editing mixed Ruby and HTML" t)
  31. (add-to-list 'auto-mode-alist '("\\.html\\.erb$" . rhtml-mode))
  32. ;; HTML, CSS, JavaScript
  33. (add-to-list 'auto-mode-alist '("\\.css\\.scss$" . css-mode))
  34. (add-hook 'css-mode-hook 'usk-programming-mode-hook)
  35. (add-hook 'sgml-mode-hook 'usk-programming-mode-hook)
  36. (setq css-indent-offset 2 sgml-basic-offset 2
  37. js-indent-level 2 js-flat-functions t)
  38. ;; Shell scripting
  39. (setq sh-basic-offset 2)
  40. ;; Make #! scripts executable after saving them
  41. (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)