From unknown Sun Jun 22 17:16:25 2025 X-Loop: help-debbugs@gnu.org Subject: bug#41061: [PATCH] cc-mode: add =?UTF-8?Q?=E2=80=98c-lineup-ternary-bodies=E2=80=99?= Resent-From: Michal Nazarewicz Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 May 2020 20:32:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 41061 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 41061@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.15885378623556 (code B ref -1); Sun, 03 May 2020 20:32:01 +0000 Received: (at submit) by debbugs.gnu.org; 3 May 2020 20:31:02 +0000 Received: from localhost ([127.0.0.1]:58107 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jVLGP-0000v5-LQ for submit@debbugs.gnu.org; Sun, 03 May 2020 16:31:02 -0400 Received: from lists.gnu.org ([209.51.188.17]:37344) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jVLGN-0000uq-JR for submit@debbugs.gnu.org; Sun, 03 May 2020 16:31:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVLGN-0001Rw-BO for bug-gnu-emacs@gnu.org; Sun, 03 May 2020 16:30:59 -0400 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]:35727) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jVLGM-0004ms-0S for bug-gnu-emacs@gnu.org; Sun, 03 May 2020 16:30:58 -0400 Received: by mail-qt1-x841.google.com with SMTP id s30so12437265qth.2 for ; Sun, 03 May 2020 13:30:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=EZJamjLgkPV9O6+/q6v45MvO9SzZFKBhonQSf0GLcJk=; b=eK/18ji9eppUvj8q6y43Yn8x0QrCNvWst9H/9y2EeLvecnmmu4UHhsAXFbsrrKfqeK hzD56cU7JNHKLW5EP6GXyLMW68S3AfTuVKZixhJZSFchpXoZYMmPXvMxpHnpBBxdnsJP VT2w1rfo98XmVhTtF752u/BpeuvIiaGfcc7A3ghxgGSlmOHHHwSS2QWFqP6maV90OoKH k7oNsrcKXtxFKi7HH64ugW+8a7k0fLJQUBo68C0SO426R0UzWIkscwrQQKAVV8ZkPF82 UJmGr63e5l2alw/TBReahRS+HuAB+nB6ElGQOK28n8uTF4U78dFSuy8GpeB7B9yPAXJQ ww1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :mime-version:content-transfer-encoding; bh=EZJamjLgkPV9O6+/q6v45MvO9SzZFKBhonQSf0GLcJk=; b=a+wVdWcMR6ZFFrkDNaNVgckEHWbYsDd7VCIAGpIAAu0pmBD+m8EqY3kvPJKmUssC/s Z0o3eBrUWgVlUZ/xgPW//j50h80yLMPw/6kwccytmRigWkF2ON8clvI0nL/BcaaUjgfN YLTYkKDXb5ALjq9cEs5G08Ul/Jdt8DwpsvCTfzXiTmkWi1ywCyex6Dn8UB57zpDVY4FE MBS4pBFp++Bue5tmiN/SUybKY+39MEuXZKYPUle7TBis0YYu+FQawJ5fJEmLcKfoF5tc 4dBJ1YAhpquh7+F/Jcg3irUrYlggn72PboSDzZtQ5T9ZM/jXABoMNeTtqp64bNgG1xXD Z9pg== X-Gm-Message-State: AGi0PuYHGehsNRUCiAYhfvMuj35Sc880R1Mr8omOvJUjTpL3ru2BQbtB bPN7KwPmmGkOGFDT4RFqmXs1H0h0 X-Google-Smtp-Source: APiQypJjE9KUJbJs5WkeixkexuMx4Oq279r+WWG8k6CArVeDhbnpVoJTzX2Bqde4e93Tz/rHE1ilJQ== X-Received: by 2002:aed:2e83:: with SMTP id k3mr14152852qtd.2.1588537854525; Sun, 03 May 2020 13:30:54 -0700 (PDT) Received: from pikus.mina86.com ([89.36.67.7]) by smtp.gmail.com with ESMTPSA id i6sm8098431qkk.123.2020.05.03.13.30.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 May 2020 13:30:53 -0700 (PDT) From: Michal Nazarewicz Date: Sun, 3 May 2020 21:30:47 +0100 Message-Id: <20200503203047.233844-1-mina86@mina86.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::841; envelope-from=mnazarewicz@gmail.com; helo=mail-qt1-x841.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_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Introduce =?UTF-8?Q?=E2=80=98c-lineup-ternary-bodies=E2=80=99?= function which, when used as a c lineup function, aligns question mark and colon of a ternary operator. For example: return arg % 2 == 0 ? arg / 2 : (3 * arg + 1); Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (mnazarewicz[at]gmail.com) 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [209.51.188.17 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.51.188.17 listed in wl.mailspike.net] 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different 2.0 SPOOFED_FREEMAIL No description available. 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.8 (-) Introduce ‘c-lineup-ternary-bodies’ function which, when used as a c lineup function, aligns question mark and colon of a ternary operator. For example: return arg % 2 == 0 ? arg / 2 : (3 * arg + 1); * lisp/progmodes/cc-align.el (c-lineup-ternary-bodies): New function. * doc/misc/cc-mode.texi (Operator Line-Up Functions): Document the new function. * test/lisp/progmodes/cc-mode-tests.el (c-lineup-ternary-bodies): New test case. --- It’s not perfectly clear to me whether there is a better implementation of this. Some sort of function that cc-mode provides which parses an expression into a syntax tree of some kind perhaps. The approach I’ve taken does seem to work well enough though. If there isn’t any opposition to this, I’m gonna push it in a week or so. doc/misc/cc-mode.texi | 20 +++++++++++++++++ etc/NEWS | 18 ++++++++++++++++ lisp/progmodes/cc-align.el | 32 ++++++++++++++++++++++++++++ test/lisp/progmodes/cc-mode-tests.el | 20 +++++++++++++++++ 4 files changed, 90 insertions(+) diff --git a/doc/misc/cc-mode.texi b/doc/misc/cc-mode.texi index f9c9f5e1830..16eac4828c7 100644 --- a/doc/misc/cc-mode.texi +++ b/doc/misc/cc-mode.texi @@ -6395,6 +6395,26 @@ Operator Line-Up @comment ------------------------------------------------------------ +@defun c-lineup-ternary-bodies +@findex lineup-ternary-bodies @r{(c-)} +Line up true and false branches of a ternary operator +(i.e. @code{?:}). More precisely, if the line starts with a colon +which is a part of a said operator it with corresponding question +mark. For example: + +@example +@group +return arg % 2 == 0 ? arg / 2 + : (3 * arg + 1); @hereFn{c-lineup-ternary-bodies} +@end group +@end example + +@workswith @code{arglist-cont}, @code{arglist-cont-nonempty} and +@code{statement-cont}. +@end defun + +@comment ------------------------------------------------------------ + @defun c-lineup-cascaded-calls @findex lineup-cascaded-calls @r{(c-)} Line up ``cascaded calls'' under each other. If the line begins with diff --git a/etc/NEWS b/etc/NEWS index 753b7a7fd36..1b805784338 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -302,6 +302,24 @@ use ‘doxygen’ by default one might evaluate: (c++-mode . doxygen))) or use it in a custom ‘c-style’. + +*** Added support to line up ‘?’ and ‘:’ of a ternary operator. +The new ‘c-lineup-ternary-bodies’ function can be used as a lineup +function to align question mark and colon which are part of a ternary +operator (‘?:’). For example: + + return arg % 2 == 0 ? arg / 2 + : (3 * arg + 1); + +To enable, add it to appropriate entries in ‘c-offsets-alist’, e.g.: + + (c-set-offset 'arglist-cont '(c-lineup-ternary-bodies + c-lineup-gcc-asm-reg)) + (c-set-offset 'arglist-cont-nonempty '(c-lineup-ternary-bodies + c-lineup-gcc-asm-reg + c-lineup-arglist)) + (c-set-offset 'statement-cont '(c-lineup-ternary-bodies +)) + * New Modes and Packages in Emacs 28.1 diff --git a/lisp/progmodes/cc-align.el b/lisp/progmodes/cc-align.el index f30477dc787..a6f3f1f8024 100644 --- a/lisp/progmodes/cc-align.el +++ b/lisp/progmodes/cc-align.el @@ -790,6 +790,38 @@ c-lineup-math (or (c-lineup-assignments langelem) c-basic-offset)) +(defun c-lineup-ternary-bodies (langelem) + "Line up true and false branches of a ternary operator (i.e. ‘?:’). +More precisely, if the line starts with a colon which is a part of +a said operator it with corresponding question mark; otherwise return +nil. For example: + + return arg % 2 == 0 ? arg / 2 + : (3 * arg + 1); <- c-lineup-ternary-bodies + +Works with: arglist-cont, arglist-cont-nonempty and statement-cont. +" + (save-excursion + (back-to-indentation) + (when (and (eq ?: (char-after)) + (not (eq ?: (char-after (1+ (point)))))) + (let ((limit (c-langelem-pos langelem)) (depth 1)) + (catch 'done + (while (c-syntactic-skip-backward "^?:" limit t) + (goto-char (1- (point))) + (cond ((eq (char-after) ??) + ;; If we’ve found a question mark, decrease depth. If we’re + ;; reached zero, we’ve found the one we were looking for. + (when (zerop (setq depth (1- depth))) + (throw 'done (vector (current-column))))) + ((or (eq ?: (char-before)) (eq ?? (char-before))) + ;; Step over ‘::’ and ‘?:’ operators. We don’t have to + ;; handle ‘?:’ here but doing so saves an iteration. + (if (eq (point) limit) + (throw 'done) + (goto-char (1- (point))))) + ((setq depth (1+ depth)))))))))) ; Otherwise increase depth. + (defun c-lineup-cascaded-calls (langelem) "Line up \"cascaded calls\" under each other. If the line begins with \"->\" or \".\" and the preceding line ends diff --git a/test/lisp/progmodes/cc-mode-tests.el b/test/lisp/progmodes/cc-mode-tests.el index 0729841ce6f..cd461f55181 100644 --- a/test/lisp/progmodes/cc-mode-tests.el +++ b/test/lisp/progmodes/cc-mode-tests.el @@ -78,4 +78,24 @@ c-mode-macro-comment (insert macro-string) (c-mode)))) +(ert-deftest c-lineup-ternary-bodies () + "Test for c-lineup-ternary-bodies function" + (with-temp-buffer + (c-mode) + (let* ((common-prefix "int value = condition ? ") + (expected-column (- (length common-prefix) 2))) + (dolist (test '(("a : \n b" . nil) + ("a \n ::b" . nil) + ("a \n : b" . t) + ("::a \n : b" . t) + ("(p ? q : r) \n : b" . t) + ("p ?: q \n : b" . t) + ("p ? : q \n : b" . t) + ("p ? q : r \n : b" . t))) + (delete-region (point-min) (point-max)) + (insert common-prefix (car test)) + (should (equal + (and (cdr test) (vector expected-column)) + (c-lineup-ternary-bodies '(statement-cont . 1)))))))) + ;;; cc-mode-tests.el ends here -- 2.26.2 From unknown Sun Jun 22 17:16:25 2025 X-Loop: help-debbugs@gnu.org Subject: bug#41061: [PATCH] cc-mode: add =?UTF-8?Q?=C3=A2=C2=80=C2=98c-lineup-ternary-bodies=C3=A2=C2=80=C2=99?= Resent-From: Richard Stallman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 04 May 2020 03:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41061 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Michal Nazarewicz Cc: 41061@debbugs.gnu.org Reply-To: rms@gnu.org Received: via spool by 41061-submit@debbugs.gnu.org id=B41061.158856216710025 (code B ref 41061); Mon, 04 May 2020 03:17:01 +0000 Received: (at 41061) by debbugs.gnu.org; 4 May 2020 03:16:07 +0000 Received: from localhost ([127.0.0.1]:58731 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jVRaR-0002bd-Ik for submit@debbugs.gnu.org; Sun, 03 May 2020 23:16:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36802) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jVRaP-0002au-OH for 41061@debbugs.gnu.org; Sun, 03 May 2020 23:16:06 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:44800) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVRaK-0001v2-0N; Sun, 03 May 2020 23:16:00 -0400 Received: from rms by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1jVRaJ-00015F-5y; Sun, 03 May 2020 23:15:59 -0400 Content-Type: text/plain; charset=Utf-8 From: Richard Stallman In-Reply-To: <20200503203047.233844-1-mina86@mina86.com> (message from Michal Nazarewicz on Sun, 3 May 2020 21:30:47 +0100) References: <20200503203047.233844-1-mina86@mina86.com> Message-Id: Date: Sun, 03 May 2020 23:15:59 -0400 X-Spam-Score: -2.3 (--) 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 (---) [[[ To any NSA and FBI agents reading my email: please consider ]]] [[[ whether defending the US Constitution against all enemies, ]]] [[[ foreign or domestic, requires you to follow Snowden's example. ]]] > return arg % 2 == 0 ? arg / 2 > : (3 * arg + 1); You can format the code that way if you like, but the GNU convention is like this: return (arg % 2 == 0 ? arg / 2 : 3 * arg + 1); That not only makes the nesting very clear, it also indents correctly without a special hack. -- Dr Richard Stallman Chief GNUisance of the GNU Project (https://gnu.org) Founder, Free Software Foundation (https://fsf.org) Internet Hall-of-Famer (https://internethalloffame.org) From unknown Sun Jun 22 17:16:25 2025 X-Loop: help-debbugs@gnu.org Subject: bug#41061: [PATCH] cc-mode: add =?UTF-8?Q?=C3=A2=E2=82=AC=CB=9Cc-line?= =?UTF-8?Q?up-ternary?= =?UTF-8?Q?-bodies=C3=A2=E2=82=AC=E2=84=A2?= Resent-From: =?UTF-8?Q?Micha=C5=82?= Nazarewicz Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 04 May 2020 20:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41061 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: rms@gnu.org Cc: 41061@debbugs.gnu.org Received: via spool by 41061-submit@debbugs.gnu.org id=B41061.158862242621398 (code B ref 41061); Mon, 04 May 2020 20:01:01 +0000 Received: (at 41061) by debbugs.gnu.org; 4 May 2020 20:00:26 +0000 Received: from localhost ([127.0.0.1]:34024 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jVhGL-0005Z4-OH for submit@debbugs.gnu.org; Mon, 04 May 2020 16:00:26 -0400 Received: from mail-wr1-f53.google.com ([209.85.221.53]:43493) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jVhGJ-0005Yj-MX for 41061@debbugs.gnu.org; Mon, 04 May 2020 16:00:24 -0400 Received: by mail-wr1-f53.google.com with SMTP id i10so549901wrv.10 for <41061@debbugs.gnu.org>; Mon, 04 May 2020 13:00:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=w6sMSHCRbD9YCw4mO/rpaxkxdckVfX9nj+5ou2lrbcs=; b=Mfi3Cwk1PB3eijujx3FK8vQNchxBgyy/YiLXCNVLvgzFIk4CcIRuNE3bJoNdGIKDKH BtR1PpQO6pvRUECY+p/U3+6PhD1hdKEPoOXqaUxI+Rx5KQICb3vPfZJ8JxeB+5D+NE5T Hw8/4H0qvN1MTjmWbPy94doQQsnM/R7JQ3LRNPpf8Qn5B5WF7R+MohSVW3BHn4xIvDoi lTCjU7h1hliMc6EujzMi0ZzfUSMGBV21c0Kpz8v27BndFXzr7u/fh/qIO5g+7UKkn6+E BFiEFnHJ1DpIvjWCV/RRVnmMZznLesCA4EDjTU2T6Au73AEOGjxLFf8dWIv66n2vfpNb IKKw== X-Gm-Message-State: AGi0PuZBm+lbX7O79dAVUsrvaWst8ENMUfoE541VomygYwhsuJ5PULcx AJrNaczmLp83PTd0RKEWZQRS3IcyvHEIrYK5qCw= X-Google-Smtp-Source: APiQypKZIuHpI+2+lSCZeNfmZIrPiOWAefutRMVl0Mbt2O+fscfm8L4M7ZgLNJ3J4bqEJbwmiVyDib7BGbSygK1mtvc= X-Received: by 2002:adf:afd6:: with SMTP id y22mr733924wrd.417.1588622417768; Mon, 04 May 2020 13:00:17 -0700 (PDT) MIME-Version: 1.0 References: <20200503203047.233844-1-mina86@mina86.com> In-Reply-To: From: =?UTF-8?Q?Micha=C5=82?= Nazarewicz Date: Mon, 4 May 2020 21:00:06 +0100 Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.5 (/) 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.5 (/) On Mon, 4 May 2020 at 04:17, Richard Stallman wrote: > > return arg % 2 =3D=3D 0 ? arg / 2 > > : (3 * arg + 1); > > You can format the code that way if you like, It=E2=80=99s more that project I=E2=80=99m involved in enforces such style. It=E2=80=99s one of the alignments clang-format supports so I=E2=80=99m lik= ely not the only person who needs to conform to this particular style. > but the GNU convention is like this: > > return (arg % 2 =3D=3D 0 > ? arg / 2 > : 3 * arg + 1); > > That not only makes the nesting very clear, > it also indents correctly without a special hack. --=20 Best regards =E3=83=9F=E3=83=8F=E3=82=A6 =E2=80=9C=F0=9D=93=B6=F0=9D=93=B2=F0=9D=93=B7= =F0=9D=93=AA86=E2=80=9D =E3=83=8A=E3=82=B6=E3=83=AC=E3=83=B4=E3=82=A4=E3=83= =84 =C2=ABIf at first you don=E2=80=99t succeed, give up skydiving=C2=BB From debbugs-submit-bounces@debbugs.gnu.org Sat May 09 06:44:19 2020 Received: (at control) by debbugs.gnu.org; 9 May 2020 10:44:19 +0000 Received: from localhost ([127.0.0.1]:46824 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jXMxv-0005M9-2Z for submit@debbugs.gnu.org; Sat, 09 May 2020 06:44:19 -0400 Received: from mail-wr1-f41.google.com ([209.85.221.41]:37404) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jXMxs-0005Ls-Gg for control@debbugs.gnu.org; Sat, 09 May 2020 06:44:17 -0400 Received: by mail-wr1-f41.google.com with SMTP id k1so4867982wrx.4 for ; Sat, 09 May 2020 03:44:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=dZSEKIa0MJOTjkUPRRywSwjfcuqEUu90HFNFC+cZJ94=; b=jGBBtQYITAX+UsjlKdGF3VNdThGoAsCqu6Dya3KpXKN34dAIr9d7JUVPa/cvSNvUgA 9Y8JWCRSazDEUP/ze+x1CcMmVxOELfMsOfvfvk2MhoIZ2TjRR6tAEdsKmPnHi/t0J+CE 4WDjkY7oTOoLg0GXdE6CqJq9A9SNQTTUSfmM3KMWOskfoZ6nEpTDbMaDluLUtDzwdZxu BcOtkIY7+PsW5L2nFoKlLJ/WHSnp81xvB/U14q4yDe0QIVvjMUd4hPogj0cJrilWuMz8 1ajl8oC4mR4E9lv5mN34UrO63hj/2O49XqHG2V+K3EcnxlDt7iOdT5A4o/hv5h4k80fx Zorw== X-Gm-Message-State: AGi0PuatSA82tWrQhyRwh0+V8fJMVocVcNvOOPhvmHzXPs+kpiLiux4R ZiD7qrz4ztgZ+48d1QxaBcRDjjj3m2MiNr5RTwxhLcRkYgg= X-Google-Smtp-Source: APiQypIHaoNFFPAQpbnJ3IjnAGhgkWb7PjkZ6r9Cza1SpCA0lLeCeP5FBpoUXfG8/4elP7EfzZE1ERnbRsiW1MGvTyo= X-Received: by 2002:adf:f38b:: with SMTP id m11mr7774586wro.65.1589021050505; Sat, 09 May 2020 03:44:10 -0700 (PDT) MIME-Version: 1.0 From: =?UTF-8?Q?Micha=C5=82_Nazarewicz?= Date: Sat, 9 May 2020 11:43:59 +0100 Message-ID: Subject: control To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: severity 41061 wishlist close 41061 quit Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (mnazarewicz[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.7 LOCALPART_IN_SUBJECT Local part of To: address appears in Subject 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.221.41 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.221.41 listed in wl.mailspike.net] 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different 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: 0.2 (/) severity 41061 wishlist close 41061 quit From unknown Sun Jun 22 17:16:25 2025 X-Loop: help-debbugs@gnu.org Subject: bug#41061: [PATCH] cc-mode: add =?UTF-8?Q?=E2=80=98c-lineup-ternary-bodies=E2=80=99?= References: <20200503203047.233844-1-mina86@mina86.com> Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 01 Jun 2020 17:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41061 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Michal Nazarewicz Cc: 41061@debbugs.gnu.org Received: via spool by 41061-submit@debbugs.gnu.org id=B41061.15910324369753 (code B ref 41061); Mon, 01 Jun 2020 17:28:01 +0000 Received: (at 41061) by debbugs.gnu.org; 1 Jun 2020 17:27:16 +0000 Received: from localhost ([127.0.0.1]:36930 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jfoDT-0002XF-Kl for submit@debbugs.gnu.org; Mon, 01 Jun 2020 13:27:15 -0400 Received: from colin.muc.de ([193.149.48.1]:47039 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1jfoDR-0002X6-4C for 41061@debbugs.gnu.org; Mon, 01 Jun 2020 13:27:13 -0400 Received: (qmail 51571 invoked by uid 3782); 1 Jun 2020 17:27:11 -0000 Date: 1 Jun 2020 17:27:11 -0000 Message-ID: <20200601172711.51570.qmail@mail.muc.de> From: Alan Mackenzie Organization: muc.de e.V. In-Reply-To: X-Newsgroups: gnu.emacs.bug User-Agent: tin/2.4.4-20191224 ("Millburn") (FreeBSD/11.3-RELEASE-p9 (amd64)) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) 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, Michal. In article you wrote= : > Introduce =E2=80=98c-lineup-ternary-bodies=E2=80=99 function which, whe= n used as > a c lineup function, aligns question mark and colon of a ternary > operator. For example: > return arg % 2 =3D=3D 0 ? arg / 2 > : (3 * arg + 1); > * lisp/progmodes/cc-align.el (c-lineup-ternary-bodies): New function. > * doc/misc/cc-mode.texi (Operator Line-Up Functions): Document the > new function. > * test/lisp/progmodes/cc-mode-tests.el (c-lineup-ternary-bodies): New > test case. > --- > It=E2=80=99s not perfectly clear to me whether there is a better > implementation of this. Some sort of function that cc-mode provides > which parses an expression into a syntax tree of some kind perhaps. > The approach I=E2=80=99ve taken does seem to work well enough though. > If there isn=E2=80=99t any opposition to this, I=E2=80=99m gonna push i= t in a week or > so. Which you did. This afternoon I tidied up one or two typos, and made a trivial amendment to the code. Just one thing: please keep curly quotes right out of the CC Mode sources. They make working with the code more difficult (these characters don't exist on many keyboard layouts) and add nothing of value. The same applies to other awkward non-keyboard characters unless, of course, there's a good reason for using them, such as their being part of somebody's name. Thanks! --=20 Alan Mackenzie (Nuremberg, Germany).