From 5dcb98705bf7404d73dfdb9d5d64a384f99fb534 Mon Sep 17 00:00:00 2001 From: Yoav Marco Date: Wed, 11 May 2022 13:42:04 +0300 Subject: [PATCH] * lisp/sqlite-mode.el (sqlite-mode--column-names): Suppport nested parens Copyright-paperwork-exempt: yes --- lisp/sqlite-mode.el | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lisp/sqlite-mode.el b/lisp/sqlite-mode.el index ba1b81ef..8cdff96d 100644 --- a/lisp/sqlite-mode.el +++ b/lisp/sqlite-mode.el @@ -129,15 +129,21 @@ sqlite-mode-list-columns (insert (format " %s\n" column)))))))) (defun sqlite-mode--column-names (table) - (let ((sql - (caar - (sqlite-select - sqlite--db - "select sql from sqlite_master where tbl_name = ? AND type = 'table'" - (list table))))) - (mapcar - #'string-trim - (split-string (replace-regexp-in-string "^.*(\\|)$" "" sql) ",")))) + "Return a list of the column names for TABLE." + (let ((sql (caar + (sqlite-select + sqlite--db + "select sql from sqlite_master where tbl_name = ? AND type = 'table'" + (list table))))) + (with-temp-buffer + (insert sql) + (mapcar #'string-trim + (split-string + ;; Extract the args to CREATE TABLE. Point is currently at its end + (buffer-substring + (1- (point)) ; right before ) + (1+ (progn (backward-sexp) (point)))) ; right after ( + ","))))) (defun sqlite-mode-list-data () "List the data from the table under point." -- 2.35.3