]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve sqlite-mode--tablify tables
authorLars Ingebrigtsen <larsi@gnus.org>
Sat, 11 Dec 2021 05:50:58 +0000 (06:50 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Sat, 11 Dec 2021 05:50:58 +0000 (06:50 +0100)
* lisp/sqlite-mode.el (sqlite-mode--tablify): Tweak column widths
and sanitize newlines.

lisp/sqlite-mode.el

index 9edb85b61abc451bb79dbd708e4887d872845818..e33a040f7ed5998a1b7128e2ae8104a418948ffa 100644 (file)
@@ -76,7 +76,7 @@
     (when prefix
       (insert prefix))
     (dotimes (i (length widths))
-      (insert (propertize (format (format "%%-%ds" (nth i widths))
+      (insert (propertize (format (format "%%-%ds " (nth i widths))
                                   (nth i columns))
                           'face 'header-line)))
     (insert "\n")
         (when prefix
           (insert prefix))
         (dotimes (i (length widths))
-          (insert (format (format "%%%s%ds"
-                                  (if (numberp (nth i row))
-                                      "" "-")
-                                  (nth i widths))
-                          (or (nth i row) ""))))
+          (let ((elem (nth i row)))
+            (insert (format (format "%%%s%ds "
+                                    (if (numberp elem)
+                                        "" "-")
+                                    (nth i widths))
+                            (if (numberp elem)
+                                (nth i row)
+                              (string-replace "\n" " " (or elem "")))))))
         (put-text-property start (point) 'sqlite--row row)
         (insert "\n")))))