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#71364: Fix Table.el export Date: Tue, 04 Jun 2024 21:22:00 +1000 Message-ID: <8734ptj6lj.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="27728"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 71364@debbugs.gnu.org To: pranshusharma366@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jun 04 16:44:04 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 1sEVOO-000750-1F for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 04 Jun 2024 16:44:04 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEVOG-0003nw-Iy; Tue, 04 Jun 2024 10:43:58 -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 1sEVO9-0003nS-6y for bug-gnu-emacs@gnu.org; Tue, 04 Jun 2024 10:43:49 -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 1sEVO8-0008Vj-VN for bug-gnu-emacs@gnu.org; Tue, 04 Jun 2024 10:43:48 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sEVOM-0000Ji-CA for bug-gnu-emacs@gnu.org; Tue, 04 Jun 2024 10:44:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Pranshu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 04 Jun 2024 14:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 71364 X-GNU-PR-Package: emacs X-Debbugs-Original-Cc: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.17175122011084 (code B ref -1); Tue, 04 Jun 2024 14:44:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 4 Jun 2024 14:43:21 +0000 Original-Received: from localhost ([127.0.0.1]:56971 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sEVNh-0000HO-1U for submit@debbugs.gnu.org; Tue, 04 Jun 2024 10:43:21 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:43296) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sESFC-0001n7-Cy for submit@debbugs.gnu.org; Tue, 04 Jun 2024 07:22:23 -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 1sESEy-0002hk-M9 for bug-gnu-emacs@gnu.org; Tue, 04 Jun 2024 07:22:08 -0400 Original-Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sESEw-0003Ng-MI for bug-gnu-emacs@gnu.org; Tue, 04 Jun 2024 07:22:08 -0400 Original-Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-70260814b2dso1957755b3a.1 for ; Tue, 04 Jun 2024 04:22:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717500124; x=1718104924; darn=gnu.org; h=mime-version:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=vQ4k26oI03mKioJc2IiC5YGRd91x9AV9tvaLy/bk3Tg=; b=E6hy1nN67GDJjMfp9zp7Ao0X/PxqQ3XkW5h9gvNnBUKGc3FF4oGM5IENY28ljgOXjo TDXdkXeBqZCXVL3r4hZ7eArLEXzvWu3GOLAEYyDIHeiSJYjVTAp5u2k0BVwEOg8P4FFl wlBQO+7LEE3E33i+uBG7dt8dk2s1tRAh7CJDjrVgpmCx+moua+RYAsGS5WyP1minBmyQ 00oCZhJk8BSIrLXhshavuRTtJ1CUbWik6CMpFk5eGFMuKIjZDiLNANn90VwyeuiDsHlF MevUOKK/QbSzSJByzh1Sq3kmpGuhklAfxIK94NoQs3Se5sIYO2XIDwbY7pwycW3XnrIJ 6vTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717500124; x=1718104924; h=mime-version:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=vQ4k26oI03mKioJc2IiC5YGRd91x9AV9tvaLy/bk3Tg=; b=al0cM7Y4R/fSC+BmPzR2xU8YD4AAVHkmd+KcIyM+4yjPbIt2hjuZEcxjeWH+Xy80Dq reeKkuN39b1vJSspj9xuzKkUs3puAcKtQWXHMNJukzRbsc2kV6ChAPn3+LYTnyU9v4Gu LGCM+BT8SqVV+lvtAnQuwOU+Ag/wk3994+ZtNknw869PGs1jq+lESRCWp3x5csa4JKTC 5mCwPuQMJBre2S+f2D8CRqEXtQ7KJDEOSEVxvpmAtsz6j9I8A5RvTZLRtbPmK0yWZDEz PZu+aaHFmmYIjFliATmGaF2AFF1s0cetCLAE0L0MQpqzCoay7R7C3nVEzhUezRMex63w iGdw== X-Gm-Message-State: AOJu0YzDhsHsKpm8sKzh6i00hm6DasaS77OsV+0FFtgFWoa7wXL0Fp9Z xYgxhtj2glzxrnqVcF5+U0YClse4G6PwR7Z1GYwus1gd7TFLL4Lv222ZFwno X-Google-Smtp-Source: AGHT+IFmfvw8NLO7pOGPaGfJkrY34KPi0JyrjOy49DxjJKO4VrF1GQV7ILT7tKer8rvIXQeMpd16vw== X-Received: by 2002:a05:6a20:9155:b0:1ac:dead:68 with SMTP id adf61e73a8af0-1b2a3433f28mr3406314637.24.1717500123781; Tue, 04 Jun 2024 04:22:03 -0700 (PDT) Original-Received: from pebl ([2001:8003:7816:8300:7f15:5962:16a0:6470]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70242b300e8sm6825782b3a.210.2024.06.04.04.22.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 04:22:03 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=pranshusharma366@gmail.com; helo=mail-pf1-x431.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-Mailman-Approved-At: Tue, 04 Jun 2024 10:43:20 -0400 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:286546 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 Hello all, When table.el exports to latex, charecters like '$' are all escaped. This makes table.el tables practically useless for any sorts of latex export. Attached is a diff that adds a variable that controls what should be escaped. Kind Regards, Pranshu --=-=-=--