From unknown Sat Jun 21 03:07:32 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#78006 <78006@debbugs.gnu.org> To: bug#78006 <78006@debbugs.gnu.org> Subject: Status: Improving `TeX-electric-math' behavior Reply-To: bug#78006 <78006@debbugs.gnu.org> Date: Sat, 21 Jun 2025 10:07:32 +0000 retitle 78006 Improving `TeX-electric-math' behavior reassign 78006 auctex submitter 78006 Arash Esbati severity 78006 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 23 03:26:10 2025 Received: (at submit) by debbugs.gnu.org; 23 Apr 2025 07:26:10 +0000 Received: from localhost ([127.0.0.1]:52295 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u7UUk-0002Cm-BS for submit@debbugs.gnu.org; Wed, 23 Apr 2025 03:26:10 -0400 Received: from lists.gnu.org ([2001:470:142::17]:36688) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u7UUd-0002BS-Hc for submit@debbugs.gnu.org; Wed, 23 Apr 2025 03:26:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u7UUR-000421-4J for bug-auctex@gnu.org; Wed, 23 Apr 2025 03:25:51 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u7UUQ-0001h5-A8 for bug-auctex@gnu.org; Wed, 23 Apr 2025 03:25:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=YsAcUkGI87/PMO2+VQhhrYUPVbHFQIuw/muFmounDbA=; b=Ghkx1cyzqJsQA4 0peV8tWiT3oqoNjgafvk6D9pgcwaYW62vOjcXRTRDd3hTlVaUeQOSj9pQHQaTSx/Jki0Hzy9Acolz AgVV+jTiA9d6pf3WswHbjnKheeAoo+CVtDQ5zGV7JAAyj/qslOjo44482Pj7KkzLJ5KgLpjsjubtZ Vtg1aQfdjTfHke+3/kvkEdSyNnechHsJF74+yxee0TZ9UWEfZkmP76gFGShSNkt3zruRRgHfE2VHH Kwxy7ZF4bpTseQMqmAdb2eEeH6iEn+RmX2yHY2b6wKumiZUk7MnC2dk7McP2yUAl2ufLzAaoGTakA q4/8shlHVIbRHHoQfe9Q==; From: Arash Esbati To: "auctex-bugs" Subject: Improving `TeX-electric-math' behavior Date: Wed, 23 Apr 2025 09:25:25 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) 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: -1.0 (-) Hi all, currently, we have this in AUCTeX manual[1]: User Option: TeX-electric-math In addition, when the variable is non-nil and there is an active region outside math mode, typing $ will put around the active region symbols for opening and closing inline equation and keep the region active, leaving point after the closing symbol. By pressing repeatedly $ while the region is active you can toggle between an inline equation, a display equation, and no equation. To be precise, =E2=80=98$...$=E2=80=99 is replaced by =E2=80=98$$...$$=E2=80=99, whereas= =E2=80=98\(...\)=E2=80=99 is replaced by =E2=80=98\[...\]=E2=80=99. Using $$...$$ in LaTeX is discouraged, so I think AUCTeX shouldn't promote this as well, so I suggest this change to `TeX-insert-dollar-electric-region': --8<---------------cut here---------------start------------->8--- diff --git a/tex.el b/tex.el index 3d28b2c6..5d184942 100644 --- a/tex.el +++ b/tex.el @@ -6188,10 +6188,13 @@ See `TeX-electric-math'." (re-search-forward "\\=3D\\$\\$\\([^z-a]*\\)\\$\\$" (mark) t)= )) (replace-match "\\1" t) (set-mark (match-beginning 0))) - ;; $...$ to $$...$$ + ;; $...$ to $$...$$ or \[...\] dep. on mode: ((and (eq last-command #'TeX-insert-dollar) (re-search-forward "\\=3D\\$\\([^z-a]*\\)\\$" (mark) t)) - (replace-match "$$\\1$$" t) + (replace-match (if (memq major-mode '(LaTeX-mode docTeX-mode)) + "\\\\[\\1\\\\]" + "$$\\1$$") + t) (set-mark (match-beginning 0))) ;; \(...\) to \[...\] ((and (eq last-command #'TeX-insert-dollar) --8<---------------cut here---------------end--------------->8--- I think this needs some more massaging in order to make it work for ConTeXt users as well, but this should get us going for other modes. What do people think? If Ok, I would install it and update the manual accordingly. Best, Arash Footnotes: [1] https://elpa.gnu.org/packages/doc/auctex.html#index-TeX_002delectric_0= 02dmath From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 24 05:55:56 2025 Received: (at 78006) by debbugs.gnu.org; 24 Apr 2025 09:55:56 +0000 Received: from localhost ([127.0.0.1]:36354 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u7tJE-00034Y-7A for submit@debbugs.gnu.org; Thu, 24 Apr 2025 05:55:56 -0400 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]:50642) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1u7tJA-00034E-MJ for 78006@debbugs.gnu.org; Thu, 24 Apr 2025 05:55:53 -0400 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-5f435c9f2f9so1052668a12.1 for <78006@debbugs.gnu.org>; Thu, 24 Apr 2025 02:55:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745488546; x=1746093346; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=U5xUkaABm/N7GwtEwLuO/CmwZlQvlG2wJarJgd+Xn2s=; b=mHr7J4T8fF0VWvNdcxOTqJ7THBLWQwXC2w/LbLJcyTWFKvsSHzdpybtFzobUsmpucQ M9LSpWdEb68FgD3mje7bwS0O7hG0w569SPcyTBOZ/6Yi4PMsKgaisOgZVNgZhDgMz3u+ zbQBD/QOb43Nclx6BvGjhAxNqlWvTxU8skuR8VGOrlgixGsx/YF0bcjhZKGq8Xnqmwv9 OI+LBEPDmCbDewRayuOjIDHycnZ5kBuL1s/fKl4r37xgBaXGGKMM4vUhh9HePjmASjQ5 beYsaw9AIml5FdDs4+cPzcOCcvFH67reqjcpG6AXcDqr4wla4Nqx1LLwmmHd4hCi9i/f WIdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745488546; x=1746093346; h=content-transfer-encoding:mime-version:message-id:date:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=U5xUkaABm/N7GwtEwLuO/CmwZlQvlG2wJarJgd+Xn2s=; b=hesl1y1OiTiB7gAGkM+x/9nwanINZBRR+rnhgkuUL5Flj86VvYmMc6Gi6eKfm4LM5i KuayRygMrSf4nrjVNM8okmcXOA3x+4AzHX+/lTUbLDDKGIYM2OPCnlV7IN5cPiXBpPJ8 KCHtn4ChwzubujDM8GNtq2qTqO3MgUjIyRUArLybmKxdyoj1sITxuKMBjN+QmaBmpjdN YUZ2nQeqSVKq2dD9w3fvRWToG11xAHBY5Fp9rsGYSJaK97I4ZvlKILh83vAD19iYprWq F1UR6+wB987xFQQINwFJP6VIXN5gafMctqYhEbavblunP3wvV2n13ZiU0lSrxI29K8m9 OYRA== X-Gm-Message-State: AOJu0YzornC0NGignM6dRP2d0RHTUhq9i2HAvkPmCwRHyBjYG5Q38X2c ijnwlNkUmGJGtFXS/oKKjr0YVu1T5zVkcGU2hDHx2qipfNFRFqrq X-Gm-Gg: ASbGncvvFxPsIL4AuDKSy2h6knVunUaEEByNtUwpMOxVCYDb/2SlfDizf/lT8lzoiVw V5aR7kwG+PdIrPdMZ2VjYIak2G5ixl5VjWK6Hu63vLHTEtYeQxbmuh/Rbuf7jNeSB0AhBRDpvRe mrGShiPGsx7IMrrklIeRpT4j16LrqkYZNpJrcV7i/u2X97fXv8YkPIjg7dd99dCTwIt9B9K5a3z /NKRXZYnRAvBNpp+C9oeMCgTv0tJqEpJ9TiMxdsgbWbdxdXqcosMYrOypcbXxb7wRyDD0XK3ZTh gDEdDMOgTAye8AleCtXiL65UEJHiMl7SvZ+2NlZsWbyS X-Google-Smtp-Source: AGHT+IEgoApV8E5VO0zn2At9PlzFaozq3FBtMGpRR2FQYQq1aoIAE3OjfszSFseVMi6sqAjG/wPzvg== X-Received: by 2002:a05:6402:1d4f:b0:5f4:c2d0:fbb1 with SMTP id 4fb4d7f45d1cf-5f6df23359amr1903891a12.24.1745488546247; Thu, 24 Apr 2025 02:55:46 -0700 (PDT) Received: from localhost ([130.225.21.25]) by smtp.gmail.com with UTF8SMTPSA id 4fb4d7f45d1cf-5f6e85902d2sm919364a12.0.2025.04.24.02.55.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Apr 2025 02:55:45 -0700 (PDT) From: "Paul D. Nelson" To: Arash Esbati Subject: Re: bug#78006: Improving `TeX-electric-math' behavior In-Reply-To: (message from Arash Esbati on Wed, 23 Apr 2025 09:25:25 +0200) Date: Thu, 24 Apr 2025 11:55:44 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78006 Cc: 78006@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 (-) > User Option: TeX-electric-math > > In addition, when the variable is non-nil and there is an active > region outside math mode, typing $ will put around the active region > symbols for opening and closing inline equation and keep the region > active, leaving point after the closing symbol. By pressing > repeatedly $ while the region is active you can toggle between an > inline equation, a display equation, and no equation. To be precise, > =E2=80=98$...$=E2=80=99 is replaced by =E2=80=98$$...$$=E2=80=99, where= as =E2=80=98\(...\)=E2=80=99 is replaced by > =E2=80=98\[...\]=E2=80=99. > > Using $$...$$ in LaTeX is discouraged, so I think AUCTeX shouldn't > promote this as well, so I suggest this change to > `TeX-insert-dollar-electric-region': Looks good to me overall. One counterintuitive edge case: if I mark x and hit $ repeatedly, then I get $x$ -> \[x\] -> x -> etc. On the other hand, if I mark $x$ and hit $, then I get $$x$$ -> $x$ -> etc. I also wonder then whether TeX-insert-dollar (x2) should then similarly insert $$|$$ or \[|\] according to mode? Tangentially, I wonder whether this feature might be more useful if it worked not just when operating on a region for the first time, but more generally on any math region, as a way to cycle between inline and displayed math. I've had "make-inline" and "make-displayed" functions in my config for a long time now that I've tried unsuccessfully to think of an elegant way to package and contribute. From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 25 06:38:04 2025 Received: (at 78006) by debbugs.gnu.org; 25 Apr 2025 10:38:04 +0000 Received: from localhost ([127.0.0.1]:47843 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u8GRX-0005Re-Ov for submit@debbugs.gnu.org; Fri, 25 Apr 2025 06:38:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43250) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u8GRV-0005Qu-IK for 78006@debbugs.gnu.org; Fri, 25 Apr 2025 06:38:01 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u8GRP-0008Bw-Re; Fri, 25 Apr 2025 06:37:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=V7GN8gWjAuBsT1WeiYOqp7hqPzTkotV0fb7/n7ZTCsY=; b=C+WZXRKtF9StwMrk3Jau q+JQuSwmEkR+VZv55UCLpyQgIsbJckVz88DaA+iCjDDeFjI1aiW7mXy9ylmhgwlD4vUjqA3t2f00O XNUwydts7gcU9upuIfau+XpleLuIffKtnw2pjTCOi4K/DELxjmHPFmFfXtNC5BFuCjRb4PwFpkPV1 K4asRw9VgRtT9dy7RRE6xwsXBg2uUy9MwA6RYQVJkgRtYLaF2WowEn8nYUnwBiMJ4GPm0eVUNSlw+ htfFFztr7fl4cydXGV8V+bYtfQi6X5ZLgkQJgY2aCD6f3/8DJnAIFSShL6Jq3clcsTmClVJPbVKCM fLg+NMTTxdfBvw==; From: Arash Esbati To: "Paul D. Nelson" Subject: Re: bug#78006: Improving `TeX-electric-math' behavior In-Reply-To: References: Date: Fri, 25 Apr 2025 12:37:49 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78006 Cc: 78006@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: -3.3 (---) "Paul D. Nelson" writes: > Looks good to me overall. Thanks for checking > One counterintuitive edge case: if I mark x and hit $ repeatedly, then I > get $x$ -> \[x\] -> x -> etc. On the other hand, if I mark $x$ and hit > $, then I get $$x$$ -> $x$ -> etc. I think this is by design. In `TeX-insert-dollar-electric-region', we have this test: ((and (eq last-command #'TeX-insert-dollar) (re-search-forward ...)) ... > I also wonder then whether TeX-insert-dollar (x2) should then similarly > insert $$|$$ or \[|\] according to mode? AUCTeX currently enters \[|\] when you hit \[ so I think the above would be redundant. > Tangentially, I wonder whether this feature might be more useful if it > worked not just when operating on a region for the first time, but > more generally on any math region, as a way to cycle between inline > and displayed math. I've had "make-inline" and "make-displayed" > functions in my config for a long time now that I've tried > unsuccessfully to think of an elegant way to package and contribute. Hmm, maybe we can add them to AUCTeX itself. Do you want to show the code? Best, Arash From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 25 07:40:45 2025 Received: (at 78006) by debbugs.gnu.org; 25 Apr 2025 11:40:45 +0000 Received: from localhost ([127.0.0.1]:48194 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u8HQC-0004S8-IU for submit@debbugs.gnu.org; Fri, 25 Apr 2025 07:40:45 -0400 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]:59838) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1u8HQ7-0004Ro-57 for 78006@debbugs.gnu.org; Fri, 25 Apr 2025 07:40:39 -0400 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-aaf0f1adef8so319407666b.3 for <78006@debbugs.gnu.org>; Fri, 25 Apr 2025 04:40:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745581232; x=1746186032; darn=debbugs.gnu.org; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=OX3DAbF2hEththof/mF6dwlsJjnldinErM8hFfOeNng=; b=ZfENxGCR0B5DWFmztZKC6ks8/D/fA9wWDd+OV9VvIgb7t4sRZCPx62j3ctbHH0Hvbc itMBN+lq23CUqvdNhf71vHbPRPDjUcelv6Fr0bQhA89t3T8BkbWn6MuVmGSq/rF/CJNs tNKYArfUApKvuUkq6up/O3HmFPK2xmP0ARo6Gvi9+vlbBCPsYVdCTRu3cCTtM5bLbaP2 mBu272HuTZxWrgJAfA/ZklXFwjMv9UHiaAyUgfz4qqdBAHqTfpX6mS/XqiqMVwU2xnTT hvCl2ONQc4x1j1A8LBvtzfkhTVyi52LU4RQliJA/GYNMLX8QMyR/4jPu7pTE/cgtiVbD Rzvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745581232; x=1746186032; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OX3DAbF2hEththof/mF6dwlsJjnldinErM8hFfOeNng=; b=eTjVMZhCpj4cOBGV1ee8lq2GuByzPNiwnv3AhlZbjB2np5qEqKYpbjztBFKGQ5G3vt dwQl69KZx1mqecegRXrfaQFWQxHuT/7L1zpuXmZXEO2Ke7IoF9eop/aXX8siORliWNwc 2fyyrT2sqgyO8+gIW7Q33wZVHDqRVHGbiLshlPHBQSXrTKpGSXlGRULcRCLNgwvUbG5g up2RYMJ9ILSio+zIJZ1ysbYueOGd0INrizMG/8397wh9vMGnFv7vlXN4BtQoYMP7bxrK g2EZPcHy8Y9IRhd7j/8jWIjkc68bHa//N0GMRzfYMhxp0NHDmubz/jJmh5eMZFk0oISf v0xQ== X-Gm-Message-State: AOJu0YzWnFknaMUQ30Vd1MPcM63Hc3hD5lTILp9J6AK+TQlaKfc/rmRU mIk2CJhWrb/uKVBj7SZZICmD28WcoTjhQCLZZoGXwETYN8vRRKeTglTGDDfm X-Gm-Gg: ASbGncvb+514xNjsja/yvhkz4lavMnBi1bOJ0votwAgvdY9HGuzhi2Cq880qqz7AiF8 PngkzoR/R3p/60QfIr02DyLeDTdpsg+vR2guQfjjSeEll4FqLN/vKj4qPAc1ecW09J9I26v6bMQ JQCOKHvbya9mBfft61yOzhFMBBbmnHbRgiPExB6ep2nHk7hYUa0k20rC6ktrHLoVLZ55ki0m4Wb mhusgUyV6otiut21reAeB8luzsHHT+m9Me2iWE/VzSKI08/o9zKDirdHYO5wi7HES6qbuUVK6tq p40PujuaNshNn9OHsz8VP6W63Kri6HeMrEWmCQIn3WmPXp9Bay3dE5WGkbtJn8AUgho= X-Google-Smtp-Source: AGHT+IEa+hdfZTb7RS8zWocQDhxX1Ll3fZk+aEZ7SKf6Jdr/Ak9JODfdFG7XpAPchPStSMcvrq9DNQ== X-Received: by 2002:a17:907:3f94:b0:ac3:3cff:268 with SMTP id a640c23a62f3a-ace7112444amr178995566b.30.1745581232079; Fri, 25 Apr 2025 04:40:32 -0700 (PDT) Received: from localhost (users-1190.st.net.au.dk. [130.225.0.251]) by smtp.gmail.com with UTF8SMTPSA id 4fb4d7f45d1cf-5f7016f6770sm1190279a12.43.2025.04.25.04.40.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 04:40:30 -0700 (PDT) From: "Paul D. Nelson" To: Arash Esbati Subject: Re: bug#78006: Improving `TeX-electric-math' behavior In-Reply-To: (message from Arash Esbati on Fri, 25 Apr 2025 12:37:49 +0200) Date: Fri, 25 Apr 2025 13:40:29 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78006 Cc: 78006@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 (-) >> One counterintuitive edge case: if I mark x and hit $ repeatedly, then I >> get $x$ -> \[x\] -> x -> etc. On the other hand, if I mark $x$ and hit >> $, then I get $$x$$ -> $x$ -> etc. > > I think this is by design. In `TeX-insert-dollar-electric-region', we > have this test: > > ((and (eq last-command #'TeX-insert-dollar) > (re-search-forward ...)) > ... > Right, I guess I was asking if it might make sense to eliminate the "last-command" test, so that the command operates in a broader set of scenarios. I don't have strong feelings on this, since I haven't used this cycling feature before. >> Tangentially, I wonder whether this feature might be more useful if it >> worked not just when operating on a region for the first time, but >> more generally on any math region, as a way to cycle between inline >> and displayed math. I've had "make-inline" and "make-displayed" >> functions in my config for a long time now that I've tried >> unsuccessfully to think of an elegant way to package and contribute. > > Hmm, maybe we can add them to AUCTeX itself. Do you want to show the > code? Sure. There's a command for making a displayed equation inline, and another command that, among other things, makes a displayed equation inline. I bind these to "C-c i" and "C-c e". The "among other things" should probably be stripped out before sending to AUCTeX, but OK, resisting the urge to polish for now: (defcustom czm-tex-edit-punctuation-string "[\\.|,|;|!|?]" "Regexp for matching punctuation characters." :group 'czm-tex-edit :type 'regexp) ;;;###autoload (defun czm-tex-edit-make-equation-inline () "Convert LaTeX equation environment at point to inlined math. Format LaTeX environment at point by surrounding the math environment with dollar signs, removing any leading or trailing text." (interactive) (when (texmathp) (preview-clearout-at-point) (let ((cur (point-marker)) beg end) (save-excursion (LaTeX-find-matching-end) (setq end (line-beginning-position 2)) (goto-char cur) (LaTeX-find-matching-begin) (setq beg (point))) (save-restriction (narrow-to-region beg end) (goto-char (point-min)) (kill-line 1) (beginning-of-line-text) (delete-region (point-min) (point)) (goto-char (point-max)) (forward-line -2) (end-of-line) (delete-region (point) (point-max)) (whitespace-cleanup) (goto-char (point-min)) (insert "$") (goto-char (point-max)) (insert "\n") (backward-char) (while (looking-back czm-tex-edit-punctuation-string 5) (backward-char)) (insert "$") (while (> (count-lines (point-min) (point-max)) 1) (join-line)) (current-buffer)) (join-line) (goto-char cur)))) (defun czm-tex-edit-add-label () "Add LaTeX label to matching \\begin{} at environment beginning. Also, save label to kill ring as an \\eqref{} command." (interactive) (save-excursion (LaTeX-find-matching-begin) (end-of-line) (funcall czm-tex-edit-label-function) (let ((end (point))) (search-backward "{") (let ((beg (point))) (kill-new (concat "\\eqref" (buffer-substring beg end))))))) (defun czm-tex-edit--handle-env (env pos num-chars search-str numbered) "Helper function for `czm-tex-edit-make-equation-numbered'. Remove part of the environment string and insert a numbered or unnumbered LaTeX equation environment at POS. ENV specifies the name of the environment to match, NUM-CHARS specifies the number of characters to delete, SEARCH-STR specifies the string to search for and NUMBERED determines if the equation environment should be numbered." (goto-char pos) (delete-char num-chars) (when (or (equal env "equation") (equal env "equation*")) (kill-line)) (push-mark (save-excursion (search-forward search-str) (delete-region (match-beginning 0) (match-end 0)) (when (equal env "$") (while (looking-at-p czm-tex-edit-punctuation-string) (forward-char))) (point))) (activate-mark) (LaTeX-insert-environment (if numbered "equation" "equation*")) (when numbered (czm-tex-edit-add-label))) (defun czm-tex-edit-make-equation-numbered () "Toggle whether an equation is numbered." (interactive) (save-excursion (when (texmathp) (preview-clearout-at-point) (let ((env (car texmathp-why)) (pos (cdr texmathp-why))) (cond ((or (equal env '"\\[") (equal env '"$$")) (czm-tex-edit--handle-env env pos 2 (if (equal env "$$") "$$" "\\]") nil)) ((equal env "$") (czm-tex-edit--handle-env env pos 1 "$" nil)) ((equal env "equation*") (czm-tex-edit--handle-env env pos 0 "\\end{equation*}" t)) ((equal env "equation") (czm-tex-edit--handle-env env pos 0 "\\end{equation}" nil))))))) [This last function is poorly named and documented -- apologies.] These are part of https://github.com/ultronozm/czm-tex-edit.el. One thought: AUCTeX has "C-u C-c C-e" for switching the type of an environment. Perhaps the same command could be made to work in top-level $...$ regions, using something like the above "make-equation-numbered" as the implementation. Conversely, perhaps $...$ could be a hard-coded option for environment type after "C-u C-c C-e", with something like the above "make-inline" as implementation. The point of this suggestion is just to get around the scarcity of keybinds and integrate with existing commands. Any thoughts welcome! From debbugs-submit-bounces@debbugs.gnu.org Fri May 02 03:14:21 2025 Received: (at 78006) by debbugs.gnu.org; 2 May 2025 07:14:21 +0000 Received: from localhost ([127.0.0.1]:55947 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uAkbF-0004qm-0v for submit@debbugs.gnu.org; Fri, 02 May 2025 03:14:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36556) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uAkbC-0004qT-5m for 78006@debbugs.gnu.org; Fri, 02 May 2025 03:14:18 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uAkb6-0004PF-Ke; Fri, 02 May 2025 03:14:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=/CJnhUqKqOxxkuzYOmIT7c2pVtujdtuRLKibx+GXCjo=; b=kxwPRJCFr/fRYA+TF0wU IF4uz77QlkHll7WBfZsynMxx/hB692FWSUu39cAEHmMk2lvAdX0GuCr9hiMxdEf60+JLQMrX8X4wq to/i80ofZecSKKH6EVLrLGNl6n6f8LXSs1jS2Km1Sl6+Ddj1o2wkQgg6anBer5czmxEhZ6f1GyXaU IuCr59qAamJHU0zHIon/Scs3l+1YRK/oF3vzayZ/5hchZpB1xQPnO/Hj3okANXF7PcXAXIyBcmxdx dPGkHBpePreuXXuA6IpcNLvHAHbX9uMInzhrGqH+fBJzeV9EWpBSMsJRvnKDibNz+8ANPKEHtj+cB oIdrqj+1DesPiA==; From: Arash Esbati To: "Paul D. Nelson" Subject: Re: bug#78006: Improving `TeX-electric-math' behavior In-Reply-To: References: Date: Fri, 02 May 2025 09:14:08 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78006 Cc: 78006@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: -3.3 (---) "Paul D. Nelson" writes: > Right, I guess I was asking if it might make sense to eliminate the > "last-command" test, so that the command operates in a broader set of > scenarios. I don't have strong feelings on this, since I haven't used > this cycling feature before. I don't use it either, but I'm reluctant to make this change since it was there forever. I think I install the change I proposed and we'll wait and see what real users say about it. > Sure. There's a command for making a displayed equation inline, and > another command that, among other things, makes a displayed equation > inline. I bind these to "C-c i" and "C-c e". Thanks for sharing. I think we should move your code to another bug report and discuss it there. I will have to take a closer look, but I have 2 minor comments below: > The "among other things" should probably be stripped out before > sending to AUCTeX, but OK, resisting the urge to polish for now: > > (defcustom czm-tex-edit-punctuation-string > "[\\.|,|;|!|?]" Isn't "[.,;!?]" enough, presuming you don't want to search for a literal backslash? > "Regexp for matching punctuation characters." > :group 'czm-tex-edit > :type 'regexp) > > ;;;###autoload > (defun czm-tex-edit-make-equation-inline () > "Convert LaTeX equation environment at point to inlined math. > Format LaTeX environment at point by surrounding the math > environment with dollar signs, removing any leading or trailing > text." I think this will break if the equation environment has a \label{eq:x}? > One thought: AUCTeX has "C-u C-c C-e" for switching the type of an > environment. Perhaps the same command could be made to work in > top-level $...$ regions, using something like the above > "make-equation-numbered" as the implementation. Conversely, perhaps > $...$ could be a hard-coded option for environment type after "C-u C-c > C-e", with something like the above "make-inline" as implementation. > The point of this suggestion is just to get around the scarcity of > keybinds and integrate with existing commands. > > Any thoughts welcome! I see your point, but OTOH, do we have to bind every command to a key binding? I think for commands not often used people can do 'M-x foo' or bind the command to a sequence of their choice, as you did. Best, Arash From debbugs-submit-bounces@debbugs.gnu.org Sat May 03 00:27:23 2025 Received: (at 78006) by debbugs.gnu.org; 3 May 2025 04:27:23 +0000 Received: from localhost ([127.0.0.1]:36454 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uB4TC-0000nV-N8 for submit@debbugs.gnu.org; Sat, 03 May 2025 00:27:22 -0400 Received: from smtp1a.inetd.co.jp ([210.129.88.11]:33328) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uB4T7-0000nH-6Y for 78006@debbugs.gnu.org; Sat, 03 May 2025 00:27:18 -0400 Received: from localhost (i222-150-175-85.s41.a020.ap.plala.or.jp [222.150.175.85]) by smtp1a.inetd.co.jp (Postfix) with ESMTPSA id 9620F5C; Sat, 3 May 2025 13:27:13 +0900 (JST) From: Ikumi Keita To: Arash Esbati Subject: Re: bug#78006: Improving `TeX-electric-math' behavior In-reply-to: References: Comments: In-reply-to Arash Esbati message dated "Wed, 23 Apr 2025 09:25:25 +0200." X-Mailer: MH-E 8.6+git; nmh 1.8; Emacs 30.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <9527.1746246433.1@localhost> Date: Sat, 03 May 2025 13:27:13 +0900 Message-ID: <9529.1746246433@localhost> X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78006 Cc: 78006@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 (-) Hi Arash, >>>>> Arash Esbati writes: > Using $$...$$ in LaTeX is discouraged, so I think AUCTeX shouldn't > promote this as well, so I suggest this change to > `TeX-insert-dollar-electric-region': I have one minor comment about your proposal. > + (replace-match (if (memq major-mode '(LaTeX-mode docTeX-mode)) I think we should use `derived-mode-p' here instead of comparing `major-mode' directly. Regards, Ikumi Keita #StandWithUkraine #StopWarInUkraine #Gaza #StopMassiveKilling #CeasefireNOW From debbugs-submit-bounces@debbugs.gnu.org Sat May 03 04:31:50 2025 Received: (at 78006) by debbugs.gnu.org; 3 May 2025 08:31:50 +0000 Received: from localhost ([127.0.0.1]:38019 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uB8Hl-0005V4-Ms for submit@debbugs.gnu.org; Sat, 03 May 2025 04:31:49 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:56497) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uB8Hj-0005Ul-20 for 78006@debbugs.gnu.org; Sat, 03 May 2025 04:31:47 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-43ce70f9afbso22685745e9.0 for <78006@debbugs.gnu.org>; Sat, 03 May 2025 01:31:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746261101; x=1746865901; darn=debbugs.gnu.org; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=vtk1fAi3hMUBtjIbPfBFb1RkxVV4vgzLHfezM0NDwrE=; b=BdUDYowPEz4WUUPFzTMouHXqDuPv/f7JM2jWY0npHB6oYGFGOucfWurD9bwl9IrfRB m9DU93KmF3Biwt1bgLWMbSIb3ZhAVdpAWFD1UEDjHzvyCtVra+JzwjjHQgIlOWZQ3/ZA y2FtIGC8x3GeItPIDjr0ZYYyG4XPhmqBbf3b2LUb5kQELX3vvEqnN0Y98+p0S70Cb0KE 2RMEd9fkNWhdgYsgVA8oPGUTJFTHB/X5Y4flzLiSZqh4F6uMvNRaARI03gXGKrBsoyyW gSWTAvTeoJHpLhRS2/DNEVIiMYeYI7iDMi63YPeIx0hWrrmQuK/CrZJOq4CUUmIyvJEK a6CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746261101; x=1746865901; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vtk1fAi3hMUBtjIbPfBFb1RkxVV4vgzLHfezM0NDwrE=; b=HUreo/WKzsJ8uIHHSlEexmp+e7K6Obuv8PAY85LwHTPVldA94ZjqnctwrwDM2YUClA 9DObtV/TpWWzfv9Blqfo2j9gvDzN+MXNVCtmCO1JJJGPQ9Cvm00qkVe9DYlG6RM5Q8tI lNQUyfBJ9QyzB7V90oeeu928KV7dtC4BiIAw0Hr+lyVGl5trjYJY7HO3cReLxMDcEc1Q xZUiN/r/TcDlaa5eeyLYX3sooz9PRjOlx28yHs+xLLthpLyxbhTGVhhKrrqTs1a35TsT j6DQBrnI/+rerspy1UbQX6ArCcSdrEBRcK4GQ1B0hvRTQzWzVflTg35gQWawhCTs04aG pR7w== X-Gm-Message-State: AOJu0Yy8u8LxnGsAVR8mlRyxb4lYwa68HMHrseV/DvTGIhgeYO6n6Rkt NyMim21YKR9ViElUjh98ezX00qPAwfKLZqdQkvJEB/UYogs49Bry X-Gm-Gg: ASbGnctbEBHM+slADWrk+o++PHTBhKd7dlvEdO66bCKkL9NqDLtXJ3GbpPr1GEcsDbS pbLOWCfalzYcu7KUnLSlIuqpK2+ogy+emN/CJCbQMLt/IeC6+o0LHpwDpE1r/56chBS6eqG7FKx JHNMnb/Nr9r6e38N+chZp/ePqHDAFCX/SgQeD6IdtFbtmVADgTaJWDuRV5Y4hA3LvJqC65kgACB cmNdqX5a2aikXT+rzxJ6+Mllr/uGSWkOl0JAdZ2+T7CumgJFhP+1P7cYh7rkEPrzkdewmWAfyWj 64cyGrf/YOfJ3T9E8U4zFyr+8sNImIn4ApbQaizyn8U= X-Google-Smtp-Source: AGHT+IHfRBy3ZgYtdB1SNt0jI4hPAkoBCvsqeq/PZZCX9UioMCDf6y6FUO18hzCysqY0OcIqlLlCYA== X-Received: by 2002:a05:600c:45d1:b0:440:6a37:be30 with SMTP id 5b1f17b1804b1-441c48ce8d8mr3652215e9.16.1746261100600; Sat, 03 May 2025 01:31:40 -0700 (PDT) Received: from localhost ([88.128.92.20]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a099ae0d15sm4337791f8f.13.2025.05.03.01.31.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 May 2025 01:31:40 -0700 (PDT) From: "Paul D. Nelson" To: Arash Esbati Subject: Re: bug#78006: Improving `TeX-electric-math' behavior In-Reply-To: (message from Arash Esbati on Fri, 02 May 2025 09:14:08 +0200) Date: Sat, 03 May 2025 10:31:38 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78006 Cc: 78006@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 (-) Hi Arash, Thanks, sounds good. I'll plan to send these commands as a separate bug (and have no further comments on the current bug). Some responses: >> ;;;###autoload >> (defun czm-tex-edit-make-equation-inline () >> "Convert LaTeX equation environment at point to inlined math. >> Format LaTeX environment at point by surrounding the math >> environment with dollar signs, removing any leading or trailing >> text." > > I think this will break if the equation environment has a \label{eq:x}? It will indeed break (i.e., put the \label{...} inside the $...$) if the \label{...} does not occur on the same line as \begin{...}. Perhaps we could kill any labels first. A related issue is ampersands alignment characters (e.g., in align environments) that should not exist when we convert to inline, but ampersands occur in other ways (e.g., matrices), so it seems tricky to get this right. Personally, I use the command only when the displayed expression is simple enough, which restricts the possible edge cases. Thanks, best, Paul From debbugs-submit-bounces@debbugs.gnu.org Sat May 03 04:38:03 2025 Received: (at 78006) by debbugs.gnu.org; 3 May 2025 08:38:03 +0000 Received: from localhost ([127.0.0.1]:38038 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uB8Nn-0005ld-Eh for submit@debbugs.gnu.org; Sat, 03 May 2025 04:38:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35492) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uB8Nk-0005l4-Eh for 78006@debbugs.gnu.org; Sat, 03 May 2025 04:38:01 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uB8Nc-0007cN-Bk; Sat, 03 May 2025 04:37:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=7nix+chj79u70/2KtjUX/6cBQYze/ciWYL6dVJRmONU=; b=WJDC6iaYN4IO4vYMym/A 21qLWAwtmzRlfnhhXX6rFIQsoy31cDhO+3sso31shoitIbE0nuPpLkVyAHUQXQXwl5XbMPmSusL6p hi/Vjjewn+X1wWRULkzp5MYJYCnuCJdAuh6R8R13czDsdq6kBi9aCVGrngiudp+G86FgiVkE0cI67 QFQE7Ov3qtAFKtBaRuLqGnF55PeZja9v6OH3UeHMONpqdE3ARjYu7haORlAQv6R8ZQKV84vaXyac6 3JjKuFi+2MF3NPcfE+ms8gXhXY9X4XXotCgVELn9pNnaQjulkiLURq9oUz/5LS/uS0s8DMWA3H459 S3Hc2D69c1L/dA==; From: Arash Esbati To: Ikumi Keita Subject: Re: bug#78006: Improving `TeX-electric-math' behavior In-Reply-To: <9529.1746246433@localhost> References: <9529.1746246433@localhost> Date: Sat, 03 May 2025 10:37:47 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78006 Cc: 78006@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: -3.3 (---) Hi Keita, Ikumi Keita writes: > I think we should use `derived-mode-p' here instead of comparing > `major-mode' directly. Thanks for your response. Something like this? --8<---------------cut here---------------start------------->8--- diff --git a/tex.el b/tex.el index 3d28b2c6..0d47988c 100644 --- a/tex.el +++ b/tex.el @@ -6188,10 +6188,13 @@ See `TeX-electric-math'." (re-search-forward "\\=\\$\\$\\([^z-a]*\\)\\$\\$" (mark) t))) (replace-match "\\1" t) (set-mark (match-beginning 0))) - ;; $...$ to $$...$$ + ;; $...$ to $$...$$ or \[...\] dep. on mode: ((and (eq last-command #'TeX-insert-dollar) (re-search-forward "\\=\\$\\([^z-a]*\\)\\$" (mark) t)) - (replace-match "$$\\1$$" t) + (replace-match (if (derived-mode-p '(LaTeX-mode docTeX-mode)) + "\\\\[\\1\\\\]" + "$$\\1$$") + t) (set-mark (match-beginning 0))) ;; \(...\) to \[...\] ((and (eq last-command #'TeX-insert-dollar) --8<---------------cut here---------------end--------------->8--- Best, Arash From debbugs-submit-bounces@debbugs.gnu.org Sat May 03 09:13:09 2025 Received: (at 78006) by debbugs.gnu.org; 3 May 2025 13:13:09 +0000 Received: from localhost ([127.0.0.1]:39242 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uBCg1-0005rJ-BW for submit@debbugs.gnu.org; Sat, 03 May 2025 09:13:09 -0400 Received: from mta-snd-e09.jcom.zaq.ne.jp ([27.86.105.137]:52961) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uBCfx-0005qq-T6 for 78006@debbugs.gnu.org; Sat, 03 May 2025 09:13:08 -0400 Received: from airoymjc00uxweb002 by dwmta0009-jc.im.kddi.ne.jp with ESMTP id <20250503131301366.MNSC.1874.airoymjc00uxweb002@mta-snd-e09.jcom.zaq.ne.jp>; Sat, 3 May 2025 22:13:01 +0900 Received: from [61.25.129.167] by wm.zaq.ne.jp with HTTP; Sat, 3 May 2025 22:13:00 +0900 To: Arash Esbati , Ikumi Keita Message-ID: In-Reply-To: References: <9529.1746246433@localhost> Subject: Re: bug#78006: Improving `TeX-electric-math' behavior MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_27219095_1982485553.1746277980939" User-Agent: OWM Mail 3 X-SID: 132 X-Originating-IP: [61.25.129.167] From: Keita Ikumi Date: Sat, 3 May 2025 22:13:00 +0900 (JST) X-VC-DATE: Sat, 3 May 2025 22:13:01 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jcom.home.ne.jp; s=default-1th84yt82rvi; t=1746277981; bh=qyeiKvNtRgwTF/Nj1XVW3UQNb6g/4v6R+OhCVkFQC70=; h=To:Cc:In-Reply-To:References:Subject:From:Date; b=PzGYU0OicVgaSdh6FJxwVIIgtsVTRGPICJdDkD4qsIKUh249lb+XFQKVqcLUevKAmbI4uhND 8n+R8DCGnjl468iDOoMuzFxLk0l5aWvG+OIxRIpOvv4NBbTjr2duhedfuym9DSRA4/qpqqQPvS bGaeSmWc0Su0EVTy2jvp9hoDwg0Wn/smDG93GDAbmzLHaXh7jU8X35NNPYwbUJkCvdz7Tx/gme BeFilMDy8PPKSDTWUi0NAlvw98k0KdQMrdqR0V50Jiwu6QMrQSajZpbbAcEBkzom+pp+28Pm2b g7oDQYQjBDuMf/V758nwJ7zeJNMuXjABK8R5dlQ4knJ2PT5Q== X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 78006 Cc: 78006@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.3 (/) ------=_Part_27219095_1982485553.1746277980939 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable > > > ------=C2=A0Original=C2=A0Message=C2=A0------ > =C2=A0=E5=9C=9F=E6=9B=9C=E6=97=A5,=C2=A02025/5/3=C2=A0=C2=A017:37,=C2=A0A= rash=C2=A0Esbati=C2=A0=E3=81=AB=E3=82=88=E3=81=A3=E3=81=A6= =E6=9B=B8=E3=81=8B=E3=82=8C=E3=81=BE=E3=81=97=E3=81=9F: > > Hi=C2=A0Keita, > > Ikumi=C2=A0Keita=C2=A0=C2=A0writes: > >> =C2=A0I=C2=A0think=C2=A0we=C2=A0should=C2=A0use=C2=A0`derived-mode-p'=C2= =A0here=C2=A0instead=C2=A0of=C2=A0comparing >> =C2=A0`major-mode'=C2=A0directly. > > Thanks=C2=A0for=C2=A0your=C2=A0response.=C2=A0=C2=A0Something=C2=A0like= =C2=A0this? > > --8<---------------cut=C2=A0here---------------start------------->8--- > diff=C2=A0--git=C2=A0a/tex.el=C2=A0b/tex.el > index=C2=A03d28b2c6..0d47988c=C2=A0100644 > ---=C2=A0a/tex.el > +++=C2=A0b/tex.el > @@=C2=A0-6188,10=C2=A0+6188,13=C2=A0@@=C2=A0See=C2=A0`TeX-electric-math'.= " >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0(re-search-forward=C2=A0"\\=3D\\$\\$\\([^z-a]*\\)\\$\\$"=C2=A0(= mark)=C2=A0t))) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0(replace-match=C2=A0"\\1"=C2=A0t) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0(set-mark=C2=A0(match-beginning=C2=A00))) > -=C2=A0=C2=A0=C2=A0;;=C2=A0$...$=C2=A0to=C2=A0$$...$$ > +=C2=A0=C2=A0=C2=A0;;=C2=A0$...$=C2=A0to=C2=A0$$...$$=C2=A0or=C2=A0\[...\= ]=C2=A0dep.=C2=A0on=C2=A0mode: > =C2=A0=C2=A0=C2=A0=C2=A0((and=C2=A0(eq=C2=A0last-command=C2=A0#'TeX-inser= t-dollar) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0(re-search-fo= rward=C2=A0"\\=3D\\$\\([^z-a]*\\)\\$"=C2=A0(mark)=C2=A0t)) > -=C2=A0=C2=A0=C2=A0=C2=A0(replace-match=C2=A0"$$\\1$$"=C2=A0t) > +=C2=A0=C2=A0=C2=A0=C2=A0(replace-match=C2=A0(if=C2=A0(derived-mode-p=C2= =A0'(LaTeX-mode=C2=A0docTeX-mode)) Well,=C2=A0since=C2=A0docTeX-mode=C2=A0is=C2=A0already=C2=A0derived=C2=A0fr= om=C2=A0 LaTeX-mode,=C2=A0we=C2=A0can=C2=A0just=C2=A0do (derived-mode-p=C2=A0'LaTeX-mode) :-) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0"\\\\[\\1= \\\\]" > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0"$$\\1$$") > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0t) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0(set-mark=C2=A0(match-beginning=C2=A00))) > =C2=A0=C2=A0=C2=A0=C2=A0;;=C2=A0\(...\)=C2=A0to=C2=A0\[...\] > =C2=A0=C2=A0=C2=A0=C2=A0((and=C2=A0(eq=C2=A0last-command=C2=A0#'TeX-inser= t-dollar) > --8<---------------cut=C2=A0here---------------end--------------->8--- > > Best,=C2=A0Arash > ------=_Part_27219095_1982485553.1746277980939 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
>
>>------ Original Message ------
> =E5=9C=9F= =E6=9B=9C=E6=97=A5, 2025/5/3  17:37, Arash Esbati&= lt;arash@gnu.org> =E3=81=AB=E3=82=88=E3=81=A3=E3=81=A6=E6=9B=B8=E3= =81=8B=E3=82=8C=E3=81=BE=E3=81=97=E3=81=9F:
>
>Hi Keita,=
>
>Ikumi Keita <ikumi@ikumi.que.jp> wri= tes:
>
>> I think we should use&n= bsp;`derived-mode-p' here instead of comparing
= >> `major-mode' directly.
>
>Thanks = for your response.  Something like this?
= >
>--8<---------------cut here---------------start-------= ------>8---
>diff --git a/tex.el b/tex.el
>= index 3d28b2c6..0d47988c 100644
>--- a/tex.el
>= ;+++ b/tex.el
>@@ -6188,10 +6188,13 @@ See&= nbsp;`TeX-electric-math'."
>     &= nbsp;        (re-search-forward&nbs= p;"\\=3D\\$\\$\\([^z-a]*\\)\\$\\$" (mark) t)))
>=      (replace-match "\\1" t)>     (set-mark (match-beginning 0= )))
>-   ;; $...$ to $$...$$
>+=    ;; $...$ to $$...$$ or \[...\]&n= bsp;dep. on mode:
>    ((and (eq&= nbsp;last-command #'TeX-insert-dollar)
>   &= nbsp;      (re-search-forward "\\= =3D\\$\\([^z-a]*\\)\\$" (mark) t))
>-  &nbs= p; (replace-match "$$\\1$$" t)
>+ &nbs= p;  (replace-match (if (derived-mode-p '(LaTeX= -mode docTeX-mode))

Well, since docTeX-mode is=  already derived from 
LaTeX-mode, we can=  just do
(derived-mode-p 'LaTeX-mode)
:-)
>+           &= nbsp;           &quo= t;\\\\[\\1\\\\]"
>+       &n= bsp;            = ; "$$\\1$$")
>+      &n= bsp;            = ;t)
>     (set-mark (match-beginning&n= bsp;0)))
>    ;; \(...\) to \[...= \]
>    ((and (eq last-command #&= #39;TeX-insert-dollar)
>--8<---------------cut here---------= ------end--------------->8---
>
>Best, Arash
>=
------=_Part_27219095_1982485553.1746277980939-- From debbugs-submit-bounces@debbugs.gnu.org Sat May 03 16:43:43 2025 Received: (at 78006-done) by debbugs.gnu.org; 3 May 2025 20:43:43 +0000 Received: from localhost ([127.0.0.1]:43826 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uBJi3-0005aX-8u for submit@debbugs.gnu.org; Sat, 03 May 2025 16:43:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56196) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uBJhz-0005aE-K6 for 78006-done@debbugs.gnu.org; Sat, 03 May 2025 16:43:40 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uBJhs-0001tO-6N; Sat, 03 May 2025 16:43:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=GkUQLiP9zUbM1fTPgUyiU0pW5t0cKAX2CFh9H/vkYeY=; b=MUbc+x4hvR0j+C2V51N7 4aQ4sKAq0CH7YfPK+kcFf/VcHn4mJZKE01JkSr4UxBTMfExwJy0bei9AZl3wzcQyMO+H3j/z7gpO5 Gep0Bd//SUuZCCu49PNG4SLIFayE5dq9cjXKMgBARTzRdTArSjDct+Mwi+WEMafyFkFclMZ4z01xl yWZ5EHxxM7V56k3GMa0hvIBuX5fYVhYR8E+hFnA+7QlSY/tFYRO1You1cQjLI4xpYwpUgZk7UG19D G4oP/UL3ovoJJGV0IH5McFQuvTSS2L3Q174e4lw9FpR7QQvoKMv1KCO8rrs2RyitD8IVQ7MbVXU4o y8jfiaROHq92nQ==; From: Arash Esbati To: Ikumi Keita Subject: Re: bug#78006: Improving `TeX-electric-math' behavior In-Reply-To: References: <9529.1746246433@localhost> Date: Sat, 03 May 2025 22:43:22 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78006-done Cc: 78006-done@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: -3.3 (---) Keita Ikumi writes: > Well, since docTeX-mode is already derived from > LaTeX-mode, we can just do > (derived-mode-p 'LaTeX-mode) > :-) Ah, thanks. I installed that change and therefore closing this report. Thanks to you all for your comments. Best, Arash From unknown Sat Jun 21 03:07:32 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 01 Jun 2025 11:24:15 +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