Function: sql-get-login-ext
sql-get-login-ext is a byte-compiled function defined in sql.el.gz.
Signature
(sql-get-login-ext SYMBOL PROMPT HISTORY-VAR PLIST)
Documentation
Prompt user with extended login parameters.
The global value of SYMBOL is the last value and the global value of the SYMBOL is set based on the user's input.
If PLIST is nil, then the user is simply prompted for a string value.
The property :default specifies the default value. If the
:number property is non-nil then ask for a number.
The :file property prompts for a file name that must match the regexp pattern specified in its value.
The :completion property prompts for a string specified by its
value. (The property value is used as the PREDICATE argument to
completing-read.)
For both :file and :completion, there can also be a
:must-match property that controls REQUIRE-MATCH parameter to
completing-read.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/sql.el.gz
(defun sql-get-login-ext (symbol prompt history-var plist)
"Prompt user with extended login parameters.
The global value of SYMBOL is the last value and the global value
of the SYMBOL is set based on the user's input.
If PLIST is nil, then the user is simply prompted for a string
value.
The property `:default' specifies the default value. If the
`:number' property is non-nil then ask for a number.
The `:file' property prompts for a file name that must match the
regexp pattern specified in its value.
The `:completion' property prompts for a string specified by its
value. (The property value is used as the PREDICATE argument to
`completing-read'.)
For both `:file' and `:completion', there can also be a
`:must-match' property that controls REQUIRE-MATCH parameter to
`completing-read'."
(set-default
symbol
(let* ((default (plist-get plist :default))
(last-value (sql-default-value symbol))
(prompt-def (format-prompt prompt default))
(use-dialog-box nil))
(cond
((plist-member plist :file)
(let ((file-name
(read-file-name prompt-def
(file-name-directory last-value)
default
(if (plist-member plist :must-match)
(plist-get plist :must-match)
t)
(file-name-nondirectory last-value)
(when (plist-get plist :file)
`(lambda (f)
(if (not (file-regular-p f))
t
(string-match
(concat "\\<" ,(plist-get plist :file) "\\>")
(file-name-nondirectory f))))))))
(if (string= file-name "")
""
(expand-file-name file-name))))
((plist-member plist :completion)
(completing-read prompt-def
(plist-get plist :completion)
nil
(if (plist-member plist :must-match)
(plist-get plist :must-match)
t)
last-value
history-var
default))
((plist-get plist :number)
(read-number (concat prompt ": ") (or default last-value 0)))
(t
(read-string prompt-def last-value history-var default))))))