emacs-csharp / csharp-mode

A major-mode for editing C# in emacs
GNU General Public License v3.0
155 stars 47 forks source link

csharp-mode incorrectly assumes c-default-style is a list #227

Closed ErikKnowles closed 3 years ago

ErikKnowles commented 3 years ago

According to the documentation, c-default-style can either be an alist or a string ("When the value is a string, all CC Mode major modes will install this style by default."); the following code, however, fails when c-default-style is a string:

(eval-and-compile
  (unless (assoc 'csharp-mode c-default-style)
    (setq c-default-style
          (cons '(csharp-mode . "csharp")
                c-default-style))))

Changing the above block to the one below corrects the error that crops up when using a string value for c-default-style (in my case, the error is Wrong type argument: listp, "linux"). The change also respects the user's explicit intent of using a single coding style for all c-derived languages:

(eval-and-compile
  (unless (or (stringp c-default-style) (assoc 'csharp-mode c-default-style))
    (setq c-default-style
          (cons '(csharp-mode . "csharp")
                c-default-style))))
theothornhill commented 3 years ago

Is this the same as #202? :)

ErikKnowles commented 3 years ago

Ugh, yes. I swear I searched; guess I had a typo.

Thank you for checking.

theothornhill commented 3 years ago

Thats great! We already have a fix :)