From unknown Tue Jun 17 01:43:33 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#43481 <43481@debbugs.gnu.org> To: bug#43481 <43481@debbugs.gnu.org> Subject: Status: 27.1; cc-mode's c-context-line-break fails, inserting a new-line into the previous comment Reply-To: bug#43481 <43481@debbugs.gnu.org> Date: Tue, 17 Jun 2025 08:43:33 +0000 retitle 43481 27.1; cc-mode's c-context-line-break fails, inserting a new-l= ine into the previous comment reassign 43481 emacs submitter 43481 Campbell Barton severity 43481 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 17 19:38:37 2020 Received: (at submit) by debbugs.gnu.org; 17 Sep 2020 23:38:37 +0000 Received: from localhost ([127.0.0.1]:40054 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kJ3U4-0006Jx-Kp for submit@debbugs.gnu.org; Thu, 17 Sep 2020 19:38:37 -0400 Received: from lists.gnu.org ([209.51.188.17]:51608) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kJ3U2-0006Jo-Nz for submit@debbugs.gnu.org; Thu, 17 Sep 2020 19:38:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ3Tz-0001L1-6V for bug-gnu-emacs@gnu.org; Thu, 17 Sep 2020 19:38:34 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]:54878) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kJ3Tr-0004Yh-B9 for bug-gnu-emacs@gnu.org; Thu, 17 Sep 2020 19:38:26 -0400 Received: by mail-pj1-x1035.google.com with SMTP id mm21so2126576pjb.4 for ; Thu, 17 Sep 2020 16:38:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:date:user-agent:mime-version :content-transfer-encoding; bh=pPPFkzaeerLPjzJ9pMZTymn4Op7Oe8nB1GCI2Lvbp0w=; b=YxlloJHKQQrQVJx5MLlrV1r8ndYS36KtkBS5/hODcEgyZFN71d0wnMikDwaYlD3RlQ WtFA0Bg90Yj5nsTpHnAecAHiLajoe3XjuKDbwyb2XKRaBeFG+O9W9wEbnqsX7D4WoXUj cRBjKBst8HdZ1WQpRbkPtsfEmMf7Aiown/nuJl+AM3G33rCe9OrIKeFRivRWRN84enxD Oo/yqYM3X0KCitlftzFW9gQl3y9PDvsiaUEwLB+TjYceQ+5S0KAdmmTywCMWNdhc9zT+ /eeMDuGLUsaCmqFUqdlPPzbwpjTNqKIC2dEQ1dTeKL0/6i/4/OSs1UgL5mIp62TZIN8N FYMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:user-agent :mime-version:content-transfer-encoding; bh=pPPFkzaeerLPjzJ9pMZTymn4Op7Oe8nB1GCI2Lvbp0w=; b=l49tLGixSgAEJdHpzo99Dqlx7G/yAkfJRCj6DxlzSBGYk5wpxAKvZozl+GzFjJvPEr DomM9I/2LaI351RztS3NVms3Te2gYIpRK/treRTSyPDG1/FcUMC4GYRGpDVDPAxN3kI2 waDC8jZjej5gZYKXwc/0Hy674JrdsuTMeepNYLD0VrUr+1u0XJh2LnEMBn1AAd1WK9tZ ff9ydquVbSIM1nTKHiCdyuf/ATEmOsfrgU2fo34T6yutwZ0CPpwoRfY5Q2H4bmc7rn7V B0Rncv4Z7JzR99ejF7ioui7Ttgt5OHa67ZJuKRy9FpxPPZuutb5kEDwVaj4Mj3Z7vczB Z7FA== X-Gm-Message-State: AOAM531vOVKpWxAbtlgz4eNBE79dMHzAosCEcX/0DflUiaNTrYL3Zk49 rc8ov0jBL9rRd7D/XYv4IplkYw1TJJR7+w== X-Google-Smtp-Source: ABdhPJzLIWyXMhfNU2lgxLy4xHN25S26MLjsp7KiJzkq8jR2osNMJGbJ/fCtS8rCH7R1ueHXl3YUpg== X-Received: by 2002:a17:902:e9d2:b029:d1:e5e7:be63 with SMTP id 18-20020a170902e9d2b02900d1e5e7be63mr12934296plk.61.1600385900122; Thu, 17 Sep 2020 16:38:20 -0700 (PDT) Received: from austpc ([2402:b801:2844:2100::1]) by smtp.gmail.com with ESMTPSA id z28sm807051pfq.81.2020.09.17.16.38.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 16:38:19 -0700 (PDT) Message-ID: Subject: 27.1; cc-mode's c-context-line-break fails, inserting a new-line into the previous comment From: Campbell Barton To: bug-gnu-emacs@gnu.org Date: Fri, 18 Sep 2020 09:38:16 +1000 Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=ideasman42@gmail.com; helo=mail-pj1-x1035.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) Running 'c-context-line-break' sometimes adds the line break to the previous comment, this seems to depend on the internal state since it doesn't happen every time. Tested in 27.1, and current master, this has been an issue for some years IIRC. Take this example C file: ---- BEGIN `example.c` /* * A */ /* * B */ ---- END - Move the cursor the end-of-line above 'A'. - M-x, c-context-line-break ---- `example.c` (with newline above 'A', as expected). /* * * A */ /* * B */ ---- END - Move the cursor the end-of-line above 'B'. - M-x, c-context-line-break ---- `example.c` (there should be newline above 'B', but there is not). /* * * A */ /* * B */ ---- END ---- `example.c` (EXPECTED RESULT) /* * * A */ /* * * B */ ---- END Instead of a newline being added above 'B', a newline is added to the previous comment after A, with no leading character. ---- I looked into the bug and this is caused by 'c-literal-limits' returning an invalid range (where the beginning is correct, but the end is the end of the previous comment, instead of the end of the current comment). Printing 'c-literal-limits' before calling 'c-context-line-break' shows this error, temporarily advising 'c-literal-limits' to return the beginning/end of the comment is a workaround which gives the 'EXPECTED RESULT'. In GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.22, cairo version 1.17.3) of 2020-08-29 built on juergen Windowing system distributor 'The X.Org Foundation', version 11.0.12009000 System Description: Arch Linux Recent messages: Package cl is deprecated LSP :: foo.c not in project or it is blacklisted. Undo-Fu-Session discarding undo data: file length mismatch Undo [5 times] progn: Beginning of buffer mouse-yank-secondary: No secondary selection scroll-up-command: End of buffer funcall-interactively: End of buffer Configured using: 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib --localstatedir=/var --with-x-toolkit=gtk3 --with-xft --with-wide-int --with-modules --with-cairo --with-harfbuzz 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt' CPPFLAGS=-D_FORTIFY_SOURCE=2 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now' Configured features: XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY INOTIFY ACL GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD JSON PDUMPER LCMS2 GMP Important settings: value of $LC_CTYPE: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: C/*l Minor modes in effect: display-fill-column-indicator-mode: t spell-fu-mode: t which-function-mode: t highlight-numbers-mode: t default-text-scale-mode: t global-diff-hl-mode: t diff-hl-mode: t show-paren-mode: t savehist-mode: t mydoxygen-highlight-mode: t gui-clipboard-history-mode: t global-evil-surround-mode: t evil-surround-mode: t shell-dirtrack-mode: t evil-mode: t evil-local-mode: t global-undo-fu-session-mode: t undo-fu-session-mode: t override-global-mode: t tooltip-mode: t electric-indent-mode: t mouse-wheel-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 column-number-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: /home/ideasman42/.config/emacs/elpa/cmake-mode-20190710.1319/cmake-mode hides /usr/share/emacs/site-lisp/cmake-mode Features: (shadow sort mail-extr scroll-on-drag emacsbug message format-spec rfc822 mml mml-sec epa epg epg-config gnus-util rmail rmail-loaddefs text-property-search time-date mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils counsel xdg dired dired-loaddefs swiper ivy delsel ivy-faces ivy-overlay colir undo-fu jka-compr add-log vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs view lsp-svelte lsp-sqls lsp-yaml lsp-xml lsp-vimscript lsp-vhdl lsp-vetur lsp-html lsp-verilog lsp-terraform lsp-tex lsp-solargraph lsp-rust lsp-rf lsp-r lsp-purescript lsp-pyls lsp-pwsh lsp-php lsp-perl lsp- ocaml lsp-nim lsp-lua lsp-kotlin lsp-json url url-proxy url-privacy url- expand url-methods url-history url-cookie url-domsuf mailcap lsp-javascript lsp-haxe lsp-groovy lsp-hack lsp-go lsp-gdscript lsp-fsharp lsp-fortran lsp-eslint lsp-erlang lsp-elixir lsp-elm lsp-dockerfile lsp-dhall lsp-css lsp-csharp gnutls lsp-crystal lsp-cmake lsp-clojure lsp-clangd dom lsp-bash lsp-angular lsp-ada display-fill-column-indicator spell-fu rainbow-delimiters elisp-autofmt nameless lisp-mnt whitespace lisp-extra-font-lock which-func highlight-numbers parent-mode hideshow default-text-scale diff-hl face-remap vc-hg vc-git vc-dir vc vc-dispatcher diff-mode rst cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs hl-line paren stackexchange-transpose-words stackexchange-imenu-goto stackexchange-c-transpose-args stackexchange-sort-line-in-block stackexchange-scroll-and-clamp stackexchange-scratch-buffer-from-file stackexchange-revert-all-buffers stackexchange-neotree-project-dir-toggle stackexchange-mode-line-visual-bell stackexchange-ispell-word-immediate stackexchange-frame-urgent-hint-set stackexchange-delete-surround-at-point stackexchange-comment-multi-line-toggle stackexchange-backspace-whitespace-to-tab-stop savehist gui-clipboard-history-mode lsp-mode lsp-protocol yasnippet xref project url-util tree-widget wid-edit spinner cl network-stream puny nsm rmc markdown-mode rx color noutline outline lv inline imenu ht filenotify f s ewoc dash-functional dash compile bindat evil-surround evil evil-keybindings evil-integration undo-tree diff evil-maps evil- commands ffap reveal flyspell ispell evil-jumps evil-command-window evil-types evil-search evil-ex shell pcomplete comint ansi-color evil-macros evil-repeat evil-states evil-core advice evil-common windmove thingatpt rect evil-digraphs evil-vars ring edmacro kmacro undo-fu-session cl-extra help-mode pcase inkpot-theme use-package use-package-ensure use-package-delight use-package-diminish use-package-bind-key bind-key easy-mmode use-package-core derived finder-inf info package easymenu browse-url url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json subr-x map url-vars seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type 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 elisp-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame minibuffer 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 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 threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x- toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 649698 493642) (symbols 48 36426 1) (strings 32 254465 6152) (string-bytes 1 5053219) (vectors 16 42495) (vector-slots 8 1252832 32982) (floats 8 261 269) (intervals 56 1250 0) (buffers 1000 13)) From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 23 12:52:03 2020 Received: (at control) by debbugs.gnu.org; 23 Nov 2020 17:52:03 +0000 Received: from localhost ([127.0.0.1]:51058 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1khG0R-0007fk-2h for submit@debbugs.gnu.org; Mon, 23 Nov 2020 12:52:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58866) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1khG0O-0007fC-Ro; Mon, 23 Nov 2020 12:52:01 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:50044) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khG0J-0004DS-6n; Mon, 23 Nov 2020 12:51:55 -0500 Received: from [176.228.60.248] (port=2707 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1khG0I-0001UR-4K; Mon, 23 Nov 2020 12:51:54 -0500 Date: Mon, 23 Nov 2020 19:51:50 +0200 Message-Id: <83r1okufk9.fsf@gnu.org> From: Eli Zaretskii To: 44823@debbugs.gnu.org, acm@muc.de In-Reply-To: <83zh38ugeo.fsf@gnu.org> (message from Eli Zaretskii on Mon, 23 Nov 2020 19:33:35 +0200) Subject: Re: bug#44823: 27.1.50; c-context-line-break misbehaves at end of comment References: <83zh38ugeo.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) merge 44823 43481 thanks > Date: Mon, 23 Nov 2020 19:33:35 +0200 > From: Eli Zaretskii > > To reproduce: > > emacs -Q > C-x C-f src/xdisp.c > C-u 19 M-g g > C-e > > This should bring you to the end of this line in xdisp.c: > > along with GNU Emacs. If not, see . */ > > It is the end of a comment. Now do this: > > M-: (local-set-key "\C-m" 'c-context-line-break) RET > > Then press RET. I expect Emacs to open a new line, indent it > according to the context, and put point after the indentation. > Instead, the new line is inserted _before_ the point's line, and point > stays at the end of the comment as it was before. > > This is a regression wrt Emacs 26. > > I had this customization of RET in CC mode since about forever, and it > always worked like I expected. Until Emacs 27.1. I see someone already reported this 2 months ago. Merging. > Can this be fixed for Emacs 27.2, please? Yes, please. From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 24 10:02:55 2020 Received: (at 43481) by debbugs.gnu.org; 24 Nov 2020 15:02:55 +0000 Received: from localhost ([127.0.0.1]:60856 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1khZqJ-0004aZ-9g for submit@debbugs.gnu.org; Tue, 24 Nov 2020 10:02:55 -0500 Received: from colin.muc.de ([193.149.48.1]:58885 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1khZqH-0004aJ-2l for 43481@debbugs.gnu.org; Tue, 24 Nov 2020 10:02:53 -0500 Received: (qmail 17187 invoked by uid 3782); 24 Nov 2020 15:02:46 -0000 Received: from acm.muc.de (p4fe15a86.dip0.t-ipconnect.de [79.225.90.134]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Tue, 24 Nov 2020 16:02:46 +0100 Received: (qmail 30836 invoked by uid 1000); 24 Nov 2020 15:02:46 -0000 Date: Tue, 24 Nov 2020 15:02:46 +0000 To: Campbell Barton Subject: Re: bug#43481: 27.1; cc-mode's c-context-line-break fails, inserting a new-line into the previous comment Message-ID: <20201124150246.GA30574@ACM> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 43481 Cc: Eli Zaretskii , 43481@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Campbell. Thank you indeed for taking the trouble to report this bug. On Fri, Sep 18, 2020 at 09:38:16 +1000, Campbell Barton wrote: > Running 'c-context-line-break' sometimes adds the line break to the > previous comment, this seems to depend on the internal state > since it doesn't happen every time. Yes. The internal state it depends on is a cache for things like c-literal-limits (as you point out below). To make the bug show itself, first type a space in the "A" comment somewhere (which clears the cache entries for any points after the place of the change), then move point into the B comment and type M-j. > Tested in 27.1, and current master, this has been an issue for some > years IIRC. > Take this example C file: > ---- BEGIN `example.c` > /* > * A > */ > /* > * B > */ > ---- END > - Move the cursor the end-of-line above 'A'. > - M-x, c-context-line-break > ---- `example.c` (with newline above 'A', as expected). > /* > * > * A > */ > /* > * B > */ > ---- END [ .... ] > ---- > I looked into the bug and this is caused by 'c-literal-limits' > returning an invalid range (where the beginning is correct, but the > end is the end of the previous comment, instead of the end of the > current comment). Thank you very much indeed for taking the debugging so far. That was exceptionally helpful. What was happening was CC Mode read a cache entry, and because there was no entry for the "B" comment, got that for the "A" comment. It later wrongly used the END element of that cache entry, without testing properly that it was valid. > Printing 'c-literal-limits' before calling 'c-context-line-break' > shows this error, temporarily advising 'c-literal-limits' to return > the beginning/end of the comment is a workaround which > gives the 'EXPECTED RESULT'. Yes. > In GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.22, > cairo version 1.17.3) > of 2020-08-29 built on juergen > Windowing system distributor 'The X.Org Foundation', version > 11.0.12009000 > System Description: Arch Linux [ .... ] Would you please try the following patch in CC Mode. After applying it, you need byte compile only cc-engine.el (which is in emacs/lisp/progmodes/). In the unlikely event you would like any help with the patching or byte compilation, feel free to send me private email. Having applied it, please test out the problem in your real code, and confirm that the bug is, in fact, fixed, or alternatively tell us that there are still glitches with it. Thanks! diff -r 4cdd79795247 cc-engine.el --- a/cc-engine.el Sun Nov 15 10:19:11 2020 +0000 +++ b/cc-engine.el Tue Nov 24 14:53:07 2020 +0000 @@ -3152,7 +3152,7 @@ ((nth 7 s) 'c++) (t 'c))) (setq start (nth 8 s)) - (unless end + (unless (and end (>= end here)) (setq s1 (parse-partial-sexp here (point-max) nil ; TARGETDEPTH nil ; STOPBEFORE -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 25 23:58:32 2020 Received: (at 43481) by debbugs.gnu.org; 26 Nov 2020 04:58:32 +0000 Received: from localhost ([127.0.0.1]:38153 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ki9MW-0007zt-AB for submit@debbugs.gnu.org; Wed, 25 Nov 2020 23:58:32 -0500 Received: from mail-pf1-f171.google.com ([209.85.210.171]:39552) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ki9MU-0007zg-Ek for 43481@debbugs.gnu.org; Wed, 25 Nov 2020 23:58:31 -0500 Received: by mail-pf1-f171.google.com with SMTP id x24so552255pfn.6 for <43481@debbugs.gnu.org>; Wed, 25 Nov 2020 20:58:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=CliY0dAYQS7Op9ugqMIzt3XFa4uUrVUmPZAZL7BmVuY=; b=q3VOUUNY1jNIf5TAgU5DeIcv/hGkb+GlcilnefLNnH7V+5Lez/PZSYTa/zQFSjKliM g7kouLV7HHpwDmx/xZhLUjCeJlelyFlL9gADV0cdPJthpBHFnp81rmnIuWdjqrN3j/JQ t+VIzy5FSurEgcemEGPB/eMxRT8tmNi2cTgrkRVWVdofcnJkiDzStfbqUdCtcca2UKLA mJuIgV/ZaZ7X67W6Uiyeb6S7XosRvN4IxjMzU15bVqJJvkSBisr62R6oxiTv9wtUF6IW fjn6ZqSIC04xFbFQCu7JVpeBtITzc/VY5vx4jWRkR82YNIqFPMxhPGAGVtpL1Itg2x3S 80Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=CliY0dAYQS7Op9ugqMIzt3XFa4uUrVUmPZAZL7BmVuY=; b=pjcUN6MolSgQLXSOKqDk7nlU/+zau5DHkhtIVdPU6vAfGP1yueW/jaFdDxq9cajWtq mxeANI/aOluPvgmEsTXIvjOU8FHVdeW0CgcBCin20PwUHt54vJ/43XM2ByeU6bhbR+Tu U9/ALYy0eyeyaU7BimF51VklMvmgjbIxhXqXSeg+MTbJU/GZycSacUGXAjzKOCCjv5yo Vqu+lH4dnB23r1Jg4ONfnxazYpp0BEpGeZT/rIzygxGBcer9I6FMraxcDTQ5kureDbdJ ArzwOc5baMUv3nBt+1b5LOlGrNzSAMO5GwCKKNPbEup4HcHda5akrIXEmFom3bOEHbGw GCHg== X-Gm-Message-State: AOAM533Y71OUzFE78x5fmMbLmBys1wYJRvUcDeAkEn0SfWpyHF7nj7Qo yFm3mEOvT44Yndkb5ntkTmyIHd28zCE= X-Google-Smtp-Source: ABdhPJy8RAsAgEbJne0D3BGRVGYT7WFfQbyiFwQbfF+WFecnBj9yOrXhedfziSrZlDkV1FFx7QsltA== X-Received: by 2002:a62:864a:0:b029:197:ad58:4184 with SMTP id x71-20020a62864a0000b0290197ad584184mr1180381pfd.55.1606366704307; Wed, 25 Nov 2020 20:58:24 -0800 (PST) Received: from ?IPv6:2402:b801:2844:2100::1? ([2402:b801:2844:2100::1]) by smtp.gmail.com with ESMTPSA id a22sm3299426pfn.29.2020.11.25.20.58.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 Nov 2020 20:58:23 -0800 (PST) Subject: Re: bug#43481: 27.1; cc-mode's c-context-line-break fails, inserting a new-line into the previous comment To: Alan Mackenzie References: <20201124150246.GA30574@ACM> From: Campbell Barton Message-ID: <73c01ad8-4546-c059-1b5d-6edc4aca1d14@gmail.com> Date: Thu, 26 Nov 2020 15:58:20 +1100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.3 MIME-Version: 1.0 In-Reply-To: <20201124150246.GA30574@ACM> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 43481 Cc: Eli Zaretskii , 43481@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) Hi Alan, thanks for fixing this, Tested this both with `emacs -Q` and my personal (evil) config. When your fix is applied, in both cases this works as expected. On 11/25/20 2:02 AM, Alan Mackenzie wrote: > Hello, Campbell. > > Thank you indeed for taking the trouble to report this bug. > > On Fri, Sep 18, 2020 at 09:38:16 +1000, Campbell Barton wrote: >> Running 'c-context-line-break' sometimes adds the line break to the >> previous comment, this seems to depend on the internal state >> since it doesn't happen every time. > > Yes. The internal state it depends on is a cache for things like > c-literal-limits (as you point out below). To make the bug show itself, > first type a space in the "A" comment somewhere (which clears the cache > entries for any points after the place of the change), then move point > into the B comment and type M-j. > >> Tested in 27.1, and current master, this has been an issue for some >> years IIRC. > >> Take this example C file: > >> ---- BEGIN `example.c` >> /* >> * A >> */ > >> /* >> * B >> */ >> ---- END > >> - Move the cursor the end-of-line above 'A'. >> - M-x, c-context-line-break > >> ---- `example.c` (with newline above 'A', as expected). >> /* >> * >> * A >> */ > >> /* >> * B >> */ >> ---- END > > [ .... ] > >> ---- > >> I looked into the bug and this is caused by 'c-literal-limits' >> returning an invalid range (where the beginning is correct, but the >> end is the end of the previous comment, instead of the end of the >> current comment). > > Thank you very much indeed for taking the debugging so far. That was > exceptionally helpful. > > What was happening was CC Mode read a cache entry, and because there was > no entry for the "B" comment, got that for the "A" comment. It later > wrongly used the END element of that cache entry, without testing > properly that it was valid. > >> Printing 'c-literal-limits' before calling 'c-context-line-break' >> shows this error, temporarily advising 'c-literal-limits' to return >> the beginning/end of the comment is a workaround which >> gives the 'EXPECTED RESULT'. > > Yes. > >> In GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.22, >> cairo version 1.17.3) >> of 2020-08-29 built on juergen >> Windowing system distributor 'The X.Org Foundation', version >> 11.0.12009000 >> System Description: Arch Linux > > [ .... ] > > Would you please try the following patch in CC Mode. After applying it, > you need byte compile only cc-engine.el (which is in > emacs/lisp/progmodes/). In the unlikely event you would like any help > with the patching or byte compilation, feel free to send me private > email. > > Having applied it, please test out the problem in your real code, and > confirm that the bug is, in fact, fixed, or alternatively tell us that > there are still glitches with it. Thanks! > > > > diff -r 4cdd79795247 cc-engine.el > --- a/cc-engine.el Sun Nov 15 10:19:11 2020 +0000 > +++ b/cc-engine.el Tue Nov 24 14:53:07 2020 +0000 > @@ -3152,7 +3152,7 @@ > ((nth 7 s) 'c++) > (t 'c))) > (setq start (nth 8 s)) > - (unless end > + (unless (and end (>= end here)) > (setq s1 (parse-partial-sexp here (point-max) > nil ; TARGETDEPTH > nil ; STOPBEFORE > > From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 26 06:43:23 2020 Received: (at 43481-done) by debbugs.gnu.org; 26 Nov 2020 11:43:23 +0000 Received: from localhost ([127.0.0.1]:38939 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kiFgJ-0001PJ-DS for submit@debbugs.gnu.org; Thu, 26 Nov 2020 06:43:23 -0500 Received: from colin.muc.de ([193.149.48.1]:49899 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1kiFgH-0001O5-6V for 43481-done@debbugs.gnu.org; Thu, 26 Nov 2020 06:43:21 -0500 Received: (qmail 73933 invoked by uid 3782); 26 Nov 2020 11:43:15 -0000 Received: from acm.muc.de (p4fe15ad2.dip0.t-ipconnect.de [79.225.90.210]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Thu, 26 Nov 2020 12:43:14 +0100 Received: (qmail 11897 invoked by uid 1000); 26 Nov 2020 11:43:14 -0000 Date: Thu, 26 Nov 2020 11:43:14 +0000 To: Campbell Barton Subject: Re: bug#43481: 27.1; cc-mode's c-context-line-break fails, inserting a new-line into the previous comment Message-ID: References: <20201124150246.GA30574@ACM> <73c01ad8-4546-c059-1b5d-6edc4aca1d14@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <73c01ad8-4546-c059-1b5d-6edc4aca1d14@gmail.com> X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 43481-done Cc: 43481-done@debbugs.gnu.org, Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Campbell. On Thu, Nov 26, 2020 at 15:58:20 +1100, Campbell Barton wrote: > Hi Alan, thanks for fixing this, > Tested this both with `emacs -Q` and my personal (evil) config. > When your fix is applied, in both cases this works as expected. Thanks indeed for testing this. I have committed the fix to the emacs-27 branch at savannah, and am closing the bug with this post. -- Alan Mackenzie. From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 26 19:11:58 2020 Received: (at 43481-done) by debbugs.gnu.org; 27 Nov 2020 00:11:58 +0000 Received: from localhost ([127.0.0.1]:43241 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kiRMk-0002MO-H3 for submit@debbugs.gnu.org; Thu, 26 Nov 2020 19:11:58 -0500 Received: from mail-pf1-f172.google.com ([209.85.210.172]:44051) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kiRMh-0002MA-Sb for 43481-done@debbugs.gnu.org; Thu, 26 Nov 2020 19:11:57 -0500 Received: by mail-pf1-f172.google.com with SMTP id y7so2898509pfq.11 for <43481-done@debbugs.gnu.org>; Thu, 26 Nov 2020 16:11:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=cESyygHoOS9AvUX+oEcNKJ21XsD+GDpmHQcPlZdKM2M=; b=u+gZ6mOfn5YMCt70bxAT5H2CIHky318wJbxmjHwFyKPYcTd7J5BKqvdtXOwgkqxb66 1f7nDUc+dsc0svuXJXotHitoZ5hHg6D7xb4trea/6wskL5SFgMowN4/uLs7uDh3o6zCE YY4611R4CV+kUrVSLFJJmnxt4lIJxKVrvxxx/Byiv/aQjt8jVK4HpOAC4EKmQpzBYsW7 5nS8Lbq6fApDqInJinxOj4rmYmon7FDswDkTaXptGiySNaUsuX3VC407hI7bClfSI8My ZMR1krmiAqUwR+TsOer54jhv2Jz5Lecx9pOzfigxPYsdL348r/sPKZKavro8k+DK4Pak qF5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=cESyygHoOS9AvUX+oEcNKJ21XsD+GDpmHQcPlZdKM2M=; b=tDZot/OQ7ujiRPxnam9pfbAiDwm359Vh3yPAXrl4kVLW2L8i/Q8ZTz7EB4vOUeP1A5 HHMeTVev40sCNVDmbK5/qntPnbOx3o77DmAO/V9kztzbHSlZJssP9Pe6aJbLs38Qpfeo Fr0z++0SurBaQZNOEdY6c2x4vJ5L9IlfwJTzHEqKFM35C/tx7TAC+A1q6Q9NpiX1Ckch kWytrviktqZJelkxCT1weSeIrFG9C3I9U34yIsqHWsUjfjf8DLJWRUORQ03whENM2HcI oSSeSCdFG9JUhzy9KBdAutfNnKgNtraGqwkck4SPuqPRGimoq1LzlsT1/6AAs2sPZ1T4 GaYw== X-Gm-Message-State: AOAM533mwDr8S4eKOOejyMXu6Y0VYvxszs3dIqT8frPXCqpTMXXVre9c uJy/nylayffW5faJy+4QVULITf8fdkg= X-Google-Smtp-Source: ABdhPJxa2M0q1cpLm2aFvUqjMSVYIZYNL2oCuH9JLeS4fIgMVnp0Ad/cmfrb8J+wDwpVQYXlBfkF0Q== X-Received: by 2002:a17:90a:4408:: with SMTP id s8mr6590396pjg.69.1606435909912; Thu, 26 Nov 2020 16:11:49 -0800 (PST) Received: from ?IPv6:2402:b801:2844:2100::1? ([2402:b801:2844:2100::1]) by smtp.gmail.com with ESMTPSA id b15sm7653527pjz.38.2020.11.26.16.11.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Nov 2020 16:11:49 -0800 (PST) Subject: Re: bug#43481: 27.1; cc-mode's c-context-line-break fails, inserting a new-line into the previous comment To: Alan Mackenzie References: <20201124150246.GA30574@ACM> <73c01ad8-4546-c059-1b5d-6edc4aca1d14@gmail.com> From: Campbell Barton Message-ID: <7365f9fa-b999-1a2b-84d2-ab31edf15668@gmail.com> Date: Fri, 27 Nov 2020 11:11:44 +1100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.3 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 43481-done Cc: 43481-done@debbugs.gnu.org, Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) Great, any reason this isn't in master? On 11/26/20 10:43 PM, Alan Mackenzie wrote: > Hello, Campbell. > > On Thu, Nov 26, 2020 at 15:58:20 +1100, Campbell Barton wrote: >> Hi Alan, thanks for fixing this, > >> Tested this both with `emacs -Q` and my personal (evil) config. > >> When your fix is applied, in both cases this works as expected. > > Thanks indeed for testing this. I have committed the fix to the > emacs-27 branch at savannah, and am closing the bug with this post. > From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 27 02:01:36 2020 Received: (at 43481) by debbugs.gnu.org; 27 Nov 2020 07:01:36 +0000 Received: from localhost ([127.0.0.1]:43602 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kiXl9-0006AU-KX for submit@debbugs.gnu.org; Fri, 27 Nov 2020 02:01:36 -0500 Received: from mail-wm1-f42.google.com ([209.85.128.42]:51075) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kiXl6-0006AF-5x for 43481@debbugs.gnu.org; Fri, 27 Nov 2020 02:01:34 -0500 Received: by mail-wm1-f42.google.com with SMTP id c198so4214729wmd.0 for <43481@debbugs.gnu.org>; Thu, 26 Nov 2020 23:01:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:mail-copies-to:gmane-reply-to-list :date:in-reply-to:message-id:mime-version; bh=yHzMG9Fd3QR9dwQHDgIpLmG8nn2BBhUKNjqIUkSLYC4=; b=B7/BAwxhZ8VTy+QfCPm9QYDcVBM4awM76d9xj/ZaiE2dla8VmKBWUQKp8t6dZ4vbDs moU6MGo1PnGf8emr3zI3dFz7Y/6+XeaDWjiVJaIK4tdf/WYy+4uamC568F5TpcMdeOax M6NmsnGtO1PGOZrtWUoYSUnO1zD8sXxaaYJeK105XyEdxm/tu50Xbanrwv09ZsxbUOrz QT7l5Xt82uGLHIqiRY01OnybSqNc3X4E5CUoEs0bu1XDD9VFl2zGcwQMxQkjp3jJKPnV cYlTtULO4tP33coS2XtgTgBYziadnxOeX7SGflAT8C8nFfCQ88SEgODJ56zVhsIYufAl rivA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:mail-copies-to :gmane-reply-to-list:date:in-reply-to:message-id:mime-version; bh=yHzMG9Fd3QR9dwQHDgIpLmG8nn2BBhUKNjqIUkSLYC4=; b=j2ss9piZXKbJa+9xolWdwtGpeVQxtgfvhaajl1AvhNZLr/WhsvfIdYz5fupd6558wz WlmdQnim1HLQjHBVP9yUqrmmxeDDND2uFVCcO+V24uoN6EpJS/9r2bEYACVvzw0FlEyu YjiIfOdEcGUKpAOVN1QrVxM5uDkw1eW3iAjYS0cDztaZLDVB4jlGR20elGaTgX7EJwK1 sMYSZDzhammc7H0I/s+mFmJtlDm7sha+I5QTO0kgL7WDu+CALTOzdaRjNV0kEJkOqTRZ uWSJ16R/Na0a/Nh70k0WCO1nE2TX1o9Qsa4ykrmFLorAiwa87ozTCvYAqFidbg0ygJfJ g2VA== X-Gm-Message-State: AOAM530dHYrXfwuaY4VewDUMSv6qzGf+h7eQ8/WkMAhrlkdHgWn7IVrC YzSo64OjukM1SKII9dpmOOFgelrTnSY= X-Google-Smtp-Source: ABdhPJwBdFIo2dMVW7U6qyJeJSa3xZHi/Ovpf1a8m4ACqMAVya+e2qehjH3WbcH8P/N0EVmDnZMXQQ== X-Received: by 2002:a1c:bd09:: with SMTP id n9mr5394340wmf.120.1606460485766; Thu, 26 Nov 2020 23:01:25 -0800 (PST) Received: from rltb ([2a01:e34:ecfc:a860:5525:34f8:b0be:6dfc]) by smtp.gmail.com with ESMTPSA id e3sm13135242wro.90.2020.11.26.23.01.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 23:01:24 -0800 (PST) From: Robert Pluim To: Campbell Barton Subject: Re: bug#43481: 27.1; cc-mode's c-context-line-break fails, inserting a new-line into the previous comment References: <20201124150246.GA30574@ACM> <73c01ad8-4546-c059-1b5d-6edc4aca1d14@gmail.com> <7365f9fa-b999-1a2b-84d2-ab31edf15668@gmail.com> X-Debbugs-No-Ack: yes Mail-Copies-To: never Gmane-Reply-To-List: yes Date: Fri, 27 Nov 2020 08:01:23 +0100 In-Reply-To: <7365f9fa-b999-1a2b-84d2-ab31edf15668@gmail.com> (Campbell Barton's message of "Fri, 27 Nov 2020 11:11:44 +1100") Message-ID: <875z5rl1vg.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 43481 Cc: Alan Mackenzie , 43481@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Campbell Barton writes: > Great, any reason this isn't in master? > emacs-27 gets merged to master on a regular basis. Robert From unknown Tue Jun 17 01:43:33 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 25 Dec 2020 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator