2012-12-15 22:07:25 +02:00
|
|
|
;;; prelude-programming.el --- Emacs Prelude: prog-mode configuration
|
|
|
|
;;
|
2014-12-07 11:37:46 +02:00
|
|
|
;; Copyright © 2011-2014 Bozhidar Batsov
|
2012-12-15 22:07:25 +02:00
|
|
|
;;
|
|
|
|
;; Author: Bozhidar Batsov <bozhidar@batsov.com>
|
2013-03-07 09:57:33 +02:00
|
|
|
;; URL: https://github.com/bbatsov/prelude
|
2012-12-15 22:07:25 +02:00
|
|
|
;; Version: 1.0.0
|
|
|
|
;; Keywords: convenience
|
|
|
|
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; Some basic prog-mode configuration and programming related utilities.
|
|
|
|
|
|
|
|
;;; License:
|
|
|
|
|
|
|
|
;; This program is free software; you can redistribute it and/or
|
|
|
|
;; modify it under the terms of the GNU General Public License
|
|
|
|
;; as published by the Free Software Foundation; either version 3
|
|
|
|
;; of the License, or (at your option) any later version.
|
|
|
|
;;
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
;;
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
|
|
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
;; Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2013-11-26 12:52:29 +02:00
|
|
|
(prelude-require-packages '(guru-mode))
|
2013-01-02 14:29:14 +02:00
|
|
|
|
2012-12-15 22:07:25 +02:00
|
|
|
(defun prelude-local-comment-auto-fill ()
|
|
|
|
(set (make-local-variable 'comment-auto-fill-only-comments) t))
|
|
|
|
|
2013-07-24 16:26:19 +03:00
|
|
|
(defun prelude-font-lock-comment-annotations ()
|
2013-07-24 16:13:32 +03:00
|
|
|
"Highlight a bunch of well known comment annotations.
|
|
|
|
|
|
|
|
This functions should be added to the hooks of major modes for programming."
|
2012-12-15 22:07:25 +02:00
|
|
|
(font-lock-add-keywords
|
2013-09-26 14:43:04 +03:00
|
|
|
nil '(("\\<\\(\\(FIX\\(ME\\)?\\|TODO\\|OPTIMIZE\\|HACK\\|REFACTOR\\):\\)"
|
2012-12-15 22:07:25 +02:00
|
|
|
1 font-lock-warning-face t))))
|
|
|
|
|
|
|
|
;; show the name of the current function definition in the modeline
|
|
|
|
(require 'which-func)
|
|
|
|
(which-function-mode 1)
|
|
|
|
|
|
|
|
;; in Emacs 24 programming major modes generally derive from a common
|
|
|
|
;; mode named prog-mode; for others, we'll arrange for our mode
|
|
|
|
;; defaults function to run prelude-prog-mode-hook directly. To
|
|
|
|
;; augment and/or counteract these defaults your own function
|
|
|
|
;; to prelude-prog-mode-hook, using:
|
|
|
|
;;
|
|
|
|
;; (add-hook 'prelude-prog-mode-hook 'my-prog-mode-defaults t)
|
|
|
|
;;
|
|
|
|
;; (the final optional t sets the *append* argument)
|
|
|
|
|
2014-06-25 06:01:12 +03:00
|
|
|
;; smart curly braces
|
|
|
|
(sp-pair "{" nil :post-handlers
|
|
|
|
'(((lambda (&rest _ignored)
|
|
|
|
(prelude-smart-open-line-above)) "RET")))
|
|
|
|
|
2014-09-14 08:57:02 +03:00
|
|
|
;; enlist a more liberal guru
|
|
|
|
(setq guru-warn-only t)
|
|
|
|
|
2012-12-15 22:07:25 +02:00
|
|
|
(defun prelude-prog-mode-defaults ()
|
|
|
|
"Default coding hook, useful with any programming language."
|
|
|
|
(when (and (executable-find ispell-program-name)
|
|
|
|
prelude-flyspell)
|
|
|
|
(flyspell-prog-mode))
|
|
|
|
(when prelude-guru
|
|
|
|
(guru-mode +1))
|
2013-09-26 14:33:33 +03:00
|
|
|
(smartparens-mode +1)
|
2013-01-05 10:38:12 +02:00
|
|
|
(prelude-enable-whitespace)
|
2012-12-15 22:07:25 +02:00
|
|
|
(prelude-local-comment-auto-fill)
|
2013-07-24 16:26:19 +03:00
|
|
|
(prelude-font-lock-comment-annotations))
|
2012-12-15 22:07:25 +02:00
|
|
|
|
|
|
|
(setq prelude-prog-mode-hook 'prelude-prog-mode-defaults)
|
|
|
|
|
|
|
|
(add-hook 'prog-mode-hook (lambda ()
|
|
|
|
(run-hooks 'prelude-prog-mode-hook)))
|
|
|
|
|
2013-09-26 14:34:10 +03:00
|
|
|
;; enable on-the-fly syntax checking
|
2013-04-12 17:36:13 +03:00
|
|
|
(if (fboundp 'global-flycheck-mode)
|
|
|
|
(global-flycheck-mode +1)
|
|
|
|
(add-hook 'prog-mode-hook 'flycheck-mode))
|
|
|
|
|
2012-12-15 22:07:25 +02:00
|
|
|
(provide 'prelude-programming)
|
|
|
|
;;; prelude-programming.el ends here
|