From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pranshu Newsgroups: gmane.emacs.bugs Subject: bug#71375: 30.0.50 Date: Wed, 05 Jun 2024 17:14:38 +1000 Message-ID: <877cf36eu9.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12294"; mail-complaints-to="usenet@ciao.gmane.io" To: 71375@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 05 09:16:06 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sEksQ-00035D-Dr for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 05 Jun 2024 09:16:06 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEksB-0005qI-8U; Wed, 05 Jun 2024 03:15:51 -0400 Original-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 1sEks8-0005pK-Nb for bug-gnu-emacs@gnu.org; Wed, 05 Jun 2024 03:15:48 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sEks8-0001j9-Aa for bug-gnu-emacs@gnu.org; Wed, 05 Jun 2024 03:15:48 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sEksM-0000FB-1V for bug-gnu-emacs@gnu.org; Wed, 05 Jun 2024 03:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Pranshu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 05 Jun 2024 07:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 71375 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.1717571704767 (code B ref -1); Wed, 05 Jun 2024 07:16:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 Jun 2024 07:15:04 +0000 Original-Received: from localhost ([127.0.0.1]:36096 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sEkrP-0000CC-9J for submit@debbugs.gnu.org; Wed, 05 Jun 2024 03:15:03 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:39776) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sEkrM-0000BE-KK for submit@debbugs.gnu.org; Wed, 05 Jun 2024 03:15:01 -0400 Original-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 1sEkr8-0005Ui-Ex for bug-gnu-emacs@gnu.org; Wed, 05 Jun 2024 03:14:46 -0400 Original-Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sEkr6-0001R2-Rh for bug-gnu-emacs@gnu.org; Wed, 05 Jun 2024 03:14:46 -0400 Original-Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1f60a502bb2so15093075ad.3 for ; Wed, 05 Jun 2024 00:14:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717571682; x=1718176482; darn=gnu.org; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=AmN8iACSNXYRfOpgZI7mPcvEXs3jcAnJz6Bjl2n8jGA=; b=TmpwekTg0iyvWzUrq5SI1cwCoOZat13+GmGNKFzyLovtPPrKm945W57tg+aaDGbrW5 rP42lOpCmZCzTDuhg5iEryNF0WqgQM3ipOKcY1QKk1fen5Qdt8hsS/envFoxlw8E85fj 42kf26gTtcIz1M/2s7MijKjXlh7JYwu8sNSEs7C15auSdnThADbl/VejP9IYZ3UeGhjq 7v4oe7SCyUgMRXcPDq57ONCNpZzTKnGEqcnBkMEG+0sQR00JBnV6CPw+6PiEyGn//8Gv OsOupypqv0wCryA2toqAoyZVN28Or6WBD0CjvVEoPhPy2quy8CKpjcDXZJN0ahUDPw+m 5iyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717571682; x=1718176482; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=AmN8iACSNXYRfOpgZI7mPcvEXs3jcAnJz6Bjl2n8jGA=; b=MkyaNF2U6WDsdVMyNJN8FFcrTpgxZgly74ksRVaz2F+qtN2YbJmbsVYRW0XWCKS+xt JXenmlVNAwWguvhihO9WioUKHURP9MRqmxiVGw67Yrby2snfgbAwye8Kq8pPmPceaHsu ROtcz590p6ZBoRBx7lZRb9iyarFeUAJiBdoQwyK+Hblj/bgCpa9gq9q34EAUkwrC0FwK k6khhYV0mKGHgUZrg4KQp//VMOtWCWo1eHgUFVIEAq5O44KEUajRyy2fuvyyM3+SPvb8 LI5H1mkxvKPMOzWC0T7MhIjJmDDTCfBloWAUXPViab5oy0PW0i0Vda+JQebPUuchsJgp fRqw== X-Gm-Message-State: AOJu0YzmQU0Dc6P3oxCbnjtgecL6ubptd7nYDE8OL2rLf5HftINr8M22 rOX+bhL885N2WeFVIgvEoS0SI5oeAXPrpZUJFd/lE1lp0SlqODL1U461wHtP X-Google-Smtp-Source: AGHT+IGI0r0bioNwm/QoI29fAM2I0EpZnXA35LBDzh5rdtfonILN8VIzjHOBIupgHYROIHOApp7mLg== X-Received: by 2002:a17:903:32cf:b0:1f6:8489:d150 with SMTP id d9443c01a7336-1f6a5a04226mr20730575ad.13.1717571682261; Wed, 05 Jun 2024 00:14:42 -0700 (PDT) Original-Received: from pebl ([2001:8003:7816:8300:7f15:5962:16a0:6470]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f692ad015esm29919185ad.278.2024.06.05.00.14.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 00:14:41 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=pranshusharma366@gmail.com; helo=mail-pl1-x62d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:286580 Archived-At: --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=table.diff diff --git a/lisp/textmodes/table.el b/lisp/textmodes/table.el index 19c6a8d7c4..28401084a6 100644 --- a/lisp/textmodes/table.el +++ b/lisp/textmodes/table.el @@ -697,6 +697,19 @@ table-word-continuation-char :type 'character :group 'table) +(defcustom table-source-latex-escape-characters (cons "[#$~_^%{}&]" t) + "A cons cell containing which charecters to escape in the latex source +of `table-generate-source'. The head of the list, if non-nil contains a +regexp that matches all text that is to be adding a preceding backslash +to the matching text. If nil, no non-backslash charecters will be +escaped. The tail, if non-nil, escapes all the backslashes in the latex +source." + :tag "Source Latex Escape Charecters Regexp" + :type '(cons (radio (regexp :tag "regexp") + (const :tag "Off" nil)) + boolean) + :group 'table) + (defcustom table-detect-cell-alignment t "Detect cell contents alignment automatically. When non-nil cell alignment is automatically determined by the @@ -3264,19 +3277,29 @@ table--generate-source-scan-lines (lambda (from to) (let ((line (table--buffer-substring-and-trim (table--goto-coordinate (cons from y)) - (table--goto-coordinate (cons to y))))) + (table--goto-coordinate (cons to y)))) + (escape-char-reg + (apply 'concat (append (and (car table-source-latex-escape-characters) + (list "\\(" + (car table-source-latex-escape-characters) + "\\)" + (and (cdr table-source-latex-escape-characters) + "\\|"))) + (and (cdr table-source-latex-escape-characters) + (list"\\(\\\\\\)")))))) ;; escape special characters (with-temp-buffer (insert line) (goto-char (point-min)) - (while (re-search-forward "\\([#$~_^%{}&]\\)\\|\\(\\\\\\)\\|\\([<>|]\\)" nil t) - (if (match-beginning 1) - (save-excursion - (goto-char (match-beginning 1)) - (insert "\\")) - (if (match-beginning 2) - (replace-match "$\\backslash$" t t) - (replace-match (concat "$" (match-string 3) "$")) t t))) + (when (or (car table-source-latex-escape-characters) + (cdr table-source-latex-escape-characters)) + (while (re-search-forward escape-char-reg nil t) + (if (and (car table-source-latex-escape-characters) + (match-beginning 1)) + (save-excursion + (goto-char (match-beginning 1)) + (insert "\\")) + (replace-match "$\\backslash$" t t)))) (setq line (buffer-substring (point-min) (point-max)))) ;; insert a column separator and column/multicolumn contents (with-current-buffer dest-buffer --=-=-= Content-Type: text/plain Currently in table.el, charecters such as '$' sign are escaped. This diff adds a variable which can control what is escaped or not. Since a backslash is escaped in a different way to other charecters in latex, the variable had to be a cons cell of a regexp and bool. --=-=-=--