From da3357de4c0cf49657fc6374213e934d3ca1b1bb Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Sat, 2 Apr 2011 12:41:14 +0200 Subject: [PATCH] Added functions and supercharged my fontlocking for C and PHP --- emacs.d/.gitignore | 1 + emacs.d/00-functions.el | 21 +++++++++++++++++++++ emacs.d/10-font-lock.el | 25 +++++++++++++++---------- 3 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 emacs.d/00-functions.el diff --git a/emacs.d/.gitignore b/emacs.d/.gitignore index c3659e1..e2ef80f 100644 --- a/emacs.d/.gitignore +++ b/emacs.d/.gitignore @@ -1,3 +1,4 @@ tramp elpa bookmarks +abbrev_defs diff --git a/emacs.d/00-functions.el b/emacs.d/00-functions.el new file mode 100644 index 0000000..3e429ec --- /dev/null +++ b/emacs.d/00-functions.el @@ -0,0 +1,21 @@ +(defun what-face (pos) + "Find out which face the current position uses" + (interactive "d") + (let ((face (or (get-char-property (point) 'read-face-name) + (get-char-property (point) 'face)))) + (if face + (message "Face: %s" face) + (message "No face at %d" pos)))) + +(defun my-comp-finish-function (buf str) + "Don't show compilation window if everything went ok" + (if (string-match "exited abnormally" str) + ;; there were errors + (message "compilation errors, press C-x ` to visit") + ;; no errors, make the compilation window go away in 0.5 seconds + (run-at-time 0.5 nil 'delete-windows-on buf) + (message "NO COMPILATION ERRORS!"))) + +(defun show-whitespace () + (interactive) + (whitespace-mode t)) diff --git a/emacs.d/10-font-lock.el b/emacs.d/10-font-lock.el index 026099d..a98566c 100644 --- a/emacs.d/10-font-lock.el +++ b/emacs.d/10-font-lock.el @@ -1,16 +1,21 @@ -(defun add-my-php-keywords (mode) - (font-lock-add-keywords - mode - ;; Currently support for [ ] | & ! . + = - / % * , ( ) < > { } ? : => -> - '(("\\([\\[|.!+=&/%*,(){}:-]\\|\\]\\|\\ [><]\\ \\|[^<]\\?[^>]\\|\\=>\\)" 1 font-lock-operator-face) - ("\\(;\\)" 1 font-lock-end-statement)))) - +;; Currently support for [ ] | & ! . + = - / % * , ( ) < > { } ? : -> (defun add-my-c-keywords (mode) + ;; Add ! at the beginning of font lock (font-lock-add-keywords mode - ;; Currently support for [ ] | & ! . + = - / % * , ( ) < > { } ? : => -> - '(("\\([\\[|!+=&%*,(){}:-]\\|\\]\\|\\ [><]\\ \\|[^<]\\?[^>]\\|\\=>\\|[^<].*[./].*[^>]\\)" 1 font-lock-operator-face) - ("\\(;\\)" 1 font-lock-end-statement)))) + '(("\\([!()]\\)" 1 font-lock-operator-face))) + ;; Add the rest at the end of font lock + (font-lock-add-keywords + mode + '(("\\(->\\|[\\[|.+=&/%*,{}:?<>-]\\|\\]\\)" 1 font-lock-operator-face) + ("\\(;\\)" 1 font-lock-end-statement)) 1)) + +(defun add-my-php-keywords (mode) + (add-my-c-keywords mode) + (font-lock-add-keywords + mode + ;; Currently support for => + '(("\\(\\=>\\)" 1 font-lock-operator-face)))) (add-my-c-keywords 'c-mode) (add-my-php-keywords 'php-mode)