-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgnustep.el
executable file
·184 lines (167 loc) · 5.94 KB
/
gnustep.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
;; Copyright (C) 2014, 2015 Germán A. Arias
;; This file is part of gs-emacs package
;; This application 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 application 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
;; Library General Public License for more details.
;; You should have received a copy of the GNU General Public
;; License along with this library; if not, write to the Free
;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
;; Menu for GNUstep development environment.
(require 'easymenu)
;; Get the path of gs-emacs resources.
(defconst gnustep-resources-dir (file-name-directory load-file-name)
"Directory containing GNUstep's resource files.")
;; Add the path of GNUstep script, if necessary. For example:
;;(defconst gs-script ". /usr/GNUstep/System/Library/Makefiles/GNUstep.sh;")
;; If not, leave this empty.
(defconst gs-script "")
;; Add the table for auto-completion.
(setq tags-file-name (expand-file-name "TAGS" gnustep-resources-dir))
;; Define a handler to open gorm/nib/xib files.
(defun gorm-file-handler (operation &rest args)
(cond ((eq operation 'load)
(shell-command (concat gs-script "gopen " (nth 0 args)))
(message "Open a gorm file")
(run-at-time "4 sec" nil 'close-buffer
(file-name-nondirectory (nth 0 args))))
;; Handle any operation we don't know about.
(t (let ((inhibit-file-name-handlers
(cons 'gorm-file-handler
(and (eq inhibit-file-name-operation operation)
inhibit-file-name-handlers)))
(inhibit-file-name-operation operation))
(apply operation args)))))
;; Close buffer of gorm/nib/xib file after load it.
(defun close-buffer (name) (kill-buffer name))
;; Add handlers.
(add-to-list 'file-name-handler-alist
(cons ".gorm\\'" 'gorm-file-handler))
(add-to-list 'file-name-handler-alist
(cons ".nib\\'" 'gorm-file-handler))
(add-to-list 'file-name-handler-alist
(cons ".xib\\'" 'gorm-file-handler))
;; Make a simple app project.
(defun make-app ()
(interactive)
(setq dir (read-file-name "Create App Project: "
default-directory
default-directory
nil
nil))
(setq dir (expand-file-name dir))
(setq gsapp (expand-file-name "Resources/App" gnustep-resources-dir))
(copy-directory gsapp
dir nil nil t)
;; Rename the interface file
(rename-file (expand-file-name "Resources/interface.gorm" dir)
(expand-file-name (concat "Resources/" (file-name-base dir)
".gorm")
dir) 1)
;; Rename the Info.plist file
(rename-file (expand-file-name "Info.plist" dir)
(expand-file-name (concat (file-name-base dir) "Info.plist")
dir) 1)
(dired dir)
(setq file (expand-file-name (concat (file-name-base dir) "Info.plist") dir))
(find-file-other-window file)
(goto-char (point-min))
(replace-string "[APP_NAME]" (file-name-base dir))
(save-buffer)
(setq file (expand-file-name "GNUmakefile" dir))
;;(find-file-other-window file)
(find-file file)
(goto-char (point-min))
(replace-string "[APP_NAME]" (file-name-base dir))
(save-buffer))
;; Make a simple tool project.
(defun make-tool ()
(interactive)
(setq dir (read-file-name "Create Tool Project: "
default-directory
default-directory
nil
nil))
(setq dir (expand-file-name dir))
(setq gsapp (expand-file-name "Resources/Tool" gnustep-resources-dir))
(copy-directory gsapp
dir nil nil t)
(dired dir)
(setq file (expand-file-name "GNUmakefile" dir))
(find-file-other-window file)
(goto-char (point-min))
(replace-string "[TOOL_NAME]" (file-name-base dir))
(save-buffer))
;; Replace foreign characters.
(defun replace-foreign-characters ()
(interactive)
(goto-char (point-min))
(replace-string "Á" "\\U00C1")
(goto-char (point-min))
(replace-string "É" "\\U00C9")
(goto-char (point-min))
(replace-string "Í" "\\U00CD")
(goto-char (point-min))
(replace-string "Ó" "\\U00D3")
(goto-char (point-min))
(replace-string "Ú" "\\U00DA")
(goto-char (point-min))
(replace-string "á" "\\U00E1")
(goto-char (point-min))
(replace-string "é" "\\U00E9")
(goto-char (point-min))
(replace-string "í" "\\U00ED")
(goto-char (point-min))
(replace-string "ó" "\\U00F3")
(goto-char (point-min))
(replace-string "ú" "\\U00FA")
(goto-char (point-min))
(replace-string "Ü" "\\U00DC")
(goto-char (point-min))
(replace-string "ü" "\\U00FC")
(goto-char (point-min))
(replace-string "¡" "\\U00A1")
(goto-char (point-min))
(replace-string "¿" "\\U00BF")
(goto-char (point-min))
(replace-string "Ñ" "\\U00D1")
(goto-char (point-min))
(replace-string "ñ" "\\U00F1")
(goto-char (point-min))
(replace-string "Ä" "\\U00C4")
(goto-char (point-min))
(replace-string "Ö" "\\U00D6")
(goto-char (point-min))
(replace-string "ß" "\\U00DF")
(goto-char (point-min))
(replace-string "ä" "\\U00E4")
(goto-char (point-min))
(replace-string "ö" "\\U00F6")
(goto-char (point-min))
(replace-string "Ç" "\\U00C7")
(goto-char (point-min))
(replace-string "ç" "\\U00E7")
(goto-char (point-min))
(replace-string "Ë" "\\U00CB")
(goto-char (point-min))
(replace-string "Ï" "\\U00CF")
(goto-char (point-min))
(replace-string "ë" "\\U00EB")
(goto-char (point-min))
(replace-string "ï" "\\U00EF")
)
;; Define the gs-emacs menu.
(easy-menu-define gnustep-menu global-map
"Menu for GNUstep development environment."
'("GNUstep"
;;:visible (string= "objc-mode" major-mode)
["App Project..." (make-app)
:enable (menu-bar-non-minibuffer-window-p)]
["Tool Project..." (make-tool)
:enable (menu-bar-non-minibuffer-window-p)]
["--" 'ignore]
["Replace foreign characters" (replace-foreign-characters)]))