Initial commit
This commit is contained in:
commit
99e3df82b7
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.elc
|
26
configs/coding-style.el
Normal file
26
configs/coding-style.el
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
(add-to-list 'c-style-alist
|
||||||
|
'("epita"
|
||||||
|
(c-basic-offset . 2)
|
||||||
|
(c-comment-only-line-offset . 0)
|
||||||
|
(c-hanging-braces-alist . ((substatement-open before after)))
|
||||||
|
(c-offsets-alist . ((topmost-intro . 0)
|
||||||
|
(substatement . +)
|
||||||
|
(substatement-open . 0)
|
||||||
|
(case-label . +)
|
||||||
|
(access-label . -)
|
||||||
|
(inclass . ++)
|
||||||
|
(inline-open . 0)))))
|
||||||
|
|
||||||
|
(c-add-style
|
||||||
|
"e"
|
||||||
|
'("gnu"
|
||||||
|
(show-trailing-whitespace t)
|
||||||
|
(indent-tabs-mode . nil)
|
||||||
|
(tab-width . 8)
|
||||||
|
(c-offsets-alist .
|
||||||
|
((defun-block-intro . 3)
|
||||||
|
(statement-block-intro . 3)
|
||||||
|
(case-label . 1)
|
||||||
|
(statement-case-intro . 3)
|
||||||
|
(inclass . 3)
|
||||||
|
))))
|
114
configs/custom.el
Normal file
114
configs/custom.el
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
;; Remove useless features
|
||||||
|
(menu-bar-mode nil)
|
||||||
|
;(tool-bar-mode nil)
|
||||||
|
;(scroll-bar-mode nil)
|
||||||
|
(setq inhibit-startup-message t)
|
||||||
|
|
||||||
|
;;Save backup files into a specific directory, not in the working directry
|
||||||
|
(defun make-backup-file-name (file)
|
||||||
|
(concat "~/.emacs.d/backup/" (file-name-nondirectory file) "~"))
|
||||||
|
|
||||||
|
;; Enable some minor mode changing mode line
|
||||||
|
(column-number-mode t) ; Show column number
|
||||||
|
(line-number-mode t) ; Show line number
|
||||||
|
(display-time-mode t) ; A clock in the mode line
|
||||||
|
|
||||||
|
;; Show matching parentheses
|
||||||
|
(show-paren-mode t)
|
||||||
|
(defadvice show-paren-function
|
||||||
|
(after show-matching-paren-offscreen activate)
|
||||||
|
"If the matching paren is offscreen, show the matching line in the
|
||||||
|
echo area. Has no effect if the character before point is not of
|
||||||
|
the syntax class ')'."
|
||||||
|
(interactive)
|
||||||
|
(if (not (minibuffer-prompt))
|
||||||
|
(let ((matching-text nil))
|
||||||
|
;; Only call `blink-matching-open' if the character before point
|
||||||
|
;; is a close parentheses type character. Otherwise, there's not
|
||||||
|
;; really any point, and `blink-matching-open' would just echo
|
||||||
|
;; "Mismatched parentheses", which gets really annoying.
|
||||||
|
(if (char-equal (char-syntax (char-before (point))) ?\))
|
||||||
|
(setq matching-text (blink-matching-open)))
|
||||||
|
(if (not (null matching-text))
|
||||||
|
(message matching-text)))))
|
||||||
|
|
||||||
|
;; Enable usefull modes
|
||||||
|
(global-font-lock-mode t) ; syntax highlighting
|
||||||
|
(setq font-lock-maximum-decoration t) ; max decoration for all modes
|
||||||
|
(auto-compression-mode t) ; Auto decompress compressed files.
|
||||||
|
(setq set-mark-command-repeat-pop t)
|
||||||
|
(autoload 'nuke-trailing-whitespace "whitespace" nil t)
|
||||||
|
(setq delete-old-versions t) ; delete oldversion file
|
||||||
|
(setq default-major-mode 'text-mode) ; change default major mode to text
|
||||||
|
(global-auto-revert-mode t) ; auto revert modified files
|
||||||
|
(dynamic-completion-mode) ; dynamic completion
|
||||||
|
|
||||||
|
;; setting for auto-close brackets for electric-pair-mode regardless of current major mode syntax table
|
||||||
|
(electric-pair-mode t)
|
||||||
|
(setq electric-pair-pairs '(
|
||||||
|
(?\" . ?\")
|
||||||
|
(?\{ . ?\})
|
||||||
|
) )
|
||||||
|
|
||||||
|
;; In linux, make copy/paste work with other apps
|
||||||
|
(setq x-select-enable-clipboard t)
|
||||||
|
|
||||||
|
;; Compilation window
|
||||||
|
(setq compilation-window-height 14)
|
||||||
|
(setq compilation-scroll-output t)
|
||||||
|
|
||||||
|
(require 'uniquify)
|
||||||
|
(setq uniquify-buffer-name-style 'post-forward-angle-brackets)
|
||||||
|
|
||||||
|
(setq-default ispell-program-name "aspell")
|
||||||
|
|
||||||
|
;; GDB use all existing window
|
||||||
|
(setq-default gdb-many-windows t)
|
||||||
|
|
||||||
|
;; Recognize test suite output
|
||||||
|
(require 'compile)
|
||||||
|
(add-to-list 'compilation-error-regexp-alist '("^\\(PASS\\|SKIP\\|XFAIL\\|TFAIL\\): \\(.*\\)$" 2 () () 0 2))
|
||||||
|
(add-to-list 'compilation-error-regexp-alist '("^\\(FAIL\\|XPASS\\): \\(.*\\)$" 2 () () 2 2))
|
||||||
|
|
||||||
|
(require 'flymake)
|
||||||
|
(add-hook 'find-file-hooks 'flymake-find-file-hook)
|
||||||
|
|
||||||
|
;;IswitchBuffer configuration
|
||||||
|
(iswitchb-mode t)
|
||||||
|
(setq iswitchb-buffer-ignore '("^\\*"))
|
||||||
|
(defun iswitchb-local-keys ()
|
||||||
|
(mapc (lambda (K)
|
||||||
|
(let* ((key (car K)) (fun (cdr K)))
|
||||||
|
(define-key iswitchb-mode-map (edmacro-parse-keys key) fun)))
|
||||||
|
'(("<right>" . iswitchb-next-match)
|
||||||
|
("<left>" . iswitchb-prev-match)
|
||||||
|
("<up>" . ignore )
|
||||||
|
("<down>" . ignore ))))
|
||||||
|
(add-hook 'iswitchb-define-mode-map-hook 'iswitchb-local-keys)
|
||||||
|
|
||||||
|
;; Save and restore window layout
|
||||||
|
(defvar winconf-ring ())
|
||||||
|
|
||||||
|
(defun push-winconf ()
|
||||||
|
(interactive)
|
||||||
|
(window-configuration-to-register ?%)
|
||||||
|
(push (get-register ?%) winconf-ring))
|
||||||
|
|
||||||
|
(defun pop-winconf ()
|
||||||
|
(interactive)
|
||||||
|
(set-register ?% (pop winconf-ring))
|
||||||
|
(jump-to-register ?%))
|
||||||
|
|
||||||
|
(defun restore-winconf ()
|
||||||
|
(interactive)
|
||||||
|
(set-register ?% (car winconf-ring))
|
||||||
|
(jump-to-register ?%))
|
||||||
|
|
||||||
|
;; highlight when > 80 cols
|
||||||
|
(defun eightycols nil
|
||||||
|
(defface line-overflow
|
||||||
|
'((t (:background "red" :foreground "black")))
|
||||||
|
"Face to use for `hl-line-face'.")
|
||||||
|
(highlight-regexp "^.\\{80,\\}$" 'line-overflow)
|
||||||
|
)
|
||||||
|
;(add-hook 'find-file-hook 'eightycols)
|
173
configs/editing.el
Normal file
173
configs/editing.el
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
(defun c-switch-hh-cc ()
|
||||||
|
(interactive)
|
||||||
|
(let ((other
|
||||||
|
(let ((file (buffer-file-name)))
|
||||||
|
(if (string-match "\\.hh$" file)
|
||||||
|
(replace-regexp-in-string "\\.hh$" ".cc" file)
|
||||||
|
(replace-regexp-in-string "\\.cc$" ".hh" file)))))
|
||||||
|
(find-file other)))
|
||||||
|
|
||||||
|
(defun count-word (start end)
|
||||||
|
(let ((begin (min start end))(end (max start end)))
|
||||||
|
(save-excursion
|
||||||
|
(goto-char begin)
|
||||||
|
(re-search-forward "\\W*") ; skip blank
|
||||||
|
(setq i 0)
|
||||||
|
(while (< (point) end)
|
||||||
|
(re-search-forward "\\w+")
|
||||||
|
(when (<= (point) end)
|
||||||
|
(setq i (+ 1 i)))
|
||||||
|
(re-search-forward "\\W*"))))
|
||||||
|
i)
|
||||||
|
|
||||||
|
(defun stat-region (start end)
|
||||||
|
(interactive "r")
|
||||||
|
(let
|
||||||
|
((words (count-word start end)) (lines (count-lines start end)))
|
||||||
|
(message
|
||||||
|
(concat "Lines: "
|
||||||
|
(int-to-string lines)
|
||||||
|
" Words: "
|
||||||
|
(int-to-string words)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(defun ruby-command (cmd &optional output-buffer error-buffer)
|
||||||
|
"Like shell-command, but using ruby."
|
||||||
|
(interactive (list (read-from-minibuffer "Ruby command: "
|
||||||
|
nil nil nil 'ruby-command-history)
|
||||||
|
current-prefix-arg
|
||||||
|
shell-command-default-error-buffer))
|
||||||
|
(shell-command (concat "ruby -e '" cmd "'") output-buffer error-buffer))
|
||||||
|
|
||||||
|
;; Shebangs
|
||||||
|
|
||||||
|
(defun insert-shebang (bin)
|
||||||
|
(interactive "sBin: ")
|
||||||
|
(save-excursion
|
||||||
|
(goto-char (point-min))
|
||||||
|
(insert "#!" bin "\n\n")))
|
||||||
|
|
||||||
|
(defun insert-shebang-if-empty (bin)
|
||||||
|
(when (buffer-empty-p)
|
||||||
|
(insert-shebang bin)))
|
||||||
|
|
||||||
|
;; C/C++
|
||||||
|
|
||||||
|
;; Comment boxing
|
||||||
|
|
||||||
|
(defun insert-header-guard ()
|
||||||
|
(interactive)
|
||||||
|
(save-excursion
|
||||||
|
(when (buffer-file-name)
|
||||||
|
(let*
|
||||||
|
((name (file-name-nondirectory buffer-file-name))
|
||||||
|
(macro (replace-regexp-in-string
|
||||||
|
"\\." "_"
|
||||||
|
(replace-regexp-in-string
|
||||||
|
"-" "_"
|
||||||
|
(upcase name)))))
|
||||||
|
(goto-char (point-min))
|
||||||
|
(insert "#ifndef " macro "_\n")
|
||||||
|
(insert "# define " macro "_\n\n")
|
||||||
|
(goto-char (point-max))
|
||||||
|
(insert "\n#endif /* !" macro "_ */\n")))))
|
||||||
|
|
||||||
|
(defun insert-header-inclusion ()
|
||||||
|
(interactive)
|
||||||
|
(when (buffer-file-name)
|
||||||
|
(let
|
||||||
|
((name
|
||||||
|
(replace-regexp-in-string ".c$" ".h"
|
||||||
|
(replace-regexp-in-string ".cc$" ".hh"
|
||||||
|
(file-name-nondirectory buffer-file-name)))))
|
||||||
|
(insert "#include \"" name "\"\n\n"))))
|
||||||
|
|
||||||
|
|
||||||
|
(defun sandbox ()
|
||||||
|
"Opens a C++ sandbox in current window."
|
||||||
|
(interactive)
|
||||||
|
(cd "/tmp")
|
||||||
|
(let ((file (make-temp-file "/tmp/" nil ".cc")))
|
||||||
|
(find-file file)
|
||||||
|
(insert "int main()\n{\n\n}\n")
|
||||||
|
(line-move -2)
|
||||||
|
(save-buffer)
|
||||||
|
(compile (concat "g++ -W -Wall -I /usr/include/qt4/ -I /usr/include/qt4/QtCore/ -L /usr/lib/qt4 -lQtCore " file " && ./a.out"))))
|
||||||
|
|
||||||
|
(defun c-insert-debug (&optional msg)
|
||||||
|
(interactive)
|
||||||
|
(when (not (looking-at "\\W*$"))
|
||||||
|
(beginning-of-line)
|
||||||
|
(insert "\n")
|
||||||
|
(line-move -1))
|
||||||
|
(c-indent-line)
|
||||||
|
(insert "std::cerr << \"\" << std::endl;")
|
||||||
|
(backward-char 15))
|
||||||
|
|
||||||
|
(defun c-insert-block (&optional r b a)
|
||||||
|
(interactive "P")
|
||||||
|
(unless b (setq b ""))
|
||||||
|
(unless a (setq a ""))
|
||||||
|
(if r
|
||||||
|
(progn
|
||||||
|
(save-excursion
|
||||||
|
(goto-char (rbegin))
|
||||||
|
(beginning-of-line)
|
||||||
|
(insert "\n")
|
||||||
|
(line-move -1)
|
||||||
|
(insert b "{")
|
||||||
|
(c-indent-line))
|
||||||
|
(save-excursion
|
||||||
|
(goto-char (- (rend) 1))
|
||||||
|
(end-of-line)
|
||||||
|
(insert "\n}" a)
|
||||||
|
(c-indent-line)
|
||||||
|
(line-move -1)
|
||||||
|
(end-of-line))
|
||||||
|
(indent-region (rbegin) (rend)))
|
||||||
|
(progn
|
||||||
|
(beginning-of-line)
|
||||||
|
|
||||||
|
(setq begin (point))
|
||||||
|
|
||||||
|
(insert b "{\n")
|
||||||
|
(end-of-line)
|
||||||
|
(insert "\n}" a)
|
||||||
|
|
||||||
|
(indent-region begin (point))
|
||||||
|
|
||||||
|
(line-move -1)
|
||||||
|
(end-of-line))))
|
||||||
|
|
||||||
|
(defun c-insert-braces (&optional r)
|
||||||
|
(interactive "P")
|
||||||
|
(c-insert-block r))
|
||||||
|
|
||||||
|
(defun c-insert-ns (name r)
|
||||||
|
(interactive "sName: \nP")
|
||||||
|
(c-insert-block r (concat "namespace " name "\n")))
|
||||||
|
|
||||||
|
(defun c-insert-switch (value r)
|
||||||
|
(interactive "sValue: \nP")
|
||||||
|
(c-insert-block r (concat "switch (" value ")\n")))
|
||||||
|
|
||||||
|
(defun c-insert-if (c r)
|
||||||
|
(interactive "sCondition: \nP")
|
||||||
|
(c-insert-block r (concat "if (" c ")\n")))
|
||||||
|
|
||||||
|
(defun c-insert-class (name)
|
||||||
|
(interactive "sName: ")
|
||||||
|
(c-insert-block () (concat "class " name "\n") ";")
|
||||||
|
(insert "public:")
|
||||||
|
(c-indent-line)
|
||||||
|
(insert "\n")
|
||||||
|
(c-indent-line)
|
||||||
|
(insert "\n")
|
||||||
|
(insert "\n")
|
||||||
|
(insert "private:")
|
||||||
|
(c-indent-line)
|
||||||
|
(insert "\n")
|
||||||
|
(c-indent-line)
|
||||||
|
(line-move -3)
|
||||||
|
(end-of-line))
|
28
configs/hooks.el
Normal file
28
configs/hooks.el
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
; Delete trailing whitespaces on save
|
||||||
|
(add-hook 'write-file-hooks 'delete-trailing-whitespace)
|
||||||
|
|
||||||
|
;; Mode to collapse code block
|
||||||
|
(add-hook 'c-mode-common-hook (lambda () (hs-minor-mode 1)))
|
||||||
|
(add-hook 'lisp-mode-hooks (lambda () (hs-minor-mode 1)))
|
||||||
|
(add-hook 'java-mode-hooks (lambda () (hs-minor-mode 1)))
|
||||||
|
(add-hook 'python-mode-hooks (lambda () (hs-minor-mode 1)))
|
||||||
|
|
||||||
|
; Auto insert C/C++ header guard
|
||||||
|
(add-hook 'find-file-hooks
|
||||||
|
(lambda ()
|
||||||
|
(when (and (memq major-mode '(c-mode c++-mode)) (equal (point-min) (point-max)) (string-match ".*\\.hh?" (buffer-file-name)))
|
||||||
|
(insert-header-guard)
|
||||||
|
(goto-line 3)
|
||||||
|
(insert "\n"))))
|
||||||
|
(add-hook 'find-file-hooks
|
||||||
|
(lambda ()
|
||||||
|
(when (and (memq major-mode '(c-mode c++-mode)) (equal (point-min) (point-max)) (string-match ".*\\.cc?" (buffer-file-name)))
|
||||||
|
(insert-header-inclusion))))
|
||||||
|
|
||||||
|
(add-hook 'sh-mode-hook
|
||||||
|
(lambda ()
|
||||||
|
(insert-shebang-if-empty "/bin/sh")))
|
||||||
|
|
||||||
|
(add-hook 'ruby-mode-hook
|
||||||
|
(lambda ()
|
||||||
|
(insert-shebang-if-empty "/usr/bin/ruby")))
|
77
configs/key-binding.el
Normal file
77
configs/key-binding.el
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
;; Goto line #
|
||||||
|
(global-set-key [(meta g)] 'goto-line)
|
||||||
|
|
||||||
|
;; Move between windnow
|
||||||
|
(global-set-key [C-left] 'windmove-left)
|
||||||
|
(global-set-key [C-right] 'windmove-right)
|
||||||
|
(global-set-key [C-up] 'windmove-up)
|
||||||
|
(global-set-key [C-down] 'windmove-down)
|
||||||
|
|
||||||
|
;; Compile file
|
||||||
|
(global-set-key (kbd "C-c M-c") 'compile)
|
||||||
|
(global-set-key (kbd "C-c c") 'recompile)
|
||||||
|
(global-set-key (kbd "C-c e") 'next-error)
|
||||||
|
(global-set-key (kbd "C-c g") 'gdb)
|
||||||
|
|
||||||
|
;; Get some stat on region
|
||||||
|
(global-set-key [(meta =)] 'stat-region)
|
||||||
|
|
||||||
|
;; Move in buffer
|
||||||
|
(global-set-key [C-home] 'beginning-of-buffer)
|
||||||
|
(global-set-key [C-end] 'end-of-buffer)
|
||||||
|
(global-set-key [home] 'beginning-of-line)
|
||||||
|
(global-set-key [end] 'end-of-line)
|
||||||
|
|
||||||
|
(global-set-key (kbd "C-c h") 'replace-string)
|
||||||
|
(global-set-key (kbd "C-c j") 'replace-regexp)
|
||||||
|
(global-set-key (kbd "C-c o") 'bury-buffer)
|
||||||
|
(global-set-key (kbd "C-c k") 'kill-this-buffer)
|
||||||
|
(put 'narrow-to-region 'disabled nil)
|
||||||
|
|
||||||
|
;; Don't shift-selection
|
||||||
|
(setq shift-select-mode nil)
|
||||||
|
|
||||||
|
;; BINDINGS :: C/C++
|
||||||
|
|
||||||
|
(require 'cc-mode)
|
||||||
|
|
||||||
|
(define-key
|
||||||
|
c-mode-base-map
|
||||||
|
[(control c) (w)]
|
||||||
|
'c-switch-hh-cc) ; switch between .hh and .cc
|
||||||
|
(define-key
|
||||||
|
c-mode-base-map
|
||||||
|
[(control c) (f)]
|
||||||
|
'hs-hide-block) ; fold code
|
||||||
|
(define-key
|
||||||
|
c-mode-base-map
|
||||||
|
[(control c) (s)]
|
||||||
|
'hs-show-block) ; unfold code
|
||||||
|
(define-key
|
||||||
|
c-mode-base-map
|
||||||
|
[(control c) (control n)]
|
||||||
|
'c-insert-ns) ; insert namespace
|
||||||
|
(define-key
|
||||||
|
c-mode-base-map
|
||||||
|
[(control c) (control s)]
|
||||||
|
'c-insert-switch) ; insert switch
|
||||||
|
(define-key
|
||||||
|
c-mode-base-map
|
||||||
|
[(control c) (control i)]
|
||||||
|
'c-insert-if) ; insert if
|
||||||
|
(define-key
|
||||||
|
c-mode-base-map
|
||||||
|
[(control c) (control b)]
|
||||||
|
'c-insert-braces) ; insert braces
|
||||||
|
(define-key
|
||||||
|
c-mode-base-map
|
||||||
|
[(control c) (control f)]
|
||||||
|
'insert-fixme) ; insert fixme
|
||||||
|
(define-key
|
||||||
|
c-mode-base-map
|
||||||
|
[(control c) (control d)]
|
||||||
|
'c-insert-debug) ; insert debug
|
||||||
|
(define-key
|
||||||
|
c-mode-base-map
|
||||||
|
[(control c) (control l)]
|
||||||
|
'c-insert-class) ; insert class
|
13
configs/mail.el
Normal file
13
configs/mail.el
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
(add-to-list 'auto-mode-alist '("/mutt" . mail-mode))
|
||||||
|
|
||||||
|
(add-hook 'mail-mode-hook 'turn-on-auto-fill)
|
||||||
|
(add-hook 'mail-mode-hook 'mail-abbrevs-setup)
|
||||||
|
|
||||||
|
;; colorizing multiply-quoted lines
|
||||||
|
(add-hook 'mail-mode-hook
|
||||||
|
(lambda ()
|
||||||
|
(font-lock-add-keywords nil
|
||||||
|
'(("^[ \t]*>[ \t]*>[ \t]*>.*$"
|
||||||
|
(0 'mail-multiply-quoted-text-face))
|
||||||
|
("^[ \t]*>[ \t]*>.*$"
|
||||||
|
(0 'mail-double-quoted-text-face))))))
|
30
configs/modes.el
Normal file
30
configs/modes.el
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
;; Tiger mode
|
||||||
|
(autoload 'tiger-mode "tiger" "Load tiger-mode" t)
|
||||||
|
(add-to-list 'auto-mode-alist '("\\.ti[gh]$" . tiger-mode))
|
||||||
|
|
||||||
|
;; C++ mode
|
||||||
|
(add-to-list 'auto-mode-alist '("\\.l$" . c++-mode))
|
||||||
|
(add-to-list 'auto-mode-alist '("\\.y$" . c++-mode))
|
||||||
|
(add-to-list 'auto-mode-alist '("\\.ll$" . c++-mode))
|
||||||
|
(add-to-list 'auto-mode-alist '("\\.yy$" . c++-mode))
|
||||||
|
(add-to-list 'auto-mode-alist '("\\.xcc$" . c++-mode))
|
||||||
|
(add-to-list 'auto-mode-alist '("\\.xhh$" . c++-mode))
|
||||||
|
(add-to-list 'auto-mode-alist '("Drakefile$" . c++-mode))
|
||||||
|
|
||||||
|
;; SH mode
|
||||||
|
(add-to-list 'auto-mode-alist '("\\.pro$" . sh-mode)) ; Qt .pro files
|
||||||
|
(add-to-list 'auto-mode-alist '("configure$" . sh-mode))
|
||||||
|
|
||||||
|
;; Changelog mode
|
||||||
|
(add-to-list 'auto-mode-alist '("COMMIT_EDITMSG" . change-log-mode))
|
||||||
|
|
||||||
|
;; Edje-mode
|
||||||
|
(require 'edje-mode)
|
||||||
|
(add-to-list 'auto-mode-alist '("\\.edc$" . edje-mode))
|
||||||
|
|
||||||
|
;; Org-mode
|
||||||
|
(require 'org-install)
|
||||||
|
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
|
||||||
|
(define-key global-map "\C-cl" 'org-store-link)
|
||||||
|
(define-key global-map "\C-ca" 'org-agenda)
|
||||||
|
(setq org-log-done t)
|
17
configs/perso.el
Normal file
17
configs/perso.el
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
;; E-mail adress
|
||||||
|
(custom-set-variables '(user-mail-address "nemunaire@pomail.fr")
|
||||||
|
'(query-user-mail-address nil))
|
||||||
|
|
||||||
|
;; Ispell check default language
|
||||||
|
(ispell-change-dictionary "francais" t)
|
||||||
|
|
||||||
|
|
||||||
|
(defvar cpu-number 8
|
||||||
|
"Number of parallel processing units on this system")
|
||||||
|
(setq compile-command "make")
|
||||||
|
|
||||||
|
(setq c-default-style "epita")
|
||||||
|
|
||||||
|
;; Chargement de mes paramètres personnels
|
||||||
|
(if (file-exists-p "~/.private.el")
|
||||||
|
(load-file "~/.private.el"))
|
17
configs/project.el
Normal file
17
configs/project.el
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
(setq project-roots
|
||||||
|
`(("Django project"
|
||||||
|
:root-contains-files ("manage.py")
|
||||||
|
:filename-regex ,(regexify-ext-list '(py html css js sh))
|
||||||
|
:exclude-paths '("contrib"))))
|
||||||
|
|
||||||
|
(global-set-key (kbd "C-c p f") 'project-root-find-file)
|
||||||
|
(global-set-key (kbd "C-c p g") 'project-root-grep)
|
||||||
|
(global-set-key (kbd "C-c p a") 'project-root-ack)
|
||||||
|
(global-set-key (kbd "C-c p d") 'project-root-goto-root)
|
||||||
|
(global-set-key (kbd "C-c p l") 'project-root-browse-seen-projects)
|
||||||
|
|
||||||
|
(global-set-key (kbd "C-c p s")
|
||||||
|
(lambda () (interactive)
|
||||||
|
(with-project-root
|
||||||
|
(ansi-term (getenv "SHELL")
|
||||||
|
(concat (car project-details) "-shell")))
|
25
configs/tags.el
Normal file
25
configs/tags.el
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
(defadvice find-tag (around refresh-etags activate)
|
||||||
|
"Rerun etags and reload tags if tag not found and redo find-tag.
|
||||||
|
If buffer is modified, ask about save before running etags."
|
||||||
|
(let ((extension (file-name-extension (buffer-file-name))))
|
||||||
|
(condition-case err
|
||||||
|
ad-do-it
|
||||||
|
(error (and (buffer-modified-p)
|
||||||
|
(not (ding))
|
||||||
|
(y-or-n-p "Buffer is modified, save it? ")
|
||||||
|
(save-buffer))
|
||||||
|
(er-refresh-etags extension)
|
||||||
|
ad-do-it))))
|
||||||
|
|
||||||
|
(defun er-refresh-etags (&optional extension)
|
||||||
|
"Run etags on all peer files in current dir and reload them silently."
|
||||||
|
(interactive)
|
||||||
|
(shell-command (format "etags *.%s" (or extension "el")))
|
||||||
|
(let ((tags-revert-without-query t)) ; don't query, revert silently
|
||||||
|
(visit-tags-table default-directory nil)))
|
||||||
|
|
||||||
|
(defun create-tags (dir-name)
|
||||||
|
"Create tags file."
|
||||||
|
(interactive "DDirectory: ")
|
||||||
|
(eshell-command
|
||||||
|
(format "find %s -type f -name \"*.[ch]\" | etags -" dir-name)))
|
57
init.el
Normal file
57
init.el
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
;;
|
||||||
|
;; emacs configuration
|
||||||
|
;;
|
||||||
|
;; Made by Némunaire <nemunaire@nemunai.re>
|
||||||
|
|
||||||
|
(defun may-load (path)
|
||||||
|
"Load a file if it exists."
|
||||||
|
(when (file-readable-p path)
|
||||||
|
(load-file path)))
|
||||||
|
|
||||||
|
(defun reload ()
|
||||||
|
"Reload configuration file"
|
||||||
|
(interactive)
|
||||||
|
(load-file "~/.emacs.d/init.elc"))
|
||||||
|
|
||||||
|
;; Compile init file when it is modified
|
||||||
|
(defun byte-compile-current-buffer ()
|
||||||
|
"`byte-compile' current buffer if it's emacs-lisp-mode and compiled file exists."
|
||||||
|
(interactive)
|
||||||
|
(when (and (eq major-mode 'emacs-lisp-mode)
|
||||||
|
(file-exists-p (byte-compile-dest-file buffer-file-name)))
|
||||||
|
(byte-compile-file buffer-file-name)))
|
||||||
|
(add-hook 'after-save-hook 'byte-compile-current-buffer)
|
||||||
|
|
||||||
|
;; default emacs configuration directory
|
||||||
|
(defconst toc:emacs-config-dir "~/.emacs.d/configs/" "")
|
||||||
|
|
||||||
|
;; utility fonction to auto-load my package configurations
|
||||||
|
(defun toc:load-config-file (filelist)
|
||||||
|
(dolist (file filelist)
|
||||||
|
(message "Loading config file: %s..." file)
|
||||||
|
(load (expand-file-name
|
||||||
|
(concat toc:emacs-config-dir file)))
|
||||||
|
))
|
||||||
|
|
||||||
|
(add-to-list 'load-path "~/.emacs.d/stuff/")
|
||||||
|
|
||||||
|
(require 'my-autoload)
|
||||||
|
(require 'my-c-mode)
|
||||||
|
(require 'my-elisp)
|
||||||
|
(require 'my-font)
|
||||||
|
(require 'my-layout)
|
||||||
|
(require 'my-lisp-mode)
|
||||||
|
(require 'my-python-mode)
|
||||||
|
|
||||||
|
;; load my configuration files
|
||||||
|
(toc:load-config-file '("key-binding"
|
||||||
|
;; "project"
|
||||||
|
"editing"
|
||||||
|
"coding-style"
|
||||||
|
"tags"
|
||||||
|
"hooks"
|
||||||
|
"modes"
|
||||||
|
"mail"
|
||||||
|
"custom"
|
||||||
|
"perso"
|
||||||
|
))
|
512
stuff/edje-mode.el
Normal file
512
stuff/edje-mode.el
Normal file
@ -0,0 +1,512 @@
|
|||||||
|
;;; edje-mode-el -- Major mode for editing Edje files
|
||||||
|
|
||||||
|
;; Author: Gustavo Sverzut Barbieri <barbieri@gmail.com>
|
||||||
|
;; Created: 2007-07-23
|
||||||
|
;; Keywords: Edje major-mode
|
||||||
|
;; Url: http://barbieri-playground.googlecode.com/svn/dot-files/edje-mode.el
|
||||||
|
;; (if you find this file have problems, check that Url and request update)
|
||||||
|
|
||||||
|
;; Copyright (C) 2007 Gustavo Sverzut Barbieri <barbieri@gmail.com>
|
||||||
|
|
||||||
|
;; 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 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 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
|
||||||
|
|
||||||
|
;;; Commentary:
|
||||||
|
;;
|
||||||
|
;; This mode is based on tutorial from Scott Andrew Borton:
|
||||||
|
;; http://two-wugs.net/emacs/mode-tutorial.html
|
||||||
|
|
||||||
|
|
||||||
|
(defvar edje-mode-hook nil)
|
||||||
|
|
||||||
|
(defun number-or-nil-to-string (v &optional default)
|
||||||
|
(cond ((numberp v) (number-to-string v))
|
||||||
|
((stringp v) (if (string= v "") (number-to-string default) v))
|
||||||
|
(t (number-to-string default))))
|
||||||
|
|
||||||
|
(defun non-empty-string (s)
|
||||||
|
(and (not (eq 'nil s))
|
||||||
|
(not (string= "" s))))
|
||||||
|
|
||||||
|
(defun edje-new-program-action-signal-emit (source emission)
|
||||||
|
"Insert new program SIGNAL_EMIT"
|
||||||
|
(interactive "ssource: \nsemission: ")
|
||||||
|
(insert
|
||||||
|
(concat
|
||||||
|
" action: SIGNAL_EMIT \"" source "\" \"" emission "\";\n"
|
||||||
|
)))
|
||||||
|
|
||||||
|
(defun edje-new-program-action-state-set (state value target)
|
||||||
|
"Insert new program STATE_SET"
|
||||||
|
(interactive "sstate: \nsvalue (0.0): \nstarget: ")
|
||||||
|
(insert
|
||||||
|
(concat
|
||||||
|
" action: STATE_SET \"" state "\" "
|
||||||
|
(number-or-nil-to-string value 0.0) ";\n"
|
||||||
|
" target: \"" target "\";\n"
|
||||||
|
)))
|
||||||
|
|
||||||
|
(defun edje-new-program-action (action)
|
||||||
|
"Insert new program action"
|
||||||
|
(interactive "saction: ")
|
||||||
|
(setq action (upcase action))
|
||||||
|
(cond ((string= action "STATE_SET")
|
||||||
|
(edje-new-program-action-state-set "" 0.0 ""))
|
||||||
|
((string= action "SIGNAL_EMIT")
|
||||||
|
(edje-new-program-action-signal-emit "" ""))
|
||||||
|
))
|
||||||
|
|
||||||
|
(defun edje-new-program (name signal source action)
|
||||||
|
"Insert new program block"
|
||||||
|
(interactive "sname: \nssignal: \nssource: \nsaction: ")
|
||||||
|
(insert
|
||||||
|
(concat
|
||||||
|
"\n"
|
||||||
|
" program {\n"
|
||||||
|
" name: \"" name "\";\n"
|
||||||
|
|
||||||
|
(if (non-empty-string signal)
|
||||||
|
(concat " signal: \"" signal "\";\n"))
|
||||||
|
|
||||||
|
(if (non-empty-string source)
|
||||||
|
(concat " source: \"" source "\";\n"))
|
||||||
|
))
|
||||||
|
|
||||||
|
(edje-new-program-action action)
|
||||||
|
|
||||||
|
(insert
|
||||||
|
(concat
|
||||||
|
" }\n"
|
||||||
|
"\n"
|
||||||
|
)))
|
||||||
|
|
||||||
|
(defun edje-new-desc-relative (x y &optional defx defy)
|
||||||
|
"Insert new part description 'relative' line"
|
||||||
|
(interactive "sx: \nsy: ")
|
||||||
|
(insert
|
||||||
|
(concat
|
||||||
|
" relative: "
|
||||||
|
(number-or-nil-to-string x defx) " "
|
||||||
|
(number-or-nil-to-string y defy) ";\n"
|
||||||
|
)))
|
||||||
|
|
||||||
|
(defun edje-new-desc-offset (x y &optional defx defy)
|
||||||
|
"Insert new part description 'offset' line"
|
||||||
|
(interactive "sx: \nsy: ")
|
||||||
|
(insert
|
||||||
|
(concat
|
||||||
|
" offset: "
|
||||||
|
(number-or-nil-to-string x defx) " "
|
||||||
|
(number-or-nil-to-string y defy) ";\n"
|
||||||
|
)))
|
||||||
|
|
||||||
|
(defun edje-new-desc-inherit (name val)
|
||||||
|
"Insert new part description 'inherit' line"
|
||||||
|
(interactive "sname: \nsvalue: ")
|
||||||
|
(insert
|
||||||
|
(concat
|
||||||
|
" inherit: \"" name "\" "
|
||||||
|
(number-or-nil-to-string val 0.0) ";\n"
|
||||||
|
)))
|
||||||
|
|
||||||
|
(defun edje-new-desc-text (font size text)
|
||||||
|
"Insert new part description 'text' block"
|
||||||
|
(interactive "sfont: \nssize: \nstext: ")
|
||||||
|
(insert
|
||||||
|
(concat
|
||||||
|
" text {\n"
|
||||||
|
" font: \"" font "\";\n"
|
||||||
|
" size: " (number-or-nil-to-string size) ";\n"
|
||||||
|
" text: \"" text "\";\n"
|
||||||
|
" }\n"
|
||||||
|
)))
|
||||||
|
|
||||||
|
(defun edje-new-desc-image (name)
|
||||||
|
"Insert new part description 'image' block"
|
||||||
|
(interactive "sname: ")
|
||||||
|
(insert
|
||||||
|
(concat
|
||||||
|
" image {\n"
|
||||||
|
" normal: \"" name "\";\n"
|
||||||
|
" }\n"
|
||||||
|
)))
|
||||||
|
|
||||||
|
(defun edje-new-desc-color (r g b a &optional defr defg defb defa)
|
||||||
|
"Insert new part description 'color' line"
|
||||||
|
(interactive "sred: \nsgreen: \nsblue: \nsalpha: ")
|
||||||
|
(insert
|
||||||
|
(concat
|
||||||
|
" color: "
|
||||||
|
(number-or-nil-to-string r defr) " "
|
||||||
|
(number-or-nil-to-string g defg) " "
|
||||||
|
(number-or-nil-to-string b defb) " "
|
||||||
|
(number-or-nil-to-string a defa) ";\n"
|
||||||
|
)))
|
||||||
|
|
||||||
|
(defun edje-new-desc (name val &optional
|
||||||
|
r1_rx r1_ry
|
||||||
|
r2_rx r2_ry
|
||||||
|
r1_ox r1_oy
|
||||||
|
r2_ox r2_oy
|
||||||
|
part_type)
|
||||||
|
"Insert new part description block"
|
||||||
|
(interactive "sName: \nsValue: ")
|
||||||
|
(insert
|
||||||
|
(concat
|
||||||
|
" description {\n"
|
||||||
|
" state: \"" name "\" " (number-or-nil-to-string val 0.0) ";\n"))
|
||||||
|
(if (string= part_type "RECT") (edje-new-desc-color 255 255 255 255))
|
||||||
|
(insert " rel1 {\n")
|
||||||
|
(edje-new-desc-relative r1_rx r1_ry 0.0 0.0)
|
||||||
|
(edje-new-desc-offset r1_ox r1_oy 0 0)
|
||||||
|
(insert
|
||||||
|
(concat
|
||||||
|
" }\n"
|
||||||
|
" rel2 {\n"
|
||||||
|
))
|
||||||
|
(edje-new-desc-relative r2_rx r2_ry 1.0 1.0)
|
||||||
|
(edje-new-desc-offset r2_ox r2_oy -1 -1)
|
||||||
|
(insert " }\n")
|
||||||
|
(cond ((string= part_type "IMAGE") (edje-new-desc-image ""))
|
||||||
|
((string= part_type "TEXT") (edje-new-desc-text "" 10 "contents"))
|
||||||
|
)
|
||||||
|
(insert " }\n")
|
||||||
|
)
|
||||||
|
|
||||||
|
(defun edje-new-part (name type &optional
|
||||||
|
r1_rx r1_ry
|
||||||
|
r2_rx r2_ry
|
||||||
|
r1_ox r1_oy
|
||||||
|
r2_ox r2_oy)
|
||||||
|
"Insert new part"
|
||||||
|
(interactive "sName: \nsType: ")
|
||||||
|
(setq type (upcase type))
|
||||||
|
(insert
|
||||||
|
(concat
|
||||||
|
"\n"
|
||||||
|
" part {\n"
|
||||||
|
" name: \"" name "\";\n"
|
||||||
|
" type: " type ";\n"
|
||||||
|
" mouse_events: 0;\n"
|
||||||
|
))
|
||||||
|
(edje-new-desc "default" 0.0 r1_rx r1_ry r2_rx r2_ry r1_ox r1_oy r2_ox r2_oy type)
|
||||||
|
(insert
|
||||||
|
(concat
|
||||||
|
" }\n"
|
||||||
|
)))
|
||||||
|
|
||||||
|
(defun edje-setup-compile ()
|
||||||
|
(set (make-local-variable 'compile-command)
|
||||||
|
(concat "edje_cc " (buffer-file-name))
|
||||||
|
))
|
||||||
|
|
||||||
|
(defun edje-cc ()
|
||||||
|
"Runs edje_cc with current buffer."
|
||||||
|
(interactive)
|
||||||
|
(compile (edje-setup-compile)))
|
||||||
|
|
||||||
|
(defvar edje-mode-map
|
||||||
|
(let ((edje-mode-map (make-sparse-keymap)))
|
||||||
|
(define-key edje-mode-map "\C-j" 'newline-and-indent)
|
||||||
|
(define-key edje-mode-map "\C-cp" 'edje-new-part)
|
||||||
|
(define-key edje-mode-map "\C-cd" 'edje-new-desc)
|
||||||
|
(define-key edje-mode-map "\C-cr" 'edje-new-desc-relative)
|
||||||
|
(define-key edje-mode-map "\C-co" 'edje-new-desc-offset)
|
||||||
|
(define-key edje-mode-map "\C-ch" 'edje-new-desc-inherit)
|
||||||
|
(define-key edje-mode-map "\C-cc" 'edje-new-desc-color)
|
||||||
|
(define-key edje-mode-map "\C-ci" 'edje-new-desc-image)
|
||||||
|
(define-key edje-mode-map "\C-ct" 'edje-new-desc-text)
|
||||||
|
(define-key edje-mode-map "\C-cg" 'edje-new-program)
|
||||||
|
(define-key edje-mode-map "\C-ca" 'edje-new-program-action)
|
||||||
|
(define-key edje-mode-map "\C-cs" 'edje-new-program-action-state-set)
|
||||||
|
(define-key edje-mode-map "\C-ce" 'edje-new-program-action-signal-emit)
|
||||||
|
edje-mode-map)
|
||||||
|
"Keymap for Edje major mode")
|
||||||
|
|
||||||
|
(add-hook 'c-mode-hook 'edje-setup-compile)
|
||||||
|
(add-to-list 'auto-mode-alist '("\\.edc$" . edje-mode))
|
||||||
|
|
||||||
|
(defconst edje-font-lock-keywords-1
|
||||||
|
(eval-when-compile
|
||||||
|
(list
|
||||||
|
(list (concat "[ \t]*\\<"
|
||||||
|
(regexp-opt
|
||||||
|
'(
|
||||||
|
"collections"
|
||||||
|
"data"
|
||||||
|
"description"
|
||||||
|
"dragable"
|
||||||
|
"fill"
|
||||||
|
"fonts"
|
||||||
|
"group"
|
||||||
|
"image"
|
||||||
|
"images"
|
||||||
|
"origin"
|
||||||
|
"part"
|
||||||
|
"parts"
|
||||||
|
"program"
|
||||||
|
"programs"
|
||||||
|
"rel1"
|
||||||
|
"rel2"
|
||||||
|
"script"
|
||||||
|
"spectra"
|
||||||
|
"style"
|
||||||
|
"styles"
|
||||||
|
"text"
|
||||||
|
) t) "\\>\\([ \t]*{\\|\\.\\)")
|
||||||
|
'(1 font-lock-function-name-face))
|
||||||
|
|
||||||
|
))
|
||||||
|
"Major keywords")
|
||||||
|
|
||||||
|
(defconst edje-font-lock-keywords-2
|
||||||
|
(eval-when-compile
|
||||||
|
(append edje-font-lock-keywords-1
|
||||||
|
(list
|
||||||
|
(list
|
||||||
|
(concat "^\\([ \t]*\\|[ \t]*[a-z]+\\.\\|\\)\\<"
|
||||||
|
(regexp-opt
|
||||||
|
'("action"
|
||||||
|
"after"
|
||||||
|
"alias"
|
||||||
|
"align"
|
||||||
|
"angle"
|
||||||
|
"aspect"
|
||||||
|
"aspect_preference"
|
||||||
|
"base"
|
||||||
|
"border"
|
||||||
|
"clip_to"
|
||||||
|
"collections"
|
||||||
|
"color"
|
||||||
|
"color2"
|
||||||
|
"color3"
|
||||||
|
"color_class"
|
||||||
|
"color_classes"
|
||||||
|
"confine"
|
||||||
|
"data"
|
||||||
|
"description"
|
||||||
|
"dragable"
|
||||||
|
"effect"
|
||||||
|
"elipsis"
|
||||||
|
"events"
|
||||||
|
"fill"
|
||||||
|
"fit"
|
||||||
|
"fixed"
|
||||||
|
"font"
|
||||||
|
"fonts"
|
||||||
|
"gradient"
|
||||||
|
"group"
|
||||||
|
"ignore_flags"
|
||||||
|
"image"
|
||||||
|
"images"
|
||||||
|
"in"
|
||||||
|
"inherit"
|
||||||
|
"item"
|
||||||
|
"max"
|
||||||
|
"middle"
|
||||||
|
"min"
|
||||||
|
"mouse_events"
|
||||||
|
"name"
|
||||||
|
"normal"
|
||||||
|
"offset"
|
||||||
|
"origin"
|
||||||
|
"part"
|
||||||
|
"parts"
|
||||||
|
"pointer_mode"
|
||||||
|
"precise_is_inside"
|
||||||
|
"program"
|
||||||
|
"programs"
|
||||||
|
"rel1"
|
||||||
|
"rel2"
|
||||||
|
"relative"
|
||||||
|
"repeat_events"
|
||||||
|
"signal"
|
||||||
|
"size"
|
||||||
|
"smooth"
|
||||||
|
"source"
|
||||||
|
"spectra"
|
||||||
|
"spectrum"
|
||||||
|
"spread"
|
||||||
|
"state"
|
||||||
|
"step"
|
||||||
|
"style"
|
||||||
|
"styles"
|
||||||
|
"tag"
|
||||||
|
"target"
|
||||||
|
"text"
|
||||||
|
"text_class"
|
||||||
|
"text_source"
|
||||||
|
"to"
|
||||||
|
"to_x"
|
||||||
|
"to_y"
|
||||||
|
"transition"
|
||||||
|
"tween"
|
||||||
|
"type"
|
||||||
|
"use_alternate_font_metrics"
|
||||||
|
"visible"
|
||||||
|
"x"
|
||||||
|
"y"
|
||||||
|
) t) "\\>[ \t]*[:,]")
|
||||||
|
'(2 font-lock-keyword-face))
|
||||||
|
)))
|
||||||
|
"Minor keywords")
|
||||||
|
|
||||||
|
(defconst edje-font-lock-keywords-3
|
||||||
|
(eval-when-compile
|
||||||
|
(append edje-font-lock-keywords-2
|
||||||
|
(list
|
||||||
|
(list
|
||||||
|
(concat "\\<"
|
||||||
|
(regexp-opt
|
||||||
|
'(; image options (st_images_image)
|
||||||
|
"RAW"
|
||||||
|
"COMP"
|
||||||
|
"LOSSY"
|
||||||
|
"USER"
|
||||||
|
; part types (st_collections_group_parts_part_type)
|
||||||
|
"NONE"
|
||||||
|
"RECT"
|
||||||
|
"TEXT"
|
||||||
|
"IMAGE"
|
||||||
|
"SWALLOW"
|
||||||
|
"TEXTBLOCK"
|
||||||
|
"GRADIENT"
|
||||||
|
"GROUP"
|
||||||
|
; ignore flags (st_collections_group_parts_part_ignore_flags)
|
||||||
|
;"NONE"
|
||||||
|
"ON_HOLD"
|
||||||
|
; pointer mode (st_collections_group_parts_part_pointer_mode)
|
||||||
|
"AUTOGRAB"
|
||||||
|
"NOGRAB"
|
||||||
|
; aspect (st_collections_group_parts_part_description_aspect_preference)
|
||||||
|
"NONE"
|
||||||
|
"VERTICAL"
|
||||||
|
"HORIZONTAL"
|
||||||
|
"BOTH"
|
||||||
|
; text effect (st_collections_group_parts_part_effect)
|
||||||
|
"NONE"
|
||||||
|
"PLAIN"
|
||||||
|
"OUTLINE"
|
||||||
|
"SOFT_OUTLINE"
|
||||||
|
"SHADOW"
|
||||||
|
"SOFT_SHADOW"
|
||||||
|
"OUTLINE_SHADOW"
|
||||||
|
"OUTLINE_SOFT_SHADOW"
|
||||||
|
"FAR_SHADOW"
|
||||||
|
"FAR_SOFT_SHADOW"
|
||||||
|
"GLOW"
|
||||||
|
; image fill (st_collections_group_parts_part_description_fill_type)
|
||||||
|
"SCALE"
|
||||||
|
"TILE"
|
||||||
|
; program action (st_collections_group_programs_program_action)
|
||||||
|
"STATE_SET"
|
||||||
|
"ACTION_STOP"
|
||||||
|
"SIGNAL_EMIT"
|
||||||
|
"DRAG_VAL_SET"
|
||||||
|
"DRAG_VAL_STEP"
|
||||||
|
"DRAG_VAL_PAGE"
|
||||||
|
"SCRIPT"
|
||||||
|
; program transition (st_collections_group_programs_program_transition)
|
||||||
|
"LINEAR"
|
||||||
|
"SINUSOIDAL"
|
||||||
|
"ACCELERATE"
|
||||||
|
"DECELERATE"
|
||||||
|
) t) "\\>")
|
||||||
|
'(1 font-lock-builtin-face))
|
||||||
|
)))
|
||||||
|
"Enumerate values")
|
||||||
|
|
||||||
|
(defconst edje-font-lock-keywords-4
|
||||||
|
(eval-when-compile
|
||||||
|
(append edje-font-lock-keywords-3
|
||||||
|
(list
|
||||||
|
(list
|
||||||
|
(concat "[ \t]*#"
|
||||||
|
(regexp-opt
|
||||||
|
'("if"
|
||||||
|
"ifdef"
|
||||||
|
"ifndef"
|
||||||
|
"define"
|
||||||
|
"else"
|
||||||
|
"endif"
|
||||||
|
"include"
|
||||||
|
"undef") t) "[ \t]*")
|
||||||
|
'(1 font-lock-builtin-face))
|
||||||
|
)))
|
||||||
|
"CPP directives")
|
||||||
|
|
||||||
|
(defconst edje-font-lock-keywords-5
|
||||||
|
(eval-when-compile
|
||||||
|
(append edje-font-lock-keywords-4
|
||||||
|
(list
|
||||||
|
(list "[ \t]*#undef[ \t]+\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
|
||||||
|
'(1 font-lock-variable-name-face))
|
||||||
|
(list "[ \t]*#define[ \t]+\\([a-zA-Z_][a-zA-Z0-9_]*\\)("
|
||||||
|
'(1 font-lock-function-name-face))
|
||||||
|
(list "[ \t]*#define[ \t]+\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
|
||||||
|
'(1 font-lock-variable-name-face))
|
||||||
|
)))
|
||||||
|
"CPP directives that define constants")
|
||||||
|
|
||||||
|
|
||||||
|
(defvar edje-font-lock-keywords edje-font-lock-keywords-5)
|
||||||
|
|
||||||
|
(defvar edje-mode-syntax-table
|
||||||
|
(let ((edje-mode-syntax-table (make-syntax-table)))
|
||||||
|
; This is added so entity names with underscores can be more easily parsed
|
||||||
|
(modify-syntax-entry ?_ "w" edje-mode-syntax-table)
|
||||||
|
(modify-syntax-entry ?/ ". 124b" edje-mode-syntax-table)
|
||||||
|
(modify-syntax-entry ?* ". 23" edje-mode-syntax-table)
|
||||||
|
(modify-syntax-entry ?\n "> b" edje-mode-syntax-table)
|
||||||
|
|
||||||
|
edje-mode-syntax-table)
|
||||||
|
"Syntax table for edje-mode")
|
||||||
|
|
||||||
|
(c-add-style
|
||||||
|
"edje"
|
||||||
|
'("gnu"
|
||||||
|
(indent-tabs-mode . nil)
|
||||||
|
(tab-width . 8)
|
||||||
|
(c-basic-offset . 3)
|
||||||
|
(c-backslash-column . 72)
|
||||||
|
(c-hanging-braces-alist .
|
||||||
|
((block-open after)
|
||||||
|
(brace-list-open after)
|
||||||
|
(substatement-open after))
|
||||||
|
)
|
||||||
|
(c-offsets-alist .
|
||||||
|
((statement-block-intro . +)
|
||||||
|
(defun-open . 0)
|
||||||
|
(substatement-open . 0)
|
||||||
|
(defun-block-intro . +)
|
||||||
|
(block-open . 0)
|
||||||
|
(label . +)
|
||||||
|
))))
|
||||||
|
|
||||||
|
|
||||||
|
(define-derived-mode edje-mode c-mode "Edje"
|
||||||
|
"Major mode for editing Edje files"
|
||||||
|
(interactive)
|
||||||
|
(use-local-map edje-mode-map)
|
||||||
|
(set-syntax-table edje-mode-syntax-table)
|
||||||
|
(set (make-local-variable 'font-lock-defaults) '(edje-font-lock-keywords))
|
||||||
|
(set (make-local-variable 'require-final-newline) t)
|
||||||
|
(c-set-style "edje")
|
||||||
|
(run-hooks 'edje-mode-hook)
|
||||||
|
)
|
||||||
|
|
||||||
|
(provide 'edje-mode)
|
||||||
|
|
||||||
|
;;; edje-mode.el ends here
|
242
stuff/find-cmd.el
Normal file
242
stuff/find-cmd.el
Normal file
@ -0,0 +1,242 @@
|
|||||||
|
;;; find-cmd.el --- Build a valid find(1) command with sexps
|
||||||
|
|
||||||
|
;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
;; Author: Philip Jackson <phil@shellarchive.co.uk>
|
||||||
|
;; Version: 0.6
|
||||||
|
|
||||||
|
;; This file is part of GNU Emacs.
|
||||||
|
|
||||||
|
;; GNU Emacs 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.
|
||||||
|
|
||||||
|
;; GNU Emacs 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. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
;;; Commentary:
|
||||||
|
|
||||||
|
;; With this module you can build up a (hopefully) valid find(1)
|
||||||
|
;; string ready for the command line. For example:
|
||||||
|
|
||||||
|
;; (find-cmd '(prune (name ".svn" ".git" ".CVS"))
|
||||||
|
;; '(and (or (name "*.pl" "*.pm" "*.t")
|
||||||
|
;; (mtime "+1"))
|
||||||
|
;; (fstype "nfs" "ufs"))))
|
||||||
|
|
||||||
|
;; will become (un-wrapped):
|
||||||
|
|
||||||
|
;; "find '/home/phil/' \\( \\( -name '.svn' -or -name '.git' -or
|
||||||
|
;; -name '.CVS' \\) -prune -or -true \\) \\( \\( \\( -name '*.pl'
|
||||||
|
;; -or -name '*.pm' -or -name '*.t' \\) -or -mtime '+1' \\) -and \\(
|
||||||
|
;; -fstype 'nfs' -or -fstype 'ufs' \\) \\)"
|
||||||
|
|
||||||
|
;;; Code:
|
||||||
|
|
||||||
|
(defconst find-constituents
|
||||||
|
'((and . find-and)
|
||||||
|
(not . find-not)
|
||||||
|
(or . find-or)
|
||||||
|
|
||||||
|
(a . find-and)
|
||||||
|
(n . find-not)
|
||||||
|
(o . find-or)
|
||||||
|
|
||||||
|
(prune . find-prune)
|
||||||
|
|
||||||
|
;; switches
|
||||||
|
(L . (0))
|
||||||
|
(P . (0))
|
||||||
|
(H . (0))
|
||||||
|
|
||||||
|
;; generic tests
|
||||||
|
(amin . (1))
|
||||||
|
(anewer . (1))
|
||||||
|
(atime . (1))
|
||||||
|
(cmin . (1))
|
||||||
|
(cnewer . (1))
|
||||||
|
(ctime . (1))
|
||||||
|
(empty . (0))
|
||||||
|
(false . (0))
|
||||||
|
(fstype . (1))
|
||||||
|
(gid . (1))
|
||||||
|
(group . (1))
|
||||||
|
(ilname . (1))
|
||||||
|
(iname . (1))
|
||||||
|
(inum . (1))
|
||||||
|
(iwholename . (1))
|
||||||
|
(iregex . (1))
|
||||||
|
(links . (1))
|
||||||
|
(lname . (1))
|
||||||
|
(mmin . (1))
|
||||||
|
(mtime . (1))
|
||||||
|
(name . (1))
|
||||||
|
(newer . (1))
|
||||||
|
(nouser . (0))
|
||||||
|
(nogroup . (0))
|
||||||
|
(path . (1))
|
||||||
|
(perm . (0))
|
||||||
|
(regex . (1))
|
||||||
|
(wholename . (1))
|
||||||
|
(size . (1))
|
||||||
|
(true . (0))
|
||||||
|
(type . (1))
|
||||||
|
(uid . (1))
|
||||||
|
(used . (1))
|
||||||
|
(user . (1))
|
||||||
|
(xtype . (nil))
|
||||||
|
|
||||||
|
;; normal options (always true)
|
||||||
|
(depth . (0))
|
||||||
|
(maxdepth . (1))
|
||||||
|
(mindepth . (1))
|
||||||
|
(mount . (0))
|
||||||
|
(noleaf . (0))
|
||||||
|
(xdev . (0))
|
||||||
|
(ignore_readdir_race . (0))
|
||||||
|
(noignore_readdir_race . (0))
|
||||||
|
|
||||||
|
;; actions
|
||||||
|
(delete . (0))
|
||||||
|
(print0 . (0))
|
||||||
|
(printf . (1))
|
||||||
|
(fprintf . (2))
|
||||||
|
(print . (0))
|
||||||
|
(fprint0 . (1))
|
||||||
|
(fprint . (1))
|
||||||
|
(ls . (0))
|
||||||
|
(fls . (1))
|
||||||
|
(prune . (0))
|
||||||
|
(quit . (0))
|
||||||
|
|
||||||
|
;; these need to be terminated with a ;
|
||||||
|
(exec . (1 find-command t))
|
||||||
|
(ok . (1 find-command t))
|
||||||
|
(execdir . (1 find-command t))
|
||||||
|
(okdir . (1 find-command t)))
|
||||||
|
"Holds details of each of the find options. The car of each
|
||||||
|
alist is the name. The cdr is minimum args, the function used
|
||||||
|
to join many occurences of the argument together, and whether or
|
||||||
|
not to leave quotes off the string (non-nil means the string will
|
||||||
|
be quoted).")
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun find-cmd (&rest subfinds)
|
||||||
|
"Initiate the building of a find command. For exmple:
|
||||||
|
|
||||||
|
\(find-cmd '\(prune \(name \".svn\" \".git\" \".CVS\"\)\)
|
||||||
|
'\(and \(or \(name \"*.pl\" \"*.pm\" \"*.t\"\)
|
||||||
|
\(mtime \"+1\"\)\)
|
||||||
|
\(fstype \"nfs\" \"ufs\"\)\)\)\)
|
||||||
|
|
||||||
|
`default-directory' is used as the initial search path. The
|
||||||
|
result is a string that should be ready for the command line."
|
||||||
|
(concat
|
||||||
|
"find " (shell-quote-argument (expand-file-name default-directory)) " "
|
||||||
|
(cond
|
||||||
|
((cdr subfinds)
|
||||||
|
(mapconcat 'find-to-string subfinds ""))
|
||||||
|
(t
|
||||||
|
(find-to-string (car subfinds))))))
|
||||||
|
|
||||||
|
(defun find-and (form)
|
||||||
|
"And FORMs together, so:
|
||||||
|
\(and \(mtime \"+1\"\) \(name \"something\"\)\)
|
||||||
|
will produce:
|
||||||
|
find . \\\( -mtime '+1' -and -name 'something' \\\)"
|
||||||
|
(if (< (length form) 2)
|
||||||
|
(find-to-string (car form))
|
||||||
|
(concat "\\( "
|
||||||
|
(mapconcat 'find-to-string form "-and ")
|
||||||
|
"\\) ")))
|
||||||
|
|
||||||
|
(defun find-or (form)
|
||||||
|
"Or FORMs together, so:
|
||||||
|
\(or \(mtime \"+1\"\) \(name \"something\"\)\)
|
||||||
|
will produce:
|
||||||
|
find . \\\( -mtime '+1' -or -name 'something' \\\)"
|
||||||
|
(if (< (length form) 2)
|
||||||
|
(find-to-string (car form))
|
||||||
|
(concat "\\( "
|
||||||
|
(mapconcat 'find-to-string form "-or ")
|
||||||
|
"\\) ")))
|
||||||
|
|
||||||
|
(defun find-not (form)
|
||||||
|
"Or FORMs together and prefix with a -not, so:
|
||||||
|
\(not \(mtime \"+1\"\) \(name \"something\"\)\)
|
||||||
|
will produce:
|
||||||
|
-not \\\( -mtime '+1' -or -name 'something' \\\)
|
||||||
|
If you wanted the FORMs -and(ed) together instead then this would
|
||||||
|
suffice:
|
||||||
|
\(not \(and \(mtime \"+1\"\) \(name \"something\"\)\)\)"
|
||||||
|
(concat "-not " (find-or (mapcar 'find-to-string form))))
|
||||||
|
|
||||||
|
(defun find-prune (form)
|
||||||
|
"-or together FORM(s) postfix '-prune' and then -or that with a
|
||||||
|
-true, so:
|
||||||
|
\(prune \(name \".svn\" \".git\"\)\) \(name \"*.pm\"\)
|
||||||
|
will produce (unwrapped):
|
||||||
|
\\\( \\\( \\\( -name '.svn' -or -name '.git' \\\) /
|
||||||
|
-prune -or -true \\\) -and -name '*.pm' \\\)"
|
||||||
|
(find-or
|
||||||
|
(list
|
||||||
|
(concat (find-or (mapcar 'find-to-string form)) (find-generic "prune"))
|
||||||
|
(find-generic "true"))))
|
||||||
|
|
||||||
|
(defun find-generic (option &optional oper argcount args dont-quote)
|
||||||
|
"This function allows an arbitrary string to be used as a
|
||||||
|
form. OPTION is the name of the form, OPER is the function used
|
||||||
|
to either OR or AND multiple results together. ARGCOUNT is the
|
||||||
|
minimum of args that OPTION can receive and ARGS are the
|
||||||
|
arguments for OPTION."
|
||||||
|
(when (and (numberp argcount) (< (length args) argcount))
|
||||||
|
(error "'%s' needs at least %d arguments" option argcount))
|
||||||
|
(let ((oper (or oper 'find-or)))
|
||||||
|
(if (and args (length args))
|
||||||
|
(funcall oper (mapcar (lambda (x)
|
||||||
|
(concat "-" option
|
||||||
|
(if dont-quote
|
||||||
|
(concat " " x " ")
|
||||||
|
(concat " "
|
||||||
|
(shell-quote-argument x)
|
||||||
|
" "))))
|
||||||
|
args))
|
||||||
|
(concat "-" option " "))))
|
||||||
|
|
||||||
|
(defun find-command (form)
|
||||||
|
"For each item in FORM add a terminating semi-colon and turn
|
||||||
|
them into valid switches. The result is -and(ed) together."
|
||||||
|
(find-and (mapcar (lambda (x)
|
||||||
|
(concat (find-to-string x) "\\; "))
|
||||||
|
form)))
|
||||||
|
|
||||||
|
(defun find-to-string (form)
|
||||||
|
"Parse FORM to produce a set of valid find arguments."
|
||||||
|
(cond
|
||||||
|
((stringp form)
|
||||||
|
form)
|
||||||
|
((consp form)
|
||||||
|
(let ((option (cdr (assoc (car form) find-constituents))))
|
||||||
|
(cond
|
||||||
|
((and (symbolp option) (fboundp option))
|
||||||
|
(funcall option (cdr form)))
|
||||||
|
((consp option)
|
||||||
|
(let ((option (symbol-name (car form)))
|
||||||
|
(argcnt (car option))
|
||||||
|
(oper (cadr option))
|
||||||
|
(dont-quote (car (cddr option))))
|
||||||
|
(find-to-string
|
||||||
|
(find-generic option oper argcnt (cdr form) dont-quote))))
|
||||||
|
(t
|
||||||
|
(error "Sorry I don't know how to handle '%s'" (car form))))))))
|
||||||
|
|
||||||
|
(provide 'find-cmd)
|
||||||
|
|
||||||
|
;; arch-tag: 9687fd9e-4e90-4022-864a-f904526e2046
|
||||||
|
;;; find-cmd.el ends here
|
11
stuff/my-autoload.el
Executable file
11
stuff/my-autoload.el
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
(autoload 'my-rebox-comment
|
||||||
|
"my-rebox" "Draw nice boxes around comments" t)
|
||||||
|
|
||||||
|
(autoload 'insert-fixme
|
||||||
|
"my-fixme" "Insert fixme" t)
|
||||||
|
|
||||||
|
(autoload 'save-current-configuration "revive" "Save status" t)
|
||||||
|
(autoload 'resume "revive" "Resume Emacs" t)
|
||||||
|
(autoload 'wipe "revive" "Wipe Emacs" t)
|
||||||
|
|
||||||
|
(provide 'my-autoload)
|
201
stuff/my-c-mode.el
Executable file
201
stuff/my-c-mode.el
Executable file
@ -0,0 +1,201 @@
|
|||||||
|
(defun c-mode-setup ()
|
||||||
|
|
||||||
|
(require 'my-elisp)
|
||||||
|
|
||||||
|
;; ------------ ;;
|
||||||
|
;; Preprocessor ;;
|
||||||
|
;; ------------ ;;
|
||||||
|
|
||||||
|
(defun c-preproc-indent-level (pos)
|
||||||
|
"Return the indentention level of preprocessor directives for current line"
|
||||||
|
(interactive "d")
|
||||||
|
(save-excursion
|
||||||
|
(beginning-of-buffer)
|
||||||
|
(let ((res 0))
|
||||||
|
(while (< (point) pos)
|
||||||
|
(when (looking-at "#\\s-*if")
|
||||||
|
(setq res (+ res 1)))
|
||||||
|
(when (looking-at "#\\s-*endif")
|
||||||
|
(setq res (- res 1)))
|
||||||
|
(forward-line))
|
||||||
|
res
|
||||||
|
)))
|
||||||
|
|
||||||
|
;; ------------ ;;
|
||||||
|
;; Include path ;;
|
||||||
|
;; ------------ ;;
|
||||||
|
|
||||||
|
(defvar c-include-path
|
||||||
|
()
|
||||||
|
"List of path to search for includes")
|
||||||
|
|
||||||
|
(defun c-add-include-path (path)
|
||||||
|
(interactive "DDirectory: \n")
|
||||||
|
(add-to-list 'c-include-path path)
|
||||||
|
(set 'c-macro-cppflags (concat c-macro-cppflags " -I'" path "'")))
|
||||||
|
|
||||||
|
(defun c-make-include (path paths)
|
||||||
|
(if paths
|
||||||
|
(let ((rg (concat "^" (car paths))))
|
||||||
|
(if (string-match rg path)
|
||||||
|
(concat "<" (replace-regexp-in-string rg "" path) ">")
|
||||||
|
(c-make-include path (cdr paths))))
|
||||||
|
(let ((file (current-file-name)))
|
||||||
|
(concat "\""
|
||||||
|
(if file
|
||||||
|
(remove-prefix-from-string (file-name-directory file) path)
|
||||||
|
path)
|
||||||
|
"\""))))
|
||||||
|
|
||||||
|
;; -------------- ;;
|
||||||
|
;; Code templates ;;
|
||||||
|
;; -------------- ;;
|
||||||
|
|
||||||
|
;; Helpers
|
||||||
|
|
||||||
|
(defun c-fresh-line ()
|
||||||
|
(beginning-of-line)
|
||||||
|
(when (not (looking-at "\\W*$"))
|
||||||
|
(insert "\n")
|
||||||
|
(line-move -1)))
|
||||||
|
|
||||||
|
;; Preprocessor: Helpers
|
||||||
|
|
||||||
|
(defun c-open-preproc ()
|
||||||
|
(c-fresh-line)
|
||||||
|
(insert "#")
|
||||||
|
(insert (make-string (c-preproc-indent-level (point)) ? )))
|
||||||
|
|
||||||
|
;; Preprocessor: Include
|
||||||
|
|
||||||
|
(defun c-insert-include-bouncer (std)
|
||||||
|
(interactive "P")
|
||||||
|
(if std
|
||||||
|
(call-interactively 'c-insert-standard-include)
|
||||||
|
(call-interactively 'c-insert-local-include)))
|
||||||
|
|
||||||
|
(defun c-insert-local-include (name)
|
||||||
|
(interactive "fInclude: \n")
|
||||||
|
(save-excursion
|
||||||
|
(c-open-preproc)
|
||||||
|
(insert "include ")
|
||||||
|
(insert (c-make-include name c-include-path))))
|
||||||
|
|
||||||
|
(defun c-insert-standard-include (name)
|
||||||
|
(interactive "sInclude: \n")
|
||||||
|
(save-excursion
|
||||||
|
(c-open-preproc)
|
||||||
|
(insert "include <")
|
||||||
|
(insert name)
|
||||||
|
(insert ">")))
|
||||||
|
|
||||||
|
;; ------------- ;;
|
||||||
|
;; Configuration ;;
|
||||||
|
;; ------------- ;;
|
||||||
|
|
||||||
|
;; Rebox with C-style comments
|
||||||
|
(set 'my-rebox-style 223)
|
||||||
|
|
||||||
|
;; --- ;;
|
||||||
|
;; GDB ;;
|
||||||
|
;; --- ;;
|
||||||
|
|
||||||
|
(defvar my-gdb-program "")
|
||||||
|
|
||||||
|
(defun my-gdb-find-program (path)
|
||||||
|
(interactive "f")
|
||||||
|
(setq my-gdb-program path))
|
||||||
|
|
||||||
|
(defun my-gdb ()
|
||||||
|
(interactive)
|
||||||
|
(when (string-equal my-gdb-program "")
|
||||||
|
(call-interactively (function my-gdb-find-program)))
|
||||||
|
(gdb (concat "gdb " my-gdb-program))
|
||||||
|
(gdb-restore-windows))
|
||||||
|
|
||||||
|
(defun my-gdb-run ()
|
||||||
|
(interactive)
|
||||||
|
(gud-call "run"))
|
||||||
|
|
||||||
|
(defun my-gdb-stop ()
|
||||||
|
(interactive)
|
||||||
|
(gud-stop-subjob))
|
||||||
|
|
||||||
|
(defun my-gdb-kill ()
|
||||||
|
(interactive)
|
||||||
|
(my-gdb-stop)
|
||||||
|
(gud-call "kill")
|
||||||
|
(gud-call "y"))
|
||||||
|
|
||||||
|
(defun c-window-layout ()
|
||||||
|
(interactive)
|
||||||
|
(window-set-width 80))
|
||||||
|
|
||||||
|
(defun insert-class-declaration ()
|
||||||
|
(interactive)
|
||||||
|
(save-excursion
|
||||||
|
(when (buffer-file-name)
|
||||||
|
(let*
|
||||||
|
((name (file-name-nondirectory buffer-file-name))
|
||||||
|
(macro (replace-regexp-in-string
|
||||||
|
"\\." "_"
|
||||||
|
(replace-regexp-in-string
|
||||||
|
"-" "_"
|
||||||
|
(upcase name)))))
|
||||||
|
(goto-char (point-min))
|
||||||
|
(insert "#ifndef " macro "_\n")
|
||||||
|
(insert "# define " macro "_\n\n")
|
||||||
|
(goto-char (point-max))
|
||||||
|
(insert "\n#endif /* !" macro "_ */\n")))))
|
||||||
|
|
||||||
|
|
||||||
|
;; -------- ;;
|
||||||
|
;; Bindings ;;
|
||||||
|
;; -------- ;;
|
||||||
|
|
||||||
|
;; Lay window out
|
||||||
|
(define-key
|
||||||
|
c-mode-base-map
|
||||||
|
[(meta l)]
|
||||||
|
'c-window-layout)
|
||||||
|
|
||||||
|
;; Insert inclusion
|
||||||
|
(define-key
|
||||||
|
c-mode-base-map
|
||||||
|
[(control c) (control i)]
|
||||||
|
'c-insert-include-bouncer)
|
||||||
|
|
||||||
|
;; Rebox comment
|
||||||
|
(define-key
|
||||||
|
c-mode-base-map
|
||||||
|
[(meta q)]
|
||||||
|
'my-rebox-comment)
|
||||||
|
|
||||||
|
;; Show debugger
|
||||||
|
(define-key
|
||||||
|
c-mode-base-map
|
||||||
|
[(control c) (d)]
|
||||||
|
'my-gdb)
|
||||||
|
|
||||||
|
;; Run program
|
||||||
|
(define-key
|
||||||
|
c-mode-base-map
|
||||||
|
[(control c) (r)]
|
||||||
|
'my-gdb-run)
|
||||||
|
|
||||||
|
;; Stop program
|
||||||
|
(define-key
|
||||||
|
c-mode-base-map
|
||||||
|
[(control c) (s)]
|
||||||
|
'my-gdb-stop)
|
||||||
|
|
||||||
|
;; Kill program
|
||||||
|
(define-key
|
||||||
|
c-mode-base-map
|
||||||
|
[(control c) (k)]
|
||||||
|
'my-gdb-kill)
|
||||||
|
)
|
||||||
|
|
||||||
|
(add-hook 'c++-mode-hook 'c-mode-setup)
|
||||||
|
|
||||||
|
(provide 'my-c-mode)
|
48
stuff/my-elisp.el
Executable file
48
stuff/my-elisp.el
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
;; ------ ;;
|
||||||
|
;; String ;;
|
||||||
|
;; ------ ;;
|
||||||
|
|
||||||
|
(defun remove-prefix-from-string (prefix string)
|
||||||
|
(let ((rg (concat "^" prefix)))
|
||||||
|
(replace-regexp-in-string rg "" path)))
|
||||||
|
|
||||||
|
|
||||||
|
;; ----- ;;
|
||||||
|
;; Emacs ;;
|
||||||
|
;; ----- ;;
|
||||||
|
|
||||||
|
(defun buffer-empty-p ()
|
||||||
|
(equal (point-min) (point-max)))
|
||||||
|
|
||||||
|
(defun current-file-name ()
|
||||||
|
(buffer-file-name (current-buffer)))
|
||||||
|
|
||||||
|
(defun cwd ()
|
||||||
|
(replace-regexp-in-string "Directory " "" (pwd)))
|
||||||
|
|
||||||
|
(defun rbegin ()
|
||||||
|
(min (point) (mark)))
|
||||||
|
|
||||||
|
(defun rend ()
|
||||||
|
(max (point) (mark)))
|
||||||
|
|
||||||
|
|
||||||
|
;; ---- ;;
|
||||||
|
;; Lisp ;;
|
||||||
|
;; ---- ;;
|
||||||
|
|
||||||
|
(defun filter (condp l)
|
||||||
|
(if l
|
||||||
|
(let ((head (car l))
|
||||||
|
(tail (filter condp (cdr l))))
|
||||||
|
(if (funcall condp head)
|
||||||
|
(cons head tail)
|
||||||
|
tail))
|
||||||
|
()))
|
||||||
|
|
||||||
|
|
||||||
|
;; ------- ;;
|
||||||
|
;; Provide ;;
|
||||||
|
;; ------- ;;
|
||||||
|
|
||||||
|
(provide 'my-elisp)
|
14
stuff/my-fixme.el
Executable file
14
stuff/my-fixme.el
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
(defun insert-fixme (&optional msg)
|
||||||
|
(interactive "sFixme: ")
|
||||||
|
(save-excursion
|
||||||
|
(end-of-line)
|
||||||
|
(when (not (looking-back "^\\s *"))
|
||||||
|
(insert " "))
|
||||||
|
(setq start (point))
|
||||||
|
(insert "FIXME")
|
||||||
|
(when (not (string-equal msg ""))
|
||||||
|
(insert ": " msg))
|
||||||
|
(comment-region start (point))))
|
||||||
|
|
||||||
|
|
||||||
|
(provide 'my-fixme)
|
36
stuff/my-font.el
Executable file
36
stuff/my-font.el
Executable file
@ -0,0 +1,36 @@
|
|||||||
|
(defconst default-font-size 128)
|
||||||
|
|
||||||
|
(defun set-font-size (&optional size)
|
||||||
|
"Set the font size to SIZE (default: default-font-size)."
|
||||||
|
(interactive "nSize: ")
|
||||||
|
(unless size
|
||||||
|
(setq size default-font-size))
|
||||||
|
(set-face-attribute 'default nil :height size))
|
||||||
|
|
||||||
|
(defun reset-font-size ()
|
||||||
|
(interactive)
|
||||||
|
(set-font-size))
|
||||||
|
|
||||||
|
(defun current-font-size ()
|
||||||
|
(face-attribute 'default :height))
|
||||||
|
|
||||||
|
(defun alter-font-size (f)
|
||||||
|
(let ((curr (current-font-size)))
|
||||||
|
(let ((new (funcall f curr)))
|
||||||
|
(set-font-size new)
|
||||||
|
(message (concat "New font size: " (int-to-string curr) " -> " (int-to-string new))))))
|
||||||
|
|
||||||
|
(defun inc-font-size ()
|
||||||
|
(interactive)
|
||||||
|
(alter-font-size (lambda (x) (ceiling (* x 1.1)))))
|
||||||
|
|
||||||
|
(defun dec-font-size ()
|
||||||
|
(interactive)
|
||||||
|
(alter-font-size (lambda (x) (ceiling (* x 0.9)))))
|
||||||
|
|
||||||
|
|
||||||
|
(global-set-key [(control +)] 'inc-font-size)
|
||||||
|
(global-set-key [(control -)] 'dec-font-size)
|
||||||
|
(global-set-key [(control =)] 'reset-font-size)
|
||||||
|
|
||||||
|
(provide 'my-font)
|
0
stuff/my-gdb.el
Executable file
0
stuff/my-gdb.el
Executable file
5
stuff/my-layout.el
Executable file
5
stuff/my-layout.el
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
(defun window-set-width (width)
|
||||||
|
(interactive)
|
||||||
|
(enlarge-window-horizontally (- width (window-width))))
|
||||||
|
|
||||||
|
(provide 'my-layout)
|
29
stuff/my-lisp-mode.el
Executable file
29
stuff/my-lisp-mode.el
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
(defun my-lisp-mode-setup ()
|
||||||
|
|
||||||
|
(require 'lisp-mode)
|
||||||
|
|
||||||
|
|
||||||
|
;; ------------- ;;
|
||||||
|
;; Configuration ;;
|
||||||
|
;; ------------- ;;
|
||||||
|
|
||||||
|
;; Rebox style
|
||||||
|
(set 'my-rebox-style 523)
|
||||||
|
|
||||||
|
;; -------- ;;
|
||||||
|
;; Bindings ;;
|
||||||
|
;; -------- ;;
|
||||||
|
|
||||||
|
;; Rebox comment
|
||||||
|
(define-key
|
||||||
|
lisp-mode-shared-map
|
||||||
|
[(meta q)]
|
||||||
|
'my-rebox-comment)
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
(add-hook 'lisp-mode-hook 'my-lisp-mode-setup)
|
||||||
|
(add-hook 'emacs-lisp-mode-hook 'my-lisp-mode-setup)
|
||||||
|
|
||||||
|
(provide 'my-lisp-mode)
|
33
stuff/my-python-mode.el
Executable file
33
stuff/my-python-mode.el
Executable file
@ -0,0 +1,33 @@
|
|||||||
|
(custom-set-variables
|
||||||
|
'(python-indent 4))
|
||||||
|
|
||||||
|
(defun python-mode-setup ()
|
||||||
|
|
||||||
|
;; ------------- ;;
|
||||||
|
;; CONFIGURATION ;;
|
||||||
|
;; ------------- ;;
|
||||||
|
|
||||||
|
;; Comment boxing style
|
||||||
|
(set 'my-rebox-style 423)
|
||||||
|
|
||||||
|
;; -------- ;;
|
||||||
|
;; BINDINGS ;;
|
||||||
|
;; -------- ;;
|
||||||
|
|
||||||
|
;; comment
|
||||||
|
(define-key
|
||||||
|
py-mode-map
|
||||||
|
[(control c) (control c)]
|
||||||
|
'comment-region)
|
||||||
|
|
||||||
|
;; rebox
|
||||||
|
(define-key
|
||||||
|
py-mode-map
|
||||||
|
[(meta q)]
|
||||||
|
'my-rebox-comment)
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
(add-hook 'python-mode-hook 'python-mode-setup)
|
||||||
|
|
||||||
|
(provide 'my-python-mode)
|
13
stuff/my-rebox.el
Executable file
13
stuff/my-rebox.el
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
(require 'rebox)
|
||||||
|
|
||||||
|
(defvar my-rebox-style 523)
|
||||||
|
|
||||||
|
(make-variable-buffer-local 'my-rebox-style)
|
||||||
|
|
||||||
|
(defun my-rebox-comment (style)
|
||||||
|
(interactive "P")
|
||||||
|
(if style
|
||||||
|
(let ((rebox-default-style my-rebox-style)) (rebox-comment nil))
|
||||||
|
(rebox-comment nil)))
|
||||||
|
|
||||||
|
(provide 'my-rebox)
|
0
stuff/my-revive.el
Executable file
0
stuff/my-revive.el
Executable file
611
stuff/project-root.el
Normal file
611
stuff/project-root.el
Normal file
@ -0,0 +1,611 @@
|
|||||||
|
;;; project-root.el --- Define a project root and take actions based upon it.
|
||||||
|
|
||||||
|
;; Copyright (C) 2008-2010 Philip Jackson, Alexander Solovyov, Vladimir Sidorenko
|
||||||
|
|
||||||
|
;; Author: Philip Jackson <phil@shellarchive.co.uk>
|
||||||
|
;; Author: Alexander Solovyov <piranha@piranha.org.ua>
|
||||||
|
;; Author: Vladimir Sidorenko <yoyavova@gmail.com>
|
||||||
|
;; Version: 0.8-pre
|
||||||
|
|
||||||
|
;; This file is not currently part of GNU Emacs.
|
||||||
|
|
||||||
|
;; 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 2, 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 ; see the file COPYING. If not, write to
|
||||||
|
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
;; Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
;;; Commentary:
|
||||||
|
|
||||||
|
;; project-root.el allows the user to create rules that will identify
|
||||||
|
;; the root path of a project and then run an action based on the
|
||||||
|
;; details of the project.
|
||||||
|
;;
|
||||||
|
;; Example usage might be might be that you want a certain indentation
|
||||||
|
;; level/type for a particular project.
|
||||||
|
;;
|
||||||
|
;; once project-root-fetch has been run `project-details' will either
|
||||||
|
;; be nil if nothing was found or the project name and path in a cons
|
||||||
|
;; pair.
|
||||||
|
|
||||||
|
;; An example configuration:
|
||||||
|
|
||||||
|
;; (setq project-roots
|
||||||
|
;; `(("Generic Perl Project"
|
||||||
|
;; :root-contains-files ("t" "lib")
|
||||||
|
;; :filename-regex ,(regexify-ext-list '(pl pm))
|
||||||
|
;; :on-hit (lambda (p) (message (car p))))
|
||||||
|
;; ("Django project"
|
||||||
|
;; :root-contains-files ("manage.py")
|
||||||
|
;; :filename-regex ,(regexify-ext-list '(py html css js))
|
||||||
|
;; :exclude-paths ("media" "contrib"))))
|
||||||
|
;;
|
||||||
|
;; I bind the following:
|
||||||
|
;;
|
||||||
|
;; (global-set-key (kbd "C-c p f") 'project-root-find-file)
|
||||||
|
;; (global-set-key (kbd "C-c p g") 'project-root-grep)
|
||||||
|
;; (global-set-key (kbd "C-c p a") 'project-root-ack)
|
||||||
|
;; (global-set-key (kbd "C-c p d") 'project-root-goto-root)
|
||||||
|
;; (global-set-key (kbd "C-c p p") 'project-root-run-default-command)
|
||||||
|
;; (global-set-key (kbd "C-c p l") 'project-root-browse-seen-projects)
|
||||||
|
;;
|
||||||
|
;; (global-set-key (kbd "C-c p M-x")
|
||||||
|
;; 'project-root-execute-extended-command)
|
||||||
|
;;
|
||||||
|
;; (global-set-key
|
||||||
|
;; (kbd "C-c p v")
|
||||||
|
;; (lambda ()
|
||||||
|
;; (interactive)
|
||||||
|
;; (with-project-root
|
||||||
|
;; (let ((root (cdr project-details)))
|
||||||
|
;; (cond
|
||||||
|
;; ((file-exists-p ".svn")
|
||||||
|
;; (svn-status root))
|
||||||
|
;; ((file-exists-p ".git")
|
||||||
|
;; (git-status root))
|
||||||
|
;; (t
|
||||||
|
;; (vc-directory root nil)))))))
|
||||||
|
;;
|
||||||
|
;; This defines one project called "Generic Perl Projects" by running
|
||||||
|
;; the tests path-matches and root-contains-files. Once these tests
|
||||||
|
;; have been satisfied and a project found then (the optional) :on-hit
|
||||||
|
;; will be run.
|
||||||
|
|
||||||
|
;;; The tests:
|
||||||
|
|
||||||
|
;; :path-matches maps to `project-root-path-matches' and
|
||||||
|
;; :root-contains-files maps to `project-root-upward-find-files'. You
|
||||||
|
;; can use any amount of tests.
|
||||||
|
|
||||||
|
;;; Configuration:
|
||||||
|
|
||||||
|
;; :filename-regex should contain regular expression, which is passed
|
||||||
|
;; to `find` to actually find files for your project.
|
||||||
|
;; :exclude-paths can contain paths to omit when searching for files.
|
||||||
|
|
||||||
|
;;; Bookmarks:
|
||||||
|
|
||||||
|
;; If you fancy it you can add a :bookmarks property (with a list of
|
||||||
|
;; strings) and when you run `project-root-browse-seen-projects' you
|
||||||
|
;; will see the bookmarks listed under the project name, linking
|
||||||
|
;; relatively to the project root. Also, the bookmarks will present
|
||||||
|
;; themselves as anything candidates if you configure as instructed
|
||||||
|
;; below.
|
||||||
|
|
||||||
|
;;; The default command:
|
||||||
|
|
||||||
|
;; If you give a project a :default-command property you can execute
|
||||||
|
;; it by running `project-root-run-default-command'. Nothing fancy but
|
||||||
|
;; very handy.
|
||||||
|
|
||||||
|
;;; installation:
|
||||||
|
|
||||||
|
;; Put this file into your `load-path' and evaulate (require
|
||||||
|
;; 'project-root).
|
||||||
|
|
||||||
|
;;; Using yourself:
|
||||||
|
|
||||||
|
;; If you wrap a call in `with-project-root' then everything in its
|
||||||
|
;; body will execute under project root:
|
||||||
|
;;
|
||||||
|
;; (with-project-root
|
||||||
|
;; (shell-command-to-string "pwd"))
|
||||||
|
|
||||||
|
;;; anything.el intergration
|
||||||
|
|
||||||
|
;; If you want to add the bookmarks for the current project to the
|
||||||
|
;; anything source list then use:
|
||||||
|
;;
|
||||||
|
;; (add-to-list 'anything-sources
|
||||||
|
;; project-root-anything-config-bookmarks)
|
||||||
|
;;
|
||||||
|
;; If you want to add the bookmarks for each of the files in the
|
||||||
|
;; current project to the anything source list then use:
|
||||||
|
;;
|
||||||
|
;; (add-to-list 'anything-sources
|
||||||
|
;; project-root-anything-config-files)
|
||||||
|
|
||||||
|
(require 'find-cmd)
|
||||||
|
(require 'cl)
|
||||||
|
|
||||||
|
(eval-when-compile
|
||||||
|
(defvar anything-project-root)
|
||||||
|
(require 'outline)
|
||||||
|
(require 'dired))
|
||||||
|
|
||||||
|
(defun project-root-find-prune (paths &optional no-default-directory)
|
||||||
|
(mapconcat '(lambda (path)
|
||||||
|
(if no-default-directory
|
||||||
|
(concat " -path \"" path "\" -prune ")
|
||||||
|
(concat " -path \"" default-directory path "\" -prune ")))
|
||||||
|
paths "-o"))
|
||||||
|
|
||||||
|
(defvar project-root-extra-find-args
|
||||||
|
(project-root-find-prune '("*/.hg" "*/.git" "*/.svn") t)
|
||||||
|
; (find-to-string '(prune (name ".svn" ".git" ".hg")))
|
||||||
|
"Extra find args that will be AND'd to the defaults (which are
|
||||||
|
in `project-root-file-find-process')")
|
||||||
|
|
||||||
|
(defvar project-root-seen-projects nil
|
||||||
|
"All of the projects that we have met so far in this session.")
|
||||||
|
|
||||||
|
(defvar project-root-file-cache nil
|
||||||
|
"Cache for `completing-read'")
|
||||||
|
|
||||||
|
(make-variable-buffer-local
|
||||||
|
(defvar project-details nil
|
||||||
|
"The name and path of the current project root."))
|
||||||
|
|
||||||
|
(defvar project-root-test-dispatch
|
||||||
|
'((:root-contains-files . project-root-upward-find-files)
|
||||||
|
(:path-matches . project-root-path-matches))
|
||||||
|
"Map a property name to root test function.")
|
||||||
|
|
||||||
|
(defvar project-roots nil
|
||||||
|
"An alist describing the projects and how to find them.")
|
||||||
|
|
||||||
|
(defvar project-root-max-search-depth 20
|
||||||
|
"Don't go any further than this many levels when searching down
|
||||||
|
a filesystem tree")
|
||||||
|
|
||||||
|
(defvar project-root-find-options
|
||||||
|
""
|
||||||
|
"Extra options to pass to `find' when using project-root-find-file.
|
||||||
|
|
||||||
|
Use this to exclude portions of your project: \"-not -regex \\\".*vendor.*\\\"\"")
|
||||||
|
|
||||||
|
(defvar project-root-storage-file "~/.emacs.d/.project-roots"
|
||||||
|
"File, where seen projects info is saved.")
|
||||||
|
|
||||||
|
(defvar project-root-project-name-func 'project-root-project-name-from-dir
|
||||||
|
"Function to generate cute name for project.")
|
||||||
|
|
||||||
|
(defun project-root-run-default-command ()
|
||||||
|
"Run the command in :default-command, if there is one."
|
||||||
|
(interactive)
|
||||||
|
(with-project-root
|
||||||
|
(let ((command (project-root-data
|
||||||
|
:default-command project-details)))
|
||||||
|
(when command
|
||||||
|
(funcall command)))))
|
||||||
|
|
||||||
|
(defun project-root-project-name (project)
|
||||||
|
(funcall project-root-project-name-func project))
|
||||||
|
|
||||||
|
(defun project-root-path-matches (re)
|
||||||
|
"Apply RE to the current buffer name returning the first
|
||||||
|
match."
|
||||||
|
(let ((filename (cond
|
||||||
|
((string= major-mode "dired-mode")
|
||||||
|
(dired-get-filename nil t))
|
||||||
|
(buffer-file-name
|
||||||
|
buffer-file-name))))
|
||||||
|
(when (and filename (not (null (string-match re filename))))
|
||||||
|
(match-string 1 filename))))
|
||||||
|
|
||||||
|
(defun project-root-get-root (project)
|
||||||
|
"Fetch the root path of the project according to the tests
|
||||||
|
described in PROJECT."
|
||||||
|
(let ((root (plist-get project :root))
|
||||||
|
(new-root))
|
||||||
|
(catch 'not-a-project
|
||||||
|
(mapc
|
||||||
|
(lambda (test)
|
||||||
|
(when (plist-get project (car test))
|
||||||
|
;; grab a potentially different root
|
||||||
|
(setq new-root
|
||||||
|
(funcall (cdr test) (plist-get project (car test))))
|
||||||
|
(cond
|
||||||
|
((null new-root)
|
||||||
|
(throw 'not-a-project nil))
|
||||||
|
;; check root is so far consistent
|
||||||
|
((and (not (null root))
|
||||||
|
(not (string= root new-root)))
|
||||||
|
(throw 'not-a-project nil))
|
||||||
|
(t
|
||||||
|
(setq root new-root)))))
|
||||||
|
project-root-test-dispatch)
|
||||||
|
(when root
|
||||||
|
(file-name-as-directory root)))))
|
||||||
|
|
||||||
|
(defun project-root-data (key &optional project)
|
||||||
|
"Grab the value (if any) for key in PROJECT. If PROJECT is
|
||||||
|
ommited then attempt to get the value for the current
|
||||||
|
project."
|
||||||
|
(let ((project (or project project-details)))
|
||||||
|
(plist-get (cdr (assoc (car project) project-roots)) key)))
|
||||||
|
|
||||||
|
(defun project-root-bookmarks (&optional project)
|
||||||
|
"Grab the bookmarks (if any) for PROJECT."
|
||||||
|
(project-root-data :bookmarks project))
|
||||||
|
|
||||||
|
(defun project-root-project-name-from-dir (project)
|
||||||
|
"Generate cute name for project from its directory name."
|
||||||
|
(upcase-initials (car (last (split-string (cdr project) "/" t)))))
|
||||||
|
|
||||||
|
(defun project-root-gen-org-url (project)
|
||||||
|
;; The first link to the project root itself
|
||||||
|
(concat
|
||||||
|
(format "** [[file:%s][%s]] (%s)"
|
||||||
|
(cdr project)
|
||||||
|
(project-root-project-name project)
|
||||||
|
(cdr project))
|
||||||
|
(mapconcat
|
||||||
|
(lambda (b)
|
||||||
|
(let ((mark (concat (cdr project) b)))
|
||||||
|
(format "*** [[file:%s][%s]] (%s)" mark b mark)))
|
||||||
|
(project-root-bookmarks project)
|
||||||
|
"\n")
|
||||||
|
"\n"))
|
||||||
|
|
||||||
|
(define-derived-mode project-root-list-mode org-mode "Project-List"
|
||||||
|
(setq buffer-read-only t))
|
||||||
|
|
||||||
|
(dolist (keyfunc
|
||||||
|
`(("q" kill-this-buffer)
|
||||||
|
("s" isearch-forward)
|
||||||
|
("r" isearch-backward)
|
||||||
|
(,(kbd "RET")
|
||||||
|
(lambda () (interactive) (beginning-of-line)
|
||||||
|
(org-next-link) (org-open-at-point t)))
|
||||||
|
(,(kbd "C-d") (lambda () (interactive)
|
||||||
|
(setq buffer-read-only nil)
|
||||||
|
(delete-region
|
||||||
|
(line-beginning-position)
|
||||||
|
(line-beginning-position 2))
|
||||||
|
(setq buffer-read-only t)))))
|
||||||
|
|
||||||
|
(define-key project-root-list-mode-map (car keyfunc) (cadr keyfunc)))
|
||||||
|
|
||||||
|
(defun project-root-browse-seen-projects ()
|
||||||
|
"Browse the projects that have been seen so far this session."
|
||||||
|
(interactive)
|
||||||
|
(let ((current-project project-details)
|
||||||
|
(point-to nil))
|
||||||
|
(if (not project-root-seen-projects)
|
||||||
|
(project-root-load-roots))
|
||||||
|
|
||||||
|
(switch-to-buffer (get-buffer-create "*Seen Project List*"))
|
||||||
|
(erase-buffer)
|
||||||
|
(insert "* Seen projects\n")
|
||||||
|
(mapc (lambda (p)
|
||||||
|
(when (file-exists-p (cdr p))
|
||||||
|
(when (equal p current-project)
|
||||||
|
(setq point-to (point)))
|
||||||
|
(insert (project-root-gen-org-url p))))
|
||||||
|
project-root-seen-projects)
|
||||||
|
|
||||||
|
(project-root-list-mode)
|
||||||
|
;; show everything at second level
|
||||||
|
(goto-char (point-min))
|
||||||
|
(show-children)
|
||||||
|
;; expand bookmarks for current project only
|
||||||
|
(when point-to
|
||||||
|
(goto-char (+ point-to 3))
|
||||||
|
(show-children))))
|
||||||
|
|
||||||
|
(defun project-root-save-roots ()
|
||||||
|
"Saves seen projects info to file. Note that
|
||||||
|
this is not done automatically"
|
||||||
|
(interactive)
|
||||||
|
(with-temp-buffer
|
||||||
|
(print project-root-seen-projects (current-buffer))
|
||||||
|
(write-file project-root-storage-file)))
|
||||||
|
|
||||||
|
(defun project-root-load-roots ()
|
||||||
|
"Loads seen projects info from file"
|
||||||
|
(interactive)
|
||||||
|
(if (file-exists-p project-root-storage-file)
|
||||||
|
(with-temp-buffer
|
||||||
|
(insert-file-contents project-root-storage-file)
|
||||||
|
(setq project-root-seen-projects (read (buffer-string))))))
|
||||||
|
|
||||||
|
|
||||||
|
;; TODO: refactor me
|
||||||
|
(defun project-root-fetch (&optional dont-run-on-hit)
|
||||||
|
"Attempt to fetch the root project for the current file. Tests
|
||||||
|
will be used as defined in `project-roots'."
|
||||||
|
(interactive)
|
||||||
|
(let ((project
|
||||||
|
(catch 'root-found
|
||||||
|
(unless (mapc
|
||||||
|
(lambda (project)
|
||||||
|
(let ((name (car project))
|
||||||
|
(run (project-root-data :on-hit project))
|
||||||
|
(root (project-root-get-root (cdr project))))
|
||||||
|
(when root
|
||||||
|
(when (and root (not dont-run-on-hit) run)
|
||||||
|
(funcall run (cons name root)))
|
||||||
|
(throw 'root-found (cons name root)))))
|
||||||
|
project-roots)
|
||||||
|
nil))))
|
||||||
|
;; set the actual var used by apps and add to the global project
|
||||||
|
;; list
|
||||||
|
(when project
|
||||||
|
(project-root-set-project project))))
|
||||||
|
|
||||||
|
(defun project-root-set-project (p)
|
||||||
|
(if (not project-root-seen-projects)
|
||||||
|
(project-root-load-roots))
|
||||||
|
(when (not (member p project-root-seen-projects))
|
||||||
|
(add-to-list 'project-root-seen-projects project)
|
||||||
|
(project-root-save-roots))
|
||||||
|
(setq project-details project))
|
||||||
|
|
||||||
|
(defun project-root-every (pred seq)
|
||||||
|
"Return non-nil if pred of each element, of seq is non-nil."
|
||||||
|
(catch 'got-nil
|
||||||
|
(mapc (lambda (x)
|
||||||
|
(unless (funcall pred x)
|
||||||
|
(throw 'got-nil nil)))
|
||||||
|
seq)))
|
||||||
|
|
||||||
|
(defun project-root-upward-find-files (filenames &optional startdir)
|
||||||
|
"Return the first directory upwards from STARTDIR that contains
|
||||||
|
all elements of FILENAMES. If STATDIR is nil then use
|
||||||
|
current-directory."
|
||||||
|
(let ((default-directory (expand-file-name (or startdir ".")))
|
||||||
|
(depth 0))
|
||||||
|
(catch 'pr-finish
|
||||||
|
(while t
|
||||||
|
;; don't go too far down the tree
|
||||||
|
(when (> (setq depth (1+ depth)) project-root-max-search-depth)
|
||||||
|
(throw 'pr-finish nil))
|
||||||
|
(cond
|
||||||
|
((project-root-every 'file-exists-p filenames)
|
||||||
|
(throw 'pr-finish default-directory))
|
||||||
|
;; if we hit root
|
||||||
|
((string= (expand-file-name default-directory) "/")
|
||||||
|
(throw 'pr-finish nil)))
|
||||||
|
;; try again up a directory
|
||||||
|
(setq default-directory
|
||||||
|
(expand-file-name ".." default-directory))))))
|
||||||
|
|
||||||
|
(defun project-root-p (&optional p)
|
||||||
|
"Check to see if P or `project-details' is valid"
|
||||||
|
(let ((p (or p project-details)))
|
||||||
|
(and p (file-exists-p (cdr p)))))
|
||||||
|
|
||||||
|
(defun regexify-ext-list (extensions)
|
||||||
|
"Turn a list of extensions to a regexp."
|
||||||
|
(concat ".*\\.\\(" (mapconcat '(lambda (x) (format "%s" x))
|
||||||
|
extensions "\\|") "\\)"))
|
||||||
|
|
||||||
|
(defmacro with-project-root (&rest body)
|
||||||
|
"Run BODY with default-directory set to the project root. Error
|
||||||
|
if not found. If `project-root' isn't defined then try and find
|
||||||
|
one."
|
||||||
|
(declare (indent 2))
|
||||||
|
`(progn
|
||||||
|
(unless project-details (project-root-fetch))
|
||||||
|
(if (project-root-p)
|
||||||
|
(let ((default-directory (cdr project-details))
|
||||||
|
(filename-regex (or (project-root-data :filename-regex) ".*"))
|
||||||
|
(exclude-paths (project-root-data :exclude-paths)))
|
||||||
|
,@body)
|
||||||
|
(error "No project root found"))))
|
||||||
|
|
||||||
|
(defun project-root-goto-root ()
|
||||||
|
"Open up the project root in dired."
|
||||||
|
(interactive)
|
||||||
|
(with-project-root (find-file default-directory)))
|
||||||
|
|
||||||
|
(defun project-root-grep ()
|
||||||
|
"Run the grep command from the current project root."
|
||||||
|
(interactive)
|
||||||
|
(with-project-root (call-interactively 'grep)))
|
||||||
|
|
||||||
|
(defun project-root-ack ()
|
||||||
|
"Run the ack command from the current project root (if ack is
|
||||||
|
available)."
|
||||||
|
(interactive)
|
||||||
|
(with-project-root
|
||||||
|
(if (fboundp 'ack)
|
||||||
|
(call-interactively 'ack)
|
||||||
|
(error "`ack' not bound"))))
|
||||||
|
|
||||||
|
(defun project-root-files ()
|
||||||
|
"Return an alist of all filenames in the project and their path.
|
||||||
|
|
||||||
|
Files with duplicate filenames are suffixed with the name of the
|
||||||
|
directory they are found in so that they are unique."
|
||||||
|
(let ((file-alist nil))
|
||||||
|
(mapcar (lambda (file)
|
||||||
|
(let ((file-cons (cons (project-root-filename file)
|
||||||
|
(expand-file-name file))))
|
||||||
|
(add-to-list 'file-alist file-cons)
|
||||||
|
file-cons))
|
||||||
|
(split-string (shell-command-to-string
|
||||||
|
(project-root-find-cmd))))))
|
||||||
|
|
||||||
|
(setq .project-root-find-executable nil)
|
||||||
|
(defun project-root-find-executable ()
|
||||||
|
(if .project-root-find-executable
|
||||||
|
.project-root-find-executable
|
||||||
|
(setq .project-root-find-executable (executable-find "gfind"))
|
||||||
|
(if (not .project-root-find-executable)
|
||||||
|
(setq .project-root-find-executable (executable-find "find")))
|
||||||
|
.project-root-find-executable))
|
||||||
|
|
||||||
|
(defun project-root-find-cmd (&rest pattern)
|
||||||
|
(let ((pattern (car pattern)))
|
||||||
|
;; TODO: use find-cmd here
|
||||||
|
(concat (project-root-find-executable) " " default-directory
|
||||||
|
(project-root-find-prune exclude-paths)
|
||||||
|
project-root-extra-find-args
|
||||||
|
", -type f -regex \"" filename-regex "\" "
|
||||||
|
(if pattern (concat " -name '*" pattern "*' "))
|
||||||
|
project-root-find-options)))
|
||||||
|
|
||||||
|
(defun project-root-filename (file)
|
||||||
|
(let ((name (replace-regexp-in-string default-directory ""
|
||||||
|
(expand-file-name file))))
|
||||||
|
(mapconcat 'identity (reverse (split-string name "/")) "\\")))
|
||||||
|
|
||||||
|
(defun project-root-find-file ()
|
||||||
|
"Find a file from a list of those that exist in the current
|
||||||
|
project."
|
||||||
|
(interactive)
|
||||||
|
(with-project-root
|
||||||
|
(let* ((project-files (project-root-files))
|
||||||
|
(file (if (functionp 'ido-completing-read)
|
||||||
|
(ido-completing-read "Find file in project: "
|
||||||
|
(mapcar 'car project-files))
|
||||||
|
(completing-read "Find file in project: "
|
||||||
|
(mapcar 'car project-files)))))
|
||||||
|
(find-file (cdr (assoc file project-files))))))
|
||||||
|
|
||||||
|
(defun project-root-execute-extended-command ()
|
||||||
|
"Run `execute-extended-command' after having set
|
||||||
|
`default-directory' to the root of the current project."
|
||||||
|
(interactive)
|
||||||
|
(with-project-root (execute-extended-command current-prefix-arg)))
|
||||||
|
|
||||||
|
(defun project-root-file-in-project (filename &optional p)
|
||||||
|
"Check to see if FILENAME is in the project P. If P is omitted
|
||||||
|
then the current project-details are used."
|
||||||
|
(let ((p (or p (progn
|
||||||
|
(project-root-fetch)
|
||||||
|
project-details))))
|
||||||
|
(and
|
||||||
|
p
|
||||||
|
(file-exists-p filename)
|
||||||
|
(not (null (string-match
|
||||||
|
(regexp-quote (abbreviate-file-name (cdr p)))
|
||||||
|
(abbreviate-file-name filename)))))))
|
||||||
|
|
||||||
|
(defun project-root-buffer-in-project (buffer &optional p)
|
||||||
|
"Check to see if buffer is in project"
|
||||||
|
(let ((filename (buffer-file-name buffer)))
|
||||||
|
(and filename (project-root-file-in-project filename p))))
|
||||||
|
|
||||||
|
(defun ido-ignore-not-in-project (name)
|
||||||
|
"Function to use with ido-ignore-buffers.
|
||||||
|
Ignores files that are not in current project."
|
||||||
|
(not (project-root-buffer-in-project (get-buffer name))))
|
||||||
|
|
||||||
|
(defun project-root-switch-buffer (arg)
|
||||||
|
"ido-switch-buffer replacement. Ignore buffers that are not in current project,
|
||||||
|
fallback to original ido-switch-buffer if no current project.
|
||||||
|
Can be used with universal-argument to run orifinal function even in project."
|
||||||
|
(interactive "P")
|
||||||
|
(if (and (null arg) (or project-details (project-root-fetch)))
|
||||||
|
(with-project-root
|
||||||
|
(let ((ido-ignore-buffers
|
||||||
|
(append '(ido-ignore-not-in-project) ido-ignore-files)))
|
||||||
|
(ido-switch-buffer)
|
||||||
|
))
|
||||||
|
(ido-switch-buffer)))
|
||||||
|
|
||||||
|
(defun project-root-projects-names ()
|
||||||
|
"Generates a list of pairs - project name and path."
|
||||||
|
(mapcar (lambda (project)
|
||||||
|
(cons (project-root-project-name project) (cdr project)))
|
||||||
|
project-root-seen-projects))
|
||||||
|
|
||||||
|
(defun project-root-open-project ()
|
||||||
|
"Open project with ido-mode."
|
||||||
|
(interactive)
|
||||||
|
(let* ((project-names (project-root-projects-names))
|
||||||
|
(project (ido-completing-read "Select project: " (mapcar 'car project-names))))
|
||||||
|
(find-file (cdr (assoc project project-names)))))
|
||||||
|
|
||||||
|
|
||||||
|
;;; anything.el config
|
||||||
|
|
||||||
|
(defun project-root-anything-colourfy-hits (hits)
|
||||||
|
;; delete the project-root part
|
||||||
|
(let ((highs (project-root-data :anything-highlight
|
||||||
|
anything-project-root)))
|
||||||
|
(mapcar
|
||||||
|
'(lambda (hit)
|
||||||
|
(let ((new (replace-regexp-in-string
|
||||||
|
(regexp-quote (cdr anything-project-root))
|
||||||
|
""
|
||||||
|
hit)))
|
||||||
|
(when highs
|
||||||
|
(mapc '(lambda (s)
|
||||||
|
;; propertize either the first group or the whole
|
||||||
|
;; string
|
||||||
|
(when (string-match (car s) new)
|
||||||
|
(put-text-property (or (match-beginning 1) 0)
|
||||||
|
(or (match-end 1) (length new))
|
||||||
|
'face (cdr s)
|
||||||
|
new)))
|
||||||
|
highs))
|
||||||
|
(cons new hit)))
|
||||||
|
hits)))
|
||||||
|
|
||||||
|
(defvar project-root-anything-config-files
|
||||||
|
'((name . "Project Files")
|
||||||
|
(init . (lambda ()
|
||||||
|
(unless project-details
|
||||||
|
(project-root-fetch))
|
||||||
|
(setq anything-project-root project-details)))
|
||||||
|
(candidates . (lambda ()
|
||||||
|
(project-root-file-find-process anything-pattern)))
|
||||||
|
(candidate-transformer . project-root-anything-colourfy-hits)
|
||||||
|
(type . file)
|
||||||
|
(requires-pattern . 2)
|
||||||
|
(volatile)
|
||||||
|
(delayed)))
|
||||||
|
|
||||||
|
(defvar project-root-anything-config-bookmarks
|
||||||
|
'((name . "Project Bookmarks")
|
||||||
|
(init . (lambda ()
|
||||||
|
(unless project-details
|
||||||
|
(project-root-fetch))
|
||||||
|
(setq anything-default-directory (cdr project-details)
|
||||||
|
anything-project-root project-details)))
|
||||||
|
(candidates . (lambda ()
|
||||||
|
(mapcar
|
||||||
|
'(lambda (b)
|
||||||
|
(expand-file-name b anything-default-directory))
|
||||||
|
(project-root-bookmarks anything-project-root))))
|
||||||
|
(type . file)))
|
||||||
|
|
||||||
|
(defun project-root-file-find-process (pattern)
|
||||||
|
"Return a process which represents a find of all files matching
|
||||||
|
`project-root-extra-find-args' and the hard-coded arguments in
|
||||||
|
this function."
|
||||||
|
(when anything-project-root
|
||||||
|
(start-process-shell-command
|
||||||
|
"project-root-find"
|
||||||
|
nil
|
||||||
|
"find"
|
||||||
|
(cdr anything-project-root)
|
||||||
|
(find-to-string
|
||||||
|
`(and ,project-root-extra-find-args
|
||||||
|
(name ,(concat "*" pattern "*"))
|
||||||
|
(type "f"))))))
|
||||||
|
|
||||||
|
(provide 'project-root)
|
285
stuff/tiger.el
Executable file
285
stuff/tiger.el
Executable file
@ -0,0 +1,285 @@
|
|||||||
|
;;; tiger.el --- Mode for editing programs written in Appel's Tiger language.
|
||||||
|
|
||||||
|
;; Copyright (C) 2001, 2007 Edward O'Connor <ted@oconnor.cx>
|
||||||
|
|
||||||
|
;; Author: Edward O'Connor <ted@oconnor.cx>
|
||||||
|
;; Keywords: languages
|
||||||
|
;; Maintainers :
|
||||||
|
;; Jerome Bana <bana_j@epita.fr>
|
||||||
|
;; Benoit Perrot <perrot_b@epita.fr>
|
||||||
|
;; Roland Levillain <roland@lrde.epita.fr>
|
||||||
|
|
||||||
|
;; This file is free software; you can redistribute it and/or modify
|
||||||
|
;; it under the terms of version 2 of the GNU General Public License
|
||||||
|
;; as published by the Free Software Foundation.
|
||||||
|
;; 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.
|
||||||
|
|
||||||
|
;; I'm sure you already have many copies of the GPL on your machine.
|
||||||
|
;; If you're using GNU Emacs, try typing C-h C-c to bring it up. If
|
||||||
|
;; you're using XEmacs, C-h C-l does this.
|
||||||
|
|
||||||
|
;;; Commentary:
|
||||||
|
;; This mode only supports font-locking, unfortunately. If you'd like
|
||||||
|
;; to add functionality, please do so! :) You'll want to add something
|
||||||
|
;; like this to your .emacs file:
|
||||||
|
|
||||||
|
;; (autoload 'tiger-mode "tiger" "Load tiger-mode" t)
|
||||||
|
;; (add-to-list 'auto-mode-alist '("\\.ti[gh]$" . tiger-mode))
|
||||||
|
|
||||||
|
;;; History:
|
||||||
|
;; In the Compilers class I took in college[0], we used Appel's
|
||||||
|
;; _Modern Compiler Implementation in Java_ text[1], in which he uses
|
||||||
|
;; the Tiger language. After a few weeks of our final project (which
|
||||||
|
;; was to write a Tiger compiler), I got sick of looking at
|
||||||
|
;; #c0c0c0-on-black Tiger text, and decided to hack up (at least) some
|
||||||
|
;; font-lock support for the language. Hence this file. I would have
|
||||||
|
;; added indenting stuff too, but the term ended and I graduated. :)
|
||||||
|
;; If you add functionality or whatever, please send me the changes;
|
||||||
|
;; I'll gladly maintain the code base or whatever. The latest version
|
||||||
|
;; can be found here: <URL:http://oconnor.cx/elisp/tiger.el>
|
||||||
|
;;
|
||||||
|
;; -- Ted
|
||||||
|
;;
|
||||||
|
;; 0. <URL:http://www.rose-hulman.edu/>
|
||||||
|
;; 1. <URL:http://www.cs.princeton.edu/~appel/modern/>
|
||||||
|
|
||||||
|
|
||||||
|
;;; Declare Tiger mode.
|
||||||
|
(defgroup tiger nil
|
||||||
|
"Tiger code editing commands for Emacs."
|
||||||
|
:prefix "tiger-"
|
||||||
|
:group 'languages)
|
||||||
|
|
||||||
|
(defcustom tiger-mode-hook nil
|
||||||
|
"*Hook called by `tiger-mode'."
|
||||||
|
:type 'hook
|
||||||
|
:group 'tiger)
|
||||||
|
|
||||||
|
|
||||||
|
;;; Define Tiger syntax table.
|
||||||
|
(defvar tiger-mode-syntax-table nil
|
||||||
|
"Syntax table used in Tiger mode.")
|
||||||
|
(when (not tiger-mode-syntax-table)
|
||||||
|
(setq tiger-mode-syntax-table (make-syntax-table))
|
||||||
|
;; Declare the underscore character '_' as being a valid part of a word.
|
||||||
|
(modify-syntax-entry ?_ "w" tiger-mode-syntax-table)
|
||||||
|
;; Comment (n for nested works only with emacs-21)
|
||||||
|
(modify-syntax-entry ?/ ". 14n" tiger-mode-syntax-table)
|
||||||
|
(modify-syntax-entry ?* ". 23" tiger-mode-syntax-table)
|
||||||
|
)
|
||||||
|
|
||||||
|
;;; Highlight Syntax.
|
||||||
|
(defconst tiger-font-lock-keywords
|
||||||
|
`(
|
||||||
|
;; Tiger keywords:
|
||||||
|
("\\<\\(array\\|break\\|do\\|e\\(?:lse\\|nd\\)\\|f\\(?:or\\|unction\\)\\|i\\(?:f\\|mport\\|n\\)\\|let\\|nil\\|of\\|primitive\\|t\\(?:hen\\|o\\|ype\\)\\|var\\|while\\)\\>"
|
||||||
|
(1 font-lock-keyword-face))
|
||||||
|
|
||||||
|
;; Reserved keywords (only valid in Leopard):
|
||||||
|
("\\<\\(class\\|extends\\|method\\|new\\)\\>"
|
||||||
|
(1 font-lock-warning-face))
|
||||||
|
|
||||||
|
;; Reserved identifiers:
|
||||||
|
("\\<\\(_\\w*\\)\\>"
|
||||||
|
(1 font-lock-warning-face))
|
||||||
|
|
||||||
|
;; Variable declarations:
|
||||||
|
("\\<var\\s +\\([a-zA-Z]\\w*\\)"
|
||||||
|
(1 font-lock-variable-name-face))
|
||||||
|
("\\<\\([a-zA-Z]\\w*\\)\\s *:\\s *\\([a-zA-Z]\\w*\\)"
|
||||||
|
(1 font-lock-variable-name-face)
|
||||||
|
(2 font-lock-type-face))
|
||||||
|
|
||||||
|
;; Type declarations:
|
||||||
|
("\\<type\\s +\\([a-zA-Z]\\w*\\)\\>"
|
||||||
|
(1 font-lock-type-face))
|
||||||
|
;; Builtin types:
|
||||||
|
("\\<\\(boolean\\|int\\|string\\)\\>"
|
||||||
|
(1 font-lock-type-face))
|
||||||
|
;; _t and _type:
|
||||||
|
("\\<\\([a-zA-Z]\\w*_t\\(ype\\)?\\)\\>"
|
||||||
|
(1 font-lock-type-face))
|
||||||
|
|
||||||
|
;; Function declarations:
|
||||||
|
("\\<function\\s +\\([a-zA-Z]\\w*\\)\\>"
|
||||||
|
(1 font-lock-function-name-face))
|
||||||
|
(":\\s *\\([a-zA-Z]\\w*\\)\\>"
|
||||||
|
(1 font-lock-type-face))
|
||||||
|
;; Builtin functions:
|
||||||
|
("\\<\\(c\\(?:hr\\|oncat\\)\\|exit\\|flush\\|getchar\\|not\\|ord\\|print\\(?:_err\\|_int\\)?\\|s\\(?:ize\\|ubstring\\|tr\\(?:cmp\\|eq\\)\\)\\)\\>"
|
||||||
|
(1 font-lock-builtin-face))
|
||||||
|
)
|
||||||
|
|
||||||
|
"Expressions to highlight in Tiger modes.")
|
||||||
|
|
||||||
|
;;; Indent Tiger code.
|
||||||
|
(defvar tiger-indent 2
|
||||||
|
"Indentation of Tiger statements.")
|
||||||
|
|
||||||
|
(defun tiger-search-block-backward (re re-start re-end)
|
||||||
|
"Search backward for the opening of a code block."
|
||||||
|
|
||||||
|
(setq found-p t)
|
||||||
|
(let ((depth 1) (comment-level 0))
|
||||||
|
|
||||||
|
(setq re (concat re "\\|/\\*\\|\\*/"))
|
||||||
|
(while (< 0 depth)
|
||||||
|
(if (not (re-search-backward re nil t)) (setq depth 0
|
||||||
|
comment-level -1
|
||||||
|
found-p nil))
|
||||||
|
(cond
|
||||||
|
;; nested comment
|
||||||
|
((looking-at "/\\*") (setq comment-level (1+ comment-level)))
|
||||||
|
((looking-at "\\*/") (setq comment-level (1- comment-level)))
|
||||||
|
;; sentry
|
||||||
|
((< 0 comment-level) (setq depth 0))
|
||||||
|
;;
|
||||||
|
((= 0 comment-level)
|
||||||
|
(cond
|
||||||
|
((looking-at re-start) (setq depth (1+ depth)))
|
||||||
|
((looking-at re-end) (setq depth (1- depth)))
|
||||||
|
((= depth 1) (setq depth 0))
|
||||||
|
))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
found-p
|
||||||
|
)
|
||||||
|
|
||||||
|
(defun tiger-block-indentation ()
|
||||||
|
"Return block indentation."
|
||||||
|
|
||||||
|
(setq indent-inc 0)
|
||||||
|
(let
|
||||||
|
((re "") (re-start "") (re-end ""))
|
||||||
|
(cond
|
||||||
|
((looking-at "\\s *end\\>")
|
||||||
|
(setq re "\\<\\(in\\|end\\)\\>"
|
||||||
|
re-start "\\<end\\>" re-end "\\<in\\>"))
|
||||||
|
((looking-at "\\s *in\\>")
|
||||||
|
(setq re "\\<\\(let\\|in\\)\\>"
|
||||||
|
re-start "\\<in\\>" re-end "\\<let\\>"))
|
||||||
|
((looking-at "\\s *then\\>")
|
||||||
|
(setq re "\\<\\(if\\|then\\)\\>"
|
||||||
|
re-start "\\<then\\>" re-end "\\<if\\>"))
|
||||||
|
((looking-at "\\s *else\\>")
|
||||||
|
(setq re "\\<\\(then\\|else\\)\\>"
|
||||||
|
re-start "\\<else\\>" re-end "\\<then\\>"))
|
||||||
|
((looking-at "\\s *\\(var\\|type\\|function\\)\\>")
|
||||||
|
(setq re "\\<\\(let\\|end\\)\\>"
|
||||||
|
re-start "\\<end\\>" re-end "\\<let\\>"
|
||||||
|
indent-inc tiger-indent))
|
||||||
|
|
||||||
|
((looking-at "\\s *[])}]")
|
||||||
|
(setq re "[][(){}]"
|
||||||
|
re-start "[])}]" re-end "[[({]"))
|
||||||
|
;; default
|
||||||
|
(t
|
||||||
|
(setq re "\\<\\(let\\|in\\|end\\|if\\|then\\|else\\|do\\|function\\|type\\)\\>\\|[][(){};]"
|
||||||
|
re-start "\\<end\\>\\|[])}]" re-end "\\<let\\>\\|[[({]"
|
||||||
|
indent-inc tiger-indent)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(if (not (tiger-search-block-backward re re-start re-end))
|
||||||
|
(setq indent-inc 0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(if (looking-at ";")
|
||||||
|
(tiger-search-block-backward "\\<\\(let\\|in\\|end\\|if\\|then\\)\\>\\|[][(){}]"
|
||||||
|
"[])}]\\|then\\|end"
|
||||||
|
"[[({]\\|if\\|let"))
|
||||||
|
|
||||||
|
(cond
|
||||||
|
;; handle opening parenthesis
|
||||||
|
((looking-at "[[(]")
|
||||||
|
(+ (current-column)
|
||||||
|
(if (not (looking-at "[[(]\\s *$"))
|
||||||
|
(min 1 indent-inc)
|
||||||
|
indent-inc)))
|
||||||
|
;; handle "then" single on line
|
||||||
|
((looking-at "then") (+ (current-indentation) indent-inc))
|
||||||
|
;; default
|
||||||
|
(t (+ (current-column) indent-inc))
|
||||||
|
)
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
(defun tiger-indent-line ()
|
||||||
|
"Indent current line as Tiger code."
|
||||||
|
(interactive)
|
||||||
|
|
||||||
|
(if (bobp)
|
||||||
|
;; Do not indent first line
|
||||||
|
(indent-line-to 0)
|
||||||
|
|
||||||
|
;;;
|
||||||
|
(if nil
|
||||||
|
(progn
|
||||||
|
(beginning-of-line)
|
||||||
|
(tiger-block-indentation))
|
||||||
|
;;;
|
||||||
|
|
||||||
|
(let ((indent-level 0)
|
||||||
|
(move-to-indentation-p (<= (current-column)
|
||||||
|
(current-indentation))))
|
||||||
|
(save-excursion
|
||||||
|
(save-excursion
|
||||||
|
(beginning-of-line)
|
||||||
|
(setq indent-level (tiger-block-indentation)))
|
||||||
|
(indent-line-to indent-level)
|
||||||
|
)
|
||||||
|
(if move-to-indentation-p (back-to-indentation))
|
||||||
|
)
|
||||||
|
|
||||||
|
;;;
|
||||||
|
)
|
||||||
|
;;;
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;(defun tiger-indent-region (start end)
|
||||||
|
; "From start to end, indent each line."
|
||||||
|
; )
|
||||||
|
|
||||||
|
|
||||||
|
;;; Tiger mode entry function.
|
||||||
|
(defun tiger-mode ()
|
||||||
|
"Major mode for editing Tiger programs.
|
||||||
|
The following keys are bound:
|
||||||
|
\\{tiger-mode-map}"
|
||||||
|
(interactive)
|
||||||
|
|
||||||
|
;; Set up local variables
|
||||||
|
(kill-all-local-variables)
|
||||||
|
(make-local-variable 'font-lock-defaults)
|
||||||
|
(make-local-variable 'comment-start)
|
||||||
|
(make-local-variable 'comment-end)
|
||||||
|
(make-local-variable 'indent-line-function)
|
||||||
|
;;
|
||||||
|
(set-syntax-table tiger-mode-syntax-table)
|
||||||
|
(setq major-mode 'tiger-mode
|
||||||
|
mode-name "Tiger"
|
||||||
|
font-lock-defaults '(tiger-font-lock-keywords)
|
||||||
|
comment-start "/*"
|
||||||
|
comment-end "*/"
|
||||||
|
indent-line-function 'tiger-indent-line
|
||||||
|
)
|
||||||
|
|
||||||
|
(setq tiger-mode-map (make-sparse-keymap))
|
||||||
|
(use-local-map tiger-mode-map)
|
||||||
|
|
||||||
|
;; Run the Tiger mode hook
|
||||||
|
(run-hooks 'tiger-mode-hook))
|
||||||
|
|
||||||
|
(provide 'tiger)
|
||||||
|
|
||||||
|
;;; tiger.el ends here
|
21
stuff/tuareg.el
Executable file
21
stuff/tuareg.el
Executable file
@ -0,0 +1,21 @@
|
|||||||
|
(defun tuareg-mode-setup ()
|
||||||
|
|
||||||
|
;; BINDINGS
|
||||||
|
|
||||||
|
;; comment
|
||||||
|
(define-key
|
||||||
|
tuareg-mode-map
|
||||||
|
[(control c) (control c)]
|
||||||
|
'comment-region)
|
||||||
|
;; insert fixme
|
||||||
|
(define-key
|
||||||
|
tuareg-mode-map
|
||||||
|
[(control c) (control f)]
|
||||||
|
'insert-fixme)
|
||||||
|
|
||||||
|
;; MISC
|
||||||
|
|
||||||
|
(setq auto-mode-alist (cons '("\\.ml\\w?" . tuareg-mode) auto-mode-alist))
|
||||||
|
)
|
||||||
|
|
||||||
|
(add-hook 'tuareg-load-hook 'tuareg-mode-setup)
|
Loading…
Reference in New Issue
Block a user