branch: elpa/d-mode
commit dea775a4aebe40668e7f323e46754ca98a702440
Merge: 53efec4 27fbe66
Author: Russel Winder <[email protected]>
Commit: Russel Winder <[email protected]>
Merge pull request #35 from wrzoski/master
Small fixes for else and else static if indentation
---
d-mode.el | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/d-mode.el b/d-mode.el
index 31e9326..49edee9 100644
--- a/d-mode.el
+++ b/d-mode.el
@@ -240,8 +240,7 @@ operators."
(c-lang-defconst c-block-stmt-2-kwds
;; Statement keywords followed by a paren sexp and then by a substatement.
d '("for" "if" "switch" "while" "catch" "synchronized" "scope"
- "foreach" "foreach_reverse" "with" "unittest"
- "else static if" "else"))
+ "foreach" "foreach_reverse" "with" "unittest"))
(c-lang-defconst c-simple-stmt-kwds
;; Statement keywords followed by an expression or nothing.
@@ -421,6 +420,25 @@ operators."
(nil d-imenu-method-index-function 2)))
;;----------------------------------------------------------------------------
+;;;Workaround for special case of 'else static if' not being handled properly
+(defun d-special-case-looking-at (oldfun &rest args)
+ (let ((rxp (car args)))
+ (if (and (stringp rxp)
+ (string= rxp "if\\>[^_]"))
+ (or (apply oldfun '("static\\>[^_]"))
+ (apply oldfun args))
+ (apply oldfun args))))
+
+(defadvice c-add-stmt-syntax (around my-c-add-stmt-syntax-wrapper activate)
+ (if (not (string= major-mode "d-mode"))
+ ad-do-it
+ (progn
+ (add-function :around (symbol-function 'looking-at)
#'d-special-case-looking-at)
+ (unwind-protect
+ ad-do-it
+ (remove-function (symbol-function 'looking-at)
#'d-special-case-looking-at)))))
+
+;;----------------------------------------------------------------------------
;;;###autoload (add-to-list 'auto-mode-alist '("\\.d[i]?\\'" . d-mode))
;; Custom variables