[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/csharp-mode 16da60e 048/459: Merge branch 'devel' of gi
From: |
ELPA Syncer |
Subject: |
[elpa] externals/csharp-mode 16da60e 048/459: Merge branch 'devel' of github.com:josteink/csharp-mode into devel |
Date: |
Sun, 22 Aug 2021 13:58:53 -0400 (EDT) |
branch: externals/csharp-mode
commit 16da60e115df90d9cc8d241828808390396dbeeb
Merge: 64861a6 49d213a
Author: Jostein Kjønigsen <jostein@kjonigsen.net>
Commit: Jostein Kjønigsen <jostein@kjonigsen.net>
Merge branch 'devel' of github.com:josteink/csharp-mode into devel
---
csharp-mode.el | 160 +--------------------------------------------------------
1 file changed, 2 insertions(+), 158 deletions(-)
diff --git a/csharp-mode.el b/csharp-mode.el
index 0558b2a..4a07468 100644
--- a/csharp-mode.el
+++ b/csharp-mode.el
@@ -48,7 +48,8 @@
;;
;; - automagic code-doc generation when you type three slashes.
;;
-;; - intelligent insertion of matched pairs of curly braces.
+;; - compatible with electric-pair-mode for intelligent insertion
+;; of matched braces, quotes, etc.
;;
;; - imenu integration - generates an index of namespaces, classes,
;; interfaces, methods, and properties for easy navigation within
@@ -550,162 +551,6 @@ comment at the start of cc-engine.el for more info."
-(defun csharp-insert-open-brace ()
- "Intelligently insert a pair of curly braces. This fn should be
-bound to the open-curly brace, with
-
- (local-set-key (kbd \"{\") 'csharp-insert-open-brace)
-
-The default binding for an open curly brace in cc-modes is often
-`c-electric-brace' or `skeleton-pair-insert-maybe'. The former
-can be configured to insert newlines around braces in various
-syntactic positions. The latter inserts a pair of braces and
-then does not insert a newline, and does not indent.
-
-This fn provides another option, with some additional
-intelligence for csharp-mode. When you type an open curly, the
-appropriate pair of braces appears, with spacing and indent set
-in a context-sensitive manner:
-
- - Within a string literal, you just get a pair of braces, and
- point is set between them. This works for String.Format()
- purposes.
-
- - Following = or [], as in an array assignment, you get a pair
- of braces, with two intervening spaces, with a semincolon
- appended. Point is left between the braces.
-
- - Following \"new Foo\", it's an object initializer. You get:
- newline, open brace, newline, newline, close, semi. Point is
- left on the blank line between the braces. Unless the object
- initializer is within an array initializer, in which case, no
- newlines, and the semi is replaced with a comma. (Try it to
- see what this means).
-
- - Following => , implying a lambda, you get an open/close pair,
- with two intervening spaces, no semicolon, and point on the
- 2nd space.
-
- - Otherwise, you get a newline, the open curly, followed by
- an empty line and the closing curly on the line following,
- with point on the empty line.
-
-
-There may be another way to get this to happen appropriately just
-within emacs, but I could not figure out how to do it. So I
-wrote this alternative.
-
- "
- (interactive)
- (let
- (tpoint
- (in-string (string= (csharp-in-literal) "string"))
- (preceding3
- (save-excursion
- (and
- (skip-chars-backward " \t")
- (> (- (point) 2) (point-min))
- (buffer-substring-no-properties (point) (- (point) 3)))))
- (one-word-back
- (save-excursion
- (backward-word 2)
- (thing-at-point 'word))))
-
- (cond
-
- ;; Case 1: inside a string literal?
- ;; --------------------------------------------
- ;; If so, then just insert a pair of braces and put the point
- ;; between them. The most common case is a format string for
- ;; String.Format() or Console.WriteLine().
- (in-string
- (self-insert-command 1)
- (insert "}")
- (backward-char))
-
- ;; Case 2: the open brace starts an array initializer.
- ;; --------------------------------------------
- ;; When the last non-space was an equals sign or square brackets,
- ;; then it's an initializer.
- ((save-excursion
- (and (c-safe (backward-sexp) t)
- (looking-at "\\(\\w+\\b *=\\|[[]]+\\)")))
- (self-insert-command 1)
- (insert " };")
- (backward-char 3))
-
- ;; Case 3: the open brace starts an instance initializer
- ;; --------------------------------------------
- ;; If one-word-back was "new", then it's an object initializer.
- ((string= one-word-back "new")
- (csharp-log 2 "object initializer")
- (setq tpoint (point)) ;; prepare to indent-region later
- (backward-word 2)
- (c-backward-syntactic-ws)
- (if (or (eq (char-before) ?,) ;; comma
- (and (eq (char-before) 123) ;; open curly
- (progn (backward-char)
- (c-backward-syntactic-ws)
- (looking-back "\\[\\]"))))
- (progn
- ;; within an array - emit no newlines
- (goto-char tpoint)
- (self-insert-command 1)
- (insert " },")
- (backward-char 3))
-
- (progn
- (goto-char tpoint)
- (newline)
- (self-insert-command 1)
- (newline-and-indent)
- (newline)
- (insert "};")
- (c-indent-region tpoint (point))
- (forward-line -1)
- (indent-according-to-mode)
- (end-of-line))))
-
-
- ;; Case 4: a lambda initialier.
- ;; --------------------------------------------
- ;; If the open curly follows =>, then it's a lambda initializer.
- ((string= (substring preceding3 -2) "=>")
- (csharp-log 2 "lambda init")
- (self-insert-command 1)
- (insert " }")
- (backward-char 2))
-
- ;; else, it's a new scope. (if, while, class, etc)
- (t
- (save-excursion
- (csharp-log 2 "new scope")
- (set-mark (point)) ;; prepare to indent-region later
- ;; check if the prior sexp is on the same line
- (if (save-excursion
- (let ((curline (line-number-at-pos))
- (aftline (progn
- (if (c-safe (backward-sexp) t)
- (line-number-at-pos)
- -1))))
- (= curline aftline)))
- (newline-and-indent))
- (self-insert-command 1)
- (c-indent-line-or-region)
- (end-of-line)
- (newline)
- (insert "}")
- ;;(c-indent-command) ;; not sure of the difference here
- (c-indent-line-or-region)
- (forward-line -1)
- (end-of-line)
- (newline-and-indent)
- ;; point ends up on an empty line, within the braces, properly indented
- (setq tpoint (point)))
-
- (goto-char tpoint)))))
-
-
;; ==================================================================
;; end of csharp-mode utility and feature defuns
;; ==================================================================
@@ -4541,7 +4386,6 @@ Key bindings:
(c-common-init 'csharp-mode)
(local-set-key (kbd "/") 'csharp-maybe-insert-codedoc)
- (local-set-key (kbd "{") 'csharp-insert-open-brace)
;; Need the following for parse-partial-sexp to work properly with
;; verbatim literal strings Setting this var to non-nil tells
- [elpa] externals/csharp-mode b286555 054/459: Ensure csharp-mode calls `prog-mode` hooks., (continued)
- [elpa] externals/csharp-mode b286555 054/459: Ensure csharp-mode calls `prog-mode` hooks., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 78293bd 029/459: Add proper makefile for creating and publishing packages., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 44718a3 007/459: Update of csharp-mode.el - version # is now 0.7.6, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 4fc9fad 010/459: Update C# completion stuff, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode f6965a6 015/459: v0.8.3 - imenu, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode c1e2c49 024/459: Gitignore for Emacs and Elisp., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode dd321af 027/459: Update changelog and version., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 09fbadc 035/459: Build-status., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode be13af4 040/459: remove obsolete yasnippet integration closes #10, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode f4afe09 039/459: remove flymake integration, closes #8, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 16da60e 048/459: Merge branch 'devel' of github.com:josteink/csharp-mode into devel,
ELPA Syncer <=
- [elpa] externals/csharp-mode 1f11abf 052/459: Add some more reserved keywords to the list., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode a2115a6 020/459: remove unnecessary defadvice around tooltip-show, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 4c270ac 021/459: Merge pull request #5 from jesse-black/master, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 0287b32 034/459: Add build-status to readme., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 64861a6 042/459: Merge branch 'master' into devel, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode b2d8fba 049/459: Merge branch 'devel', ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 7438762 050/459: Update instructions in README., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 3050139 060/459: Add fontification-test., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 5ce7809 068/459: add compilation regexps for msbuild for #28, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode e4ce203 065/459: Updated readme., ELPA Syncer, 2021/08/22