Fix object initializer for csharp-mode (bug#61541)
* lisp/progmodes/csharp-mode.el (csharp-guess-basic-syntax): Make sure we check the openers as well as closers.
This commit is contained in:
parent
fc4bfa76db
commit
dfc850ca02
1 changed files with 21 additions and 12 deletions
|
@ -474,28 +474,37 @@ compilation and evaluation time conflicts."
|
||||||
(and (eq (char-before) ?\])
|
(and (eq (char-before) ?\])
|
||||||
(not (eq (char-after) ?\;))))))
|
(not (eq (char-after) ?\;))))))
|
||||||
`((annotation-top-cont ,(c-point 'iopl))))
|
`((annotation-top-cont ,(c-point 'iopl))))
|
||||||
|
|
||||||
((and
|
((and
|
||||||
;; Heuristics to find object initializers
|
;; Heuristics to find object initializers
|
||||||
(save-excursion
|
(save-excursion
|
||||||
;; Next non-whitespace character should be '{'
|
;; Next non-whitespace character should be '{'
|
||||||
(goto-char (c-point 'boi))
|
(goto-char (c-point 'boi))
|
||||||
(eq (char-after) ?{))
|
(unless (eq (char-after) ?{)
|
||||||
(save-excursion
|
(backward-up-list 1 t t))
|
||||||
;; 'new' should be part of the line
|
(save-excursion
|
||||||
(goto-char (c-point 'iopl))
|
;; 'new' should be part of the line
|
||||||
(looking-at ".*new.*"))
|
(goto-char (c-point 'iopl))
|
||||||
|
(looking-at ".*new.*")))
|
||||||
;; Line should not already be terminated
|
;; Line should not already be terminated
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char (c-point 'eopl))
|
(goto-char (c-point 'eopl))
|
||||||
(or (not (eq (char-before) ?\;))
|
(or (not (eq (char-before) ?\;))
|
||||||
(not (eq (char-before) ?\{)))))
|
(not (eq (char-before) ?\{)))))
|
||||||
(if (save-excursion
|
(cond
|
||||||
;; if we have a hanging brace on line before
|
((save-excursion
|
||||||
(goto-char (c-point 'eopl))
|
;; if we have a hanging brace on line before
|
||||||
(eq (char-before) ?\{))
|
(goto-char (c-point 'eopl))
|
||||||
`((brace-list-intro ,(c-point 'iopl)))
|
(eq (char-before) ?\{))
|
||||||
`((block-open) (statement ,(c-point 'iopl)))))
|
`((brace-list-intro ,(c-point 'iopl))))
|
||||||
|
((save-excursion
|
||||||
|
;; if we have a hanging brace on line before
|
||||||
|
(goto-char (c-point 'boi))
|
||||||
|
(and (eq (char-after) ?\})
|
||||||
|
`((brace-list-close ,(save-excursion
|
||||||
|
(backward-up-list 1 t t)
|
||||||
|
(point)))))))
|
||||||
|
(t
|
||||||
|
`((block-open) (statement ,(c-point 'iopl))))))
|
||||||
(t
|
(t
|
||||||
(apply orig-fun args))))
|
(apply orig-fun args))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue