Skip to content

Commit b9b6acb

Browse files
author
Jason Duncan
committed
Using string-trim rather than my own custom version of the same.
1 parent 38b6248 commit b9b6acb

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

TODO.org

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
** TODO Some docstrings are quite long which lets you pass package-lint and makes for good enough M-x apropos output, but they wrap poorly in M-x help.
22
** DONE "delimiater" -> "delimiter"
3-
** TODO Since you're using Emacs 25 you can use the string-trim functions (could format-table-trim-row be rewritten as just (string-trim row begin-row end-row)?
3+
** DONE Since you're using Emacs 25 you can use the string-trim functions (could format-table-trim-row be rewritten as just (string-trim row begin-row end-row)?
44
** TODO Could the first conditional in format-table-remove-noise be written either as:
55

66
#+BEGIN_SRC emacs-lisp

format-table.el

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,12 @@
106106
(if (plist-get input-mode :top-border-fn)
107107
(-slice ret 0 (1- (length ret))) ret))))
108108

109-
(defun format-table-trim-row (row begin-row end-row)
110-
"Given the string ROW trim the string BEGIN-ROW from the beginning and END-ROW from the end."
111-
(replace-regexp-in-string
112-
(concat "^" (regexp-quote begin-row))
113-
""
114-
(replace-regexp-in-string
115-
(concat (regexp-quote end-row) "$")
116-
""
117-
row)))
118-
119109
(defun format-table-get-col-widths (dashes input-mode)
120110
"Using the line of all DASHES from the table and the INPUT-MODE, determine the widths of the columns and return them in a list."
121-
(let* ((separator-begin-row (plist-get input-mode :separator-begin-row))
122-
(separator-end-row (plist-get input-mode :separator-end-row))
111+
(let* ((separator-begin-row (regexp-quote (plist-get input-mode :separator-begin-row)))
112+
(separator-end-row (regexp-quote (plist-get input-mode :separator-end-row)))
123113
(separator-col-separator (plist-get input-mode :separator-col-separator))
124-
(dashes (format-table-trim-row dashes separator-begin-row separator-end-row)))
114+
(dashes (string-trim dashes separator-begin-row separator-end-row)))
125115
(-map #'length (split-string dashes
126116
(regexp-quote separator-col-separator)))))
127117

@@ -130,7 +120,7 @@
130120
(let* ((begin-row (plist-get input-mode :begin-row))
131121
(end-row (plist-get input-mode :end-row))
132122
(col-separator (plist-get input-mode :col-separator))
133-
(row (format-table-trim-row row begin-row end-row))
123+
(row (string-trim row begin-row end-row))
134124
split)
135125
(reverse
136126
(dolist (cur-width col-widths split)

0 commit comments

Comments
 (0)