* bug#71375: 30.0.50
@ 2024-06-05 7:14 Pranshu
2024-06-05 9:13 ` Andrea Corallo
0 siblings, 1 reply; 2+ messages in thread
From: Pranshu @ 2024-06-05 7:14 UTC (permalink / raw)
To: 71375
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: table.diff --]
[-- Type: text/x-diff, Size: 3649 bytes --]
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
[-- Attachment #2: Type: text/plain, Size: 270 bytes --]
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.
^ permalink raw reply related [flat|nested] 2+ messages in thread
* bug#71375: 30.0.50
2024-06-05 7:14 bug#71375: 30.0.50 Pranshu
@ 2024-06-05 9:13 ` Andrea Corallo
0 siblings, 0 replies; 2+ messages in thread
From: Andrea Corallo @ 2024-06-05 9:13 UTC (permalink / raw)
To: Pranshu; +Cc: 71375
Pranshu <pranshusharma366@gmail.com> writes:
> 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.
Hi Pranshu,
I think you sent this by mistake twice, I'm merging it with 71364.
Andrea
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-05 9:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-05 7:14 bug#71375: 30.0.50 Pranshu
2024-06-05 9:13 ` Andrea Corallo
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).