Emacs config utilizing prelude as a base
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.

97 lines
3.1 KiB

13 years ago
13 years ago
12 years ago
  1. ;;; prelude-programming.el --- Emacs Prelude: prog-mode configuration
  2. ;;
  3. ;; Copyright © 2011-2013 Bozhidar Batsov
  4. ;;
  5. ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
  6. ;; URL: https://github.com/bbatsov/prelude
  7. ;; Version: 1.0.0
  8. ;; Keywords: convenience
  9. ;; This file is not part of GNU Emacs.
  10. ;;; Commentary:
  11. ;; Some basic prog-mode configuration and programming related utilities.
  12. ;;; License:
  13. ;; This program is free software; you can redistribute it and/or
  14. ;; modify it under the terms of the GNU General Public License
  15. ;; as published by the Free Software Foundation; either version 3
  16. ;; of the License, or (at your option) any later version.
  17. ;;
  18. ;; This program is distributed in the hope that it will be useful,
  19. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. ;; GNU General Public License for more details.
  22. ;;
  23. ;; You should have received a copy of the GNU General Public License
  24. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  25. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  26. ;; Boston, MA 02110-1301, USA.
  27. ;;; Code:
  28. (prelude-require-packages '(guru-mode))
  29. ;; add a shortcut for prelude-ido-goto-symbol
  30. (eval-after-load 'prelude-mode
  31. ')
  32. (defun prelude-local-comment-auto-fill ()
  33. (set (make-local-variable 'comment-auto-fill-only-comments) t))
  34. (defun prelude-font-lock-comment-annotations ()
  35. "Highlight a bunch of well known comment annotations.
  36. This functions should be added to the hooks of major modes for programming."
  37. (font-lock-add-keywords
  38. nil '(("\\<\\(\\(FIX\\(ME\\)?\\|TODO\\|OPTIMIZE\\|HACK\\|REFACTOR\\):\\)"
  39. 1 font-lock-warning-face t))))
  40. ;; show the name of the current function definition in the modeline
  41. (require 'which-func)
  42. (which-function-mode 1)
  43. ;; in Emacs 24 programming major modes generally derive from a common
  44. ;; mode named prog-mode; for others, we'll arrange for our mode
  45. ;; defaults function to run prelude-prog-mode-hook directly. To
  46. ;; augment and/or counteract these defaults your own function
  47. ;; to prelude-prog-mode-hook, using:
  48. ;;
  49. ;; (add-hook 'prelude-prog-mode-hook 'my-prog-mode-defaults t)
  50. ;;
  51. ;; (the final optional t sets the *append* argument)
  52. ;; smart curly braces
  53. (sp-pair "{" nil :post-handlers
  54. '(((lambda (&rest _ignored)
  55. (prelude-smart-open-line-above)) "RET")))
  56. ;; enlist a more liberal guru
  57. (setq guru-warn-only t)
  58. (defun prelude-prog-mode-defaults ()
  59. "Default coding hook, useful with any programming language."
  60. (when (and (executable-find ispell-program-name)
  61. prelude-flyspell)
  62. (flyspell-prog-mode))
  63. (when prelude-guru
  64. (guru-mode +1))
  65. (smartparens-mode +1)
  66. (prelude-enable-whitespace)
  67. (prelude-local-comment-auto-fill)
  68. (prelude-font-lock-comment-annotations))
  69. (setq prelude-prog-mode-hook 'prelude-prog-mode-defaults)
  70. (add-hook 'prog-mode-hook (lambda ()
  71. (run-hooks 'prelude-prog-mode-hook)))
  72. ;; enable on-the-fly syntax checking
  73. (if (fboundp 'global-flycheck-mode)
  74. (global-flycheck-mode +1)
  75. (add-hook 'prog-mode-hook 'flycheck-mode))
  76. (provide 'prelude-programming)
  77. ;;; prelude-programming.el ends here