From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Nesa K Newsgroups: gmane.emacs.bugs Subject: Re: bug#24483: 25.1; sql-mode error due to nil prompt-cont-regexp Date: Thu, 18 Jan 2018 13:52:59 -0800 (PST) Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1516314677 2471 195.159.176.226 (18 Jan 2018 22:31:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 18 Jan 2018 22:31:17 +0000 (UTC) Injection-Date: Thu, 18 Jan 2018 21:53:00 +0000 User-Agent: G2/1.0 To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jan 18 23:31:13 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ecIiD-00007R-Ro for geb-bug-gnu-emacs@m.gmane.org; Thu, 18 Jan 2018 23:31:10 +0100 Original-Received: from localhost ([::1]:60089 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecIkD-0007i1-Pt for geb-bug-gnu-emacs@m.gmane.org; Thu, 18 Jan 2018 17:33:13 -0500 X-Received: by 10.200.17.20 with SMTP id c20mr13344367qtj.57.1516312380126; Thu, 18 Jan 2018 13:53:00 -0800 (PST) X-Received: by 10.31.49.86 with SMTP id x83mr288382vkx.0.1516312379876; Thu, 18 Jan 2018 13:52:59 -0800 (PST) Original-Path: usenet.stanford.edu!i22no4263541qta.1!news-out.google.com!e39ni1594qtk.1!nntp.google.com!i22no4263539qta.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.bug In-Reply-To: Complaints-To: groups-abuse@google.com Original-Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=71.19.161.130; posting-account=ASHE6woAAABFPTwBA6TBXdnNbuGYjfAG Original-NNTP-Posting-Host: 71.19.161.130 Original-Xref: usenet.stanford.edu gnu.emacs.bug:160548 X-Mailman-Approved-At: Thu, 18 Jan 2018 17:33:04 -0500 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:142277 Archived-At: On Tuesday, September 20, 2016 at 1:50:11 PM UTC-4, Michael Kleehammer wrot= e: > It looks like sql-interactive-remove-continuation-prompt needs to explici= tly check for a nil sql-prompt-cont-regexp, which is the default value for = some SQL products. >=20 > In particular, this line marked with an arrow on the left needs a guard: >=20 > (when (and comint-prompt-regexp > (or (> (length (or sql-preoutput-hold "")) 0) > (> (or sql-output-newline-count 0) 0) > (not (or (string-match sql-prompt-regexp oline) > --> (string-match sql-prompt-cont-regexp oline)))= )) >=20 > In my case I am using a custom "SQL product" for a SQL Server command > line utility which prints "Connected to xyzzy\n" on startup but there > are some standard "products" that also don't have a prompt-cont-regexp > set. >=20 > It should be easy to reproduce using "ansi", but here is how I > reproduced it with PostgreSQL: >=20 > 1) Set the PostgreSQL regexp to nil: >=20 > (sql-set-product-feature 'postgres :prompt-cont-regexp nil) >=20 > 2) Make sure psql prints something on connect. I have this in my > ~/.psqlrc: >=20 > \pset null =C2=A4 >=20 > When you open a connection using sql-postgres you'll get: >=20 > error in process filter: sql-interactive-remove-continuation-prompt: = Wrong type argument: stringp, nil > error in process filter: Wrong type argument: stringp, nil >=20 > This is new in 25.1. I used 24.5 and did not have this issue.=20 >=20 > Thanks, > Michael Kleehammer > michael@kleehammer.com >=20 >=20 > In GNU Emacs 25.1.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version= 10.9.5 (Build 13F1911)) > of 2016-09-17 built on builder10-9.porkrind.org > Windowing system distributor 'Apple', version 10.3.1504 > Configured using: > 'configure --with-ns '--enable-locallisppath=3D/Library/Application > Support/Emacs/${version}/site-lisp:/Library/Application > Support/Emacs/site-lisp'' >=20 > Configured features: > NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS >=20 > Important settings: > value of $LANG: en_US.UTF8 > locale-coding-system: utf-8-unix >=20 > Major mode: Emacs-Lisp >=20 > Minor modes in effect: > diff-auto-refine-mode: t > magit-auto-revert-mode: t > global-git-commit-mode: t > shell-dirtrack-mode: t > ws-butler-global-mode: t > ws-butler-mode: t > yas-global-mode: t > yas-minor-mode: t > ido-vertical-mode: t > flx-ido-mode: t > ido-everywhere: t > global-undo-tree-mode: t > undo-tree-mode: t > projectile-global-mode: t > projectile-mode: t > recentf-mode: t > pcre-mode: t > drag-stuff-global-mode: t > drag-stuff-mode: t > delete-selection-mode: t > cua-mode: t > highlight-changes-visible-mode: t > show-paren-mode: t > global-linum-mode: t > linum-mode: t > override-global-mode: t > global-eldoc-mode: t > electric-indent-mode: t > mouse-wheel-mode: t > menu-bar-mode: t > file-name-shadow-mode: t > global-font-lock-mode: t > font-lock-mode: t > auto-composition-mode: t > auto-encryption-mode: t > auto-compression-mode: t > column-number-mode: t > line-number-mode: t > transient-mark-mode: t >=20 > Recent messages: > buf: nil > Login...done > w # > Quit > uncompressing sql.el.gz...done > Mark saved where search started > Mark set > Mark saved where search started [4 times] > Mark set > Quit >=20 > Load-path shadows: > /Users/mkleehammer/.emacs.d/misc/expand-region/web-mode-expansions hides = /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/web-mode-expansions > /Users/mkleehammer/.emacs.d/misc/expand-region/the-org-mode-expansions hi= des /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/the-org-mode-expa= nsions > /Users/mkleehammer/.emacs.d/misc/expand-region/text-mode-expansions hides= /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/text-mode-expansions > /Users/mkleehammer/.emacs.d/misc/expand-region/sml-mode-expansions hides = /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/sml-mode-expansions > /Users/mkleehammer/.emacs.d/misc/expand-region/ruby-mode-expansions hides= /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/ruby-mode-expansions > /Users/mkleehammer/.emacs.d/misc/expand-region/python-mode-expansions hid= es /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/python-mode-expans= ions > /Users/mkleehammer/.emacs.d/misc/expand-region/python-el-fgallina-expansi= ons hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/python-el-f= gallina-expansions > /Users/mkleehammer/.emacs.d/misc/expand-region/python-el-expansions hides= /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/python-el-expansions > /Users/mkleehammer/.emacs.d/misc/expand-region/octave-expansions hides /U= sers/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/octave-expansions > /Users/mkleehammer/.emacs.d/misc/expand-region/nxml-mode-expansions hides= /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/nxml-mode-expansions > /Users/mkleehammer/.emacs.d/misc/expand-region/latex-mode-expansions hide= s /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/latex-mode-expansio= ns > /Users/mkleehammer/.emacs.d/misc/expand-region/jsp-expansions hides /User= s/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/jsp-expansions > /Users/mkleehammer/.emacs.d/misc/expand-region/js2-mode-expansions hides = /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/js2-mode-expansions > /Users/mkleehammer/.emacs.d/misc/expand-region/js-mode-expansions hides /= Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/js-mode-expansions > /Users/mkleehammer/.emacs.d/misc/expand-region/html-mode-expansions hides= /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/html-mode-expansions > /Users/mkleehammer/.emacs.d/misc/expand-region/feature-mode-expansions hi= des /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/feature-mode-expa= nsions > /Users/mkleehammer/.emacs.d/misc/expand-region/expand-region hides /Users= /mkleehammer/.emacs.d/elpa/expand-region-0.10.0/expand-region > /Users/mkleehammer/.emacs.d/misc/expand-region/expand-region-pkg hides /U= sers/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/expand-region-pkg > /Users/mkleehammer/.emacs.d/misc/expand-region/expand-region-custom hides= /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/expand-region-custom > /Users/mkleehammer/.emacs.d/misc/expand-region/expand-region-core hides /= Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/expand-region-core > /Users/mkleehammer/.emacs.d/misc/expand-region/erlang-mode-expansions hid= es /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/erlang-mode-expans= ions > /Users/mkleehammer/.emacs.d/misc/expand-region/er-basic-expansions hides = /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/er-basic-expansions > /Users/mkleehammer/.emacs.d/misc/expand-region/enh-ruby-mode-expansions h= ides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/enh-ruby-mode-ex= pansions > /Users/mkleehammer/.emacs.d/misc/expand-region/css-mode-expansions hides = /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/css-mode-expansions > /Users/mkleehammer/.emacs.d/misc/expand-region/cperl-mode-expansions hide= s /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/cperl-mode-expansio= ns > /Users/mkleehammer/.emacs.d/misc/expand-region/clojure-mode-expansions hi= des /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/clojure-mode-expa= nsions > /Users/mkleehammer/.emacs.d/misc/expand-region/cc-mode-expansions hides /= Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/cc-mode-expansions > /Users/mkleehammer/.emacs.d/misc/undo-tree hides /Users/mkleehammer/.emac= s.d/elpa/undo-tree-0.6.5/undo-tree > /Users/mkleehammer/.emacs.d/misc/python hides /Applications/Emacs.app/Con= tents/Resources/lisp/progmodes/python > /Users/mkleehammer/.emacs.d/elpa/seq-2.16/seq hides /Applications/Emacs.a= pp/Contents/Resources/lisp/emacs-lisp/seq >=20 > Features: > (shadow sort mail-extr emacsbug sendmail pp timezone parse-time > jka-compr shr-color color network-stream nsm starttls url-http tls > gnutls url-gw url-auth eww mm-url gnus gnus-ems nnheader url-queue shr > dom browse-url less-css-mode css-mode smie derived wdired web-mode > disp-table dabbrev misearch multi-isearch smex magit-blame magit-stash > magit-bisect magit-remote magit-commit magit-sequence magit magit-apply > magit-wip magit-log magit-diff smerge-mode diff-mode magit-core > magit-autorevert autorevert filenotify magit-process magit-popup > magit-mode magit-git crm magit-section magit-utils git-commit log-edit > message rfc822 mml mml-sec epg mm-decode mm-bodies mm-encode mail-parse > rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev mail-utils gmm-utils > mailheader pcvs-util add-log with-editor async-bytecomp async python > tramp-sh tramp tramp-compat tramp-loaddefs trampver shell format-spec > dired-aux server sunshine url-cache url url-proxy url-privacy url-expand > url-methods url-history url-cookie url-domsuf url-util url-parse > auth-source gnus-util mm-util help-fns mail-prsvr password-cache > url-vars mailcap cal-china lunar solar cal-dst cal-bahai cal-islam > cal-hebrew holidays hol-loaddefs appt diary-lib diary-loaddefs cal-menu > calendar cal-loaddefs sql view tea-time pcomplete esh-var esh-io esh-cmd > esh-opt esh-ext esh-proc esh-arg esh-groups eshell esh-module esh-mode > esh-util js2-mode etags xref project eieio eieio-core js sgml-mode > cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine > cc-vars cc-defs imenu ws-butler whitespace yasnippet cl browse-kill-ring > avy ido-vertical-mode ido-ubiquitous cl-seq ido-completing-read+ > cus-edit flx-ido flx ido undo-tree iedit iedit-lib flycheck json map > find-func subr-x projectile ibuf-ext ibuffer dash thingatpt recentf > tree-widget pcre2el rxt cl-macs re-builder rx drag-stuff > whole-line-or-region align2 edmacro kmacro wgrep reveal-in-osx-finder > dired-x dired exec-path-from-shell delsel cua-base hydra lv hilit-chg > wid-edit paren avoid linum zenburn-theme use-package diminish bind-key > easy-mmode finder-inf advice info package epg-config seq byte-opt gv > bytecomp byte-compile cl-extra help-mode easymenu cconv cl-loaddefs > pcase cl-lib grep compile comint ansi-color ring cus-start cus-load > time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks > lisp-float-type mwheel ns-win ucs-normalize term/common-win tool-bar dnd > fontset image regexp-opt fringe tabulated-list newcomment elisp-mode > lisp-mode prog-mode register page menu-bar rfn-eshadow timer select > scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame > cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai > tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian > slovak czech european ethiopic indian cyrillic chinese charscript > case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer > cl-preloaded nadvice loaddefs button faces cus-face macroexp files > text-properties overlay sha1 md5 base64 format env code-pages mule > custom widget hashtable-print-readable backquote kqueue cocoa ns > multi-tty make-network-process emacs) >=20 > Memory information: > ((conses 16 764072 122496) > (symbols 48 50260 0) > (miscs 40 1811 957) > (strings 32 147544 5627) > (string-bytes 1 4555893) > (vectors 16 105142) > (vector-slots 8 2292082 293693) > (floats 8 12056 11134) > (intervals 56 19325 3290) > (buffers 976 43)) The bug is present in emacs version 25.3.1 as well. The same error happens = if I use sql-ms mode. As Michael noted the error happens within sql-interac= tive-remove-continuation-prompt (oline) function at the line he marked with= an arrow above.=20 I was able to workaround the bug by overriding the function in my .emacs fi= le with the following code: (eval-after-load "sql" '(defun sql-interactive-remove-continuation-prompt (oline) "Strip out continuation prompts out of the OLINE. Added to the `comint-preoutput-filter-functions' hook in a SQL interactive buffer. If `sql-output-newline-count' is greater than zero, then an output line matching the continuation prompt is filtered out. If the count is zero, then a newline is inserted into the output to force the output from the query to appear on a new line. The complication to this filter is that the continuation prompts may arrive in multiple chunks. If they do, then the function saves any unfiltered output in a buffer and prepends that buffer to the next chunk to properly match the broken-up prompt. If the filter gets confused, it should reset and stop filtering to avoid deleting non-prompt output." ;; continue gathering lines of text iff ;; + we know what a prompt looks like, and ;; + there is held text, or ;; + there are continuation prompt yet to come, or ;; + not just a prompt string (when (and comint-prompt-regexp (or (> (length (or sql-preoutput-hold "")) 0) (> (or sql-output-newline-count 0) 0) (not (or (string-match sql-prompt-regexp oline) (and sql-prompt-cont-regexp (string-match sql-prompt-cont-regexp olin= e)))))) (save-match-data (let (prompt-found last-nl) ;; Add this text to what's left from the last pass (setq oline (concat sql-preoutput-hold oline) sql-preoutput-hold "") ;; If we are looking for multiple prompts (when (and (integerp sql-output-newline-count) (>=3D sql-output-newline-count 1)) ;; Loop thru each starting prompt and remove it (let ((start-re (sql-starts-with-prompt-re))) (while (and (not (string=3D oline "")) (> sql-output-newline-count 0) (string-match start-re oline)) (setq oline (replace-match "" nil nil oline) sql-output-newline-count (1- sql-output-newline-coun= t) prompt-found t))) ;; If we've found all the expected prompts, stop looking (if (=3D sql-output-newline-count 0) (setq sql-output-newline-count nil oline (concat "\n" oline)) ;; Still more possible prompts, leave them for the next pass (setq sql-preoutput-hold oline oline ""))) ;; If no prompts were found, stop looking (unless prompt-found (setq sql-output-newline-count nil oline (concat oline sql-preoutput-hold) sql-preoutput-hold "")) ;; Break up output by physical lines if we haven't hit the final= prompt (let ((end-re (sql-ends-with-prompt-re))) (unless (and (not (string=3D oline "")) (string-match end-re oline) (>=3D (match-end 0) (length oline))) ;; Find everything upto the last nl (setq last-nl 0) (while (string-match "\n" oline last-nl) (setq last-nl (match-end 0))) ;; Hold after the last nl, return upto last nl (setq sql-preoutput-hold (concat (substring oline last-nl) sql-preoutput-hold) oline (substring oline 0 last-nl))))))) oline))