unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* sql-automatic-login
@ 2008-02-29 11:52 Andreas Röhler
  0 siblings, 0 replies; only message in thread
From: Andreas Röhler @ 2008-02-29 11:52 UTC (permalink / raw)
  To: Michael Mauger; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 292 bytes --]


Hi,

using sql-mysql, I'd prefer to login without being
queried, if default values are customised.

Couldn't see it in the code, so here a diff for that.

A new introduced variable `sql-automatic-login'
provides such thing doesn't happen inadvertently.

Thanks

Andreas Röhler

[-- Attachment #2: sql.diff --]
[-- Type: text/x-diff, Size: 2477 bytes --]

--- alt/sql.el	2007-09-26 02:28:25.000000000 +0200
+++ neu/sql.el	2008-02-29 12:28:49.000000000 +0100
@@ -246,6 +246,12 @@
 
 ;; These four variables will be used as defaults, if set.
 
+(defcustom sql-automatic-login  t 
+ "Login from default values without query" 
+
+:type 'boolean
+:group 'SQL)
+
 (defcustom sql-user ""
   "*Default username."
   :type 'string
@@ -1929,37 +1935,40 @@
 
 (defun sql-get-login (&rest what)
   "Get username, password and database from the user.
-
 The variables `sql-user', `sql-password', `sql-server', and
 `sql-database' can be customized.  They are used as the default values.
 Usernames, servers and databases are stored in `sql-user-history',
 `sql-server-history' and `database-history'.  Passwords are not stored
 in a history.
-
 Parameter WHAT is a list of the arguments passed to this function.
 The function asks for the username if WHAT contains symbol `user', for
 the password if it contains symbol `password', for the server if it
 contains symbol `server', and for the database if it contains symbol
 `database'.  The members of WHAT are processed in the order in which
 they are provided.
-
 In order to ask the user for username, password and database, call the
 function like this: (sql-get-login 'user 'password 'database)."
   (interactive)
   (while what
     (cond
-     ((eq (car what) 'user)		; user
+     ((eq (car what) 'user)	; user
       (setq sql-user
-	    (read-from-minibuffer "User: " sql-user nil nil
-				  sql-user-history)))
-     ((eq (car what) 'password)		; password
+	    (if sql-automatic-login
+		sql-user
+	      (read-from-minibuffer "User: " sql-user nil nil
+				    sql-user-history))))
+     ((eq (car what) 'password)	; password
       (setq sql-password
-	    (sql-read-passwd "Password: " sql-password)))
-     ((eq (car what) 'server)		; server
+	    (if sql-automatic-login
+		sql-password
+	      (sql-read-passwd "Password: " sql-password))))
+     ((eq (car what) 'server)	; server
       (setq sql-server
-	    (read-from-minibuffer "Server: " sql-server nil nil
-				  sql-server-history)))
-     ((eq (car what) 'database)		; database
+	    (if sql-automatic-login
+		sql-server
+	      (read-from-minibuffer "Server: " sql-server nil nil
+				    sql-server-history))))
+     ((eq (car what) 'database)	; database
       (setq sql-database
 	    (read-from-minibuffer "Database: " sql-database nil nil
 				  sql-database-history))))

Diff finished.  Fri Feb 29 12:33:48 2008

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-02-29 11:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-29 11:52 sql-automatic-login Andreas Röhler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).