[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug#24483: 25.1; sql-mode error due to nil prompt-cont-regexp
From: |
Nesa K |
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) |
User-agent: |
G2/1.0 |
On Tuesday, September 20, 2016 at 1:50:11 PM UTC-4, Michael Kleehammer wrote:
> It looks like sql-interactive-remove-continuation-prompt needs to explicitly
> check for a nil sql-prompt-cont-regexp, which is the default value for some
> SQL products.
>
> In particular, this line marked with an arrow on the left needs a guard:
>
> (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)))))
>
> 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.
>
> It should be easy to reproduce using "ansi", but here is how I
> reproduced it with PostgreSQL:
>
> 1) Set the PostgreSQL regexp to nil:
>
> (sql-set-product-feature 'postgres :prompt-cont-regexp nil)
>
> 2) Make sure psql prints something on connect. I have this in my
> ~/.psqlrc:
>
> \pset null ยค
>
> When you open a connection using sql-postgres you'll get:
>
> error in process filter: sql-interactive-remove-continuation-prompt:
> Wrong type argument: stringp, nil
> error in process filter: Wrong type argument: stringp, nil
>
> This is new in 25.1. I used 24.5 and did not have this issue.
>
> Thanks,
> Michael Kleehammer
> michael@kleehammer.com
>
>
> 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=/Library/Application
> Support/Emacs/${version}/site-lisp:/Library/Application
> Support/Emacs/site-lisp''
>
> Configured features:
> NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS
>
> Important settings:
> value of $LANG: en_US.UTF8
> locale-coding-system: utf-8-unix
>
> Major mode: Emacs-Lisp
>
> 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
>
> Recent messages:
> buf: nil
> Login...done
> w #<window 21 on sqlwchar.cpp>
> Quit
> uncompressing sql.el.gz...done
> Mark saved where search started
> Mark set
> Mark saved where search started [4 times]
> Mark set
> Quit
>
> 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 hides
> /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/the-org-mode-expansions
> /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 hides
> /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/python-mode-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/python-el-fgallina-expansions
> hides
> /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/python-el-fgallina-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
> /Users/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 hides
> /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/latex-mode-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/jsp-expansions hides
> /Users/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 hides
> /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/feature-mode-expansions
> /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
> /Users/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 hides
> /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/erlang-mode-expansions
> /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 hides
> /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/enh-ruby-mode-expansions
> /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 hides
> /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/cperl-mode-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/clojure-mode-expansions hides
> /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/clojure-mode-expansions
> /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/.emacs.d/elpa/undo-tree-0.6.5/undo-tree
> /Users/mkleehammer/.emacs.d/misc/python hides
> /Applications/Emacs.app/Contents/Resources/lisp/progmodes/python
> /Users/mkleehammer/.emacs.d/elpa/seq-2.16/seq hides
> /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/seq
>
> 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)
>
> 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-interactive-remove-continuation-prompt (oline) function at the line he
marked with an arrow above.
I was able to workaround the bug by overriding the function in my .emacs file
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
oline))))))
(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)
(>= 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= 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-count)
prompt-found t)))
;; If we've found all the expected prompts, stop looking
(if (= 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= oline ""))
(string-match end-re oline)
(>= (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))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: bug#24483: 25.1; sql-mode error due to nil prompt-cont-regexp,
Nesa K <=