]> code.delx.au - gnu-emacs-elpa/blob - packages/gnome-c-style/gnome-c-style.el
Merge '0c8e5e554199814c25258bc93b64dc008a9ab840', register assoc early.
[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 not part of GNU Emacs.
10
11 ;; This program is free software: you can redistribute it and/or
12 ;; modify it under the terms of the GNU General Public License as
13 ;; published by the Free Software Foundation, either version 3 of the
14 ;; License, or (at your option) any later version.
15
16 ;; This program is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program. If not, see
23 ;; <http://www.gnu.org/licenses/>.
24
25 ;;; Commentary:
26
27 ;; This package provides a minor mode to help editing C source code
28 ;; in the GNOME C coding style:
29 ;;
30 ;; <https://developer.gnome.org/programming-guidelines/stable/c-coding-style.html.en#header-files>
31 ;; <https://developer.gnome.org/programming-guidelines/stable/c-coding-style.html.en#functions>
32 ;;
33 ;; It basically provides two functions: code alignment and snippet
34 ;; insertion. To align code, use `gnome-c-style-align-region' to
35 ;; line-up multiple function declarations in region, and
36 ;; `gnome-c-style-align-at-point' to line-up arguments in the argument
37 ;; list at point.
38 ;;
39 ;; To insert code snippet, use `gnome-c-snippet-insert'. The command
40 ;; will let you choose a template to be inserted. This package also
41 ;; provide commands to insert package/class names in upper case,
42 ;; capital case, and lower case. For complete list of commands, do
43 ;; M-x describe-bindings.
44
45 ;;; Code:
46
47 (require 'gnome-c-align)
48 (require 'gnome-c-snippet)
49
50 (defgroup gnome-c-style nil
51 "GNOME-style C source code editing"
52 :prefix "gnome-c-"
53 :group 'c)
54
55 (defvar gnome-c-style-mode-map
56 (let ((keymap (make-sparse-keymap)))
57 (define-key keymap "\C-c\C-ga" 'gnome-c-align-arglist-at-point)
58 (define-key keymap "\C-c\C-gr" 'gnome-c-align-decls-region)
59 (define-key keymap "\C-c\C-gf" 'gnome-c-align-set-column)
60 (define-key keymap "\C-c\C-gg" 'gnome-c-align-guess-columns)
61 (define-key keymap "\C-c\C-g\C-g" 'gnome-c-align-guess-optimal-columns)
62 (define-key keymap "\C-c\C-gc" 'gnome-c-snippet-insert-package_class)
63 (define-key keymap "\C-c\C-gC" 'gnome-c-snippet-insert-PACKAGE_CLASS)
64 (define-key keymap "\C-c\C-g\C-c" 'gnome-c-snippet-insert-PackageClass)
65 (define-key keymap "\C-c\C-gs" 'gnome-c-snippet-insert)
66 keymap))
67
68 ;;;###autoload
69 (define-minor-mode gnome-c-style-mode
70 "A minor-mode for editing GNOME-style C source code."
71 nil " GNOME" gnome-c-style-mode-map)
72
73 (provide 'gnome-c-style)
74
75 ;;; gnome-c-style.el ends here