blob: 654792d31fff4ab2752421ae086c073e20a54a35 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
;;; pika variants of c skeletons
;; Copyright (C) 2004, 2005 Jose Antonio Ortega Ruiz
;; Author: Jose A Ortega Ruiz <jao@gnu.org>
;; Keywords: tools
;; This file 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 2, or (at your option)
;; any later version.
;; This file 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., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; Pika variants for c skeletons
;;; Code:
(require 'common-skel)
(defun jao-pika-guard ()
(upcase (concat "include__" (jao-basedir) "__" (jao-basename) "_h")))
(define-skeleton jao-pika-header
""
"Brief file description: "
"/* " (file-name-nondirectory (buffer-file-name)) ": " str
\n "*" > \n
"****************************************************************"
> \n (jao-copyright-line "* ")
> \n "*" > \n
"* See the file \"COPYING\" for further information about"
> n
"* the copyright and warranty status of this work."
> n
"*/" \n "" \n _)
(define-skeleton jao-skel-pika-h
"Standard pika c header"
nil
(jao-pika-header)
'(setq guard (jao-pika-guard))
"#ifndef " guard \n
"#define " guard \n
""
\n \n "#include \"" _ "\""\n \n
""
\n \n \n
""
\n
"#endif /* " guard " */"
\n \n "" \n
(jao-arch-line "/* " "*/")
\n)
(define-skeleton jao-skel-pika-c
"Standard pika c body"
nil
(jao-pika-header)
\n "#include \"" (jao-dir-level 2) ".h\"" \n
\n
""
\n \n _ \n \n "" \n
(jao-arch-line "/* " "*/")
\n)
(defun jao-skel-pika-activate ()
(interactive)
(let ((c (assoc "\\.c$" auto-insert-alist))
(h (assoc "\\.h$" auto-insert-alist)))
(if c (setf (cdr c) 'jao-skel-pika-c)
(add-to-list 'auto-insert-alist '("\\.c$" . jao-skel-pika-c)))
(if h (setf (cdr h) 'jao-skel-pika-h)
(add-to-list 'auto-insert-alist '("\\.h$" . jao-skel-pika-h)))))
(provide 'pika-skel)
|