branch: externals/csharp-mode commit fe3ca7e036b5df57f5387ab897a10d41d32e3961 Author: Jostein Kjønigsen <jost...@kjonigsen.net> Commit: Jostein Kjønigsen <jost...@kjonigsen.net>
Inline square-parenthesis detection. This was only used one place. Fixes byte-compilation regression introduced in: https://github.com/josteink/csharp-mode/commit/0a2a3b0943c2463ca38b673c6c42d2e3e9bc2d5a Partially adresses: https://github.com/josteink/csharp-mode/issues/79 --- csharp-mode.el | 43 ++++++++++--------------------------------- 1 file changed, 10 insertions(+), 33 deletions(-) diff --git a/csharp-mode.el b/csharp-mode.el index f5c5e47..ffa1a8e 100644 --- a/csharp-mode.el +++ b/csharp-mode.el @@ -558,38 +558,6 @@ to work properly with code that includes attributes. ))) -;; essentially the same as (progn), but this this is required to avoid -;; byte-compilation warnings due to some forms referencing this -;; getting expanded during compilation. -(eval-when-compile - (defun csharp-is-square-parentasis-block-p () - "Attempts to safely assess if the current point is at the opening of -a square parentasis block [ ... ]." - (let* ((start (point)) ;; variables used to hold our position, so that we know that - (end)) ;; our code isn't stuck trying to look for a non-existant sexp. - (and (eq (char-after) 91) ;; open square - (while (and (eq (char-after) 91) - (not (eq start end))) - (c-safe (c-forward-sexp 1)) - (setq end (point))) - (eq (char-before) 93))) ;; close square - )) - -;; nasty hack to silence compile-time warnings and runtime-warnings. -;; exact copy of defun above. -(defun csharp-is-square-parentasis-block-p () - "Attempts to safely assess if the current point is at the opening of -a square parentasis block [ ... ]." - (let* ((start (point)) ;; variables used to hold our position, so that we know that - (end)) ;; our code isn't stuck trying to look for a non-existant sexp. - (and (eq (char-after) 91) ;; open square - (while (and (eq (char-after) 91) - (not (eq start end))) - (c-safe (c-forward-sexp 1)) - (setq end (point))) - (eq (char-before) 93))) ;; close square - ) - ;; ================================================================== ;; end of csharp-mode utility and feature defuns ;; ================================================================== @@ -913,7 +881,16 @@ a square parentasis block [ ... ]." (if (or (eq (char-after) ?{) ;; open curly - (csharp-is-square-parentasis-block-p) + ;; is square parenthesis block? - start + (let* ((start (point)) ;; used to hold our position, so that we know that + (end)) ;; our code isn't stuck trying to look for a non-existant sexp. + (and (eq (char-after) 91) ;; open square + (while (and (eq (char-after) 91) + (not (eq start end))) + (c-safe (c-forward-sexp 1)) + (setq end (point))) + (eq (char-before) 93))) + ;; is square parenthesis block? - end (and (eq (char-after) 40) ;; open paren (c-safe (c-forward-sexp 1) t)))