bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#23566: 25.0.94; sql-sqlite: selecting database file is crippled


From: rolf
Subject: bug#23566: 25.0.94; sql-sqlite: selecting database file is crippled
Date: Tue, 17 May 2016 22:02:49 +0200

The problem is in 24.5.1 as well as in current 25.1 branch. (Note: you
don't need to use sqlite or have it (and a database file) on your disk,
to see the problem.)


To reproduce:

- Start emacs -Q

- M-x sql-sqlite

This prompts the user to specify a sqlite database file in the
minibuffer. 

Lets assume, you have a sqlite database file in /var/tmp (you don't
actually have to, that's just a path that is assumed to exist at least
on a lot of unix systems).

Try to navigate there in the minibuffer prompt: Remove everthing and
start typing /v, then <Tab> for completion. The prompt doesn't complete
nor provides multiple alternatives, if what you have already typed isn't
unambiguous. You have to spell out (mean: type in) every character of
the path.

(Note: This is only one simple way, to stumble about the problem. It
raises its head also, if you put a buffer in sql-mode, select product
"sqlite" and open a sqli buffer (C-c Tab))

This problem has his roots in the combination of the default value of
the variable sql-sqlite-login-params (which itself is debatable, but
this is not the main point of this bug report) and the implementation of 
sql-get-login-ext, which is called behind the scene, as part of the
implementation of sql-sqlite.

The default value of sql-sqlite-login-params is:
((database :file ".*\\.\\(db\\|sqlite[23]?\\)"))

The crucial part of sql-get-login-ext for this bug report is:

     (cond
      ((plist-member plist :file)
       (expand-file-name
        (read-file-name prompt
                        (file-name-directory last-value) default t
                        (file-name-nondirectory last-value)
                        (when (plist-get plist :file)
                          `(lambda (f)
                             (string-match
                              (concat "\\<" ,(plist-get plist :file) "\\>")
                              (file-name-nondirectory f)))))))
      <more conditions follow>
       
Look at the params of the used read-file-name. Since there is a :file
property in the sql-sqlite-login-params default value, the
read-file-name has a PREDICATE argument, the lambda function

                          `(lambda (f)
                             (string-match
                              (concat "\\<" ,(plist-get plist :file) "\\>")
                              (file-name-nondirectory f)))))))

read-file-name will call this function for every completion candidate
(thats the f argument). The function will return nil for almost all
directory names and most file names (all, that doesn't end in
.db|.sqlite2|.sqlite3), which means they are ruled out as possible
completion candiates. Therefor, tab completion of a sub path doesn't
work, as shown above.

If ever, that cond condition should look like:

      ((plist-member plist :file)
       (expand-file-name
        (read-file-name prompt
                        (file-name-directory last-value) default t
                        (file-name-nondirectory last-value)
                        (when (plist-get plist :file)
                          `(lambda (f)
                             (if (not(file-regular-p))
                                 t
                               (string-match
                                 (concat "\\<" ,(plist-get plist :file) "\\>")
                                 (file-name-nondirectory f))))))))

Note the modification in the lambda function: check for the file name
pattern only, if the completion candidate is a regular file. Everything
else - especially directory names - are valid completion candidates.




In GNU Emacs 25.0.94.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.10)
 of 2016-05-17 built on linux-qg7d
Repository revision: a35826dbd44122b97e93d0c67bf658ced0a07ec6
Windowing system distributor 'The X.Org Foundation', version 11.0.11203000
System Description:     openSUSE 12.2 (x86_64)

Configured using:
 'configure --with-modules'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY
LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK2 X11 MODULES

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=local
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Making completion list...
Quit
Making completion list... [2 times]

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message dired format-spec rfc822 mml
mml-sec password-cache epg epg-config gnus-util mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util help-fns help-mode mail-prsvr
mail-utils sql easymenu view thingatpt comint ansi-color ring
cl-loaddefs pcase cl-lib time-date mule-util tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win
term/common-win x-dnd 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
dbusbind inotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 93084 4930)
 (symbols 48 20431 0)
 (miscs 40 39 121)
 (strings 32 16670 4379)
 (string-bytes 1 518027)
 (vectors 16 12706)
 (vector-slots 8 436890 4797)
 (floats 8 171 172)
 (intervals 56 207 0)
 (buffers 976 12)
 (heap 1024 22938 671))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]