aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes
diff options
context:
space:
mode:
authorJoakim Verona2012-03-06 09:23:09 +0100
committerJoakim Verona2012-03-06 09:23:09 +0100
commit28485daaf752ff5264ed2f6a32ec15588beaa929 (patch)
treea480205aa664c61b1d212833144c0a2d44f7ac01 /lisp/progmodes
parente8e42079e76ca6255bbd53312994ba8e1b3b0ee8 (diff)
parent2e86d8576c668e149cc100f3222bcf19b38019dc (diff)
downloademacs-28485daaf752ff5264ed2f6a32ec15588beaa929.tar.gz
emacs-28485daaf752ff5264ed2f6a32ec15588beaa929.zip
upstream
Diffstat (limited to 'lisp/progmodes')
-rw-r--r--lisp/progmodes/antlr-mode.el8
-rw-r--r--lisp/progmodes/cc-engine.el233
-rw-r--r--lisp/progmodes/cc-langs.el6
-rw-r--r--lisp/progmodes/gdb-mi.el18
-rw-r--r--lisp/progmodes/sql.el187
-rw-r--r--lisp/progmodes/vhdl-mode.el6
6 files changed, 302 insertions, 156 deletions
diff --git a/lisp/progmodes/antlr-mode.el b/lisp/progmodes/antlr-mode.el
index 634570cf3e4..9c9a8e09d49 100644
--- a/lisp/progmodes/antlr-mode.el
+++ b/lisp/progmodes/antlr-mode.el
@@ -1,6 +1,6 @@
1;;; antlr-mode.el --- major mode for ANTLR grammar files 1;;; antlr-mode.el --- major mode for ANTLR grammar files
2 2
3;; Copyright (C) 1999-2012 Free Software Foundation, Inc. 3;; Copyright (C) 1999-2012 Free Software Foundation, Inc.
4 4
5;; Author: Christoph.Wedler@sap.com 5;; Author: Christoph.Wedler@sap.com
6;; Keywords: languages, ANTLR, code generator 6;; Keywords: languages, ANTLR, code generator
@@ -961,7 +961,7 @@ group. The string matched by the first group is highlighted with
961 (antlr-re-search-forward 961 (antlr-re-search-forward
962 "^\\(private\\|public\\|protected\\)\\>[ \t]*\\(\\(\\sw+[ \t]*\\(:\\)?\\)\\)?" 962 "^\\(private\\|public\\|protected\\)\\>[ \t]*\\(\\(\\sw+[ \t]*\\(:\\)?\\)\\)?"
963 limit)) 963 limit))
964 (1 font-lock-type-face) ; not XEmacs' java level-3 fruit salad 964 (1 font-lock-type-face) ; not XEmacs's java level-3 fruit salad
965 (3 (if (antlr-upcase-p (char-after (match-beginning 3))) 965 (3 (if (antlr-upcase-p (char-after (match-beginning 3)))
966 antlr-tokendef-face 966 antlr-tokendef-face
967 antlr-ruledef-face) nil t) 967 antlr-ruledef-face) nil t)
@@ -1030,7 +1030,7 @@ not to confuse their context_cache.")
1030(define-abbrev-table 'antlr-mode-abbrev-table ()) 1030(define-abbrev-table 'antlr-mode-abbrev-table ())
1031 1031
1032(defvar antlr-slow-cache-enabling-symbol 'loudly 1032(defvar antlr-slow-cache-enabling-symbol 'loudly
1033;; Emacs' font-lock changes buffer's tick counter, therefore this value should 1033;; Emacs's font-lock changes buffer's tick counter, therefore this value should
1034;; be a parameter of a font-lock function, but not any other variable of 1034;; be a parameter of a font-lock function, but not any other variable of
1035;; functions which call `antlr-slow-syntactic-context'. 1035;; functions which call `antlr-slow-syntactic-context'.
1036 "If value is a bound symbol, cache will be used even with text changes. 1036 "If value is a bound symbol, cache will be used even with text changes.
@@ -1113,7 +1113,7 @@ WARNING: this may alter `match-data'."
1113 (or (buffer-syntactic-context) (buffer-syntactic-context-depth)) 1113 (or (buffer-syntactic-context) (buffer-syntactic-context-depth))
1114 :EMACS 1114 :EMACS
1115 (let ((orig (point)) diff state 1115 (let ((orig (point)) diff state
1116 ;; Arg, Emacs' (buffer-modified-tick) changes with font-lock. Use 1116 ;; Arg, Emacs's (buffer-modified-tick) changes with font-lock. Use
1117 ;; hack that `loudly' is bound during font-locking => cache use will 1117 ;; hack that `loudly' is bound during font-locking => cache use will
1118 ;; increase from 7% to 99.99% during font-locking. 1118 ;; increase from 7% to 99.99% during font-locking.
1119 (tick (or (boundp antlr-slow-cache-enabling-symbol) 1119 (tick (or (boundp antlr-slow-cache-enabling-symbol)
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 95b43e763d5..3b33ac894f2 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -219,6 +219,38 @@
219 (point)))) 219 (point))))
220 c-macro-start)) 220 c-macro-start))
221 221
222;; One element macro cache to cope with continual movement within very large
223;; CPP macros.
224(defvar c-macro-cache nil)
225(make-variable-buffer-local 'c-macro-cache)
226;; Nil or cons of the bounds of the most recent CPP form probed by
227;; `c-beginning-of-macro', `c-end-of-macro' or `c-syntactic-end-of-macro'.
228;; The cdr will be nil if we know only the start of the CPP form.
229(defvar c-macro-cache-start-pos nil)
230(make-variable-buffer-local 'c-macro-cache-start-pos)
231;; The starting position from where we determined `c-macro-cache'.
232(defvar c-macro-cache-syntactic nil)
233(make-variable-buffer-local 'c-macro-cache-syntactic)
234;; non-nil iff `c-macro-cache' has both elements set AND the cdr is at a
235;; syntactic end of macro, not merely an apparent one.
236
237(defun c-invalidate-macro-cache (beg end)
238 ;; Called from a before-change function. If the change region is before or
239 ;; in the macro characterised by `c-macro-cache' etc., nullify it
240 ;; appropriately. BEG and END are the standard before-change-functions
241 ;; parameters. END isn't used.
242 (cond
243 ((null c-macro-cache))
244 ((< beg (car c-macro-cache))
245 (setq c-macro-cache nil
246 c-macro-cache-start-pos nil
247 c-macro-cache-syntactic nil))
248 ((and (cdr c-macro-cache)
249 (< beg (cdr c-macro-cache)))
250 (setcdr c-macro-cache nil)
251 (setq c-macro-cache-start-pos beg
252 c-macro-cache-syntactic nil))))
253
222(defun c-beginning-of-macro (&optional lim) 254(defun c-beginning-of-macro (&optional lim)
223 "Go to the beginning of a preprocessor directive. 255 "Go to the beginning of a preprocessor directive.
224Leave point at the beginning of the directive and return t if in one, 256Leave point at the beginning of the directive and return t if in one,
@@ -226,19 +258,36 @@ otherwise return nil and leave point unchanged.
226 258
227Note that this function might do hidden buffer changes. See the 259Note that this function might do hidden buffer changes. See the
228comment at the start of cc-engine.el for more info." 260comment at the start of cc-engine.el for more info."
229 (when c-opt-cpp-prefix 261 (let ((here (point)))
230 (let ((here (point))) 262 (when c-opt-cpp-prefix
231 (save-restriction 263 (if (and (car c-macro-cache)
232 (if lim (narrow-to-region lim (point-max))) 264 (>= (point) (car c-macro-cache))
233 (beginning-of-line) 265 (or (and (cdr c-macro-cache)
234 (while (eq (char-before (1- (point))) ?\\) 266 (<= (point) (cdr c-macro-cache)))
235 (forward-line -1)) 267 (<= (point) c-macro-cache-start-pos)))
236 (back-to-indentation) 268 (unless (< (car c-macro-cache) (or lim (point-min)))
237 (if (and (<= (point) here) 269 (progn (goto-char (max (or lim (point-min)) (car c-macro-cache)))
238 (looking-at c-opt-cpp-start)) 270 (setq c-macro-cache-start-pos
239 t 271 (max c-macro-cache-start-pos here))
240 (goto-char here) 272 t))
241 nil))))) 273 (setq c-macro-cache nil
274 c-macro-cache-start-pos nil
275 c-macro-cache-syntactic nil)
276
277 (save-restriction
278 (if lim (narrow-to-region lim (point-max)))
279 (beginning-of-line)
280 (while (eq (char-before (1- (point))) ?\\)
281 (forward-line -1))
282 (back-to-indentation)
283 (if (and (<= (point) here)
284 (looking-at c-opt-cpp-start))
285 (progn
286 (setq c-macro-cache (cons (point) nil)
287 c-macro-cache-start-pos here)
288 t)
289 (goto-char here)
290 nil))))))
242 291
243(defun c-end-of-macro () 292(defun c-end-of-macro ()
244 "Go to the end of a preprocessor directive. 293 "Go to the end of a preprocessor directive.
@@ -248,12 +297,24 @@ done that the point is inside a cpp directive to begin with.
248 297
249Note that this function might do hidden buffer changes. See the 298Note that this function might do hidden buffer changes. See the
250comment at the start of cc-engine.el for more info." 299comment at the start of cc-engine.el for more info."
251 (while (progn 300 (if (and (cdr c-macro-cache)
252 (end-of-line) 301 (<= (point) (cdr c-macro-cache))
253 (when (and (eq (char-before) ?\\) 302 (>= (point) (car c-macro-cache)))
254 (not (eobp))) 303 (goto-char (cdr c-macro-cache))
255 (forward-char) 304 (unless (and (car c-macro-cache)
256 t)))) 305 (<= (point) c-macro-cache-start-pos)
306 (>= (point) (car c-macro-cache)))
307 (setq c-macro-cache nil
308 c-macro-cache-start-pos nil
309 c-macro-cache-syntactic nil))
310 (while (progn
311 (end-of-line)
312 (when (and (eq (char-before) ?\\)
313 (not (eobp)))
314 (forward-char)
315 t)))
316 (when (car c-macro-cache)
317 (setcdr c-macro-cache (point)))))
257 318
258(defun c-syntactic-end-of-macro () 319(defun c-syntactic-end-of-macro ()
259 ;; Go to the end of a CPP directive, or a "safe" pos just before. 320 ;; Go to the end of a CPP directive, or a "safe" pos just before.
@@ -268,12 +329,15 @@ comment at the start of cc-engine.el for more info."
268 ;; at the start of cc-engine.el for more info. 329 ;; at the start of cc-engine.el for more info.
269 (let* ((here (point)) 330 (let* ((here (point))
270 (there (progn (c-end-of-macro) (point))) 331 (there (progn (c-end-of-macro) (point)))
271 (s (parse-partial-sexp here there))) 332 s)
272 (while (and (or (nth 3 s) ; in a string 333 (unless c-macro-cache-syntactic
273 (nth 4 s)) ; in a comment (maybe at end of line comment) 334 (setq s (parse-partial-sexp here there))
274 (> there here)) ; No infinite loops, please. 335 (while (and (or (nth 3 s) ; in a string
275 (setq there (1- (nth 8 s))) 336 (nth 4 s)) ; in a comment (maybe at end of line comment)
276 (setq s (parse-partial-sexp here there))) 337 (> there here)) ; No infinite loops, please.
338 (setq there (1- (nth 8 s)))
339 (setq s (parse-partial-sexp here there)))
340 (setq c-macro-cache-syntactic (car c-macro-cache)))
277 (point))) 341 (point)))
278 342
279(defun c-forward-over-cpp-define-id () 343(defun c-forward-over-cpp-define-id ()
@@ -2089,6 +2153,18 @@ comment at the start of cc-engine.el for more info."
2089;; reduced by buffer changes, and increased by invocations of 2153;; reduced by buffer changes, and increased by invocations of
2090;; `c-state-literal-at'. 2154;; `c-state-literal-at'.
2091 2155
2156(defvar c-state-semi-nonlit-pos-cache nil)
2157(make-variable-buffer-local 'c-state-semi-nonlit-pos-cache)
2158;; A list of buffer positions which are known not to be in a literal. This is
2159;; ordered with higher positions at the front of the list. Only those which
2160;; are less than `c-state-semi-nonlit-pos-cache-limit' are valid.
2161
2162(defvar c-state-semi-nonlit-pos-cache-limit 1)
2163(make-variable-buffer-local 'c-state-semi-nonlit-pos-cache-limit)
2164;; An upper limit on valid entries in `c-state-semi-nonlit-pos-cache'. This is
2165;; reduced by buffer changes, and increased by invocations of
2166;; `c-state-literal-at'. FIMXE!!!
2167
2092(defsubst c-state-pp-to-literal (from to) 2168(defsubst c-state-pp-to-literal (from to)
2093 ;; Do a parse-partial-sexp from FROM to TO, returning either 2169 ;; Do a parse-partial-sexp from FROM to TO, returning either
2094 ;; (STATE TYPE (BEG . END)) if TO is in a literal; or 2170 ;; (STATE TYPE (BEG . END)) if TO is in a literal; or
@@ -2129,48 +2205,93 @@ comment at the start of cc-engine.el for more info."
2129 (widen) 2205 (widen)
2130 (save-excursion 2206 (save-excursion
2131 (let ((c c-state-nonlit-pos-cache) 2207 (let ((c c-state-nonlit-pos-cache)
2132 pos npos lit macro-beg macro-end) 2208 pos npos high-pos lit macro-beg macro-end)
2133 ;; Trim the cache to take account of buffer changes. 2209 ;; Trim the cache to take account of buffer changes.
2134 (while (and c (> (car c) c-state-nonlit-pos-cache-limit)) 2210 (while (and c (> (car c) c-state-nonlit-pos-cache-limit))
2135 (setq c (cdr c))) 2211 (setq c (cdr c)))
2136 (setq c-state-nonlit-pos-cache c) 2212 (setq c-state-nonlit-pos-cache c)
2137 2213
2138 (while (and c (> (car c) here)) 2214 (while (and c (> (car c) here))
2215 (setq high-pos (car c))
2139 (setq c (cdr c))) 2216 (setq c (cdr c)))
2140 (setq pos (or (car c) (point-min))) 2217 (setq pos (or (car c) (point-min)))
2141 2218
2142 (while 2219 (unless high-pos
2143 ;; Add an element to `c-state-nonlit-pos-cache' each iteration. 2220 (while
2144 (and 2221 ;; Add an element to `c-state-nonlit-pos-cache' each iteration.
2145 (<= (setq npos (+ pos c-state-nonlit-pos-interval)) here) 2222 (and
2223 (<= (setq npos (+ pos c-state-nonlit-pos-interval)) here)
2146 2224
2147 ;; Test for being in a literal. 2225 ;; Test for being in a literal. If so, go to after it.
2148 (progn 2226 (progn
2149 (setq lit (car (cddr (c-state-pp-to-literal pos npos)))) 2227 (setq lit (car (cddr (c-state-pp-to-literal pos npos))))
2150 (or (null lit) 2228 (or (null lit)
2151 (prog1 (<= (cdr lit) here) 2229 (prog1 (<= (cdr lit) here)
2152 (setq npos (cdr lit))))) 2230 (setq npos (cdr lit)))))
2153 2231
2154 ;; Test for being in a macro. 2232 ;; Test for being in a macro. If so, go to after it.
2155 (progn 2233 (progn
2156 (goto-char npos) 2234 (goto-char npos)
2157 (setq macro-beg 2235 (setq macro-beg
2158 (and (c-beginning-of-macro) (/= (point) npos) (point))) 2236 (and (c-beginning-of-macro) (/= (point) npos) (point)))
2159 (when macro-beg 2237 (when macro-beg
2160 (c-syntactic-end-of-macro) 2238 (c-syntactic-end-of-macro)
2161 (or (eobp) (forward-char)) 2239 (or (eobp) (forward-char))
2162 (setq macro-end (point))) 2240 (setq macro-end (point)))
2163 (or (null macro-beg) 2241 (or (null macro-beg)
2164 (prog1 (<= macro-end here) 2242 (prog1 (<= macro-end here)
2165 (setq npos macro-end))))) 2243 (setq npos macro-end)))))
2166 2244
2167 (setq pos npos) 2245 (setq pos npos)
2168 (setq c-state-nonlit-pos-cache (cons pos c-state-nonlit-pos-cache))) 2246 (setq c-state-nonlit-pos-cache (cons pos c-state-nonlit-pos-cache)))
2247 ;; Add one extra element above HERE so as to to avoid the previous
2248 ;; expensive calculation when the next call is close to the current
2249 ;; one. This is especially useful when inside a large macro.
2250 (setq c-state-nonlit-pos-cache (cons npos c-state-nonlit-pos-cache)))
2169 2251
2170 (if (> pos c-state-nonlit-pos-cache-limit) 2252 (if (> pos c-state-nonlit-pos-cache-limit)
2171 (setq c-state-nonlit-pos-cache-limit pos)) 2253 (setq c-state-nonlit-pos-cache-limit pos))
2172 pos)))) 2254 pos))))
2173 2255
2256(defun c-state-semi-safe-place (here)
2257 ;; Return a buffer position before HERE which is "safe", i.e. outside any
2258 ;; string or comment. It may be in a macro.
2259 (save-restriction
2260 (widen)
2261 (save-excursion
2262 (let ((c c-state-semi-nonlit-pos-cache)
2263 pos npos high-pos lit macro-beg macro-end)
2264 ;; Trim the cache to take account of buffer changes.
2265 (while (and c (> (car c) c-state-semi-nonlit-pos-cache-limit))
2266 (setq c (cdr c)))
2267 (setq c-state-semi-nonlit-pos-cache c)
2268
2269 (while (and c (> (car c) here))
2270 (setq high-pos (car c))
2271 (setq c (cdr c)))
2272 (setq pos (or (car c) (point-min)))
2273
2274 (unless high-pos
2275 (while
2276 ;; Add an element to `c-state-semi-nonlit-pos-cache' each iteration.
2277 (and
2278 (<= (setq npos (+ pos c-state-nonlit-pos-interval)) here)
2279
2280 ;; Test for being in a literal. If so, go to after it.
2281 (progn
2282 (setq lit (car (cddr (c-state-pp-to-literal pos npos))))
2283 (or (null lit)
2284 (prog1 (<= (cdr lit) here)
2285 (setq npos (cdr lit))))))
2286
2287 (setq pos npos)
2288 (setq c-state-semi-nonlit-pos-cache
2289 (cons pos c-state-semi-nonlit-pos-cache))))
2290
2291 (if (> pos c-state-semi-nonlit-pos-cache-limit)
2292 (setq c-state-semi-nonlit-pos-cache-limit pos))
2293 pos))))
2294
2174(defun c-state-literal-at (here) 2295(defun c-state-literal-at (here)
2175 ;; If position HERE is inside a literal, return (START . END), the 2296 ;; If position HERE is inside a literal, return (START . END), the
2176 ;; boundaries of the literal (which may be outside the accessible bit of the 2297 ;; boundaries of the literal (which may be outside the accessible bit of the
@@ -2985,9 +3106,11 @@ comment at the start of cc-engine.el for more info."
2985 ;; 3106 ;;
2986 ;; This function is called from c-after-change. 3107 ;; This function is called from c-after-change.
2987 3108
2988 ;; The cache of non-literals: 3109 ;; The caches of non-literals:
2989 (if (< here c-state-nonlit-pos-cache-limit) 3110 (if (< here c-state-nonlit-pos-cache-limit)
2990 (setq c-state-nonlit-pos-cache-limit here)) 3111 (setq c-state-nonlit-pos-cache-limit here))
3112 (if (< here c-state-semi-nonlit-pos-cache-limit)
3113 (setq c-state-semi-nonlit-pos-cache-limit here))
2991 3114
2992 ;; `c-state-cache': 3115 ;; `c-state-cache':
2993 ;; Case 1: if `here' is in a literal containing point-min, everything 3116 ;; Case 1: if `here' is in a literal containing point-min, everything
@@ -4230,7 +4353,7 @@ Note that this function might do hidden buffer changes. See the
4230comment at the start of cc-engine.el for more info." 4353comment at the start of cc-engine.el for more info."
4231 (save-restriction 4354 (save-restriction
4232 (widen) 4355 (widen)
4233 (let* ((safe-place (c-state-safe-place (point))) 4356 (let* ((safe-place (c-state-semi-safe-place (point)))
4234 (lit (c-state-pp-to-literal safe-place (point)))) 4357 (lit (c-state-pp-to-literal safe-place (point))))
4235 (or (cadr lit) 4358 (or (cadr lit)
4236 (and detect-cpp 4359 (and detect-cpp
@@ -4254,7 +4377,7 @@ comment at the start of cc-engine.el for more info."
4254 4377
4255 (save-excursion 4378 (save-excursion
4256 (let* ((pos (point)) 4379 (let* ((pos (point))
4257 (lim (or lim (c-state-safe-place pos))) 4380 (lim (or lim (c-state-semi-safe-place pos)))
4258 (pp-to-lit (save-restriction 4381 (pp-to-lit (save-restriction
4259 (widen) 4382 (widen)
4260 (c-state-pp-to-literal lim pos))) 4383 (c-state-pp-to-literal lim pos)))
@@ -4372,7 +4495,7 @@ comment at the start of cc-engine.el for more info."
4372 ;; Get a "safe place" approximately TRY-SIZE characters before START. 4495 ;; Get a "safe place" approximately TRY-SIZE characters before START.
4373 ;; This doesn't preserve point. 4496 ;; This doesn't preserve point.
4374 (let* ((pos (max (- start try-size) (point-min))) 4497 (let* ((pos (max (- start try-size) (point-min)))
4375 (base (c-state-safe-place pos)) 4498 (base (c-state-semi-safe-place pos))
4376 (s (parse-partial-sexp base pos))) 4499 (s (parse-partial-sexp base pos)))
4377 (if (or (nth 4 s) (nth 3 s)) ; comment or string 4500 (if (or (nth 4 s) (nth 3 s)) ; comment or string
4378 (nth 8 s) 4501 (nth 8 s)
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index fafbfb70552..493f3db0961 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -459,8 +459,10 @@ so that all identifiers are recognized as words.")
459 ;; For documentation see the following c-lang-defvar of the same name. 459 ;; For documentation see the following c-lang-defvar of the same name.
460 ;; The value here may be a list of functions or a single function. 460 ;; The value here may be a list of functions or a single function.
461 t nil 461 t nil
462 c++ '(c-extend-region-for-CPP c-before-change-check-<>-operators) 462 c++ '(c-extend-region-for-CPP
463 (c objc) 'c-extend-region-for-CPP 463 c-before-change-check-<>-operators
464 c-invalidate-macro-cache)
465 (c objc) '(c-extend-region-for-CPP c-invalidate-macro-cache)
464 ;; java 'c-before-change-check-<>-operators 466 ;; java 'c-before-change-check-<>-operators
465 awk 'c-awk-record-region-clear-NL) 467 awk 'c-awk-record-region-clear-NL)
466(c-lang-defvar c-get-state-before-change-functions 468(c-lang-defvar c-get-state-before-change-functions
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 301714ec55f..0c45c3f5e5d 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -1672,8 +1672,6 @@ static char *magick[] = {
1672 (if (not (string= "" string)) 1672 (if (not (string= "" string))
1673 (setq gdb-last-command string) 1673 (setq gdb-last-command string)
1674 (if gdb-last-command (setq string gdb-last-command))) 1674 (if gdb-last-command (setq string gdb-last-command)))
1675 (if gdb-enable-debug
1676 (push (cons 'mi-send (concat string "\n")) gdb-debug-log))
1677 (if (string-match "^-" string) 1675 (if (string-match "^-" string)
1678 ;; MI command 1676 ;; MI command
1679 (progn 1677 (progn
@@ -1683,10 +1681,22 @@ static char *magick[] = {
1683 (if (string-match "\\\\$" string) 1681 (if (string-match "\\\\$" string)
1684 (setq gdb-continuation (concat gdb-continuation string "\n")) 1682 (setq gdb-continuation (concat gdb-continuation string "\n"))
1685 (setq gdb-first-done-or-error t) 1683 (setq gdb-first-done-or-error t)
1686 (process-send-string proc (concat "-interpreter-exec console \"" 1684 (let ((to-send (concat "-interpreter-exec console "
1687 gdb-continuation string "\"\n")) 1685 (gdb-mi-quote string)
1686 "\n")))
1687 (if gdb-enable-debug
1688 (push (cons 'mi-send to-send) gdb-debug-log))
1689 (process-send-string proc to-send))
1688 (setq gdb-continuation nil)))) 1690 (setq gdb-continuation nil))))
1689 1691
1692(defun gdb-mi-quote (string)
1693 "Return STRING quoted properly as an MI argument.
1694The string is enclosed in double quotes.
1695All embedded quotes, newlines, and backslashes are preceded with a backslash."
1696 (setq string (replace-regexp-in-string "\\([\"\\]\\)" "\\\\\\&" string))
1697 (setq string (replace-regexp-in-string "\n" "\\n" string t t))
1698 (concat "\"" string "\""))
1699
1690(defun gdb-input (command handler-function) 1700(defun gdb-input (command handler-function)
1691 "Send COMMAND to GDB via the MI interface. 1701 "Send COMMAND to GDB via the MI interface.
1692Run the function HANDLER-FUNCTION, with no arguments, once the command is 1702Run the function HANDLER-FUNCTION, with no arguments, once the command is
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index f5bfe526aae..56f42e31cf1 100644
--- a/lisp/progmodes/sql.el
+++ b/lisp/progmodes/sql.el
@@ -2853,9 +2853,12 @@ appended to the SQLi buffer without disturbing your SQL buffer."
2853 "Read a password using PROMPT. Optional DEFAULT is password to start with." 2853 "Read a password using PROMPT. Optional DEFAULT is password to start with."
2854 (read-passwd prompt nil default)) 2854 (read-passwd prompt nil default))
2855 2855
2856(defun sql-get-login-ext (prompt last-value history-var plist) 2856(defun sql-get-login-ext (symbol prompt history-var plist)
2857 "Prompt user with extended login parameters. 2857 "Prompt user with extended login parameters.
2858 2858
2859The global value of SYMBOL is the last value and the global value
2860of the SYMBOL is set based on the user's input.
2861
2859If PLIST is nil, then the user is simply prompted for a string 2862If PLIST is nil, then the user is simply prompted for a string
2860value. 2863value.
2861 2864
@@ -2868,38 +2871,41 @@ regexp pattern specified in its value.
2868The `:completion' property prompts for a string specified by its 2871The `:completion' property prompts for a string specified by its
2869value. (The property value is used as the PREDICATE argument to 2872value. (The property value is used as the PREDICATE argument to
2870`completing-read'.)" 2873`completing-read'.)"
2871 (let* ((default (plist-get plist :default)) 2874 (set-default
2872 (prompt-def 2875 symbol
2873 (if default 2876 (let* ((default (plist-get plist :default))
2874 (if (string-match "\\(\\):[ \t]*\\'" prompt) 2877 (last-value (default-value symbol))
2875 (replace-match (format " (default \"%s\")" default) t t prompt 1) 2878 (prompt-def
2876 (replace-regexp-in-string "[ \t]*\\'" 2879 (if default
2877 (format " (default \"%s\") " default) 2880 (if (string-match "\\(\\):[ \t]*\\'" prompt)
2878 prompt t t)) 2881 (replace-match (format " (default \"%s\")" default) t t prompt 1)
2879 prompt)) 2882 (replace-regexp-in-string "[ \t]*\\'"
2880 (use-dialog-box nil)) 2883 (format " (default \"%s\") " default)
2881 (cond 2884 prompt t t))
2882 ((plist-member plist :file) 2885 prompt))
2883 (expand-file-name 2886 (use-dialog-box nil))
2884 (read-file-name prompt 2887 (cond
2885 (file-name-directory last-value) default t 2888 ((plist-member plist :file)
2886 (file-name-nondirectory last-value) 2889 (expand-file-name
2887 (when (plist-get plist :file) 2890 (read-file-name prompt
2888 `(lambda (f) 2891 (file-name-directory last-value) default t
2889 (string-match 2892 (file-name-nondirectory last-value)
2890 (concat "\\<" ,(plist-get plist :file) "\\>") 2893 (when (plist-get plist :file)
2891 (file-name-nondirectory f))))))) 2894 `(lambda (f)
2892 2895 (string-match
2893 ((plist-member plist :completion) 2896 (concat "\\<" ,(plist-get plist :file) "\\>")
2894 (completing-read prompt-def (plist-get plist :completion) nil t 2897 (file-name-nondirectory f)))))))
2895 last-value history-var default)) 2898
2896 2899 ((plist-member plist :completion)
2897 ((plist-get plist :number) 2900 (completing-read prompt-def (plist-get plist :completion) nil t
2898 (read-number prompt (or default last-value 0))) 2901 last-value history-var default))
2899 2902
2900 (t 2903 ((plist-get plist :number)
2901 (let ((r (read-from-minibuffer prompt-def last-value nil nil history-var nil))) 2904 (read-number prompt (or default last-value 0)))
2902 (if (string= "" r) (or default "") r)))))) 2905
2906 (t
2907 (let ((r (read-from-minibuffer prompt-def last-value nil nil history-var nil)))
2908 (if (string= "" r) (or default "") r)))))))
2903 2909
2904(defun sql-get-login (&rest what) 2910(defun sql-get-login (&rest what)
2905 "Get username, password and database from the user. 2911 "Get username, password and database from the user.
@@ -2937,28 +2943,20 @@ function like this: (sql-get-login 'user 'password 'database)."
2937 2943
2938 (cond 2944 (cond
2939 ((eq token 'user) ; user 2945 ((eq token 'user) ; user
2940 (setq sql-user 2946 (sql-get-login-ext 'sql-user "User: " 'sql-user-history plist))
2941 (sql-get-login-ext "User: " sql-user
2942 'sql-user-history plist)))
2943 2947
2944 ((eq token 'password) ; password 2948 ((eq token 'password) ; password
2945 (setq sql-password 2949 (setq-default sql-password
2946 (sql-read-passwd "Password: " sql-password))) 2950 (sql-read-passwd "Password: " sql-password)))
2947 2951
2948 ((eq token 'server) ; server 2952 ((eq token 'server) ; server
2949 (setq sql-server 2953 (sql-get-login-ext 'sql-server "Server: " 'sql-server-history plist))
2950 (sql-get-login-ext "Server: " sql-server
2951 'sql-server-history plist)))
2952 2954
2953 ((eq token 'database) ; database 2955 ((eq token 'database) ; database
2954 (setq sql-database 2956 (sql-get-login-ext 'sql-database "Database: " 'sql-database-history plist))
2955 (sql-get-login-ext "Database: " sql-database
2956 'sql-database-history plist)))
2957 2957
2958 ((eq token 'port) ; port 2958 ((eq token 'port) ; port
2959 (setq sql-port 2959 (sql-get-login-ext 'sql-port "Port: " nil (append '(:number t) plist))))))
2960 (sql-get-login-ext "Port: " sql-port
2961 nil (append '(:number t) plist)))))))
2962 what)) 2960 what))
2963 2961
2964(defun sql-find-sqli-buffer (&optional product connection) 2962(defun sql-find-sqli-buffer (&optional product connection)
@@ -3841,6 +3839,7 @@ you entered, right above the output it created.
3841 (set (make-local-variable 'sql-server) sql-server) 3839 (set (make-local-variable 'sql-server) sql-server)
3842 (set (make-local-variable 'sql-port) sql-port) 3840 (set (make-local-variable 'sql-port) sql-port)
3843 (set (make-local-variable 'sql-connection) sql-connection) 3841 (set (make-local-variable 'sql-connection) sql-connection)
3842 (setq-default sql-connection nil)
3844 ;; Contains the name of database objects 3843 ;; Contains the name of database objects
3845 (set (make-local-variable 'sql-contains-names) t) 3844 (set (make-local-variable 'sql-contains-names) t)
3846 ;; Keep track of existing object names 3845 ;; Keep track of existing object names
@@ -3935,43 +3934,50 @@ is specified in the connection settings."
3935 ;; Settings are defined 3934 ;; Settings are defined
3936 (if connect-set 3935 (if connect-set
3937 ;; Set the desired parameters 3936 ;; Set the desired parameters
3938 (eval `(let* 3937 (let (param-var login-params set-params rem-params)
3939 (,@(cdr connect-set) 3938
3940 ;; :sqli-login params variable 3939 ;; :sqli-login params variable
3941 (param-var (sql-get-product-feature sql-product 3940 (setq param-var
3942 :sqli-login nil t)) 3941 (sql-get-product-feature sql-product :sqli-login nil t))
3943 ;; :sqli-login params value 3942
3944 (login-params (sql-get-product-feature sql-product 3943 ;; :sqli-login params value
3945 :sqli-login)) 3944 (setq login-params
3946 ;; which params are in the connection 3945 (sql-get-product-feature sql-product :sqli-login))
3947 (set-params (mapcar 3946
3948 (lambda (v) 3947 ;; Params in the connection
3949 (cond 3948 (setq set-params
3950 ((eq (car v) 'sql-user) 'user) 3949 (mapcar
3951 ((eq (car v) 'sql-password) 'password) 3950 (lambda (v)
3952 ((eq (car v) 'sql-server) 'server) 3951 (cond
3953 ((eq (car v) 'sql-database) 'database) 3952 ((eq (car v) 'sql-user) 'user)
3954 ((eq (car v) 'sql-port) 'port) 3953 ((eq (car v) 'sql-password) 'password)
3955 (t (car v)))) 3954 ((eq (car v) 'sql-server) 'server)
3956 (cdr connect-set))) 3955 ((eq (car v) 'sql-database) 'database)
3957 ;; the remaining params (w/o the connection params) 3956 ((eq (car v) 'sql-port) 'port)
3958 (rem-params (sql-for-each-login 3957 (t (car v))))
3959 login-params 3958 (cdr connect-set)))
3960 (lambda (token plist) 3959
3961 (unless (member token set-params) 3960 ;; the remaining params (w/o the connection params)
3962 (if plist 3961 (setq rem-params
3963 (cons token plist) 3962 (sql-for-each-login login-params
3964 token)))))) 3963 (lambda (token plist)
3965 3964 (unless (member token set-params)
3966 ;; Set the remaining parameters and start the 3965 (if plist (cons token plist) token)))))
3967 ;; interactive session 3966
3968 (eval `(let ((sql-connection ,connection) 3967 ;; Set the parameters and start the interactive session
3969 (,param-var ',rem-params)) 3968 (mapc
3970 (sql-product-interactive sql-product 3969 (lambda (vv)
3971 new-name))))) 3970 (set-default (car vv) (eval (cadr vv))))
3971 (cdr connect-set))
3972 (setq-default sql-connection connection)
3973
3974 ;; Start the SQLi session with revised list of login parameters
3975 (eval `(let ((,param-var ',rem-params))
3976 (sql-product-interactive sql-product new-name))))
3972 3977
3973 (message "SQL Connection <%s> does not exist" connection) 3978 (message "SQL Connection <%s> does not exist" connection)
3974 nil))) 3979 nil)))
3980
3975 (message "No SQL Connections defined") 3981 (message "No SQL Connections defined")
3976 nil)) 3982 nil))
3977 3983
@@ -4101,9 +4107,14 @@ the call to \\[sql-product-interactive] with
4101 4107
4102 ;; Connect to database. 4108 ;; Connect to database.
4103 (message "Login...") 4109 (message "Login...")
4104 (funcall (sql-get-product-feature product :sqli-comint-func) 4110 (let ((sql-user (default-value 'sql-user))
4105 product 4111 (sql-password (default-value 'sql-password))
4106 (sql-get-product-feature product :sqli-options)) 4112 (sql-server (default-value 'sql-server))
4113 (sql-database (default-value 'sql-database))
4114 (sql-port (default-value 'sql-port)))
4115 (funcall (sql-get-product-feature product :sqli-comint-func)
4116 product
4117 (sql-get-product-feature product :sqli-options)))
4107 4118
4108 ;; Set SQLi mode. 4119 ;; Set SQLi mode.
4109 (let ((sql-interactive-product product)) 4120 (let ((sql-interactive-product product))
@@ -4113,7 +4124,7 @@ the call to \\[sql-product-interactive] with
4113 (setq new-sqli-buffer (current-buffer)) 4124 (setq new-sqli-buffer (current-buffer))
4114 (when new-name 4125 (when new-name
4115 (sql-rename-buffer new-name)) 4126 (sql-rename-buffer new-name))
4116 (set (make-local-variable 'sql-buffer) 4127 (set (make-local-variable 'sql-buffer)
4117 (buffer-name new-sqli-buffer)) 4128 (buffer-name new-sqli-buffer))
4118 4129
4119 ;; Set `sql-buffer' in the start buffer 4130 ;; Set `sql-buffer' in the start buffer
diff --git a/lisp/progmodes/vhdl-mode.el b/lisp/progmodes/vhdl-mode.el
index d765a960470..c9bf638bb59 100644
--- a/lisp/progmodes/vhdl-mode.el
+++ b/lisp/progmodes/vhdl-mode.el
@@ -1,6 +1,6 @@
1;;; vhdl-mode.el --- major mode for editing VHDL code 1;;; vhdl-mode.el --- major mode for editing VHDL code
2 2
3;; Copyright (C) 1992-2012 Free Software Foundation, Inc. 3;; Copyright (C) 1992-2012 Free Software Foundation, Inc.
4 4
5;; Authors: Reto Zimmermann <reto@gnu.org> 5;; Authors: Reto Zimmermann <reto@gnu.org>
6;; Rodney J. Whitby <software.vhdl-mode@rwhitby.net> 6;; Rodney J. Whitby <software.vhdl-mode@rwhitby.net>
@@ -2040,7 +2040,7 @@ Ignore byte-compiler warnings you might see."
2040;; `wildcard-to-regexp' is included only in XEmacs 21 2040;; `wildcard-to-regexp' is included only in XEmacs 21
2041(unless (fboundp 'wildcard-to-regexp) 2041(unless (fboundp 'wildcard-to-regexp)
2042 (defun wildcard-to-regexp (wildcard) 2042 (defun wildcard-to-regexp (wildcard)
2043 "Simplified version of `wildcard-to-regexp' from Emacs' `files.el'." 2043 "Simplified version of `wildcard-to-regexp' from Emacs's `files.el'."
2044 (let* ((i (string-match "[*?]" wildcard)) 2044 (let* ((i (string-match "[*?]" wildcard))
2045 (result (substring wildcard 0 i)) 2045 (result (substring wildcard 0 i))
2046 (len (length wildcard))) 2046 (len (length wildcard)))
@@ -2087,7 +2087,7 @@ Ignore byte-compiler warnings you might see."
2087;; `file-expand-wildcards' undefined (XEmacs) 2087;; `file-expand-wildcards' undefined (XEmacs)
2088(unless (fboundp 'file-expand-wildcards) 2088(unless (fboundp 'file-expand-wildcards)
2089 (defun file-expand-wildcards (pattern &optional full) 2089 (defun file-expand-wildcards (pattern &optional full)
2090 "Taken from Emacs' `files.el'." 2090 "Taken from Emacs's `files.el'."
2091 (let* ((nondir (file-name-nondirectory pattern)) 2091 (let* ((nondir (file-name-nondirectory pattern))
2092 (dirpart (file-name-directory pattern)) 2092 (dirpart (file-name-directory pattern))
2093 (dirs (if (and dirpart (string-match "[[*?]" dirpart)) 2093 (dirs (if (and dirpart (string-match "[[*?]" dirpart))