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.

85 lines
2.7 KiB

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