;; file specific-nagra-secure.el (message "> Begin nagra secure specific code") (defun bruce-disable-block-c (begin end) "switch block between #ifdef" (interactive "r") (let ((how-many 8) (my-symbol "DISABLE_") (me "FRE")) (while (> how-many 0) (setq how-many (- how-many 1)) (setq my-symbol (concat my-symbol (char-to-string (+ 65 (random 26)))))) (goto-char end) (insert (concat "#endif /* FIXME (" me ") : " my-symbol " */\n")) (goto-char begin) (insert (concat "#ifdef " my-symbol " /* FIXME (" me ") */ \n")) )) (defun bruce-enable-block-c () "remove current" (interactive) (let* ((my-line (buffer-substring (line-beginning-position) (line-end-position))) (beg-ifdef (line-beginning-position)) (end-ifdef (line-end-position)) (my-symbol (replace-regexp-in-string ".*if.*\\(DISABLE_.*?\\)\\ .*$" "\\1" my-line))) (if (search-forward my-symbol) (let() (delete-region (line-beginning-position) (line-end-position)) (delete-region beg-ifdef end-ifdef)) nil))) (defun bruce-figlet (begin end) "switch block between #ifdef" (interactive "r") (let* () (call-process-region begin end "C://cygnus//local//bin//figlet.exe" t t nil ))) ;; c-mode specific hook (defun c-workstation-specific () "" (interactive) (message "specific C nagra secure") (c-set-style "nagra") (auto-fill-mode t) (set-fill-column 80) (setq c-default-style (append '((c-mode . "nagra") ) c-default-style)) (define-key c-mode-map [(control c) (l)] 'center-line) (define-key c-mode-map [(control c) (w)] 'bruce-disable-block-c) (define-key c-mode-map [(control c) (control w)] 'bruce-enable-block-c) (define-key c-mode-map [(control x) (control s)] 'save-buffer-c) (define-key c-mode-map [(control c) (control d)] 'bruce-doxygen) (define-key c-mode-map [(f10)] 'complete-symbol) (define-key c-mode-map [(f5)] (lambda () nil (interactive) (compile (concat "~/bin/compile.sh " buffer-file-name)))) (define-key c-mode-map [(M-f5)] (lambda () nil (interactive) (compile "~/bin/fullbuild.sh"))) ;; (set 'compile-command ;; (concat "compile.sh" buffer-file-name)) ;; (compile))) (define-key c-mode-map [(M-f10)] 'find-tag-other-window) (define-key c-mode-map [(control c) (d) (p)] (lambda () nil (interactive) (insert "debugOutputPointer();"))) (define-key c-mode-map [(control c) (d) (e)] (lambda () nil (interactive) (insert "debugOutputEnum(,pTlsStatusToString);"))) (define-key c-mode-map [(control c) (d) (b)] (lambda () nil (interactive) (insert "debugOutputBoolean();"))) (define-key c-mode-map [(control c) (d) (o)] (lambda () nil (interactive) (insert "debugOutputObject();"))) (define-key c-mode-map [(control c) (d) (n)] (lambda () nil (interactive) (insert "debugOutputNumber(,DEBUG_FORMAT_);"))) (define-key c-mode-map [(control c) (d) (f)] (lambda () nil (interactive) (insert "debugOutputEntry(,DBG_PRECISE,DEBUG_ROLE_GENERIC);\n") (insert "debugOutputExit();\n"))) (define-key c-mode-map [(control c) (control f)] 'bruce-c-fixme ) (define-key c-mode-map [(control c) (d) (control h)] 'bruce-debug-file-header ) (define-key c-mode-map [(control c) (b)] (lambda () "insere @brief, pratique pour les doxycomments" (interactive) (insert "/**\n * @brief\n *"))) ) (defun save-buffer-c nil "untabify avant de sauver" (interactive) (untabify 0 (buffer-size)) (save-buffer) ) (defun bruce-debug-file-header nil "insert standard nagra header" (interactive) (insert (concat "debugDeclareFile (" (file-name-sans-extension (file-name-nondirectory buffer-file-name)) ",MOD_ );"))) (defun bruce-doxygen () "Lance doxygen sur le buffer courant" (interactive) (compile (concat "cd " (file-name-directory buffer-file-name) "../../../.. && bash.exe ./tools/doxygen/src/com/process.doxygen.sh " buffer-file-name)) (browse-url (concat "" (file-name-directory buffer-file-name) "../../../../obj/html/" (file-name-sans-extension (file-name-nondirectory buffer-file-name)) "_8c.html" ))) (defun tex-mode-specific () (flyspell-mode t) (setq ispell-parser 'tex)) ; keys bindings (global-set-key [(control l) (c)] 'ispell-word) (defun log-mode () (bruce-log-get-colors) ) ;; needed for cygwin (setq shell-file-name "bash") (setq explicit-shell-file-name shell-file-name) (setq process-coding-system-alist '(("bash" . undecided-unix))) (setq w32-quote-process-args ?\") (setenv "SHELL" shell-file-name) (add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m nil t) (add-hook 'comint-output-filter-functions 'comint-watch-for-password-prompt nil t) ;; compilation mode (add-hook 'compilation-filter 'shell-strip-ctrl-m nil t) (add-hook 'compilation-filter 'comint-watch-for-password-prompt nil t) (setq compilation-scroll-output t) (setq compile-auto-highlight t) (setq ps-lpr-switches '("/D:\\\\\\\\SATURNE2\\\\PRNT177-PS")) ; the printer name (setq ps-lpr-buffer "c:\\\\tmp\\\\psspool.ps") ; a tmp spool file (setq auto-mode-alist (append '( ("\\.xml$" . nxml-mode) ("\\.xsl$" . nxml-mode) ("\\.xsd$" . nxml-mode) ("\\.php$" . nxml-mode) ("\\.php3$" . nxml-mode) ("\\.cash$" . sh-mode) ("\\.pl$" . cperl-mode) ("\\.log$" . log-mode) )auto-mode-alist)) ;; autoxml mode ;;(load "C:/prog/emacs/emacs-21.3/site-lisp/nxml-mode-20041004/rng-auto.el") ;; use gnuserv for communication (setq gnuserv-frame (selected-frame)) ;;(set-frame-icon "C:/prog/emacs/gnuserv/emacs.ico") ;; ispell usage (setq ispell-program-name "c:/prog/aspell/bin/aspell") (setq aspell-dictionary "english") (setq ispell-dictionary "english") (setq flyspell-default-dictionary "english") ;; Nagra uses 2 char indentation (setq standard-indent 2) (setq c-basic-offset 2) ;; coding style (c-add-style "nagra" (quote ( ;; default offset for indenting is 2 space (c-basic-offset . 2) (c-backslash-column . 48) (c-cleanup-list scope-operator) (c-comment-only-line-offset . 0) (c-electric-pound-behavior) (c-hanging-braces-alist (brace-list-open) (brace-entry-open) (substatement-open after) (block-close . c-snug-do-while) (extern-lang-open after) (inexpr-class-open after) (inexpr-class-close before)) (c-hanging-colons-alist) (c-hanging-comment-starter-p . t) (c-hanging-comment-ender-p . t) (c-offsets-alist (string . c-lineup-dont-change) (c . c-lineup-C-comments) (defun-open . 0) (defun-close . 0) (defun-block-intro . +) (class-open . 0) (class-close . 0) (inline-open . +) (inline-close . 0) (func-decl-cont . +) (knr-argdecl-intro . +) (knr-argdecl . 0) (topmost-intro . 0) (topmost-intro-cont . 0) (member-init-intro . +) (member-init-cont . 0) (inher-intro . +) (inher-cont . c-lineup-multi-inher) (block-open . 0) (block-close . 0) (brace-list-open . 0) (brace-list-close . -) (brace-list-intro . +) (brace-list-entry . 0) (brace-entry-open . 0) (statement . 0) (statement-cont . +) (statement-block-intro . +) (statement-case-intro . +) (statement-case-open . 0) (substatement . +) ;; no offset when opening a block (substatement-open . 0) (case-label . 0) (access-label . -) (label . 2) (do-while-closure . 0) (else-clause . 0) (catch-clause . 0) (comment-intro . c-lineup-comment) (arglist-intro . +) (arglist-cont . 0) (arglist-cont-nonempty . c-lineup-arglist) (arglist-close . -) (stream-op . c-lineup-streamop) (inclass . +) (cpp-macro . -1000) (cpp-macro-cont . c-lineup-dont-change) (friend . 0) (objc-method-intro . -1000) (objc-method-args-cont . c-lineup-ObjC-method-args) (objc-method-call-cont . c-lineup-ObjC-method-call) (extern-lang-open . 0) (extern-lang-close . 0) (inextern-lang . +) (namespace-open . 0) (namespace-close . 0) (innamespace . +) (template-args-cont . +) (inlambda . c-lineup-inexpr-block) (lambda-intro-cont . +) (inexpr-statement . 0) (inexpr-class . +) ) ) ) ) ;; use library ansi-colors for logs (load-library "ansi-color") ;; use magenta instead of yellow for better lisibility (setq ansi-color-names-vector ["black" "red" "green" "magenta" "blue" "yellow" "cyan" "white"]) (setq ansi-color-map (ansi-color-make-color-map)) ;; defines useful functions for logs (defun bruce-log-get-colors () "get colors from an ANSI seq on a buffer" (interactive) (ansi-color-apply-on-region 0 (buffer-size))) (defun bruce-log-remove-timestamps () "remove timestamps from logs" (interactive) (replace-regexp "^\[[0-9]+\.[0-9][0-9][0-9]\]" "" nil 0 (buffer-size))) (defun bruce-log-remove-context (xContext) "remove trace from a context" (interactive "sContext to remove : ") (goto-char 0) (while (re-search-forward "\\[[0-9.]+\\] \\([A-Z1-9]+\\)-\\([A-Z1-9]+\\)" nil t) (if (equal (match-string 1) (upcase xContext)) (let () (goto-char (point-at-bol)) (kill-line nil))))) (defun bruce-log-keep-task (xContext) "remove trace from a context" (interactive "sTask to keep : ") (goto-char 0) (while (re-search-forward "\\[[0-9.]+\\] \\([-A-Z1-9]+\\)\\>" nil t) (if (not (equal (match-string 1) (upcase xContext))) (let () (goto-char (point-at-bol)) (kill-line nil))))) (setq woman-manpath (list "C:/cygnus/cygwin1.0/usr/man" "C:/cygnus/cygwin1.0/usr/share/man" "C:/cygnus/cygwin1.0/usr/local/share/man")) (setq woman-use-own-frame nil) (defun bruce-figlet (begin end) "switch block between #ifdef" (interactive "r") (let* () (call-process-region begin end "C://cygnus//local//bin//figlet.exe" t t ;; nil))) ;; "-d C://cygnus//local//share//figlet -f small " ))) " -f small " ))) (defun bruce-array-to-hexa () "encadre un bloc" (interactive) (if (and mark-active transient-mark-mode) (let ((beg (min (point) (mark))) (end (max (point) (mark)))) (replace-string "10," "a," nil beg end) (replace-string "11," "b," nil beg end) (replace-string "12," "c," nil beg end) (replace-string "13," "d," nil beg end) (replace-string "14," "e," nil beg end) (replace-string "15," "f," nil beg end) (replace-string "," "" nil beg end) ))) (set-foreground-color "ivory") (set-background-color "Black") (set-background-color "ivory") (set-background-color "floral white") (set-foreground-color "ivory") (set-background-color "Black") (set-foreground-color "grey") (set-background-color "Black") (set-cursor-color "Cyan") (scroll-bar-mode -1) (message "> End nagra secure specific code")