-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathphp-skeleton.el
150 lines (128 loc) · 3.77 KB
/
php-skeleton.el
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
;;; php-skeleton.el --- Skeleton template for PHP language strucures
;; Copyright (C) 2019 Friends of Emacs-PHP development
;; Copyright (C) 2015 David Arroyo Menéndez
;; Author: David Arroyo Menéndez <[email protected]>
;; Maintainer: USAMI Kenta <[email protected]>
;; Version: 0.0.1
;; Keywords: languages, php
;; URL: https://github.com/emacs-php/php-skeleton
;; Package-Requires: ((emacs "24.3"))
;; License: GPL-3.0-or-later
;; 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 this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; php-skeleton is some skeleton templates.
;; Control Structure functions
;; http://php.net/manual/en/language.control-structures.php
;; file:///usr/share/doc/php-doc/html/language.control-structures.html
;;; Code:
(define-skeleton php-if
"Insert a if statement"
""
'(setq condition (skeleton-read "Condition? ")) \n
> "if (" condition ") {" \n
> _ \n
( "other condition, %s: "
> -2 "}"
> " elseif (" str ") {" \n
> \n
> _ )
> -2 "}"
> " else {" \n
> _ \n
resume:
"}" \n)
(define-skeleton php-foreach
"Insert a foreach statement."
""
'(setq value (skeleton-read "Value variable? ")) \n
'(setq array (skeleton-read "Array? ")) \n
> "foreach (" array " as " value ") {" \n
> _ \n
> -2 "}" \n)
(define-skeleton php-for
"Insert a for statement."
""
'(setq index (skeleton-read "Index variable? ")) \n
'(setq condition (skeleton-read "Condition? ")) \n
> "for (" condition "; " index "++) {" \n
> _ \n
> -2 "}" \n)
(define-skeleton php-switch
"Insert a switch statement."
""
'(setq index (skeleton-read "Index variable? ")) \n
"switch (" index ") {" \n
( "Some case? %s: "
> "case " str ":" \n
> _ \n
> -2 "break;" \n
)
"}")
(define-skeleton php-switch-case
"Insert a switch statement."
""
( "Some case? %s: "
> "case " str ":" \n
> _ \n
> -2 "break;" \n
))
(define-skeleton php-include
"Insert a include statement."
""
'(setq file (skeleton-read "File? ")) \n
> "include_once '" file "';")
(define-skeleton php-include_once
"Insert a include_once statement."
""
'(setq file (skeleton-read "File? ")) \n
> "include_once '" file "';")
(define-skeleton php-return
"Insert a return statement."
""
> "return " _ ";")
(define-skeleton php-require
"Insert a require statement."
""
'(setq file (skeleton-read "File? ")) \n
> "require '" file "';")
(define-skeleton php-require_once
"Insert a require_once statement."
""
'(setq file (skeleton-read "File? ")) \n
> "require_once '" file "';")
(define-skeleton php-goto
"Insert a goto statement."
""
'(setq index (skeleton-read "Index variable? ")) \n
> "goto " index ";" \n
> _ \n
> index ":" \n
> _ \n)
(define-skeleton php-function
"Insert a function statement."
""
'(setq function (skeleton-read "Function name? ")) \n
'(setq argument (skeleton-read "Argument? ")) \n
> "function " function "(" argument
( "Another argument? %s: "
> ", " str )
> ") {" \n
_ \n
> "}")
(define-skeleton php-define
"Insert a define statement"
""
'(setq variable (skeleton-read "Variable? "))
'(setq value (skeleton-read "Value? "))
"define(\"" variable "\",\"" value "\");")
(provide 'php-skeleton)
;;; php-skeleton.el ends here