unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#61541: 30.0.50; Wrong indentarion in csharp-mode
       [not found] <87k00i7hko.fsf.ref@aol.com>
@ 2023-02-15 21:19 ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-02-17 19:28   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 7+ messages in thread
From: Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-02-15 21:19 UTC (permalink / raw)
  To: 61541


Hi:

I just found that this indentations are wrong in csharp mode:

// wrong
new myNamespace.myClass
{
    Name1 = x.Value, // defun-block-intro
	var2 = 2     // statement-cont
	}            // statement-cont


The problem seems to be related with the dot (.) in the new, because
this variant indents correctly:

// right
new myClass
{
    Name1 = x.Value,   // brace-list-intro
    var2 = 2           // brace-list-entry
}                      // brace-list-close


csharp-ts-mode is doing it right BTW.




In GNU Emacs 30.0.50 (build 12, x86_64-pc-linux-gnu, GTK+ Version
 3.24.36, cairo version 1.17.8) of 2023-02-15 built on Ergus
Repository revision: 6a677fd3b6677248a8bc1787b105879684289fa2
Repository branch: master
System Description: Arch Linux

Configured using:
 'configure --prefix=/home/ergo/.local/ --with-mailutils --with-json
 --with-x-toolkit=gtk3 --with-xft --with-modules --with-cairo
 --with-harfbuzz --with-native-compilation
 '--program-transform-name=s/^ctags$/ctags.emacs/''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER
PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: C#//law

Minor modes in effect:
  subword-mode: t
  windmove-mode: t
  fancy-compilation-mode: t
  global-auto-revert-mode: t
  electric-pair-mode: t
  flyspell-mode: t
  company-mode: t
  flycheck-mode: t
  diff-hl-margin-mode: t
  gtags-mode: t
  repeat-mode: t
  c-ms-space-for-alignment-mode: t
  xterm-mouse-mode: t
  xclip-mode: t
  override-global-mode: t
  winner-mode: t
  save-place-mode: t
  delete-selection-mode: t
  savehist-mode: t
  global-display-fill-column-indicator-mode: t
  display-fill-column-indicator-mode: t
  global-display-line-numbers-mode: t
  display-line-numbers-mode: t
  which-key-mode: t
  show-paren-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  context-menu-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  size-indication-mode: t
  column-number-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/mnt/casa/gits/emacs_clones/gtags-mode/gtags-mode hides /home/ergo/.config/emacs/elpa/gtags-mode-1.0/gtags-mode
/home/ergo/.config/emacs/elpa/transient-20230213.1337/transient hides /home/ergo/.local/share/emacs/30.0.50/lisp/transient

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny rfc822
mml mml-sec epa derived epg rfc6068 epg-config gnus-util mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
time-date dabbrev cap-words superword subword cape-keyword windmove
jka-compr shortdoc csharp-mode c-ts-common treesit cc-langs cc-mode
cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars
cc-defs fancy-compilation compile text-property-search comint ansi-osc
help-fns radix-tree autorevert filenotify ffap thingatpt url-parse
auth-source password-cache url-vars elec-pair flyspell-correct flyspell
ispell company-semantic company-template company-capf company flycheck
ansi-color json map find-func dash pcase diff-hl-margin diff-hl-dired
dired-x dired dired-loaddefs diff-hl log-view pcvs-util vc-dir ewoc vc
vc-dispatcher diff-mode cape compat comp comp-cstr warnings icons rx
gtags-mode subr-x files-x xref project term/tmux term/xterm xterm init
repeat xt-mouse xclip edmacro kmacro use-package-bind-key bind-key
simple-16-theme winner ring saveplace delsel savehist easy-mmode
display-fill-column-indicator display-line-numbers diminish which-key
cl-extra help-mode use-package-diminish use-package-core disp-table info
dumb-jump-autoloads highlight-indent-guides-autoloads
company-lua-autoloads evil-collection-autoloads vundo-autoloads
sudo-edit-autoloads cuda-mode-autoloads nginx-mode-autoloads
crdt-autoloads annalist-autoloads company-auctex-autoloads
cape-autoloads groovy-mode-autoloads flycheck-rust-autoloads
string-inflection-autoloads company-c-headers-autoloads
protobuf-mode-autoloads markdown-mode-autoloads tree-sitter-autoloads
lice-autoloads lorem-ipsum-autoloads julia-mode-autoloads
nasm-mode-autoloads deadgrep-autoloads popup-autoloads
company-nginx-autoloads csv-mode-autoloads d-mode-autoloads
tsc-autoloads i3wm-config-mode-autoloads ssh-config-mode-autoloads
move-dup-autoloads clang-format-autoloads esup-autoloads
dired-sidebar-autoloads gnuplot-autoloads web-completion-data-autoloads
phi-search-autoloads better-shell-autoloads fancy-compilation-autoloads
arduino-cli-mode-autoloads flycheck-julia-autoloads magit-autoloads
magit-section-autoloads auctex-autoloads tex-site which-key-autoloads
git-commit-autoloads with-editor-autoloads evil-autoloads
goto-chg-autoloads flycheck-autoloads multiple-cursors-autoloads
ibuffer-sidebar-autoloads dired-subtree-autoloads
dired-hacks-utils-autoloads systemd-autoloads pkgbuild-mode-autoloads
neotree-autoloads modern-cpp-font-lock-autoloads
company-reftex-autoloads google-c-style-autoloads flymake-nasm-autoloads
request-autoloads caml-autoloads arduino-mode-autoloads ede/auto
eieio-base cl-seq eieio byte-opt bytecomp byte-compile eieio-core
cl-macs gv cl-loaddefs cl-lib sphinx-mode-autoloads f-autoloads
diff-hl-autoloads lua-mode-autoloads gtags-mode-autoloads
mutt-mode-autoloads xclip-autoloads diminish-autoloads
imenu-list-autoloads paradox-autoloads spinner-autoloads
avy-zap-autoloads nftables-mode-autoloads s-autoloads
ibuffer-vc-autoloads objed-autoloads iedit-autoloads
languagetool-autoloads vterm-toggle-autoloads vterm-autoloads
avy-autoloads git-timemachine-autoloads emamux-autoloads
transient-autoloads flymake-quickdef-autoloads slime-autoloads
yasnippet-snippets-autoloads ibuffer-project-autoloads
haskell-mode-autoloads shell-command+-autoloads notmuch-autoloads
e2ansi-autoloads face-explorer-autoloads pkg-info-autoloads
flx-autoloads opencl-mode-autoloads ptemplate-templates-autoloads
ptemplate-autoloads yasnippet-autoloads git-modes-autoloads
compat-autoloads ibuffer-tramp-autoloads debbugs-autoloads
cobol-mode-autoloads macrostep-autoloads flyspell-correct-autoloads
company-autoloads dash-autoloads epl-autoloads vdiff-autoloads
hydra-autoloads lv-autoloads early-init rmc iso-transl tooltip cconv
eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type
elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd
fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit xinput2 x multi-tty make-network-process
native-compile emacs)

Memory information:
((conses 16 314716 25828)
 (symbols 48 18893 0)
 (strings 32 80618 11390)
 (string-bytes 1 2807148)
 (vectors 16 45056)
 (vector-slots 8 1351905 127627)
 (floats 8 236 1199)
 (intervals 56 3420 54)
 (buffers 984 15))





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#61541: 30.0.50; Wrong indentarion in csharp-mode
  2023-02-15 21:19 ` bug#61541: 30.0.50; Wrong indentarion in csharp-mode Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-02-17 19:28   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-02-17 21:06     ` Jostein Kjønigsen
  0 siblings, 1 reply; 7+ messages in thread
From: Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-02-17 19:28 UTC (permalink / raw)
  To: Ergus; +Cc: jostein, 61541

Ergus <spacibba@aol.com> writes:

> Hi:
>
> I just found that this indentations are wrong in csharp mode:
>
> // wrong
> new myNamespace.myClass
> {
>     Name1 = x.Value, // defun-block-intro
> 	var2 = 2     // statement-cont
> 	}            // statement-cont
>
>
> The problem seems to be related with the dot (.) in the new, because
> this variant indents correctly:
>
> // right
> new myClass
> {
>     Name1 = x.Value,   // brace-list-intro
>     var2 = 2           // brace-list-entry
> }                      // brace-list-close
>
>
> csharp-ts-mode is doing it right BTW.
>

Hi!

Yeah, this is one of the harder issues iirc, and one of the ones that
made us move to tree-sitter in csharp-mode in the first place.

What do you think Jostein?

Patches welcome!

Theo






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#61541: 30.0.50; Wrong indentarion in csharp-mode
  2023-02-17 19:28   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-02-17 21:06     ` Jostein Kjønigsen
  2023-02-17 21:43       ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 7+ messages in thread
From: Jostein Kjønigsen @ 2023-02-17 21:06 UTC (permalink / raw)
  To: Theodor Thornhill, Ergus; +Cc: jostein, 61541

2/17/23 20:28, Theodor Thornhill wrote:
> Ergus <spacibba@aol.com> writes:
>
>> Hi:
>>
>> I just found that this indentations are wrong in csharp mode:
>>
>> // wrong
>> new myNamespace.myClass
>> {
>>      Name1 = x.Value, // defun-block-intro
>> 	var2 = 2     // statement-cont
>> 	}            // statement-cont
>>
>>
>> The problem seems to be related with the dot (.) in the new, because
>> this variant indents correctly:
>>
>> // right
>> new myClass
>> {
>>      Name1 = x.Value,   // brace-list-intro
>>      var2 = 2           // brace-list-entry
>> }                      // brace-list-close
>>
>>
>> csharp-ts-mode is doing it right BTW.
>>
> Hi!
>
> Yeah, this is one of the harder issues iirc, and one of the ones that
> made us move to tree-sitter in csharp-mode in the first place.
>
> What do you think Jostein?
>
> Patches welcome!
>
> Theo
>
First of all: Thanks for a detailed bug-report.

Then for the bad news: I may be missing something here. I'm on the 
latest revision of the emacs-29 branch, and I really can't reproduce at all.

I've tried typing out the concrete code-samples above, and I've tried 
copy-pasting them.

No matter what I do, I cannot reproduce the behaviour outlined above.

Ergus: Could you come up with a even more complete example?

I mean... If I can't reproduce, I definitely won't be able to come up 
with a patch.

--
Jostein






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#61541: 30.0.50; Wrong indentarion in csharp-mode
  2023-02-17 21:06     ` Jostein Kjønigsen
@ 2023-02-17 21:43       ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-02-17 23:38         ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 7+ messages in thread
From: Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-02-17 21:43 UTC (permalink / raw)
  To: jostein; +Cc: Theodor Thornhill, 61541

On Fri, Feb 17, 2023 at 10:06:50PM +0100, Jostein Kj�nigsen wrote:
>2/17/23 20:28, Theodor Thornhill wrote:
>>Ergus <spacibba@aol.com> writes:
>>
>>>Hi:
>>>
>>>I just found that this indentations are wrong in csharp mode:
>>>
>>>// wrong
>>>new myNamespace.myClass
>>>{
>>>     Name1 = x.Value, // defun-block-intro
>>>	var2 = 2     // statement-cont
>>>	}            // statement-cont
>>>
>>>
>>>The problem seems to be related with the dot (.) in the new, because
>>>this variant indents correctly:
>>>
>>>// right
>>>new myClass
>>>{
>>>     Name1 = x.Value,   // brace-list-intro
>>>     var2 = 2           // brace-list-entry
>>>}                      // brace-list-close
>>>
>>>
>>>csharp-ts-mode is doing it right BTW.
>>>
>>Hi!
>>
>>Yeah, this is one of the harder issues iirc, and one of the ones that
>>made us move to tree-sitter in csharp-mode in the first place.
>>
>>What do you think Jostein?
>>
>>Patches welcome!
>>
>>Theo
>>
>First of all: Thanks for a detailed bug-report.
>
>Then for the bad news: I may be missing something here. I'm on the 
>latest revision of the emacs-29 branch, and I really can't reproduce 
>at all.
>
>I've tried typing out the concrete code-samples above, and I've tried 
>copy-pasting them.
>
>No matter what I do, I cannot reproduce the behaviour outlined above.
>
>Ergus: Could you come up with a even more complete example?
>
>I mean... If I can't reproduce, I definitely won't be able to come up 
>with a patch.
>
>--
>Jostein
>

Hi Jostein:

I just do:

emacs -Q /tmp/main.cs

Then pasted (or write) the code snippet shown in the example, and
re-indent the buffer:

I get this:

new myNamespace.myClass
{
     Name1 = 1,
         Name2 =2
         }

Exactly like in the example C-c C-o shows the same than in the
example. Even the fontification is wrong.

If I remove the dot like this myNamespacemyClass the fontification and
indentation is fixed immediately.

I am using the master branch (emacs-version = 30.0.50) tomorrow I can
try to reproduce the issue on emacs-29 branch, but I have to build it.

Best,
Ergus






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#61541: 30.0.50; Wrong indentarion in csharp-mode
  2023-02-17 21:43       ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-02-17 23:38         ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-02-19  1:58           ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-04 19:45           ` stefankangas
  0 siblings, 2 replies; 7+ messages in thread
From: Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-02-17 23:38 UTC (permalink / raw)
  To: Ergus, jostein; +Cc: 61541

Ergus <spacibba@aol.com> writes:

> On Fri, Feb 17, 2023 at 10:06:50PM +0100, Jostein Kj�nigsen wrote:
>>2/17/23 20:28, Theodor Thornhill wrote:
>>>Ergus <spacibba@aol.com> writes:
>>>
>>>>Hi:
>>>>
>>>>I just found that this indentations are wrong in csharp mode:
>>>>
>>>>// wrong
>>>>new myNamespace.myClass
>>>>{
>>>>     Name1 = x.Value, // defun-block-intro
>>>>	var2 = 2     // statement-cont
>>>>	}            // statement-cont
>>>>
>>>>
>>>>The problem seems to be related with the dot (.) in the new, because
>>>>this variant indents correctly:
>>>>
>>>>// right
>>>>new myClass
>>>>{
>>>>     Name1 = x.Value,   // brace-list-intro
>>>>     var2 = 2           // brace-list-entry
>>>>}                      // brace-list-close
>>>>
>>>>
>>>>csharp-ts-mode is doing it right BTW.
>>>>
>>>Hi!
>>>
>>>Yeah, this is one of the harder issues iirc, and one of the ones that
>>>made us move to tree-sitter in csharp-mode in the first place.
>>>
>>>What do you think Jostein?
>>>
>>>Patches welcome!
>>>
>>>Theo
>>>
>>First of all: Thanks for a detailed bug-report.
>>
>>Then for the bad news: I may be missing something here. I'm on the 
>>latest revision of the emacs-29 branch, and I really can't reproduce 
>>at all.
>>
>>I've tried typing out the concrete code-samples above, and I've tried 
>>copy-pasting them.
>>
>>No matter what I do, I cannot reproduce the behaviour outlined above.
>>
>>Ergus: Could you come up with a even more complete example?
>>
>>I mean... If I can't reproduce, I definitely won't be able to come up 
>>with a patch.
>>
>>--
>>Jostein
>>
>
> Hi Jostein:
>
> I just do:
>
> emacs -Q /tmp/main.cs
>
> Then pasted (or write) the code snippet shown in the example, and
> re-indent the buffer:
>
> I get this:
>
> new myNamespace.myClass
> {
>      Name1 = 1,
>          Name2 =2
>          }
>
> Exactly like in the example C-c C-o shows the same than in the
> example. Even the fontification is wrong.
>
> If I remove the dot like this myNamespacemyClass the fontification and
> indentation is fixed immediately.
>
> I am using the master branch (emacs-version = 30.0.50) tomorrow I can
> try to reproduce the issue on emacs-29 branch, but I have to build it.
>
> Best,
> Ergus


Try this, Ergus and Jostein. What do you think?

diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el
index b6b842d7fd..293a910081 100644
--- a/lisp/progmodes/csharp-mode.el
+++ b/lisp/progmodes/csharp-mode.el
@@ -474,28 +474,37 @@ csharp-guess-basic-syntax
          (and (eq (char-before) ?\])
               (not (eq (char-after) ?\;))))))
     `((annotation-top-cont ,(c-point 'iopl))))
-
    ((and
      ;; Heuristics to find object initializers
      (save-excursion
        ;; Next non-whitespace character should be '{'
        (goto-char (c-point 'boi))
-       (eq (char-after) ?{))
-     (save-excursion
-       ;; 'new' should be part of the line
-       (goto-char (c-point 'iopl))
-       (looking-at ".*new.*"))
+       (unless (eq (char-after) ?{)
+         (backward-up-list 1 t t))
+       (save-excursion
+         ;; 'new' should be part of the line
+         (goto-char (c-point 'iopl))
+         (looking-at ".*new.*")))
      ;; Line should not already be terminated
      (save-excursion
        (goto-char (c-point 'eopl))
        (or (not (eq (char-before) ?\;))
            (not (eq (char-before) ?\{)))))
-    (if (save-excursion
-          ;; if we have a hanging brace on line before
-          (goto-char (c-point 'eopl))
-          (eq (char-before) ?\{))
-        `((brace-list-intro ,(c-point 'iopl)))
-      `((block-open) (statement ,(c-point 'iopl)))))
+    (cond
+     ((save-excursion
+        ;; if we have a hanging brace on line before
+        (goto-char (c-point 'eopl))
+        (eq (char-before) ?\{))
+      `((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
     (apply orig-fun args))))
 





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#61541: 30.0.50; Wrong indentarion in csharp-mode
  2023-02-17 23:38         ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-02-19  1:58           ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-04 19:45           ` stefankangas
  1 sibling, 0 replies; 7+ messages in thread
From: Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-02-19  1:58 UTC (permalink / raw)
  To: Theodor Thornhill; +Cc: jostein, 61541

Hi Theo:

I think this works... I will try it a bit more tomorrow.

Thanks,
Ergus

On Sat, Feb 18, 2023 at 12:38:20AM +0100, Theodor Thornhill wrote:
>Ergus <spacibba@aol.com> writes:
>
>> On Fri, Feb 17, 2023 at 10:06:50PM +0100, Jostein Kj�nigsen wrote:
>>>2/17/23 20:28, Theodor Thornhill wrote:
>>>>Ergus <spacibba@aol.com> writes:
>>>>
>>>>>Hi:
>>>>>
>>>>>I just found that this indentations are wrong in csharp mode:
>>>>>
>>>>>// wrong
>>>>>new myNamespace.myClass
>>>>>{
>>>>>     Name1 = x.Value, // defun-block-intro
>>>>>	var2 = 2     // statement-cont
>>>>>	}            // statement-cont
>>>>>
>>>>>
>>>>>The problem seems to be related with the dot (.) in the new, because
>>>>>this variant indents correctly:
>>>>>
>>>>>// right
>>>>>new myClass
>>>>>{
>>>>>     Name1 = x.Value,   // brace-list-intro
>>>>>     var2 = 2           // brace-list-entry
>>>>>}                      // brace-list-close
>>>>>
>>>>>
>>>>>csharp-ts-mode is doing it right BTW.
>>>>>
>>>>Hi!
>>>>
>>>>Yeah, this is one of the harder issues iirc, and one of the ones that
>>>>made us move to tree-sitter in csharp-mode in the first place.
>>>>
>>>>What do you think Jostein?
>>>>
>>>>Patches welcome!
>>>>
>>>>Theo
>>>>
>>>First of all: Thanks for a detailed bug-report.
>>>
>>>Then for the bad news: I may be missing something here. I'm on the
>>>latest revision of the emacs-29 branch, and I really can't reproduce
>>>at all.
>>>
>>>I've tried typing out the concrete code-samples above, and I've tried
>>>copy-pasting them.
>>>
>>>No matter what I do, I cannot reproduce the behaviour outlined above.
>>>
>>>Ergus: Could you come up with a even more complete example?
>>>
>>>I mean... If I can't reproduce, I definitely won't be able to come up
>>>with a patch.
>>>
>>>--
>>>Jostein
>>>
>>
>> Hi Jostein:
>>
>> I just do:
>>
>> emacs -Q /tmp/main.cs
>>
>> Then pasted (or write) the code snippet shown in the example, and
>> re-indent the buffer:
>>
>> I get this:
>>
>> new myNamespace.myClass
>> {
>>      Name1 = 1,
>>          Name2 =2
>>          }
>>
>> Exactly like in the example C-c C-o shows the same than in the
>> example. Even the fontification is wrong.
>>
>> If I remove the dot like this myNamespacemyClass the fontification and
>> indentation is fixed immediately.
>>
>> I am using the master branch (emacs-version = 30.0.50) tomorrow I can
>> try to reproduce the issue on emacs-29 branch, but I have to build it.
>>
>> Best,
>> Ergus
>
>
>Try this, Ergus and Jostein. What do you think?
>
>diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el
>index b6b842d7fd..293a910081 100644
>--- a/lisp/progmodes/csharp-mode.el
>+++ b/lisp/progmodes/csharp-mode.el
>@@ -474,28 +474,37 @@ csharp-guess-basic-syntax
>          (and (eq (char-before) ?\])
>               (not (eq (char-after) ?\;))))))
>     `((annotation-top-cont ,(c-point 'iopl))))
>-
>    ((and
>      ;; Heuristics to find object initializers
>      (save-excursion
>        ;; Next non-whitespace character should be '{'
>        (goto-char (c-point 'boi))
>-       (eq (char-after) ?{))
>-     (save-excursion
>-       ;; 'new' should be part of the line
>-       (goto-char (c-point 'iopl))
>-       (looking-at ".*new.*"))
>+       (unless (eq (char-after) ?{)
>+         (backward-up-list 1 t t))
>+       (save-excursion
>+         ;; 'new' should be part of the line
>+         (goto-char (c-point 'iopl))
>+         (looking-at ".*new.*")))
>      ;; Line should not already be terminated
>      (save-excursion
>        (goto-char (c-point 'eopl))
>        (or (not (eq (char-before) ?\;))
>            (not (eq (char-before) ?\{)))))
>-    (if (save-excursion
>-          ;; if we have a hanging brace on line before
>-          (goto-char (c-point 'eopl))
>-          (eq (char-before) ?\{))
>-        `((brace-list-intro ,(c-point 'iopl)))
>-      `((block-open) (statement ,(c-point 'iopl)))))
>+    (cond
>+     ((save-excursion
>+        ;; if we have a hanging brace on line before
>+        (goto-char (c-point 'eopl))
>+        (eq (char-before) ?\{))
>+      `((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
>     (apply orig-fun args))))
>





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#61541: 30.0.50; Wrong indentarion in csharp-mode
  2023-02-17 23:38         ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-02-19  1:58           ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-04 19:45           ` stefankangas
  1 sibling, 0 replies; 7+ messages in thread
From: stefankangas @ 2023-09-04 19:45 UTC (permalink / raw)
  To: Theodor Thornhill; +Cc: Ergus, jostein, 61541-done

Theodor Thornhill <theo@thornhill.no> writes:

> Try this, Ergus and Jostein. What do you think?

it seems like this patch was installed as commit dfc850ca0223, but the
bug was left open.

I'm therefore closing this bug report.





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-09-04 19:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <87k00i7hko.fsf.ref@aol.com>
2023-02-15 21:19 ` bug#61541: 30.0.50; Wrong indentarion in csharp-mode Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-17 19:28   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-17 21:06     ` Jostein Kjønigsen
2023-02-17 21:43       ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-17 23:38         ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-19  1:58           ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-04 19:45           ` stefankangas

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).