Subject: bug#33794: closed (Re: bug#33794: 26.1; electric-pair-mode breaks auto-newline minor mode of cc-mode)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 15 Jan 2019 16:22:02 +0000

Your bug report

#33794: 26.1; electric-pair-mode breaks auto-newline minor mode of cc-mode

which was filed against the emacs,cc-mode package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
33794: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=33794
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#33794: 26.1; electric-pair-mode breaks auto-newline minor mode of cc-mode
From: Alan Mackenzie <[email-masked]>
To: [email-masked]
Cc: João Távora <[email-masked]>, [email-masked]
Date: Tue, 15 Jan 2019 16:10:52 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello, Beatrix.

I have committed the patch from two weeks ago (to the Emacs master
branch), and I'm closing the bug as fixed.

-- 
Alan Mackenzie (Nuremberg, Germany).

On Tue, Jan 01, 2019 at 19:27:29 +0000, Alan Mackenzie wrote:
> Hello, Beatrix,

> Happy New Year!

> On Fri, Dec 21, 2018 at 11:00:10 -0500, Beatrix Klebe wrote:
> > What would be ideal, and what I'm looking for, is to get auto-pairing
> > of brackets with braces being placed where they should be
> > automatically and the insertion point getting put in between them at
> > the correct indent level, such as what happens with Visual Studio, or
> > Visual Studio Code, or several other editors with this functionality.
> > Perhaps it is not emacslike to have such behavior be totally
> > automated, but I am used to it and finds it decreases my ordinary
> > levels of frustration when working with verbose and imperative
> > languages. I am currently trying to write some insert specifiers for
> > smartparens to do this, but it is proving more difficult to find an
> > elegant solution than I had expected.

> I think the following patch to CC Mode gives you nearly everything you
> want, if not actually everything.

> It turned out that the amendment didn't require any modification to
> electric-pair-mode, so apologies to João.

> I don't know how much you've explored electric-pair-mode, but if the
> answer is "not very much", can I suggest you try setting
> electric-pair-skip-whitespace to 'chomp?  The following editing pattern
> is then available.  With electric-pair-mode and c-auto-newline mode
> enabled:

> ("|" represents point.)

> At the end of the line

>     if (foo)|
>     foo = bar;

> , type {.  This will give you something like:

>     if (foo)
>       {
>         |
>       }
>     foo = bar;

> .  Type in a statement ending with a semicolon:

>     if (foo)
>       {
>         foo = bar;
> 	|
>       }
>     foo = bar;

> .  Now type in }.  The effect is to "chomp" the space to the next }, and
> CC Mode's auto-newline then inserts an empty line after the brace:

>     if (foo)
>       {
>         foo = bar;
>       }
>     |
>     foo = bar;

> .  So, please try out the patch, and please let us all know how well it
> corresponds with what you were looking for.  Also please let me know
> about any bugs you notice, so that I can fix them.  Thanks for such an
> interesting problem!

> Here's the patch, which should apply cleanly to the emacs-26.1 source:

[ snip patch ].

Subject: 26.1; electric-pair-mode breaks auto-newline minor mode of cc-mode
From: Beatrix Klebe <[email-masked]>
To: [email-masked]
Date: Tue, 18 Dec 2018 12:38:41 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

When using cc-mode, turning on electric-pair-mode causes the
auto-newline minor mode to stop inserting newlines where expected. This
is relevant to the formatting of C# code with the Allman/BSD brace style
in particular, though it would be nice if these modes specifically did
work together.

In GNU Emacs 26.1 (build 1, x86_64-apple-darwin14.5.0, NS
appkit-1348.17 Version 10.10.5 (Build 14F2511))
 of 2018-05-30 built on builder10-10.porkrind.org
Windowing system distributor 'Apple', version 10.3.1671
Recent messages:
Saving file /Users/bea/.emacs.d/lisp/dotnet.el...
Wrote /Users/bea/.emacs.d/lisp/dotnet.el
; expected
Undo!
; expected
Undo! [2 times]
; expected
Auto-saving...
; expected [2 times]
Making completion list...

Configured using:
 'configure --with-ns '--enable-locallisppath=/Library/Application
 Support/Emacs/${version}/site-lisp:/Library/Application
 Support/Emacs/site-lisp' --with-modules'

Configured features:
NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES THREADS

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

Major mode: C#//la

Minor modes in effect:
  smartparens-global-strict-mode: t
  smartparens-strict-mode: t
  smartparens-mode: t
  diff-auto-refine-mode: t
  projectile-mode: t
  omnisharp-mode: t
  rainbow-delimiters-mode: t
  delete-selection-mode: t
  global-flycheck-mode: t
  flycheck-mode: t
  global-company-mode: t
  company-mode: t
  global-hl-line-mode: t
  global-display-line-numbers-mode: t
  display-line-numbers-mode: t
  override-global-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  size-indication-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug sendmail smartparens-config warnings
smartparens-text smartparens-ruby smartparens autoload radix-tree
lisp-mnt tar-mode mm-archive message format-spec rfc822 mml mml-sec epa
derived epg gnus-util rmail rmail-loaddefs mailabbrev gmm-utils
mailheader mm-decode mm-bodies mm-encode mail-utils network-stream
starttls url-http tls gnutls mail-parse rfc2231 rfc2047 rfc2045 mm-util
ietf-drums mail-prsvr url-gw nsm rmc puny url-cache url-auth url
url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util mailcap pp cus-edit cus-start cus-load wid-edit
vc-git diff-mode projectile grep ibuf-ext ibuffer ibuffer-loaddefs
omnisharp omnisharp-unit-test-actions omnisharp-code-structure
omnisharp-server-installation omnisharp-format-actions
omnisharp-solution-actions omnisharp-helm-integration
omnisharp-navigation-actions omnisharp-current-symbol-actions
omnisharp-auto-complete-actions omnisharp-server-actions
omnisharp-http-utils omnisharp-utils omnisharp-server-management
omnisharp-settings f s popup dired dired-loaddefs thingatpt ido
csharp-mode imenu compile comint ansi-color cc-mode cc-fonts cc-guess
cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
parinfer-ext parinfer ediff-merg ediff-wind ediff-diff ediff-mult
ediff-help ediff-init ediff-util ediff mode-local parinferlib
rainbow-delimiters windows-config macos-config exec-path-from-shell
org-mode-config development proof-general-config dotnet elec-pair ocaml
backup editor delsel flycheck-config flycheck json map find-func rx
subr-x company-config delight advice company-oddmuse company-keywords
company-etags etags xref project ring company-gtags company-dabbrev-code
company-dabbrev company-files company-capf company-cmake company-xcode
company-clang company-semantic company-eclim company-template
company-bbdb company edmacro kmacro pcase ui hl-line
display-line-numbers zenburn-theme package-config auto-package-update
dash use-package use-package-ensure use-package-delight
use-package-diminish use-package-bind-key bind-key easy-mmode
use-package-core cl-extra help-mode finder-inf proof-site
proof-autoloads pg-vars info package easymenu epg-config url-handlers
url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache url-vars seq byte-opt bytecomp byte-compile cconv cl gv
cl-loaddefs cl-lib time-date tooltip eldoc electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel term/ns-win ns-win ucs-normalize
mule-util term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic 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 charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote kqueue cocoa ns multi-tty make-network-process emacs)

Memory information:
((conses 16 500415 57879)
 (symbols 48 41866 532)
 (miscs 40 198 1263)
 (strings 32 116702 6337)
 (string-bytes 1 3303823)
 (vectors 16 61571)
 (vector-slots 8 1021437 30984)
 (floats 8 135 577)
 (intervals 56 1409 585)
 (buffers 992 21))