Received: (at 78586) by debbugs.gnu.org; 30 May 2025 07:01:00 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri May 30 03:01:00 2025 Received: from localhost ([127.0.0.1]:44617 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1uKtjg-0002EB-63 for submit <at> debbugs.gnu.org; Fri, 30 May 2025 03:01:00 -0400 Received: from smtp1a.inetd.co.jp ([210.129.88.11]:52228) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <ikumi@HIDDEN>) id 1uKtjd-00022M-26 for 78586 <at> debbugs.gnu.org; Fri, 30 May 2025 03:00:58 -0400 Received: from localhost (42-144-37-89.rev.home.ne.jp [42.144.37.89]) by smtp1a.inetd.co.jp (Postfix) with ESMTPSA id 72F6C8A; Fri, 30 May 2025 16:00:53 +0900 (JST) From: Ikumi Keita <ikumi@HIDDEN> To: "Paul D. Nelson" <ultrono@HIDDEN> Subject: Re: bug#78586: TeX-make-inline In-reply-to: <uxsg7th613gso4.fsf@HIDDEN> References: <uxsg7th613gso4.fsf@HIDDEN> Comments: In-reply-to "Paul D. Nelson" <ultrono@HIDDEN> message dated "Thu, 29 May 2025 20:47:55 +0200." X-Mailer: MH-E 8.6+git; nmh 1.8; Emacs 30.1 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-2022-jp Date: Fri, 30 May 2025 16:00:52 +0900 Message-ID: <10409.1748588452@localhost> X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78586 Cc: arash@HIDDEN, 78586 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hi Paul, >>>>> "Paul D. Nelson" <ultrono@HIDDEN> writes: > Thanks Ikuya, good catch! Please find attached the updated patch. Paul > +(defun LaTeX-make-inline () > + "Convert LaTeX display math environment at point to inline math. > +Remove the enclosing math environment (such as \\\\=[...\\\\=] or That works but I recommend \\=\\[ rather than \\\\=[ . See (elisp) Keys in Documentation: ,---- | ‘\=’ | quotes the following character and is discarded; thus, ‘\=`’ puts | ‘`’ into the output, ‘\=\[’ puts ‘\[’ into the output, and ‘\=\=’ | puts ‘\=’ into the output. `---- And you don't have to quote \]. It will be displayed literally. Additionally, we should provide similar quotation in > +(ert-deftest LaTeX-make-inline-bracket-period () > + "Convert \\[..\\] to $..$ and keep trailing period." as well. Bye, Ikumi Keita #StandWithUkraine #StopWarInUkraine #Gaza #StopMassiveKilling #CeasefireNOW
bug-auctex@HIDDEN
:bug#78586
; Package auctex
.
Full text available.Received: (at 78586) by debbugs.gnu.org; 29 May 2025 18:48:07 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu May 29 14:48:07 2025 Received: from localhost ([127.0.0.1]:38957 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1uKiIQ-0004ht-Vx for submit <at> debbugs.gnu.org; Thu, 29 May 2025 14:48:07 -0400 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]:59797) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <ultrono@HIDDEN>) id 1uKiIN-0004hL-Gk for 78586 <at> debbugs.gnu.org; Thu, 29 May 2025 14:48:04 -0400 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-604533a2f62so2263127a12.3 for <78586 <at> debbugs.gnu.org>; Thu, 29 May 2025 11:48:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748544477; x=1749149277; 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=7av0hB5a+uv6imAvR6zdqQudE/tMpenNGKax7EdPH7g=; b=h5oBXs7eZg9xJXhVSXrmJpCxLrGAgTZ4+h4NmK2P2ihVO9MuBBfiHZx6KDjR/tC1su hi3Eu84nUZ4fVXuPyLXQHdaXFf8rY12wzfp6ueF9uz9Ku+vWRI3ZitydidwtsYBCzRWs C3b7I4t0CGKYnVRobDI47h/lE5GnZDVfilJIONidsliNA0EqFRi21zJMTLvaLpdz0600 p41YPNbOI08rhfGKz//Tlo5UVidhLK/F/JVLylzOeWGPovIzhfDgXKeWqes4rGDU4bgy 30RcK5xLwZQbhl5ivMQWgyruCtnI9fb9zFcv343XYeKYvDEIP8r1udJu4uDuHHpmY8VL tP0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748544477; x=1749149277; 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=7av0hB5a+uv6imAvR6zdqQudE/tMpenNGKax7EdPH7g=; b=v6vaIP3YtYvjg598mJ7FdqwxunE2qjSsJPpDZNlrH8/b/cskYoy9QGkM4D40NSASdi Qv3KnuraOZN2EI56NKw+AK+5pGL1AXhyf7HWyw4PGMwPfd7UgjWeSlyrjIg3C8+qx4Lf ccLaKnwRNEngOvo7ik7PRSk3fzICC+c5grU9z1keE+cvvogzzF9At8FUC1nUtIV5sbZC Tk1voL+sUhG37jiU8r7+GXQUBFUM8WPtHNIZ03mwAacNeTHPkDekjZQukg5A6yg/cmne ttNjG0SyPuNoFoKSbVeiH3SYu/7okS9rZU5WgdWBg1r5AHz2kAqi9X2Qitf5YlA4btTw Yv1Q== X-Forwarded-Encrypted: i=1; AJvYcCVLOH3wOayHPeCOW1DYIH5t42AaFcKPO5Kr8h+bFagWddP4T5urdGZM1gVRRQfA+fasETV6nw==@debbugs.gnu.org X-Gm-Message-State: AOJu0YzJssEFL0sPscs2sZQ0AXOL4PPApx3muMfU1q7BnCVqCWu4sqb4 M9ob4h6CpZqNpFEyMbbnvtoPGykgyYNird2r6VQGR728URv2nsSVcmsW X-Gm-Gg: ASbGncsC2Yn9YhTnCNY3k6AzaWvHXyZnyDaatkRT2xbaGP80UcZXtAhJtHEFEU2go/D ktT7G8tmaO26EG3NhmhkZNMb+kHd5jgLMKMqpRHkIHgpD5r0MCj8GZlSHA9Ldp8/cx7FSOl62tf vVh/Hd7ysNF1arMgPcuaZ7jKDfh7Afe+pXbLOc2r+jPCkXAg8VXQuJuX8UVRYtRhnHevAcTDwhj 4sV1iSmO0hqJ6mKb1Ia/2pOgxF5ekRS6s7imZN9dPu/Pkqlb3RRk4rK958HiTiaPkyISBlriUnQ /62MwaT6F2C0BoRxGQeX2jywt04QzrJg2OE5ZigvOnRmXLkREjJ5gPuiLA== X-Google-Smtp-Source: AGHT+IEyKUJd7VQcNK8YcFt771cphWPbPx06BXd6Ton3R6I6mqyyaGOenzz5HKOKzHDPHdCp6PCiqg== X-Received: by 2002:a17:906:6a06:b0:ace:c518:1327 with SMTP id a640c23a62f3a-adb322d8a67mr58789466b.14.1748544476957; Thu, 29 May 2025 11:47:56 -0700 (PDT) Received: from localhost ([185.229.154.228]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-ada6ad696d1sm186302066b.161.2025.05.29.11.47.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 May 2025 11:47:56 -0700 (PDT) From: "Paul D. Nelson" <ultrono@HIDDEN> To: Ikumi Keita <ikumi@HIDDEN> Subject: Re: bug#78586: TeX-make-inline In-Reply-To: <9450.1748543705@localhost> (message from Ikumi Keita on Fri, 30 May 2025 03:35:05 +0900) Date: Thu, 29 May 2025 20:47:55 +0200 Message-ID: <uxsg7th613gso4.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78586 Cc: arash@HIDDEN, 78586 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Thanks Ikuya, good catch! Please find attached the updated patch. Paul --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-LaTeX-make-inline-command.patch From c5c70ca6e9b0f6e48429476792da877cd605a920 Mon Sep 17 00:00:00 2001 From: Paul Nelson <ultrono@HIDDEN> Date: Thu, 29 May 2025 11:14:11 +0200 Subject: [PATCH] Add LaTeX-make-inline command * latex.el (LaTeX-make-inline): New command. (LaTeX--make-inline-finalize-region): New helper function. * tests/latex/latex-make-inline-test.el: New test file. (latex-make-inline-test--with-temp-buffer): New test macro. (LaTeX-make-inline-bracket-period) (LaTeX-make-inline-double-dollar) (LaTeX-make-inline-electric-math, LaTeX-make-inline-equation-env) (LaTeX-make-inline-noop): New test cases. * doc/auctex.texi (Quotes): Document LaTeX-make-inline. --- doc/auctex.texi | 10 ++++ latex.el | 82 +++++++++++++++++++++++++++ tests/latex/latex-make-inline-test.el | 79 ++++++++++++++++++++++++++ 3 files changed, 171 insertions(+) create mode 100644 tests/latex/latex-make-inline-test.el diff --git a/doc/auctex.texi b/doc/auctex.texi index 0b486c8c..9602c062 100644 --- a/doc/auctex.texi +++ b/doc/auctex.texi @@ -484,6 +484,16 @@ to prevent unmatched dollar. Note that Texinfo mode does nothing special for @kbd{$}. It inserts dollar sign(s) just in the same way as the other normal keys do. +@AUCTeX{} provides the command @code{LaTeX-make-inline} which converts the +display math environment at point to inline math. + +@deffn Command LaTeX-make-inline +Convert @LaTeX{} display math environment at point to inline math. This +command replaces the enclosing math environment such as @samp{\[...\]} or +@samp{\begin@{equation@}...\end@{equation@}} with the value of +@code{TeX-electric-math} or @samp{$...$} by default. +@end deffn + @subheading Braces To avoid unbalanced braces, it is useful to insert them pairwise. You diff --git a/latex.el b/latex.el index 797513f2..c305fa3a 100644 --- a/latex.el +++ b/latex.el @@ -9551,6 +9551,88 @@ no caption key is found, an error is issued. See also the docstring of "LARGE" "huge" "Huge") "List of LaTeX font size declarations.") +(defun LaTeX-make-inline () + "Convert LaTeX display math environment at point to inline math. +Remove the enclosing math environment (such as \\\\=[...\\\\=] or +\\begin{equation}...\\end{equation}) and replace it with inline math +surrounded by `TeX-electric-math' if non-nil, or \"$...$\", fitting the +result onto one line. Finally, leave any trailing punctuation outside +the math delimiters." + (interactive) + (when (texmathp) + (when (fboundp 'preview-clearout-at-point) + (preview-clearout-at-point)) + (save-excursion + (let ((env (car texmathp-why)) + (pos (cdr texmathp-why)) + (delims (or TeX-electric-math '("$" . "$")))) + (cond + ((member env '("\\(" "$"))) + ((member env '("\\[" "$$")) + (goto-char pos) + (when (looking-back "\n[[:space:]]*") + (forward-char 2) + (save-excursion (join-line)) + (forward-char -2)) + (delete-char 2) + (let ((start (point)) + (end-delim (if (equal env "\\[") "\\]" "$$"))) + (search-forward end-delim) + (delete-char -2) + (if (looking-back "\n[[:space:]]*") + (goto-char (match-beginning 0))) + (LaTeX--make-inline-finalize-region start (point) delims))) + (t + (goto-char pos) + (kill-whole-line) + (let ((start (point))) + (search-forward (concat "\\end{" env "}")) + (beginning-of-line) + (kill-whole-line) + (backward-char) + (LaTeX--make-inline-finalize-region start (point) delims)))))))) + +(defun LaTeX--make-inline-finalize-region (start end delims) + "Finalize the inline conversion from START to END using DELIMS." + (save-restriction + (narrow-to-region start end) + + (goto-char (point-min)) + (let ((re (concat "\\(?:" + (if (bound-and-true-p reftex-label-regexps) + (mapconcat #'identity reftex-label-regexps "\\|") + "\\\\label{[^}]*}") + "\\)"))) + (while (re-search-forward re nil t) + (replace-match ""))) + + (goto-char (point-min)) + (while (looking-at "\\s-*$") + (delete-line)) + (beginning-of-line-text) + (delete-region (point-min) (point)) + + (goto-char (point-max)) + (while (and (> (point) (point-min)) + (progn (forward-line -1) + (looking-at "\\s-*$"))) + (delete-line)) + (end-of-line) + (skip-chars-backward " \t") + (delete-region (point) (point-max)) + + (goto-char (point-min)) + (insert (car delims)) + (goto-char (point-max)) + + (while (looking-back "[.,;:!?]" (max (point-min) (- (point) 5))) + (backward-char)) + (insert (cdr delims)) + + (while (> (count-lines (point-min) (point-max)) 1) + (join-line))) + (join-line)) + (provide 'latex) ;;; latex.el ends here diff --git a/tests/latex/latex-make-inline-test.el b/tests/latex/latex-make-inline-test.el new file mode 100644 index 00000000..f4dbadf0 --- /dev/null +++ b/tests/latex/latex-make-inline-test.el @@ -0,0 +1,79 @@ +;;; latex-make-inline-test.el --- tests for LaTeX-make-inline -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; This file is part of AUCTeX. + +;; AUCTeX is free software; you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; AUCTeX is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with AUCTeX; see the file COPYING. If not, write to the Free +;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +;; 02110-1301, USA. + +;;; Code: + +(require 'ert) +(require 'cl-lib) +(require 'latex) + +(defmacro latex-make-inline-test--with-temp-buffer (contents &rest body) + (declare (indent 1) (debug t)) + `(with-temp-buffer + (LaTeX-mode) + (insert ,contents) + (goto-char (point-min)) + (cl-letf (((symbol-function 'preview-clearout-at-point) #'ignore)) + ,@body))) + +(ert-deftest LaTeX-make-inline-bracket-period () + "Convert \\[..\\] to $..$ and keep trailing period." + (latex-make-inline-test--with-temp-buffer + "We have\n\\[ a+b = c. \\]" + (search-forward "b") + (LaTeX-make-inline) + (should (equal (buffer-string) "We have $a+b = c$.")))) + +(ert-deftest LaTeX-make-inline-double-dollar () + "Convert $$..$$ to $..$." + (latex-make-inline-test--with-temp-buffer + "$$x!$$" + (search-forward "x") + (LaTeX-make-inline) + (should (equal (buffer-string) "$x$!")))) + +(ert-deftest LaTeX-make-inline-electric-math () + "Respect `TeX-electric-math'." + (let ((TeX-electric-math '("\\(" . "\\)"))) + (latex-make-inline-test--with-temp-buffer + "\\[ x \\]" + (search-forward "x") + (LaTeX-make-inline) + (should (equal (buffer-string) "\\(x\\)"))))) + +(ert-deftest LaTeX-make-inline-equation-env () + "Convert equation environment, drop \\label, keep comma." + (latex-make-inline-test--with-temp-buffer + "\\begin{equation}\n\\label{l}x+y,\n\\end{equation}\n" + (search-forward "x") + (let ((TeX-electric-math '("\\(" . "\\)"))) + (LaTeX-make-inline) + (should (equal (buffer-string) "\\(x+y\\),\n"))))) + +(ert-deftest LaTeX-make-inline-noop () + "Call inside inline math leaves buffer unchanged." + (latex-make-inline-test--with-temp-buffer + "Already $z$ inline." + (search-forward "z") + (LaTeX-make-inline) + (should (equal (buffer-string) "Already $z$ inline.")))) + +;;; latex-make-inline-test.el ends here -- 2.39.3 (Apple Git-145) --=-=-=--
bug-auctex@HIDDEN
:bug#78586
; Package auctex
.
Full text available.Received: (at 78586) by debbugs.gnu.org; 29 May 2025 18:35:14 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu May 29 14:35:14 2025 Received: from localhost ([127.0.0.1]:38864 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1uKi5x-0003nM-TD for submit <at> debbugs.gnu.org; Thu, 29 May 2025 14:35:14 -0400 Received: from smtp1a.inetd.co.jp ([210.129.88.11]:45952) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <ikumi@HIDDEN>) id 1uKi5t-0003ij-3G for 78586 <at> debbugs.gnu.org; Thu, 29 May 2025 14:35:11 -0400 Received: from localhost (42-144-37-89.rev.home.ne.jp [42.144.37.89]) by smtp1a.inetd.co.jp (Postfix) with ESMTPSA id C151877; Fri, 30 May 2025 03:35:05 +0900 (JST) From: Ikumi Keita <ikumi@HIDDEN> To: "Paul D. Nelson" <ultrono@HIDDEN> Subject: Re: bug#78586: TeX-make-inline In-reply-to: <uxsg7tmsavhj5d.fsf@HIDDEN> References: <uxsg7tecwcrdpt.fsf@HIDDEN> <uxsg7tmsavhj5d.fsf@HIDDEN> Comments: In-reply-to "Paul D. Nelson" <ultrono@HIDDEN> message dated "Thu, 29 May 2025 11:15:58 +0200." X-Mailer: MH-E 8.6+git; nmh 1.8; Emacs 30.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 30 May 2025 03:35:05 +0900 Message-ID: <9450.1748543705@localhost> X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78586 Cc: Arash Esbati <arash@HIDDEN>, 78586 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hi Paul, >>>>> "Paul D. Nelson" <ultrono@HIDDEN> writes: > Thanks again for your feedback, and sounds good on all counts. Please > see attached. Thanks for your continuous contributions. I have a very minor comment this time. > +(defun LaTeX-make-inline () > + "Convert LaTeX display math environment at point to inline math. > +Remove the enclosing math environment (such as \\[...\\] or ^^^ In docstrings, we need \=3D to escape \[ which introduces command-to-keybind syntax =F0=9F=99=83 Bye, Ikumi Keita #StandWithUkraine #StopWarInUkraine #Gaza #StopMassiveKilling #CeasefireNOW
bug-auctex@HIDDEN
:bug#78586
; Package auctex
.
Full text available.Received: (at 78586) by debbugs.gnu.org; 29 May 2025 09:16:10 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu May 29 05:16:09 2025 Received: from localhost ([127.0.0.1]:33875 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1uKZMv-0003xE-0Y for submit <at> debbugs.gnu.org; Thu, 29 May 2025 05:16:09 -0400 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]:54551) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <ultrono@HIDDEN>) id 1uKZMt-0003wG-1a for 78586 <at> debbugs.gnu.org; Thu, 29 May 2025 05:16:07 -0400 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-602039559d8so1286852a12.1 for <78586 <at> debbugs.gnu.org>; Thu, 29 May 2025 02:16:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748510161; x=1749114961; 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=dS4NGkfxpk1z5ViNidzpzNstx8ZZwfpkwT1r2rFAqbM=; b=gBahwTtz8GnXweCz2tCb0ZKt99bgSkO+uknHvSpYAGLc/njmSKP42RJv9FpTncXOT4 gA3lubj4Bgj3pTGOQ+uKdS92JwYIfLYa33VtEonaKHG5QqgRiUIhs2WLgCSTgAffdISM y5wsrHq4K6zd/tRlBwcvdkF+J4A0ffxhCS2gfNcLiTdQz0UUHBpPh/KFrhlisiGjeuIX Po9+pf1A/6JbO541Q96KccJnlrynVwn8L60cQZOeYt3Zh5YKviUarT4lVTMEVTIKs/Xy a3vEZZq5j/FF00ABnPZekqcfbahkbwqGduShrvfJWuNXaU1PiBz2lN4j3Pjxw3Q5z9Ek 5JPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748510161; x=1749114961; 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=dS4NGkfxpk1z5ViNidzpzNstx8ZZwfpkwT1r2rFAqbM=; b=kbZplo5clPd/aaEO/n+IagVTHKjXnrbdU/6Dz79HKlOiicGf/PUy/3aKSnea6v3NGf AZuFoZT9ulgySR0aOIHQA0gBzZKhOj/htKLMw/v5y9STv2am/njQGG1tlfsc9vuBJXGS Mon2fNcop50eh8o5KNAzxdT5JWAct0Av7jCXBPvRCKzToBKqBYM4VlEX6U2BXH46lQOu VBe3k7t6X8eAc52L7vKpS3kQwj4F94fO2R2S6ECRo2/1DTiYbKAz5T9u6GXDdJ2ePBsF dfY/TqPyc2Dr3aIi+c0LU1RnfYfkCj1U5ccgWs4QL6wLB/QeyUeTqCLDWeY7awPWknnx HkbA== X-Gm-Message-State: AOJu0YxbtpEWHDtoOH8mLRvVS+fZk0+yCX41FZgrMnbcAbwnb47ASlul OmXDkdij2zgxmgJI8SnOPFNi/EEEVj/+nK9yIbbrZ8eXoloXGhAm7E+gJRU9hjdu X-Gm-Gg: ASbGnct5KFObOXyE3QV6zhXuDMhoSG3426pe4m2Yph6zg1WMNJIllqWc2vlCmlBPyga hCnCM3F/6OadC3NUAwbULEeVWqaB2QayIEluK8uXCrpKMa1xgyk3Cjv4iT8bzGZAsWc6C7UO2+u 9XkdeBMjVMJAK5djtAauFLxLgH709Tp48mTvFUe1eliM/gHgE0MENMnBXSgCJpKE5+wrpD8uDSd 2j7FOzpk1oP63TuRrzBIFsmkPY3V0H2cS9PcTjqTafk1k52wSOugKAbbShBsV2Wm8a4K9Sqy21s ZPjvKn19BTKwwQL/KW6CoGiO82RjG5uedSyqeAuqXckhcAes3qFiYzJ4SBudtW8z43o= X-Google-Smtp-Source: AGHT+IG+gWS1Qh7+4vWISm+VMnw17DLaMXsqPGLCz5k58cBHKHlDIJJJ18OovwOjkkPImfBNjc/+aw== X-Received: by 2002:a17:907:553:b0:ad8:9041:7706 with SMTP id a640c23a62f3a-ad890417d9fmr615748466b.56.1748510160365; Thu, 29 May 2025 02:16:00 -0700 (PDT) Received: from localhost ([185.229.154.43]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-ada5d7fed53sm106864166b.27.2025.05.29.02.15.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 May 2025 02:15:59 -0700 (PDT) From: "Paul D. Nelson" <ultrono@HIDDEN> To: Arash Esbati <arash@HIDDEN> Subject: Re: bug#78586: TeX-make-inline In-Reply-To: <m21ps7op1p.fsf@HIDDEN> (message from Arash Esbati on Thu, 29 May 2025 09:26:42 +0200) Date: Thu, 29 May 2025 11:15:58 +0200 Message-ID: <uxsg7tmsavhj5d.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78586 Cc: 78586 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Hi Arash, Thanks again for your feedback, and sounds good on all counts. Please see attached. Thanks, best, Paul --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-LaTeX-make-inline-command.patch From 129d469a2ab47f61b10f5eb9557de7e525a3830f Mon Sep 17 00:00:00 2001 From: Paul Nelson <ultrono@HIDDEN> Date: Thu, 29 May 2025 11:14:11 +0200 Subject: [PATCH] Add LaTeX-make-inline command * latex.el (LaTeX-make-inline): New command. (LaTeX--make-inline-finalize-region): New helper function. * tests/latex/latex-make-inline-test.el: New test file. (latex-make-inline-test--with-temp-buffer): New test macro. (LaTeX-make-inline-bracket-period) (LaTeX-make-inline-double-dollar) (LaTeX-make-inline-electric-math, LaTeX-make-inline-equation-env) (LaTeX-make-inline-noop): New test cases. * doc/auctex.texi (Quotes): Document LaTeX-make-inline. --- doc/auctex.texi | 10 ++++ latex.el | 82 +++++++++++++++++++++++++++ tests/latex/latex-make-inline-test.el | 79 ++++++++++++++++++++++++++ 3 files changed, 171 insertions(+) create mode 100644 tests/latex/latex-make-inline-test.el diff --git a/doc/auctex.texi b/doc/auctex.texi index 0b486c8c..9602c062 100644 --- a/doc/auctex.texi +++ b/doc/auctex.texi @@ -484,6 +484,16 @@ to prevent unmatched dollar. Note that Texinfo mode does nothing special for @kbd{$}. It inserts dollar sign(s) just in the same way as the other normal keys do. +@AUCTeX{} provides the command @code{LaTeX-make-inline} which converts the +display math environment at point to inline math. + +@deffn Command LaTeX-make-inline +Convert @LaTeX{} display math environment at point to inline math. This +command replaces the enclosing math environment such as @samp{\[...\]} or +@samp{\begin@{equation@}...\end@{equation@}} with the value of +@code{TeX-electric-math} or @samp{$...$} by default. +@end deffn + @subheading Braces To avoid unbalanced braces, it is useful to insert them pairwise. You diff --git a/latex.el b/latex.el index 797513f2..6e34dfc5 100644 --- a/latex.el +++ b/latex.el @@ -9551,6 +9551,88 @@ no caption key is found, an error is issued. See also the docstring of "LARGE" "huge" "Huge") "List of LaTeX font size declarations.") +(defun LaTeX-make-inline () + "Convert LaTeX display math environment at point to inline math. +Remove the enclosing math environment (such as \\[...\\] or +\\begin{equation}...\\end{equation}) and replace it with inline math +surrounded by `TeX-electric-math' if non-nil, or \"$..$\", fitting the +result onto one line. Finally, leave any trailing punctuation outside +the math delimiters." + (interactive) + (when (texmathp) + (when (fboundp 'preview-clearout-at-point) + (preview-clearout-at-point)) + (save-excursion + (let ((env (car texmathp-why)) + (pos (cdr texmathp-why)) + (delims (or TeX-electric-math '("$" . "$")))) + (cond + ((member env '("\\(" "$"))) + ((member env '("\\[" "$$")) + (goto-char pos) + (when (looking-back "\n[[:space:]]*") + (forward-char 2) + (save-excursion (join-line)) + (forward-char -2)) + (delete-char 2) + (let ((start (point)) + (end-delim (if (equal env "\\[") "\\]" "$$"))) + (search-forward end-delim) + (delete-char -2) + (if (looking-back "\n[[:space:]]*") + (goto-char (match-beginning 0))) + (LaTeX--make-inline-finalize-region start (point) delims))) + (t + (goto-char pos) + (kill-whole-line) + (let ((start (point))) + (search-forward (concat "\\end{" env "}")) + (beginning-of-line) + (kill-whole-line) + (backward-char) + (LaTeX--make-inline-finalize-region start (point) delims)))))))) + +(defun LaTeX--make-inline-finalize-region (start end delims) + "Finalize the inline conversion from START to END using DELIMS." + (save-restriction + (narrow-to-region start end) + + (goto-char (point-min)) + (let ((re (concat "\\(?:" + (if (bound-and-true-p reftex-label-regexps) + (mapconcat #'identity reftex-label-regexps "\\|") + "\\\\label{[^}]*}") + "\\)"))) + (while (re-search-forward re nil t) + (replace-match ""))) + + (goto-char (point-min)) + (while (looking-at "\\s-*$") + (delete-line)) + (beginning-of-line-text) + (delete-region (point-min) (point)) + + (goto-char (point-max)) + (while (and (> (point) (point-min)) + (progn (forward-line -1) + (looking-at "\\s-*$"))) + (delete-line)) + (end-of-line) + (skip-chars-backward " \t") + (delete-region (point) (point-max)) + + (goto-char (point-min)) + (insert (car delims)) + (goto-char (point-max)) + + (while (looking-back "[.,;:!?]" (max (point-min) (- (point) 5))) + (backward-char)) + (insert (cdr delims)) + + (while (> (count-lines (point-min) (point-max)) 1) + (join-line))) + (join-line)) + (provide 'latex) ;;; latex.el ends here diff --git a/tests/latex/latex-make-inline-test.el b/tests/latex/latex-make-inline-test.el new file mode 100644 index 00000000..f4dbadf0 --- /dev/null +++ b/tests/latex/latex-make-inline-test.el @@ -0,0 +1,79 @@ +;;; latex-make-inline-test.el --- tests for LaTeX-make-inline -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 Free Software Foundation, Inc. + +;; This file is part of AUCTeX. + +;; AUCTeX is free software; you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; AUCTeX is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with AUCTeX; see the file COPYING. If not, write to the Free +;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +;; 02110-1301, USA. + +;;; Code: + +(require 'ert) +(require 'cl-lib) +(require 'latex) + +(defmacro latex-make-inline-test--with-temp-buffer (contents &rest body) + (declare (indent 1) (debug t)) + `(with-temp-buffer + (LaTeX-mode) + (insert ,contents) + (goto-char (point-min)) + (cl-letf (((symbol-function 'preview-clearout-at-point) #'ignore)) + ,@body))) + +(ert-deftest LaTeX-make-inline-bracket-period () + "Convert \\[..\\] to $..$ and keep trailing period." + (latex-make-inline-test--with-temp-buffer + "We have\n\\[ a+b = c. \\]" + (search-forward "b") + (LaTeX-make-inline) + (should (equal (buffer-string) "We have $a+b = c$.")))) + +(ert-deftest LaTeX-make-inline-double-dollar () + "Convert $$..$$ to $..$." + (latex-make-inline-test--with-temp-buffer + "$$x!$$" + (search-forward "x") + (LaTeX-make-inline) + (should (equal (buffer-string) "$x$!")))) + +(ert-deftest LaTeX-make-inline-electric-math () + "Respect `TeX-electric-math'." + (let ((TeX-electric-math '("\\(" . "\\)"))) + (latex-make-inline-test--with-temp-buffer + "\\[ x \\]" + (search-forward "x") + (LaTeX-make-inline) + (should (equal (buffer-string) "\\(x\\)"))))) + +(ert-deftest LaTeX-make-inline-equation-env () + "Convert equation environment, drop \\label, keep comma." + (latex-make-inline-test--with-temp-buffer + "\\begin{equation}\n\\label{l}x+y,\n\\end{equation}\n" + (search-forward "x") + (let ((TeX-electric-math '("\\(" . "\\)"))) + (LaTeX-make-inline) + (should (equal (buffer-string) "\\(x+y\\),\n"))))) + +(ert-deftest LaTeX-make-inline-noop () + "Call inside inline math leaves buffer unchanged." + (latex-make-inline-test--with-temp-buffer + "Already $z$ inline." + (search-forward "z") + (LaTeX-make-inline) + (should (equal (buffer-string) "Already $z$ inline.")))) + +;;; latex-make-inline-test.el ends here -- 2.39.3 (Apple Git-145) --=-=-=--
bug-auctex@HIDDEN
:bug#78586
; Package auctex
.
Full text available.Received: (at 78586) by debbugs.gnu.org; 29 May 2025 07:26:55 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu May 29 03:26:55 2025 Received: from localhost ([127.0.0.1]:33282 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1uKXfC-0004Zt-Kb for submit <at> debbugs.gnu.org; Thu, 29 May 2025 03:26:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59972) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <arash@HIDDEN>) id 1uKXfA-0004ZZ-MA for 78586 <at> debbugs.gnu.org; Thu, 29 May 2025 03:26:53 -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 <arash@HIDDEN>) id 1uKXf5-0005NR-9F; Thu, 29 May 2025 03:26:47 -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=0TfVnBxy6HawUxY8tM/sHGigYo4aIiPGBLy5TAjZaI4=; b=khZC0lwPQpRBVHtdB34j ra/IrLpn5im7sbaI39nRSLGky5q9hIchrRX2zIrKYiOrtRc/dtBNZUics1rhkrHXBDnPW6XPj6Vv2 x85CZtcC4p4wUZ4b65k51K1DDAMjiS7f30CnZUqTxC1pCN8TevEzC+Mu5lfB2mI1q1bmezM+zzQEg Hr0fotBCvYe3yv1klHEsSlZ0Cz+X7x+oWXvGYh2HEaAxCaceuNe4YRrmyIFhiCzk0fTPXhYfLY3Oi 4qNRJd4XvE6vjIcN2sMCLpRl+BoShc1ySfYvGixqKaK4Yn4KWVcdgAOPULQ8a8ndvIc7DrcjWo/le d2v+J5ynT57iiw==; From: Arash Esbati <arash@HIDDEN> To: "Paul D. Nelson" <ultrono@HIDDEN> Subject: Re: bug#78586: TeX-make-inline In-Reply-To: <uxsg7t34cqf6bx.fsf@HIDDEN> References: <uxsg7t34cqf6bx.fsf@HIDDEN> Date: Thu, 29 May 2025 09:26:42 +0200 Message-ID: <m21ps7op1p.fsf@HIDDEN> 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: 78586 Cc: 78586 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) Hi Paul, "Paul D. Nelson" <ultrono@HIDDEN> writes: > Hi Arash, thanks for your feedback. You're welcome. > I put the updated draft at the end of this message (to be converted > into a patch once one of us thinks of a good place to put it), and > attach some tests. You said that you also have some other commands, right? So I suggest we put them at the end of latex.el, under ;; Utilities:. WDYT? Reg. manual: I suggest to document this command under @subheading Dollar Signs Maybe something like this: --8<---------------cut here---------------start------------->8--- diff --git a/doc/auctex.texi b/doc/auctex.texi index 0b486c8c..9602c062 100644 --- a/doc/auctex.texi +++ b/doc/auctex.texi @@ -484,6 +484,16 @@ to prevent unmatched dollar. Note that Texinfo mode does nothing special for @kbd{$}. It inserts dollar sign(s) just in the same way as the other normal keys do. +@AUCTeX{} provides the command @code{LaTeX-make-inline} which converts the +display math environment at point to inline math. + +@deffn Command LaTeX-make-inline +Convert @LaTeX{} display math environment at point to inline math. This +command replaces the enclosing math environment such as @samp{\[...\]} or +@samp{\begin@{equation@}...\end@{equation@}} with the value of +@code{TeX-electric-math} or @samp{$...$} by default. +@end deffn + @subheading Braces To avoid unbalanced braces, it is useful to insert them pairwise. You --8<---------------cut here---------------end--------------->8--- > (defun LaTeX-make-inline () > "Convert LaTeX display math environment at point to inline math. > Removes the enclosing math environment (such as \\[...\\] or > \\begin{equation}...\\end{equation}). Replaces it with inline math > surrounded by surrounded by `TeX-electric-math' if non-nil, or \"$..$\", > fitting the result onto one line. Leaves any trailing punctuation > outside the math delimiters." Please use active voice, maybe something like this: "Convert LaTeX display math environment at point to inline math. Remove the enclosing math environment (such as \\[...\\] or \\begin{equation}...\\end{equation}) and replace it with inline math surrounded by `TeX-electric-math' if non-nil, or \"$...$\", fitting the result onto one line. Finally, leave any trailing punctuation outside the math delimiters." > (interactive) > (when (texmathp) > (when (fboundp 'preview-clearout-at-point) > (preview-clearout-at-point)) > (save-excursion > (let* ((env (car texmathp-why)) > (pos (cdr texmathp-why)) > (delims (or TeX-electric-math '("$" . "$")))) Why `let*'? > (cond > ((member env '("\\(" "$"))) > ((member env '("\\[" "$$")) > (goto-char pos) > (when (looking-back "\n[[:space:]]*") > (forward-char 2) > (save-excursion (join-line)) > (forward-char -2)) > (delete-char 2) > (let ((start (point)) > (end-delim (if (equal env "\\[") "\\]" "$$"))) > (search-forward end-delim) > (delete-char -2) > (if (looking-back "\n[[:space:]]*") > (goto-char (match-beginning 0))) > (LaTeX--make-inline-finalize-region start (point) delims))) > (t > (goto-char pos) > (kill-whole-line) > (let ((start (point))) > (search-forward (concat "\\end{" env "}")) > (beginning-of-line) > (kill-whole-line) > (backward-char) > (LaTeX--make-inline-finalize-region start (point) delims)))))))) > > (defun LaTeX--make-inline-finalize-region (start end delims) > "Finalize the inline conversion from START to END using DELIMS." > (save-restriction > (narrow-to-region start end) > > (goto-char (point-min)) > (let ((re > (concat "\\(?:" > (mapconcat #'identity > (if (boundp 'reftex-label-regexps) > reftex-label-regexps > '("\\\\label{[^}]*")) > "\\|") > "\\)"))) This looks somewhat easier to me: (let ((re (concat "\\(?:" (if (bound-and-true-p reftex-label-regexps) (mapconcat #'identity reftex-label-regexps "\\|") "\\\\label{[^}]*}") "\\)"))) And note the missing '}' in "\\\\label{[^}]*". Otherwise LGTM. Best, Arash
bug-auctex@HIDDEN
:bug#78586
; Package auctex
.
Full text available.Received: (at 78586) by debbugs.gnu.org; 27 May 2025 14:59:10 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue May 27 10:59:10 2025 Received: from localhost ([127.0.0.1]:42375 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1uJvll-000611-5u for submit <at> debbugs.gnu.org; Tue, 27 May 2025 10:59:09 -0400 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]:52559) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <ultrono@HIDDEN>) id 1uJvli-0005zy-H1 for 78586 <at> debbugs.gnu.org; Tue, 27 May 2025 10:59:07 -0400 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-acb5ec407b1so584233366b.1 for <78586 <at> debbugs.gnu.org>; Tue, 27 May 2025 07:59:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748357940; x=1748962740; 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=laT1D2N0/TIuBa3+5TnTL9LtM/CswcDt4OdFvkTXlD4=; b=AkVXMEJteOBk34zqgnqLFBDIwm3BTA4xszb5uAbWlt7cfhpmXFMQMpH3H5vo726hRv DetIj13DaURRY18xhsNsnVP8vJchjwaeS/hJmMDTSBhKyMMqQoA+cpMIMhJKKlO9JUjn KbwCmUvz8Bxq97cI/S9Svgg6d64iI3EXAczTNKLilLRLi4UKufNhH8pko/gDgT5ElKR9 8cJ2b0525DD5Z2sye5UAAMb287j4mH314MuGnl+aOkZemKjrPHaxp2Dm4HrzjrDOBrqL s8+0MkDQWHr5fMC5wgUn0YiuYd/PwaADqRhCstwjCUqYsKJSAUTIuNceDUEh8D+C83Cw ikFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748357940; x=1748962740; 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=laT1D2N0/TIuBa3+5TnTL9LtM/CswcDt4OdFvkTXlD4=; b=Fou2K2ixmgJLiVWCxCbxxi/LraApe8f1nguFQ95uHurywVWHG2aIfvaGyvJHQ7eute hpF35UiMy/wQj0HqPMIwkhMWDFk9WPyWLXp9MMydRiG1mGXrPnyM14OX2rrlyILFEXJP +M43XOhz6qd7qEZ1nnwo4NNxg9hy0uMS0zCY3ayoEAZ8dMy5dM27ermXkPdkQmlrZ74w CvhfSIvGzeYhzuJNZoZyZE09FvE0WiomZwH/lj/Bx3kWVMkDe6GkyOfHq5rd1TgYJn+X yfBU2sp+UynXQgcToqTT7LM084bT3X6+tChF3gvkH6iMOmPJDA29RjKW8TALFkt3u3cj tF5Q== X-Gm-Message-State: AOJu0YxGp2AUzr/RjkHIEThdNETchMUld+U3RPqpcVmygeXJ53EkXa9P OOgpMQPXphHYPSlSwQjxTLCBzJgrIX/BeUXQxvzfM7bnvwiq0APRIeXb20sPeJ3lhFo= X-Gm-Gg: ASbGnctJomHG88/Ws2c4VzT1E80iDllk5YUAq1Lc/eyrwBkZMuJVVIzhh3pJGgBHrZ1 OeB9qYzgAfbuxmzixo9fhYQjwTG3+/ruwXW8HxwM+grbtHpby5BGvc+lJemsVx3/1F5Qr1jHDja IgNKt3UAlXK/+AZvNI+i/7ocpf+w3ET0dAbqi2HoY3QtAMPx9v8mGYlzLNaOAyECkkWXz6feFAq fUZHN3HnwfnoGhEg2QQD64UOf2gbaGLzqoluFRty/TioBtz37EEAv8gPiVgg48pBcLMMOK5EOwR WyrrVn4X1wjjxr8wSgi2eVth9UVh+hd1wvVuCtcYim8ddzQlo692ilPMjijpYoAhDAW8PQ+KX02 WLO9uV4cn4qDx X-Google-Smtp-Source: AGHT+IFc+YXPAjz3BHdSV+QA9Fy91SyUb7rjJoLZG9FEbG4KNYmH8Ay0d7DYBp+D57AaCmNp4pc1Qg== X-Received: by 2002:a17:907:72cf:b0:ad2:417b:2ab5 with SMTP id a640c23a62f3a-ad85b32d8e0mr938657666b.60.1748357940026; Tue, 27 May 2025 07:59:00 -0700 (PDT) Received: from localhost (users-1190.st.net.au.dk. [130.225.0.251]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-ad52d498737sm1857367666b.138.2025.05.27.07.58.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 May 2025 07:58:59 -0700 (PDT) From: "Paul D. Nelson" <ultrono@HIDDEN> To: Arash Esbati <arash@HIDDEN> Subject: Re: bug#78586: TeX-make-inline In-Reply-To: <m2msaygqi3.fsf@HIDDEN> (message from Arash Esbati on Tue, 27 May 2025 14:57:56 +0200) Date: Tue, 27 May 2025 16:58:58 +0200 Message-ID: <uxsg7t34cqf6bx.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78586 Cc: 78586 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Hi Arash, thanks for your feedback. I put the updated draft at the end of this message (to be converted into a patch once one of us thinks of a good place to put it), and attach some tests. Paul --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=latex-make-inline-test.el Content-Transfer-Encoding: quoted-printable ;;; latex-make-inline-test.el --- tests for LaTeX-make-inline -*- lexical-= binding: t; -*- ;; Copyright (C) 2025 Free Software Foundation, Inc. ;; This file is part of AUCTeX. ;; AUCTeX is free software; you can redistribute it and/or modify it ;; under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; AUCTeX is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with AUCTeX; see the file COPYING. If not, write to the Free ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ;; 02110-1301, USA. ;;; Code: (require 'ert) (require 'cl-lib) (require 'latex) (defmacro latex-make-inline-test--with-temp-buffer (contents &rest body) (declare (indent 1) (debug t)) `(with-temp-buffer (LaTeX-mode) (insert ,contents) (goto-char (point-min)) (cl-letf (((symbol-function 'preview-clearout-at-point) #'ignore)) ,@body))) (ert-deftest LaTeX-make-inline-bracket-period () "Convert \\[..\\] to $..$ and keep trailing period." (latex-make-inline-test--with-temp-buffer "We have\n\\[ a+b =3D c. \\]" (search-forward "b") (LaTeX-make-inline) (should (equal (buffer-string) "We have $a+b =3D c$.")))) (ert-deftest LaTeX-make-inline-double-dollar () "Convert $$..$$ to $..$." (latex-make-inline-test--with-temp-buffer "$$x!$$" (search-forward "x") (LaTeX-make-inline) (should (equal (buffer-string) "$x$!")))) (ert-deftest LaTeX-make-inline-electric-math () "Respect `TeX-electric-math'." (let ((TeX-electric-math '("\\(" . "\\)"))) (latex-make-inline-test--with-temp-buffer "\\[ x \\]" (search-forward "x") (LaTeX-make-inline) (should (equal (buffer-string) "\\(x\\)"))))) (ert-deftest LaTeX-make-inline-equation-env () "Convert equation environment, drop \\label, keep comma." (latex-make-inline-test--with-temp-buffer "\\begin{equation}\n\\label{l}x+y,\n\\end{equation}\n" (search-forward "x") (let ((TeX-electric-math '("\\(" . "\\)"))) (LaTeX-make-inline) (should (equal (buffer-string) "\\(x+y\\),\n"))))) (ert-deftest LaTeX-make-inline-noop () "Call inside inline math leaves buffer unchanged." (latex-make-inline-test--with-temp-buffer "Already $z$ inline." (search-forward "z") (LaTeX-make-inline) (should (equal (buffer-string) "Already $z$ inline.")))) ;;; latex-make-inline-test.el ends here --=-=-= Content-Type: text/plain --8<---------------cut here---------------start------------->8--- (defun LaTeX-make-inline () "Convert LaTeX display math environment at point to inline math. Removes the enclosing math environment (such as \\[...\\] or \\begin{equation}...\\end{equation}). Replaces it with inline math surrounded by surrounded by `TeX-electric-math' if non-nil, or \"$..$\", fitting the result onto one line. Leaves any trailing punctuation outside the math delimiters." (interactive) (when (texmathp) (when (fboundp 'preview-clearout-at-point) (preview-clearout-at-point)) (save-excursion (let* ((env (car texmathp-why)) (pos (cdr texmathp-why)) (delims (or TeX-electric-math '("$" . "$")))) (cond ((member env '("\\(" "$"))) ((member env '("\\[" "$$")) (goto-char pos) (when (looking-back "\n[[:space:]]*") (forward-char 2) (save-excursion (join-line)) (forward-char -2)) (delete-char 2) (let ((start (point)) (end-delim (if (equal env "\\[") "\\]" "$$"))) (search-forward end-delim) (delete-char -2) (if (looking-back "\n[[:space:]]*") (goto-char (match-beginning 0))) (LaTeX--make-inline-finalize-region start (point) delims))) (t (goto-char pos) (kill-whole-line) (let ((start (point))) (search-forward (concat "\\end{" env "}")) (beginning-of-line) (kill-whole-line) (backward-char) (LaTeX--make-inline-finalize-region start (point) delims)))))))) (defun LaTeX--make-inline-finalize-region (start end delims) "Finalize the inline conversion from START to END using DELIMS." (save-restriction (narrow-to-region start end) (goto-char (point-min)) (let ((re (concat "\\(?:" (mapconcat #'identity (if (boundp 'reftex-label-regexps) reftex-label-regexps '("\\\\label{[^}]*")) "\\|") "\\)"))) (while (re-search-forward re nil t) (replace-match ""))) (goto-char (point-min)) (while (looking-at "\\s-*$") (delete-line)) (beginning-of-line-text) (delete-region (point-min) (point)) (goto-char (point-max)) (while (and (> (point) (point-min)) (progn (forward-line -1) (looking-at "\\s-*$"))) (delete-line)) (end-of-line) (skip-chars-backward " \t") (delete-region (point) (point-max)) (goto-char (point-min)) (insert (car delims)) (goto-char (point-max)) (while (looking-back "[.,;:!?]" (max (point-min) (- (point) 5))) (backward-char)) (insert (cdr delims)) (while (> (count-lines (point-min) (point-max)) 1) (join-line))) (join-line)) --8<---------------cut here---------------end--------------->8--- --=-=-=--
bug-auctex@HIDDEN
:bug#78586
; Package auctex
.
Full text available.Received: (at 78586) by debbugs.gnu.org; 27 May 2025 12:58:13 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue May 27 08:58:13 2025 Received: from localhost ([127.0.0.1]:40053 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1uJtsj-0005D6-Cd for submit <at> debbugs.gnu.org; Tue, 27 May 2025 08:58:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44954) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <arash@HIDDEN>) id 1uJtse-0005Cg-6H for 78586 <at> debbugs.gnu.org; Tue, 27 May 2025 08:58:10 -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 <arash@HIDDEN>) id 1uJtsX-00040m-Ge; Tue, 27 May 2025 08:58:01 -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=00WOnd+iQz27WMuNH6cwi24SuO1dFQMVPvrCU5M/Q00=; b=LwE69OzLzbs7Z+ouG0Tt B2qxelra/fZodt7GyUbIQCPlblLRDEFX6cL2LmMN9pY0mJxP81+CJzAKdDTgLjTL8ji3jSC9HoWcn nvSipMb53BGfHDfxAMri15LBAVZDm6mfyz7SJEwp/rhxyQhB+saBmn5mk2cwnMOir5XrrGG1VlR79 h4eV7WuzxE2hHCbC5WujHSCgc8ZIJI7LGK8EtzI7IzrG1N7HkRMTbWFgror+t9TG3ljhiQnLxavhG WqEo6Hxm06Gxz9QbvNRZtktoMXcKpPPPWndq/Scllqx0HPnv4O+p7bfSYGFaV+evfTh+JInV//bgm CVYZSvnpELPruw==; From: Arash Esbati <arash@HIDDEN> To: "Paul D. Nelson" <ultrono@HIDDEN> Subject: Re: bug#78586: TeX-make-inline In-Reply-To: <uxsg7tecwcrdpt.fsf@HIDDEN> References: <uxsg7tecwcrdpt.fsf@HIDDEN> Date: Tue, 27 May 2025 14:57:56 +0200 Message-ID: <m2msaygqi3.fsf@HIDDEN> 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: -2.3 (--) X-Debbugs-Envelope-To: 78586 Cc: 78586 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) Hi Paul, "Paul D. Nelson" <ultrono@HIDDEN> writes: > We had discussed in an earlier thread (bug#78006) the possibility of > adding some of my editing commands to AUCTeX (as standalone commands, > without default binds). Thanks for sharing. I have some comments below: > We could start with this one, discussed a bit in that thread: > > (defcustom TeX-make-inline-delims '("$" . "$") > "Delimiters for `TeX-make-inline' to surround inline LaTeX math." > :type '(radio (const :tag "Dollar ($...$)" ("$" . "$")) > (const :tag "Paren (\\(...\\))" ("\\(" . "\\)")) > (cons :tag "Custom delimiters" > (string :tag "Left") (string :tag "Right")))) Do we really need this? Can we just take the value of `TeX-electric-math', and make an assumption if it's nil? > (defun TeX-make-inline () This function is LaTeX centric, right? So I would call is `LaTeX-make-inline-math' or something and put it in latex.el. > "Convert LaTeX display math environment at point to inline math. > Removes the enclosing math environment (such as \\[...\\] or > \\begin{equation}...\\end{equation}). Replaces it with inline math > surrounded by `TeX-make-inline-delims', surrounded by `TeX-electric-math' if non-nil, or \"$..$\", > fitting the result onto one > line. Leaves any trailing punctuation outside the math delimiters." > (interactive) > (when (texmathp) > (when (fboundp 'preview-clearout-at-point) > (preview-clearout-at-point)) > (save-excursion > (let* ((env (car texmathp-why)) > (pos (cdr texmathp-why)) > (delims TeX-make-inline-delims)) (delims (or TeX-electric-math '("$" . "$"))) > (cond > ((member env '("\\(" "$"))) > ((member env '("\\[" "$$")) > (goto-char pos) > (delete-char 2) > (let ((start (point)) > (end-delim (if (equal env "\\[") "\\]" "$$"))) > (search-forward end-delim) > (delete-char -2) > (TeX-make-inline--finalize-region start (point) delims))) > (t > (goto-char pos) > (kill-line) > (let ((start (point))) > (search-forward (concat "\\end{" env "}")) > (beginning-of-line) > (kill-line) > (TeX-make-inline--finalize-region start (point) delims)))))))) > > (defun TeX-make-inline--finalize-region (start end delims) (defun LaTeX--whatever-we-agree-to (...) Would it be possible to write an ERT-test for feature? > I haven't prepared this as a patch because I'm not sure where to put it > or where to document it. I looked around, and couldn't find a natural > place. I will have a look, will try to make a suggestion. > For what it's worth, there are a couple of other editing-related > commands I'd be inclined to propose. =F0=9F=91=8D Best, Arash
bug-auctex@HIDDEN
:bug#78586
; Package auctex
.
Full text available.Received: (at submit) by debbugs.gnu.org; 25 May 2025 14:02:17 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun May 25 10:02:17 2025 Received: from localhost ([127.0.0.1]:46132 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1uJBvc-0006nH-Nq for submit <at> debbugs.gnu.org; Sun, 25 May 2025 10:02:17 -0400 Received: from lists.gnu.org ([2001:470:142::17]:59304) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <ultrono@HIDDEN>) id 1uJBvY-0006lu-6i for submit <at> debbugs.gnu.org; Sun, 25 May 2025 10:02:13 -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 <ultrono@HIDDEN>) id 1uJBvH-0002Yl-Ls for bug-auctex@HIDDEN; Sun, 25 May 2025 10:01:56 -0400 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <ultrono@HIDDEN>) id 1uJBvG-000793-0D for bug-auctex@HIDDEN; Sun, 25 May 2025 10:01:55 -0400 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-ad574992fcaso261026466b.1 for <bug-auctex@HIDDEN>; Sun, 25 May 2025 07:01:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748181712; x=1748786512; darn=gnu.org; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=kAQk0CAA/VgcEl1FrkJxKqKbFlbFgCr6hr4TtQznZcA=; b=SBaCgrtmLxbCEKNpI9iNRdzeilh7jRE5bjRmsHjsSH+i+OcrsOXxE/nW8LTDkzZIWL A5CitRvBIsm7e6IBIdFMnFSCb0OIQUpPeq0/ZE3h8whaamqrBSUELC7+X/7P1zbpOeVs Ikb2RBwVF6wegP68kjky6KK65YiFsAdAMsO94ge4iAfowXq/laCpQkcaTpEIOvZjZAws Yf6WjkVME7ag+2V7k7uqYyfWaP5WjvwXdkvy0Pknlxl+RQ7T+vG1brNE99NFhchEFuTv NRbuhPK+yVtQlYtwjbrnjj4Ll9/W4UKM+cf5ilARGt1sr6IsfRsoU2odXjNqb814SUCZ TrhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748181712; x=1748786512; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=kAQk0CAA/VgcEl1FrkJxKqKbFlbFgCr6hr4TtQznZcA=; b=tUy3GB7YrVOPlFR4AAVRtaKJnLoCVFLrbhDkxmcthoyzQk44K760uB0mAQtLIPeks+ HGmJXf0m0kR1kqUPcUj2vXBLgjQxj3eaV3SDo8qdoiubrMGJeGOzMKLEXw0zl8QcJyXw +jobLkOx1pNy9Ty4MKVcPSfTYDKFxuFRmSqZDV7PyxYGQmOxXtZMprVP2LDcLh7FXJrM 9BbcHzzvoy1u4ldxEoY+hRu5G4Gqvo2lHiZSkVMvI8+C7kgNuZa9RLp30AXXlx9Zkgk4 XldtEVWckr1FCtUIaDLhgJJAjfpdsDgJj9uo6yxg7hEV42SNnHmQw71nfFs0QViHYsWr 3XXQ== X-Gm-Message-State: AOJu0Yygn0p9t8c8VKYVdDyK8Xsq6diQmJ2XDUP2nqrovLK8TrR6RBUg Xk9PViBfKjADkBmXiVrjRZZiwVWEFPLvpYXYIMOCOM4Nr2cpFXwZNRqmYONSKQMm X-Gm-Gg: ASbGncsB9jFNzFoQEEgtEf4yf8RCaUBeY8Z1ytN3fLQoQFjnrZ/1CyjIY4B1j01nLmt 3xBAk8JwfPhS4XZ9MyQzDhlXE0xwc4F8ri6w2mPOgiEKmwk7uIJJ43aSyTgw2U3J+BoznBHM29v GxFXnrQNte9bTCeClJ2wF5OmGsBQBujC3lBbSIe0t2+Kq73U2aQIJ4lJLIuAqWl7lAm3NuBbvSd 6nOw6VUbT0uZfqWJfLp57yqpftMVKxGgxYMTtgndJyqvjiqCEQMbyr88JvD2127Fu3nU9VkJe/q Pui8f/YmufKWarjXO2WB6etgbMtznkhCCunklHqWMroZst+lk/Bi6cR6MmaaQMW2T+jOhcir+9M vlZU= X-Google-Smtp-Source: AGHT+IGSlTw6ILExPqOX9+Es9+jXiMTc3Lj0Xs7L+HFxt63T7BUCpwjF4hsdyBgV9PMdS5RW3NmBzA== X-Received: by 2002:a17:906:338d:b0:ad5:6422:4ef4 with SMTP id a640c23a62f3a-ad85b2a49b5mr365846666b.55.1748181711712; Sun, 25 May 2025 07:01:51 -0700 (PDT) Received: from localhost ([185.229.154.237]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-ad52d4cbe90sm1522729966b.165.2025.05.25.07.01.51 for <bug-auctex@HIDDEN> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 May 2025 07:01:51 -0700 (PDT) From: "Paul D. Nelson" <ultrono@HIDDEN> To: bug-auctex@HIDDEN Subject: TeX-make-inline Date: Sun, 25 May 2025 16:01:50 +0200 Message-ID: <uxsg7tecwcrdpt.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=ultrono@HIDDEN; helo=mail-ej1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_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: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.0 (/) Hi Arash and all, We had discussed in an earlier thread (bug#78006) the possibility of adding some of my editing commands to AUCTeX (as standalone commands, without default binds). We could start with this one, discussed a bit in that thread: --8<---------------cut here---------------start------------->8--- (defcustom TeX-make-inline-delims '("$" . "$") "Delimiters for `TeX-make-inline' to surround inline LaTeX math." :type '(radio (const :tag "Dollar ($...$)" ("$" . "$")) (const :tag "Paren (\\(...\\))" ("\\(" . "\\)")) (cons :tag "Custom delimiters" (string :tag "Left") (string :tag "Right")))) (defun TeX-make-inline () "Convert LaTeX display math environment at point to inline math. Removes the enclosing math environment (such as \\[...\\] or \\begin{equation}...\\end{equation}). Replaces it with inline math surrounded by `TeX-make-inline-delims', fitting the result onto one line. Leaves any trailing punctuation outside the math delimiters." (interactive) (when (texmathp) (when (fboundp 'preview-clearout-at-point) (preview-clearout-at-point)) (save-excursion (let* ((env (car texmathp-why)) (pos (cdr texmathp-why)) (delims TeX-make-inline-delims)) (cond ((member env '("\\(" "$"))) ((member env '("\\[" "$$")) (goto-char pos) (delete-char 2) (let ((start (point)) (end-delim (if (equal env "\\[") "\\]" "$$"))) (search-forward end-delim) (delete-char -2) (TeX-make-inline--finalize-region start (point) delims))) (t (goto-char pos) (kill-line) (let ((start (point))) (search-forward (concat "\\end{" env "}")) (beginning-of-line) (kill-line) (TeX-make-inline--finalize-region start (point) delims)))))))) (defun TeX-make-inline--finalize-region (start end delims) "Finalize the inline conversion from START to END using DELIMS." (save-restriction (narrow-to-region start end) (whitespace-cleanup) (goto-char (point-min)) (let ((re (concat "\\(?:" (mapconcat #'identity (if (boundp 'reftex-label-regexps) reftex-label-regexps '("\\\\label{[^}]*")) "\\|") "\\)"))) (while (re-search-forward re nil t) (replace-match ""))) (goto-char (point-min)) (while (looking-at "\\s-*$") (delete-line)) (beginning-of-line-text) (delete-region (point-min) (point)) (goto-char (point-max)) (while (and (> (point) (point-min)) (progn (forward-line -1) (looking-at "\\s-*$"))) (delete-line)) (end-of-line) (skip-chars-backward " \t") (delete-region (point) (point-max)) (goto-char (point-min)) (insert (car delims)) (goto-char (point-max)) (insert "\n") (backward-char) (while (looking-back "[.,;:!?]" 5) (backward-char)) (insert (cdr delims)) (while (> (count-lines (point-min) (point-max)) 1) (join-line)))) --8<---------------cut here---------------end--------------->8--- I haven't prepared this as a patch because I'm not sure where to put it or where to document it. I looked around, and couldn't find a natural place. If no better idea comes to mind, then perhaps some new "miscellaneous commands" section of latex.el, with a corresponding section in the manual? For what it's worth, there are a couple of other editing-related commands I'd be inclined to propose. Any feedback welcome. Thanks, best, Paul
"Paul D. Nelson" <ultrono@HIDDEN>
:bug-auctex@HIDDEN
.
Full text available.bug-auctex@HIDDEN
:bug#78586
; Package auctex
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.