Added functions and supercharged my fontlocking for C and PHP
This commit is contained in:
parent
8a637b9d4d
commit
da3357de4c
3 changed files with 37 additions and 10 deletions
1
emacs.d/.gitignore
vendored
1
emacs.d/.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
tramp
|
tramp
|
||||||
elpa
|
elpa
|
||||||
bookmarks
|
bookmarks
|
||||||
|
abbrev_defs
|
||||||
|
|
21
emacs.d/00-functions.el
Normal file
21
emacs.d/00-functions.el
Normal file
|
@ -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))
|
|
@ -1,16 +1,21 @@
|
||||||
(defun add-my-php-keywords (mode)
|
;; Currently support for [ ] | & ! . + = - / % * , ( ) < > { } ? : ->
|
||||||
(font-lock-add-keywords
|
|
||||||
mode
|
|
||||||
;; Currently support for [ ] | & ! . + = - / % * , ( ) < > { } ? : => ->
|
|
||||||
'(("\\([\\[|.!+=&/%*,(){}:-]\\|\\]\\|\\ [><]\\ \\|[^<]\\?[^>]\\|\\=>\\)" 1 font-lock-operator-face)
|
|
||||||
("\\(;\\)" 1 font-lock-end-statement))))
|
|
||||||
|
|
||||||
(defun add-my-c-keywords (mode)
|
(defun add-my-c-keywords (mode)
|
||||||
|
;; Add ! at the beginning of font lock
|
||||||
(font-lock-add-keywords
|
(font-lock-add-keywords
|
||||||
mode
|
mode
|
||||||
;; Currently support for [ ] | & ! . + = - / % * , ( ) < > { } ? : => ->
|
'(("\\([!()]\\)" 1 font-lock-operator-face)))
|
||||||
'(("\\([\\[|!+=&%*,(){}:-]\\|\\]\\|\\ [><]\\ \\|[^<]\\?[^>]\\|\\=>\\|[^<].*[./].*[^>]\\)" 1 font-lock-operator-face)
|
;; Add the rest at the end of font lock
|
||||||
("\\(;\\)" 1 font-lock-end-statement))))
|
(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-c-keywords 'c-mode)
|
||||||
(add-my-php-keywords 'php-mode)
|
(add-my-php-keywords 'php-mode)
|
||||||
|
|
Loading…
Reference in a new issue