My favorites | Sign in
Project Logo
Project hosting will be READ-ONLY Wednesday at 8am PST due to brief network maintenance.
                
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
; -*- mode: lisp -*-

(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(auto-compression-mode t nil (jka-compr))
'(blink-cursor-mode nil)
'(c-default-style (quote ((c-mode . "cc-mode") (java-mode . "java") (other . "gnu"))))
'(case-fold-search t)
'(column-number-mode t)
'(cscope-database-file "/home/gustavo/Development/cscope.out")
'(current-language-environment "UTF-8")
'(default-input-method "rfc1345")
'(global-font-lock-mode t nil (font-lock))
'(indent-tabs-mode nil)
'(indicate-empty-lines t)
'(inhibit-startup-screen t)
'(ispell-program-name "aspell" t)
'(iswitchb-mode t)
'(menu-bar-mode nil)
'(mmm-global-mode (quote maybe) nil (mmm-mode))
'(mouse-wheel-mode t nil (mwheel))
'(require-final-newline t)
'(safe-local-variable-values (quote ((mmm-classes . edje-lua) (todo-categories "Personal" "Evasive" "Guarana" "Personal" "Tecsys-STB" "Evasive" "Guarana") (todo-categories "Personal" "Tecsys-STB" "Evasive" "Guarana"))))
'(save-place t nil (saveplace))
'(scroll-bar-mode nil)
'(semanticdb-default-system-save-directory "/home/gustavo/.semantic.db" t)
'(show-paren-mode t nil (paren))
'(show-trailing-whitespace t)
'(speedbar-frame-parameters (quote ((minibuffer) (width . 20) (border-width . 0) (menu-bar-lines . 0) (tool-bar-lines . 0) (unsplittable . t) (set-background-color "black"))))
'(tab-width 8)
'(tool-bar-mode nil nil (tool-bar))
'(transient-mark-mode t)
'(uniquify-buffer-name-style (quote forward) nil (uniquify))
'(version-control nil))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:stipple nil :background "#000000" :foreground "#d9d9d9" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 80 :width normal :family "terminus"))))
'(background "blue")
'(diff-added ((t (:inherit diff-changed-face :foreground "#00ff00"))))
'(diff-added-face ((t (:inherit diff-changed-face :foreground "#00ff00"))) t)
'(diff-changed ((t (:foreground "#ffff00"))))
'(diff-changed-face ((t (:foreground "#ffff00"))) t)
'(diff-file-header ((t (:background "grey20" :foreground "wheat" :weight bold))))
'(diff-file-header-face ((t (:background "grey20" :foreground "wheat" :weight bold))) t)
'(diff-function ((t (:inherit diff-context-face :foreground "#00ffff"))))
'(diff-function-face ((t (:inherit diff-context-face :foreground "#00ffff"))) t)
'(diff-header ((((class color) (background dark)) (:background "grey20" :foreground "grey75"))))
'(diff-header-face ((((class color) (background dark)) (:background "grey20" :foreground "grey75"))) t)
'(diff-hunk-header ((t (:inherit diff-header-face :foreground "#ff00ff"))))
'(diff-hunk-header-face ((t (:inherit diff-header-face :foreground "#ff00ff"))) t)
'(diff-removed ((t (:inherit diff-changed-face :foreground "#ff0000"))))
'(diff-removed-face ((t (:inherit diff-changed-face :foreground "#ff0000"))) t)
'(highlight ((t (:background "CornflowerBlue"))))
'(list-mode-item-selected ((t (:background "gold"))))
'(makefile-space-face ((t (:background "wheat"))) t)
'(mmm-default-submode-face ((t (:background "gray15"))))
'(mode-line ((t (:background "#333333" :foreground "wheat"))))
'(mode-line-inactive ((default (:inherit mode-line)) (((class color) (min-colors 88) (background dark)) (:background "grey10" :foreground "grey40" :box (:line-width -1 :color "grey30") :weight light))))
'(paren-match ((t (:background "cyan"))))
'(region ((t (:background "#005577"))))
'(semantic-highlight-edits-face ((((class color) (background dark)) (:background "#222200"))))
'(show-paren-match ((t (:foreground "black" :background "cyan"))))
'(show-paren-mismatch ((((class color)) (:foreground "white" :background "red"))))
'(speedbar-button-face ((((class color) (background dark)) (:foreground "green4"))))
'(speedbar-directory-face ((((class color) (background dark)) (:foreground "khaki"))))
'(speedbar-file-face ((((class color) (background dark)) (:foreground "cyan"))))
'(speedbar-tag-face ((((class color) (background dark)) (:foreground "Springgreen"))))
'(which-func ((((class color) (min-colors 88) (background dark)) (:foreground "#00ffff"))))
'(widget-field ((((class grayscale color) (background light)) (:background "DarkBlue")))))

(defun re-read-current-file ()
(interactive)
(find-file buffer-file-truename))

(defun search-word-under-cursor ()
"Performs a nonincremental-search-forward. The word at or near point
is the word to search for."
(interactive)
(let ((word (current-word)))
(nonincremental-search-forward word)))


(global-set-key [(M delete)] 'delete-region)
(global-set-key "\M-g" 'goto-line)
(global-set-key [f1] 'manual-entry)
(global-set-key [f2] 'save-buffer)
(global-set-key [f3] 'search-word-under-cursor)
(global-set-key [f4] 'find-file)
(global-set-key [f5] 'compile)
(global-set-key [f6] 'ff-find-other-file)
(global-set-key [f7] 're-read-current-file)
(global-set-key [f8] 'gobject-class-generate)
(global-set-key [(shift f1)] 'cscope-find-this-symbol)
(global-set-key [(shift f2)] 'cscope-find-global-definition)
(global-set-key [(shift f3)] 'cscope-find-functions-calling-this-function)
(global-set-key [(shift f4)] 'cscope-find-egrep-pattern)
(global-set-key [(shift f5)] 'cscope-find-this-file)
(global-set-key [(shift f6)] 'cscope-find-this-text-string)
(global-set-key [(shift f7)] 'cscope-find-files-including-file)
(global-set-key [(shift f9)] 'cscope-prev-symbol)
(global-set-key [(shift f10)] 'cscope-next-symbol)
(global-set-key [(shift f11)] 'cscope-prev-file)
(global-set-key [(shift f12)] 'cscope-next-file)
(global-set-key [(shift prior)] 'previous-multiframe-window)
(global-set-key [(shift next)] 'next-multiframe-window)

(global-set-key [(control tab)] 'bs-cycle-next)
(global-set-key [(control prior)] 'previous-multiframe-window)
(global-set-key [(control next)] 'next-multiframe-window)

(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)
(global-set-key [f11] 'git-status)

(c-add-style
"e17"
'("gnu"
(indent-tabs-mode . t)
(tab-width . 8)
(c-offsets-alist
.
((defun-block-intro . 3)
(statement-block-intro . 3)
(case-label . 1)
(statement-case-intro . 3)
(inclass . 3)
))))

(c-add-style
"linux4"
'("linux"
(indent-tabs-mode . nil)
(tab-width . 8)
(c-basic-offset . 4)))

(c-add-style
"linux2"
'("linux"
(indent-tabs-mode . nil)
(tab-width . 8)
(c-basic-offset . 2)))

(c-add-style
"webkit"
'((c-tab-always-indent . f)
(indent-tabs-mode . nil)
(tab-width . 8)
(c-basic-offset . 4)
(c-offsets-alist
.
((innamespace . 0)
(inline-open . 0)
(label . 0)
(statement-cont . +)))))

(defun evas-c-mode-hooks ()
(let ((path (buffer-file-name)))
(cond
((string-match "/evas/src/" path) (c-set-style "e17"))
((string-match "/svn/e" path) (c-set-style "e17"))
((string-match "/e17/" path) (c-set-style "e17"))
)
)
)
(add-hook 'c-mode-common-hook 'evas-c-mode-hooks)

(defun profusion-c-mode-hooks ()
(let ((path (buffer-file-name)))
(cond
((string-match "guarana" path) (c-set-style "linux4"))
((string-match "tecsys-stb" path) (c-set-style "linux4"))
((string-match "evasive" path) (c-set-style "linux4"))
)
)
)
(add-hook 'c-mode-common-hook 'profusion-c-mode-hooks)

(defun webkit-c-mode-hooks ()
(let ((path (buffer-file-name)))
(cond
((string-match "/webkit/" path) (c-set-style "webkit"))
)
)
)
(add-hook 'c-mode-common-hook 'webkit-c-mode-hooks)

(defun poor-mans-csharp-mode ()
(java-mode)
(setq mode-name "C#")
(set-variable 'tab-width 8)
(set-variable 'indent-tabs-mode t)
(set-variable 'c-basic-offset 8)
(c-set-offset 'inline-open 0)
(c-set-offset 'case-label 0)
)

(setq auto-mode-alist (append '(("\\.cs\\'" . poor-mans-csharp-mode))
auto-mode-alist))


;; webkit has no tab in changelog
;; (defun my-change-log-mode-common-hook ()
;; ;; highlight tabs
;; (font-lock-add-keywords nil my-extra-keywords)
;; ;; other customizations
;; (setq tab-width 8
;; ;; this will make sure spaces are used instead of tabs
;; indent-tabs-mode nil)
;; )
;; (add-hook 'change-log-mode-hook 'my-change-log-mode-common-hook)


(defun string-join (list separator)
"Takes a list of string and joins them using delimiter."
(mapconcat (lambda (x) x) list separator))

(defun string-concat (list)
"Takes a list of strings and joins them."
(mapconcat (lambda (x) x) list ""))

(defun ask-value-non-empty (prompt)
"Ask a question in minibuffer and ensure it's not empty string."
(let ((x (read-string prompt)))
(if (string= "" x)
(ask-value-non-empty prompt)
x)))

(defun gobject-class-header (class_name parent_class_name)
"Generate the header definition for a GObject derived class.

It takes 2 parameters:
CLASS_NAME: class name, like 'gtk_button' or 'gtk_tree_view'. First
element before the underscore character (_) will be used as name
space. Example: 'gtk_button' is the 'button' class in 'gtk' name
space.
PARENT_CLASS_NAME: parent class name, like 'g_object'. First element
before the underscore character (_) will be used as name space.
Example: 'g_object' is the 'object' class in 'g' namespace.
"
(interactive "sClass name (ie: gtk_tree_view): \nsParent class name (default: g_object): ")

(defun right-fill (len string)
"Takes a string and fill it to take at least len characters"
(setq missing (- len (length string)))
(if (> missing 0)
(concat string (make-string missing ?\ ))
string))
(defun macro-line-cnt (&rest sequences)
(concat (right-fill 72 (string-concat sequences)) "\\\n"))
(defun macro-line-end (&rest sequences)
(concat (string-concat sequences) "\n"))


(let* ((parent_class_name (if (string= "" parent_class_name)
"g_object"
(downcase parent_class_name)))
(class_name (downcase (if (string= "" class_name)
(ask-value-non-empty
"You must provide class name (ie: gtk_tree_view): ")
class_name)))
(pieces-class_name (split-string (downcase class_name) "_"))
(pieces-parent_class_name (split-string parent_class_name "_"))
(namespace (car-safe pieces-class_name))
(name (string-join (cdr-safe pieces-class_name) "_"))
(ParentClassName (mapconcat 'capitalize pieces-parent_class_name ""))
(NAMESPACE (upcase namespace))
(NAME (upcase name))
(NameSpace (capitalize namespace))
(Name (mapconcat 'capitalize (cdr-safe pieces-class_name) ""))
(ClassName (concat NameSpace Name))
)

(insert
(concat
"\n"
"G_BEGIN_DECLS\n"
"\n"
(macro-line-cnt "#define " NAMESPACE "_TYPE_" NAME)
(macro-line-end " (" namespace "_" name "_get_type())")
(macro-line-cnt "#define " NAMESPACE "_" NAME "(obj)")
(macro-line-cnt " (G_TYPE_CHECK_INSTANCE_CAST ((obj),")
(macro-line-cnt " " NAMESPACE "_TYPE_" NAME ",")
(macro-line-end " " ClassName "))")
(macro-line-cnt "#define " NAMESPACE "_" NAME "_CLASS(klass)")
(macro-line-cnt " (G_TYPE_CHECK_CLASS_CAST ((klass),")
(macro-line-cnt " " NAMESPACE "_TYPE_" NAME ",")
(macro-line-end " " ClassName "Class))")
(macro-line-cnt "#define " NAMESPACE "_IS_" NAME "(obj)")
(macro-line-cnt " (G_TYPE_CHECK_INSTANCE_TYPE ((obj),")
(macro-line-end " " NAMESPACE "_TYPE_" NAME "))")
(macro-line-cnt "#define " NAMESPACE "_IS_" NAME "_CLASS(klass)")
(macro-line-cnt " (G_TYPE_CHECK_CLASS_TYPE ((klass),")
(macro-line-end " " NAMESPACE "_TYPE_" NAME "))")
(macro-line-cnt "#define " NAMESPACE "_" NAME "_GET_CLASS(obj)")
(macro-line-cnt " (G_TYPE_INSTANCE_GET_CLASS ((obj),")
(macro-line-cnt " " NAMESPACE "_TYPE_" NAME ",")
(macro-line-end " " ClassName "Class))")
"\n"
"typedef struct _" ClassName " " ClassName ";\n"
"typedef struct _" ClassName "Class " ClassName "Class;\n"
"\n"
"struct _" ClassName "Class\n"
"{\n"
" " ParentClassName "Class parent_class;\n"
"};\n"
"\n"
"struct _" ClassName "\n"
"{\n"
" " ParentClassName " parent;\n"
"};\n"
"\n"
"GType " namespace "_" name "_get_type (void) G_GNUC_CONST;\n"
"\n"
"G_END_DECLS\n"
"\n"
)
)
)
)

(defun gobject-class-code (class_name parent_class_name)
"Generate the code implementation for a GObject derived class.

It takes 2 parameters:
CLASS_NAME: class name, like 'gtk_button' or 'gtk_tree_view'. First
element before the underscore character (_) will be used as name
space. Example: 'gtk_button' is the 'button' class in 'gtk' name
space.
PARENT_CLASS_NAME: parent class name, like 'g_object'. First element
before the underscore character (_) will be used as name space.
Example: 'g_object' is the 'object' class in 'g' namespace.
"
(interactive "sClass name (ie: gtk_tree_view): \nsParent class name (default: g_object): ")

(let* ((parent_class_name (if (string= "" parent_class_name)
"g_object"
(downcase parent_class_name)))
(class_name (downcase (if (string= "" class_name)
(ask-value-non-empty
"You must provide class name (ie: gtk_tree_view): ")
class_name)))
(pieces-class_name (split-string (downcase class_name) "_"))
(pieces-parent_class_name (split-string parent_class_name "_"))
(namespace (car-safe pieces-class_name))
(name (string-join (cdr-safe pieces-class_name) "_"))
(ParentClassName (mapconcat 'capitalize pieces-parent_class_name ""))
(NameSpace (capitalize namespace))
(Name (mapconcat 'capitalize (cdr-safe pieces-class_name) ""))
(ClassName (concat NameSpace Name))
(class_name (concat namespace "_" name))
(PARENT_NAMESPACE (upcase (car-safe pieces-parent_class_name)))
(PARENT_NAME (mapconcat 'upcase (cdr-safe pieces-parent_class_name) "_"))
)

(insert
(concat
"\n"
"static void " class_name "_dispose (GObject *object);\n"
"static void " class_name "_finalize (GObject *object);\n"
"\n"
"G_DEFINE_TYPE (" ClassName ", " class_name ", " PARENT_NAMESPACE "_TYPE_" PARENT_NAME ");\n"
"\n"
"static void\n"
class_name "_class_init (" ClassName "Class *klass)\n"
"{\n"
" GObjectClass *gobject_class = (GObjectClass *)klass;\n"
"\n"
" gobject_class->dispose = " class_name "_dispose;\n"
" gobject_class->finalize = " class_name "_finalize;\n"
"}\n"
"\n"
"static void\n"
class_name "_init (" ClassName " *self)\n"
"{\n"
"}\n"
"\n"
"static void\n"
class_name "_dispose (GObject *object)\n"
"{\n"
" " ClassName " *self = (" ClassName " *)object;\n"
"\n"
" G_OBJECT_CLASS (" class_name "_parent_class)->dispose (object);\n"
"}\n"
"\n"
"static void\n"
class_name "_finalize (GObject *object)\n"
"{\n"
" " ClassName " *self = (" ClassName " *)object;\n"
"\n"
" g_signal_handlers_destroy (object);\n"
" G_OBJECT_CLASS (" class_name "_parent_class)->finalize (object);\n"
"}\n"
"\n"
)
)
)
)

(defun gobject-class-generate (class_name parent_class_name)
"Generate header (.h) and code (.c) files for a GObject derived class.

It takes 2 parameters:
CLASS_NAME: class name, like 'gtk_button' or 'gtk_tree_view'. First
element before the underscore character (_) will be used as name
space. Example: 'gtk_button' is the 'button' class in 'gtk' name
space.
PARENT_CLASS_NAME: parent class name, like 'g_object'. First element
before the underscore character (_) will be used as name space.
Example: 'g_object' is the 'object' class in 'g' namespace.
"
(interactive "sClass name (ie: gtk_tree_view): \nsParent class name (default: g_object): ")

(let* ((parent_class_name (if (string= "" parent_class_name)
"g_object"
(downcase parent_class_name)))
(class_name (downcase (if (string= "" class_name)
(ask-value-non-empty
"You must provide class name (ie: gtk_tree_view): ")
class_name)))
(pieces-class_name (split-string (downcase class_name) "_"))
(pieces-parent_class_name (split-string parent_class_name "_"))
(base_file_name (string-join pieces-class_name "-"))
(file_header (concat base_file_name ".h"))
(file_code (concat base_file_name ".c"))
(DEFINE_NAME (concat (upcase class_name) "_H"))
(parent_include (if (string= "g_object" parent_class_name)
"glib-object.h"
(if (string-match "^gtk_" parent_class_name)
"gtk/gtk.h"
(concat (string-join pieces-parent_class_name "-") ".h")
)
))
)

(delete-other-windows)
(split-window-vertically)

(find-file file_header)
(insert
(concat
"#ifndef __" DEFINE_NAME "__\n"
"#define __" DEFINE_NAME "__\n"
"\n"
"#include <" parent_include ">\n"
"\n"))
(gobject-class-header class_name parent_class_name)
(insert "#endif /* __" DEFINE_NAME "__ */\n")

(other-window 1)

(find-file file_code)
(insert
(concat
"#include \"" file_header "\"\n"
"\n"))
(gobject-class-code class_name parent_class_name)
)
)

(defun insert-license ()
(interactive)
(insert
"/*
* Canola library
* Copyright (C) 2008 ProFUSION embedded systems
* @author Gustavo Sverzut Barbieri <barbieri@profusion.mobi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 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 Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
"))

(defun insert-include-config ()
(interactive)
(insert
"
#ifdef HAVE_CONFIG_H
#include \"config.h\"
#endif

"))

(defun insert-license-and-include-config ()
(interactive)
(insert-license)
(insert-include-config))

(put 'downcase-region 'disabled nil)

(setq load-path (cons "/home/gustavo/.emacs.d/site-packages" load-path))

(add-to-list 'load-path "/home/gustavo/.emacs.d/site-packages/pyrex-mode.el")
(add-to-list 'auto-mode-alist '("\\.pyx$\\|\\.pxi$\\|\\.pxd$" . pyrex-mode))
(autoload 'pyrex-mode "pyrex-mode")

(add-to-list 'load-path "/home/gustavo/.emacs.d/site-packages/edje-mode.el")
(add-to-list 'auto-mode-alist '("\\.edc$" . edje-mode))
(autoload 'edje-mode "edje-mode")

(add-to-list 'load-path "/home/gustavo/.emacs.d/site-packages/edje-lua-mode.el")
(require 'edje-lua-mode)

(put 'upcase-region 'disabled nil)

(require 'xcscope)
(require 'taskjuggler-mode)

(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))

(require 'session)
(add-hook 'after-init-hook 'session-initialize)

(require 'pastebin)

(server-start)
Show details Hide details

Change log

r169 by barbieri on Jan 06, 2010   Diff
sync with my .emacs
Go to: 
Project members, sign in to write a code review

Older revisions

r165 by barbieri on May 25, 2009   Diff
add my mod pastebin.el

this mod will report yrl in message as
well.
r164 by barbieri on Apr 27, 2009   Diff
update my .emacs
r143 by barbieri on Dec 04, 2008   Diff
update my .emacs
All revisions of this file

File info

Size: 20139 bytes, 533 lines
Hosted by Google Code