emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/csharp-mode ba7a81a 253/459: Advise c-inside-bracelist-


From: ELPA Syncer
Subject: [elpa] externals/csharp-mode ba7a81a 253/459: Advise c-inside-bracelist-p (#122)
Date: Sun, 22 Aug 2021 13:59:38 -0400 (EDT)

branch: externals/csharp-mode
commit ba7a81a85ee5fd234f24333ab156ce897cb20cc7
Author: James Nguyen <james@jojojames.com>
Commit: Jostein Kjønigsen <jostein@kjonigsen.net>

    Advise c-inside-bracelist-p (#122)
---
 csharp-mode-tests.el |  7 +++++++
 csharp-mode.el       | 11 +++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/csharp-mode-tests.el b/csharp-mode-tests.el
index 12becdd..38d485e 100644
--- a/csharp-mode-tests.el
+++ b/csharp-mode-tests.el
@@ -422,6 +422,13 @@
       (should
        (equal "C#" c-indentation-style)))))
 
+(ert-deftest inside-bracelist-test ()
+  (let ((c-default-style "defaultc#"))
+    (with-temp-buffer
+      (csharp-mode)
+      (insert "public class A { public void F() {")
+      (call-interactively #'newline))))
+
 ;;(ert-run-tests-interactively t)
 ;; (local-set-key (kbd "<f6>") '(lambda ()
 ;;                               (interactive)
diff --git a/csharp-mode.el b/csharp-mode.el
index 04c49ec..7fd4a50 100644
--- a/csharp-mode.el
+++ b/csharp-mode.el
@@ -2576,11 +2576,18 @@ are the string substitutions (see `format')."
 
         res))))
 
+(advice-add 'c-inside-bracelist-p
+            :around 'csharp-inside-bracelist-or-c-inside-bracelist-p)
 
+(defun csharp-inside-bracelist-or-c-inside-bracelist-p (command &rest args)
+  "Run `csharp-inside-bracelist-p' if in `csharp-mode'.
 
+Otherwise run `c-inside-bracelist-p'."
+  (if (eq major-mode 'csharp-mode)
+      (csharp-inside-bracelist-p (nth 0 args) (nth 1 args))
+    (apply command args)))
 
-
-(defun c-inside-bracelist-p (containing-sexp paren-state)
+(defun csharp-inside-bracelist-p (containing-sexp paren-state)
   ;; return the buffer position of the beginning of the brace list
   ;; statement if we're inside a brace list, otherwise return nil.
   ;; CONTAINING-SEXP is the buffer pos of the innermost containing



reply via email to

[Prev in Thread] Current Thread [Next in Thread]