]> code.delx.au - gnu-emacs-elpa/blob - packages/gnome-c-style/gnome-c-style.el
Merge commit '1054ea1bc5b07a1438a18c1b33f4266b28ff9d77'
[gnu-emacs-elpa] / packages / gnome-c-style / gnome-c-style.el
1 ;;; gnome-c-style.el --- minor mode for editing GNOME-style C source code -*- lexical-binding: t; -*-
2 ;; Copyright (C) 2016 Free Software Foundation, Inc.
3
4 ;; Author: Daiki Ueno <ueno@gnu.org>
5 ;; Keywords: GNOME, C, coding style
6 ;; Version: 0.1
7 ;; Maintainer: Daiki Ueno <ueno@gnu.org>
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
15
16 ;; GNU Emacs 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. If not, see <http://www.gnu.org/licenses/>.
23
24 ;;; Commentary:
25
26 ;; This package provides a minor mode to help editing C source code
27 ;; in the GNOME C coding style:
28 ;;
29 ;; <https://developer.gnome.org/programming-guidelines/stable/c-coding-style.html.en#header-files>
30 ;; <https://developer.gnome.org/programming-guidelines/stable/c-coding-style.html.en#functions>
31 ;;
32 ;; It basically provides two functions: code alignment and snippet
33 ;; insertion. To align code, use `gnome-c-style-align-decls-region'
34 ;; to line-up multiple function declarations in region, and
35 ;; `gnome-c-style-align-arglist-at-point' to line-up arguments in the
36 ;; argument list at point.
37 ;;
38 ;; To insert code snippet, use `gnome-c-snippet-insert'. The command
39 ;; will let you choose a template to be inserted. This package also
40 ;; provide commands to insert package/class names in upper case,
41 ;; capital case, and lower case. For complete list of commands, do
42 ;; M-x describe-bindings.
43
44 ;;; Code:
45
46 (require 'gnome-c-align)
47 (require 'gnome-c-snippet)
48
49 (defgroup gnome-c-style nil
50 "GNOME-style C source code editing"
51 :prefix "gnome-c-"
52 :group 'c)
53
54 (defvar gnome-c-style-mode-map
55 (let ((keymap (make-sparse-keymap)))
56 (define-key keymap "\C-c\C-ga" 'gnome-c-align-arglist-at-point)
57 (define-key keymap "\C-c\C-gr" 'gnome-c-align-decls-region)
58 (define-key keymap "\C-c\C-gf" 'gnome-c-align-set-column)
59 (define-key keymap "\C-c\C-gg" 'gnome-c-align-guess-columns)
60 (define-key keymap "\C-c\C-g\C-g" 'gnome-c-align-guess-optimal-columns)
61 (define-key keymap "\C-c\C-gc" 'gnome-c-snippet-insert-package_class)
62 (define-key keymap "\C-c\C-gC" 'gnome-c-snippet-insert-PACKAGE_CLASS)
63 (define-key keymap "\C-c\C-g\C-c" 'gnome-c-snippet-insert-PackageClass)
64 (define-key keymap "\C-c\C-gs" 'gnome-c-snippet-insert)
65 keymap))
66
67 ;;;###autoload
68 (define-minor-mode gnome-c-style-mode
69 "A minor-mode for editing GNOME-style C source code."
70 nil " GNOME" gnome-c-style-mode-map)
71
72 (provide 'gnome-c-style)
73
74 ;;; gnome-c-style.el ends here