diff options
| author | Tom Tromey | 2013-03-17 05:17:24 -0600 |
|---|---|---|
| committer | Tom Tromey | 2013-03-17 05:17:24 -0600 |
| commit | 6bd488cd8d05aa3983ca55f70ee384732d8c0085 (patch) | |
| tree | 5645fc7b882638d6c0eb3f61fd55bde1a63fc190 /lisp/progmodes | |
| parent | 71f91792e3013b397996905224f387da5cc539a9 (diff) | |
| parent | 9c44569ea2a18099307e0571d523d8637000a153 (diff) | |
| download | emacs-6bd488cd8d05aa3983ca55f70ee384732d8c0085.tar.gz emacs-6bd488cd8d05aa3983ca55f70ee384732d8c0085.zip | |
merge from trunk
Diffstat (limited to 'lisp/progmodes')
| -rw-r--r-- | lisp/progmodes/cfengine.el | 106 | ||||
| -rw-r--r-- | lisp/progmodes/gdb-mi.el | 632 | ||||
| -rw-r--r-- | lisp/progmodes/idlwave.el | 4 | ||||
| -rw-r--r-- | lisp/progmodes/scheme.el | 3 | ||||
| -rw-r--r-- | lisp/progmodes/sql.el | 317 |
5 files changed, 728 insertions, 334 deletions
diff --git a/lisp/progmodes/cfengine.el b/lisp/progmodes/cfengine.el index 6fb9caa1a42..74b81b0cd01 100644 --- a/lisp/progmodes/cfengine.el +++ b/lisp/progmodes/cfengine.el | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | ;; Author: Dave Love <fx@gnu.org> | 5 | ;; Author: Dave Love <fx@gnu.org> |
| 6 | ;; Maintainer: Ted Zlatanov <tzz@lifelogs.com> | 6 | ;; Maintainer: Ted Zlatanov <tzz@lifelogs.com> |
| 7 | ;; Keywords: languages | 7 | ;; Keywords: languages |
| 8 | ;; Version: 1.1 | 8 | ;; Version: 1.2 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -58,6 +58,70 @@ | |||
| 58 | :group 'cfengine | 58 | :group 'cfengine |
| 59 | :type 'integer) | 59 | :type 'integer) |
| 60 | 60 | ||
| 61 | (defcustom cfengine-parameters-indent '(promise pname 0) | ||
| 62 | "*Indentation of CFEngine3 promise parameters (hanging indent). | ||
| 63 | |||
| 64 | For example, say you have this code: | ||
| 65 | |||
| 66 | bundle x y | ||
| 67 | { | ||
| 68 | section: | ||
| 69 | class:: | ||
| 70 | promise ... | ||
| 71 | promiseparameter => ... | ||
| 72 | } | ||
| 73 | |||
| 74 | You can choose to indent promiseparameter from the beginning of | ||
| 75 | the line (absolutely) or from the word \"promise\" (relatively). | ||
| 76 | |||
| 77 | You can also choose to indent the start of the word | ||
| 78 | \"promiseparameter\" or the arrow that follows it. | ||
| 79 | |||
| 80 | Finally, you can choose the amount of the indent. | ||
| 81 | |||
| 82 | The default is to anchor at promise, indent parameter name, and offset 0: | ||
| 83 | |||
| 84 | bundle agent rcfiles | ||
| 85 | { | ||
| 86 | files: | ||
| 87 | any:: | ||
| 88 | \"/tmp/netrc\" | ||
| 89 | comment => \"my netrc\", | ||
| 90 | perms => mog(\"600\", \"tzz\", \"tzz\"); | ||
| 91 | } | ||
| 92 | |||
| 93 | Here we anchor at beginning of line, indent arrow, and offset 10: | ||
| 94 | |||
| 95 | bundle agent rcfiles | ||
| 96 | { | ||
| 97 | files: | ||
| 98 | any:: | ||
| 99 | \"/tmp/netrc\" | ||
| 100 | comment => \"my netrc\", | ||
| 101 | perms => mog(\"600\", \"tzz\", \"tzz\"); | ||
| 102 | } | ||
| 103 | |||
| 104 | Some, including cfengine_stdlib.cf, like to anchor at promise, indent | ||
| 105 | arrow, and offset 16 or so: | ||
| 106 | |||
| 107 | bundle agent rcfiles | ||
| 108 | { | ||
| 109 | files: | ||
| 110 | any:: | ||
| 111 | \"/tmp/netrc\" | ||
| 112 | comment => \"my netrc\", | ||
| 113 | perms => mog(\"600\", \"tzz\", \"tzz\"); | ||
| 114 | } | ||
| 115 | " | ||
| 116 | |||
| 117 | :group 'cfengine | ||
| 118 | :type '(list | ||
| 119 | (choice (const :tag "Anchor at beginning of promise" promise) | ||
| 120 | (const :tag "Anchor at beginning of line" bol)) | ||
| 121 | (choice (const :tag "Indent parameter name" pname) | ||
| 122 | (const :tag "Indent arrow" arrow)) | ||
| 123 | (integer :tag "Indentation amount from anchor"))) | ||
| 124 | |||
| 61 | (defvar cfengine-mode-debug nil | 125 | (defvar cfengine-mode-debug nil |
| 62 | "Whether `cfengine-mode' should print debugging info.") | 126 | "Whether `cfengine-mode' should print debugging info.") |
| 63 | 127 | ||
| @@ -94,7 +158,7 @@ This includes those for cfservd as well as cfagent.") | |||
| 94 | (regexp-opt cfengine3-defuns t) | 158 | (regexp-opt cfengine3-defuns t) |
| 95 | "Regex to match the CFEngine 3.x defuns.") | 159 | "Regex to match the CFEngine 3.x defuns.") |
| 96 | 160 | ||
| 97 | (defconst cfengine3-class-selector-regex "\\([[:alnum:]_().&|!]+\\)::") | 161 | (defconst cfengine3-class-selector-regex "\\([[:alnum:]_().&|!:]+\\)::") |
| 98 | 162 | ||
| 99 | (defconst cfengine3-category-regex "\\([[:alnum:]_]+\\):") | 163 | (defconst cfengine3-category-regex "\\([[:alnum:]_]+\\):") |
| 100 | 164 | ||
| @@ -126,8 +190,8 @@ This includes those for cfservd as well as cfagent.") | |||
| 126 | ;; Defuns. This happens early so they don't get caught by looser | 190 | ;; Defuns. This happens early so they don't get caught by looser |
| 127 | ;; patterns. | 191 | ;; patterns. |
| 128 | (,(concat "\\<" cfengine3-defuns-regex "\\>" | 192 | (,(concat "\\<" cfengine3-defuns-regex "\\>" |
| 129 | "[ \t]+\\<\\([[:alnum:]_]+\\)\\>" | 193 | "[ \t]+\\<\\([[:alnum:]_.:]+\\)\\>" |
| 130 | "[ \t]+\\<\\([[:alnum:]_]+\\)" | 194 | "[ \t]+\\<\\([[:alnum:]_.:]+\\)" |
| 131 | ;; Optional parentheses with variable names inside. | 195 | ;; Optional parentheses with variable names inside. |
| 132 | "\\(?:(\\([^)]*\\))\\)?") | 196 | "\\(?:(\\([^)]*\\))\\)?") |
| 133 | (1 font-lock-builtin-face) | 197 | (1 font-lock-builtin-face) |
| @@ -144,8 +208,8 @@ This includes those for cfservd as well as cfagent.") | |||
| 144 | 1 font-lock-builtin-face) | 208 | 1 font-lock-builtin-face) |
| 145 | 209 | ||
| 146 | ;; Variables, including scope, e.g. module.var | 210 | ;; Variables, including scope, e.g. module.var |
| 147 | ("[@$](\\([[:alnum:]_.]+\\))" 1 font-lock-variable-name-face) | 211 | ("[@$](\\([[:alnum:]_.:]+\\))" 1 font-lock-variable-name-face) |
| 148 | ("[@$]{\\([[:alnum:]_.]+\\)}" 1 font-lock-variable-name-face) | 212 | ("[@$]{\\([[:alnum:]_.:]+\\)}" 1 font-lock-variable-name-face) |
| 149 | 213 | ||
| 150 | ;; Variable definitions. | 214 | ;; Variable definitions. |
| 151 | ("\\<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1 font-lock-variable-name-face) | 215 | ("\\<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1 font-lock-variable-name-face) |
| @@ -305,10 +369,10 @@ Intended as the value of `indent-line-function'." | |||
| 305 | ((looking-at (concat cfengine3-defuns-regex "\\>")) | 369 | ((looking-at (concat cfengine3-defuns-regex "\\>")) |
| 306 | (indent-line-to 0)) | 370 | (indent-line-to 0)) |
| 307 | ;; Categories are indented one step. | 371 | ;; Categories are indented one step. |
| 308 | ((looking-at (concat cfengine3-category-regex "[ \t]*$")) | 372 | ((looking-at (concat cfengine3-category-regex "[ \t]*\\(#.*\\)*$")) |
| 309 | (indent-line-to cfengine-indent)) | 373 | (indent-line-to cfengine-indent)) |
| 310 | ;; Class selectors are indented two steps. | 374 | ;; Class selectors are indented two steps. |
| 311 | ((looking-at (concat cfengine3-class-selector-regex "[ \t]*$")) | 375 | ((looking-at (concat cfengine3-class-selector-regex "[ \t]*\\(#.*\\)*$")) |
| 312 | (indent-line-to (* 2 cfengine-indent))) | 376 | (indent-line-to (* 2 cfengine-indent))) |
| 313 | ;; Outdent leading close brackets one step. | 377 | ;; Outdent leading close brackets one step. |
| 314 | ((or (eq ?\} (char-after)) | 378 | ((or (eq ?\} (char-after)) |
| @@ -317,6 +381,8 @@ Intended as the value of `indent-line-function'." | |||
| 317 | (indent-line-to (save-excursion | 381 | (indent-line-to (save-excursion |
| 318 | (forward-char) | 382 | (forward-char) |
| 319 | (backward-sexp) | 383 | (backward-sexp) |
| 384 | (move-beginning-of-line nil) | ||
| 385 | (skip-chars-forward " \t") | ||
| 320 | (current-column))) | 386 | (current-column))) |
| 321 | (error nil))) | 387 | (error nil))) |
| 322 | ;; Inside a string and it starts before this line. | 388 | ;; Inside a string and it starts before this line. |
| @@ -331,7 +397,23 @@ Intended as the value of `indent-line-function'." | |||
| 331 | ;; plus 2. That way, promises indent deeper than class | 397 | ;; plus 2. That way, promises indent deeper than class |
| 332 | ;; selectors, which in turn are one deeper than categories. | 398 | ;; selectors, which in turn are one deeper than categories. |
| 333 | ((= 1 (nth 0 parse)) | 399 | ((= 1 (nth 0 parse)) |
| 334 | (indent-line-to (* (+ 2 (nth 0 parse)) cfengine-indent))) | 400 | (let ((p-anchor (nth 0 cfengine-parameters-indent)) |
| 401 | (p-what (nth 1 cfengine-parameters-indent)) | ||
| 402 | (p-indent (nth 2 cfengine-parameters-indent))) | ||
| 403 | ;; Do we have the parameter anchor and location and indent | ||
| 404 | ;; defined, and are we looking at a promise parameter? | ||
| 405 | (if (and p-anchor p-what p-indent | ||
| 406 | (looking-at "\\([[:alnum:]_]+[ \t]*\\)=>")) | ||
| 407 | (let* ((arrow-offset (* -1 (length (match-string 1)))) | ||
| 408 | (extra-offset (if (eq p-what 'arrow) arrow-offset 0)) | ||
| 409 | (base-offset (if (eq p-anchor 'promise) | ||
| 410 | (* (+ 2 (nth 0 parse)) cfengine-indent) | ||
| 411 | 0))) | ||
| 412 | (indent-line-to (max 0 (+ p-indent base-offset extra-offset)))) | ||
| 413 | ;; Else, indent to cfengine-indent times the nested depth | ||
| 414 | ;; plus 2. That way, promises indent deeper than class | ||
| 415 | ;; selectors, which in turn are one deeper than categories. | ||
| 416 | (indent-line-to (* (+ 2 (nth 0 parse)) cfengine-indent))))) | ||
| 335 | ;; Inside brackets/parens: indent to start column of non-comment | 417 | ;; Inside brackets/parens: indent to start column of non-comment |
| 336 | ;; token on line following open bracket or by one step from open | 418 | ;; token on line following open bracket or by one step from open |
| 337 | ;; bracket's column. | 419 | ;; bracket's column. |
| @@ -436,7 +518,8 @@ Intended as the value of `indent-line-function'." | |||
| 436 | ;; The syntax defaults seem OK to give reasonable word movement. | 518 | ;; The syntax defaults seem OK to give reasonable word movement. |
| 437 | (modify-syntax-entry ?# "<" table) | 519 | (modify-syntax-entry ?# "<" table) |
| 438 | (modify-syntax-entry ?\n ">#" table) | 520 | (modify-syntax-entry ?\n ">#" table) |
| 439 | (modify-syntax-entry ?\" "\"" table) | 521 | (modify-syntax-entry ?\" "\"" table) ; "string" |
| 522 | (modify-syntax-entry ?\' "\"" table) ; 'string' | ||
| 440 | ;; Variable substitution. | 523 | ;; Variable substitution. |
| 441 | (modify-syntax-entry ?$ "." table) | 524 | (modify-syntax-entry ?$ "." table) |
| 442 | ;; Doze path separators. | 525 | ;; Doze path separators. |
| @@ -475,7 +558,6 @@ to the action header." | |||
| 475 | ;; Shell commands can be quoted by single, double or back quotes. | 558 | ;; Shell commands can be quoted by single, double or back quotes. |
| 476 | ;; It's debatable whether we should define string syntax, but it | 559 | ;; It's debatable whether we should define string syntax, but it |
| 477 | ;; should avoid potential confusion in some cases. | 560 | ;; should avoid potential confusion in some cases. |
| 478 | (modify-syntax-entry ?\' "\"" cfengine2-mode-syntax-table) | ||
| 479 | (modify-syntax-entry ?\` "\"" cfengine2-mode-syntax-table) | 561 | (modify-syntax-entry ?\` "\"" cfengine2-mode-syntax-table) |
| 480 | 562 | ||
| 481 | (set (make-local-variable 'indent-line-function) #'cfengine2-indent-line) | 563 | (set (make-local-variable 'indent-line-function) #'cfengine2-indent-line) |
| @@ -505,7 +587,7 @@ on the buffer contents" | |||
| 505 | (forward-line))) | 587 | (forward-line))) |
| 506 | (if v3 (cfengine3-mode) (cfengine2-mode)))) | 588 | (if v3 (cfengine3-mode) (cfengine2-mode)))) |
| 507 | 589 | ||
| 508 | (defalias 'cfengine-mode 'cfengine-auto-mode) | 590 | (defalias 'cfengine-mode 'cfengine3-mode) |
| 509 | 591 | ||
| 510 | (provide 'cfengine3) | 592 | (provide 'cfengine3) |
| 511 | (provide 'cfengine) | 593 | (provide 'cfengine) |
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index 90c7cfc5008..8ba2822c3a3 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; gdb-mi.el --- User Interface for running GDB | 1 | ;;; gdb-mi.el --- User Interface for running GDB -*- lexical-binding: t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2007-2013 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2007-2013 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -192,8 +192,8 @@ address for root variables.") | |||
| 192 | (defvar gdb-disassembly-position nil) | 192 | (defvar gdb-disassembly-position nil) |
| 193 | 193 | ||
| 194 | (defvar gdb-location-alist nil | 194 | (defvar gdb-location-alist nil |
| 195 | "Alist of breakpoint numbers and full filenames. Only used for files that | 195 | "Alist of breakpoint numbers and full filenames. |
| 196 | Emacs can't find.") | 196 | Only used for files that Emacs can't find.") |
| 197 | (defvar gdb-active-process nil | 197 | (defvar gdb-active-process nil |
| 198 | "GUD tooltips display variable values when t, and macro definitions otherwise.") | 198 | "GUD tooltips display variable values when t, and macro definitions otherwise.") |
| 199 | (defvar gdb-error "Non-nil when GDB is reporting an error.") | 199 | (defvar gdb-error "Non-nil when GDB is reporting an error.") |
| @@ -227,9 +227,8 @@ This variable is updated in `gdb-done-or-error' and returned by | |||
| 227 | It is initialized to `gdb-non-stop-setting' at the beginning of | 227 | It is initialized to `gdb-non-stop-setting' at the beginning of |
| 228 | every GDB session.") | 228 | every GDB session.") |
| 229 | 229 | ||
| 230 | (defvar gdb-buffer-type nil | 230 | (defvar-local gdb-buffer-type nil |
| 231 | "One of the symbols bound in `gdb-buffer-rules'.") | 231 | "One of the symbols bound in `gdb-buffer-rules'.") |
| 232 | (make-variable-buffer-local 'gdb-buffer-type) | ||
| 233 | 232 | ||
| 234 | (defvar gdb-output-sink 'nil | 233 | (defvar gdb-output-sink 'nil |
| 235 | "The disposition of the output of the current gdb command. | 234 | "The disposition of the output of the current gdb command. |
| @@ -294,9 +293,7 @@ argument (see `gdb-emit-signal')." | |||
| 294 | (funcall (cdr subscriber) signal))) | 293 | (funcall (cdr subscriber) signal))) |
| 295 | 294 | ||
| 296 | (defvar gdb-buf-publisher '() | 295 | (defvar gdb-buf-publisher '() |
| 297 | "Used to invalidate GDB buffers by emitting a signal in | 296 | "Used to invalidate GDB buffers by emitting a signal in `gdb-update'. |
| 298 | `gdb-update'. | ||
| 299 | |||
| 300 | Must be a list of pairs with cars being buffers and cdr's being | 297 | Must be a list of pairs with cars being buffers and cdr's being |
| 301 | valid signal handlers.") | 298 | valid signal handlers.") |
| 302 | 299 | ||
| @@ -327,8 +324,7 @@ valid signal handlers.") | |||
| 327 | "When in non-stop mode, stopped threads can be examined while | 324 | "When in non-stop mode, stopped threads can be examined while |
| 328 | other threads continue to execute. | 325 | other threads continue to execute. |
| 329 | 326 | ||
| 330 | GDB session needs to be restarted for this setting to take | 327 | GDB session needs to be restarted for this setting to take effect." |
| 331 | effect." | ||
| 332 | :type 'boolean | 328 | :type 'boolean |
| 333 | :group 'gdb-non-stop | 329 | :group 'gdb-non-stop |
| 334 | :version "23.2") | 330 | :version "23.2") |
| @@ -336,19 +332,18 @@ effect." | |||
| 336 | ;; TODO Some commands can't be called with --all (give a notice about | 332 | ;; TODO Some commands can't be called with --all (give a notice about |
| 337 | ;; it in setting doc) | 333 | ;; it in setting doc) |
| 338 | (defcustom gdb-gud-control-all-threads t | 334 | (defcustom gdb-gud-control-all-threads t |
| 339 | "When enabled, GUD execution commands affect all threads when | 335 | "When non-nil, GUD execution commands affect all threads when |
| 340 | in non-stop mode. Otherwise, only current thread is affected." | 336 | in non-stop mode. Otherwise, only current thread is affected." |
| 341 | :type 'boolean | 337 | :type 'boolean |
| 342 | :group 'gdb-non-stop | 338 | :group 'gdb-non-stop |
| 343 | :version "23.2") | 339 | :version "23.2") |
| 344 | 340 | ||
| 345 | (defcustom gdb-switch-reasons t | 341 | (defcustom gdb-switch-reasons t |
| 346 | "List of stop reasons which cause Emacs to switch to the thread | 342 | "List of stop reasons for which Emacs should switch thread. |
| 347 | which caused the stop. When t, switch to stopped thread no matter | 343 | When t, switch to stopped thread no matter what the reason was. |
| 348 | what the reason was. When nil, never switch to stopped thread | 344 | When nil, never switch to stopped thread automatically. |
| 349 | automatically. | ||
| 350 | 345 | ||
| 351 | This setting is used in non-stop mode only. In all-stop mode, | 346 | This setting is used in non-stop mode only. In all-stop mode, |
| 352 | Emacs always switches to the thread which caused the stop." | 347 | Emacs always switches to the thread which caused the stop." |
| 353 | ;; exited, exited-normally and exited-signaled are not | 348 | ;; exited, exited-normally and exited-signaled are not |
| 354 | ;; thread-specific stop reasons and therefore are not included in | 349 | ;; thread-specific stop reasons and therefore are not included in |
| @@ -404,7 +399,7 @@ and GDB buffers were updated in `gdb-stopped'." | |||
| 404 | :link '(info-link "(gdb)GDB/MI Async Records")) | 399 | :link '(info-link "(gdb)GDB/MI Async Records")) |
| 405 | 400 | ||
| 406 | (defcustom gdb-switch-when-another-stopped t | 401 | (defcustom gdb-switch-when-another-stopped t |
| 407 | "When nil, Emacs won't switch to stopped thread if some other | 402 | "When nil, don't switch to stopped thread if some other |
| 408 | stopped thread is already selected." | 403 | stopped thread is already selected." |
| 409 | :type 'boolean | 404 | :type 'boolean |
| 410 | :group 'gdb-non-stop | 405 | :group 'gdb-non-stop |
| @@ -447,8 +442,7 @@ stopped thread is already selected." | |||
| 447 | :version "23.2") | 442 | :version "23.2") |
| 448 | 443 | ||
| 449 | (defcustom gdb-show-threads-by-default nil | 444 | (defcustom gdb-show-threads-by-default nil |
| 450 | "Show threads list buffer instead of breakpoints list by | 445 | "Show threads list buffer instead of breakpoints list by default." |
| 451 | default." | ||
| 452 | :type 'boolean | 446 | :type 'boolean |
| 453 | :group 'gdb-buffers | 447 | :group 'gdb-buffers |
| 454 | :version "23.2") | 448 | :version "23.2") |
| @@ -490,12 +484,12 @@ predefined macros." | |||
| 490 | 484 | ||
| 491 | (defcustom gdb-create-source-file-list t | 485 | (defcustom gdb-create-source-file-list t |
| 492 | "Non-nil means create a list of files from which the executable was built. | 486 | "Non-nil means create a list of files from which the executable was built. |
| 493 | Set this to nil if the GUD buffer displays \"initializing...\" in the mode | 487 | Set this to nil if the GUD buffer displays \"initializing...\" in the mode |
| 494 | line for a long time when starting, possibly because your executable was | 488 | line for a long time when starting, possibly because your executable was |
| 495 | built from a large number of files. This allows quicker initialization | 489 | built from a large number of files. This allows quicker initialization |
| 496 | but means that these files are not automatically enabled for debugging, | 490 | but means that these files are not automatically enabled for debugging, |
| 497 | e.g., you won't be able to click in the fringe to set a breakpoint until | 491 | e.g., you won't be able to click in the fringe to set a breakpoint until |
| 498 | execution has already stopped there." | 492 | execution has already stopped there." |
| 499 | :type 'boolean | 493 | :type 'boolean |
| 500 | :group 'gdb | 494 | :group 'gdb |
| 501 | :version "23.1") | 495 | :version "23.1") |
| @@ -507,6 +501,9 @@ Also display the main routine in the disassembly buffer if present." | |||
| 507 | :group 'gdb | 501 | :group 'gdb |
| 508 | :version "22.1") | 502 | :version "22.1") |
| 509 | 503 | ||
| 504 | (defvar gdbmi-debug-mode nil | ||
| 505 | "When non-nil, print the messages sent/received from GDB/MI in *Messages*.") | ||
| 506 | |||
| 510 | (defun gdb-force-mode-line-update (status) | 507 | (defun gdb-force-mode-line-update (status) |
| 511 | (let ((buffer gud-comint-buffer)) | 508 | (let ((buffer gud-comint-buffer)) |
| 512 | (if (and buffer (buffer-name buffer)) | 509 | (if (and buffer (buffer-name buffer)) |
| @@ -570,7 +567,7 @@ When `gdb-non-stop' is nil, return COMMAND unchanged." | |||
| 570 | 567 | ||
| 571 | (defmacro gdb-gud-context-call (cmd1 &optional cmd2 noall noarg) | 568 | (defmacro gdb-gud-context-call (cmd1 &optional cmd2 noall noarg) |
| 572 | "`gud-call' wrapper which adds --thread/--all options between | 569 | "`gud-call' wrapper which adds --thread/--all options between |
| 573 | CMD1 and CMD2. NOALL is the same as in `gdb-gud-context-command'. | 570 | CMD1 and CMD2. NOALL is the same as in `gdb-gud-context-command'. |
| 574 | 571 | ||
| 575 | NOARG must be t when this macro is used outside `gud-def'" | 572 | NOARG must be t when this macro is used outside `gud-def'" |
| 576 | `(gud-call | 573 | `(gud-call |
| @@ -603,7 +600,7 @@ and source-file directory for your debugger. | |||
| 603 | 600 | ||
| 604 | COMMAND-LINE is the shell command for starting the gdb session. | 601 | COMMAND-LINE is the shell command for starting the gdb session. |
| 605 | It should be a string consisting of the name of the gdb | 602 | It should be a string consisting of the name of the gdb |
| 606 | executable followed by command-line options. The command-line | 603 | executable followed by command line options. The command line |
| 607 | options should include \"-i=mi\" to use gdb's MI text interface. | 604 | options should include \"-i=mi\" to use gdb's MI text interface. |
| 608 | Note that the old \"--annotate\" option is no longer supported. | 605 | Note that the old \"--annotate\" option is no longer supported. |
| 609 | 606 | ||
| @@ -846,6 +843,8 @@ detailed description of this mode. | |||
| 846 | gdb-register-names '() | 843 | gdb-register-names '() |
| 847 | gdb-non-stop gdb-non-stop-setting) | 844 | gdb-non-stop gdb-non-stop-setting) |
| 848 | ;; | 845 | ;; |
| 846 | (gdbmi-bnf-init) | ||
| 847 | ;; | ||
| 849 | (setq gdb-buffer-type 'gdbmi) | 848 | (setq gdb-buffer-type 'gdbmi) |
| 850 | ;; | 849 | ;; |
| 851 | (gdb-force-mode-line-update | 850 | (gdb-force-mode-line-update |
| @@ -1254,7 +1253,7 @@ With arg, enter name of variable to be watched in the minibuffer." | |||
| 1254 | (cond | 1253 | (cond |
| 1255 | ((> new previous) | 1254 | ((> new previous) |
| 1256 | ;; Add new children to list. | 1255 | ;; Add new children to list. |
| 1257 | (dotimes (dummy previous) | 1256 | (dotimes (_ previous) |
| 1258 | (push (pop temp-var-list) var-list)) | 1257 | (push (pop temp-var-list) var-list)) |
| 1259 | (dolist (child children) | 1258 | (dolist (child children) |
| 1260 | (let ((varchild | 1259 | (let ((varchild |
| @@ -1268,9 +1267,9 @@ With arg, enter name of variable to be watched in the minibuffer." | |||
| 1268 | (push varchild var-list)))) | 1267 | (push varchild var-list)))) |
| 1269 | ;; Remove deleted children from list. | 1268 | ;; Remove deleted children from list. |
| 1270 | ((< new previous) | 1269 | ((< new previous) |
| 1271 | (dotimes (dummy new) | 1270 | (dotimes (_ new) |
| 1272 | (push (pop temp-var-list) var-list)) | 1271 | (push (pop temp-var-list) var-list)) |
| 1273 | (dotimes (dummy (- previous new)) | 1272 | (dotimes (_ (- previous new)) |
| 1274 | (pop temp-var-list))))) | 1273 | (pop temp-var-list))))) |
| 1275 | (push var1 var-list)) | 1274 | (push var1 var-list)) |
| 1276 | (setq var1 (pop temp-var-list))) | 1275 | (setq var1 (pop temp-var-list))) |
| @@ -1502,7 +1501,7 @@ this trigger is subscribed to `gdb-buf-publisher' and called with | |||
| 1502 | (gdb-input | 1501 | (gdb-input |
| 1503 | (concat "-inferior-tty-set " tty) 'ignore)))) | 1502 | (concat "-inferior-tty-set " tty) 'ignore)))) |
| 1504 | 1503 | ||
| 1505 | (defun gdb-inferior-io-sentinel (proc str) | 1504 | (defun gdb-inferior-io-sentinel (proc _str) |
| 1506 | (when (eq (process-status proc) 'failed) | 1505 | (when (eq (process-status proc) 'failed) |
| 1507 | ;; When the debugged process exits, Emacs gets an EIO error on | 1506 | ;; When the debugged process exits, Emacs gets an EIO error on |
| 1508 | ;; read from the pty, and stops listening to it. If the gdb | 1507 | ;; read from the pty, and stops listening to it. If the gdb |
| @@ -1739,6 +1738,7 @@ complete." | |||
| 1739 | (setq gdb-token-number (1+ gdb-token-number)) | 1738 | (setq gdb-token-number (1+ gdb-token-number)) |
| 1740 | (setq command (concat (number-to-string gdb-token-number) command)) | 1739 | (setq command (concat (number-to-string gdb-token-number) command)) |
| 1741 | (push (cons gdb-token-number handler-function) gdb-handler-alist) | 1740 | (push (cons gdb-token-number handler-function) gdb-handler-alist) |
| 1741 | (if gdbmi-debug-mode (message "gdb-input: %s" command)) | ||
| 1742 | (process-send-string (get-buffer-process gud-comint-buffer) | 1742 | (process-send-string (get-buffer-process gud-comint-buffer) |
| 1743 | (concat command "\n"))) | 1743 | (concat command "\n"))) |
| 1744 | 1744 | ||
| @@ -1761,8 +1761,7 @@ If `gdb-thread-number' is nil, just wrap NAME in asterisks." | |||
| 1761 | "*")) | 1761 | "*")) |
| 1762 | 1762 | ||
| 1763 | (defun gdb-current-context-mode-name (mode) | 1763 | (defun gdb-current-context-mode-name (mode) |
| 1764 | "Add thread information to MODE which is to be used as | 1764 | "Add thread information to MODE which is to be used as `mode-name'." |
| 1765 | `mode-name'." | ||
| 1766 | (concat mode | 1765 | (concat mode |
| 1767 | (if gdb-thread-number | 1766 | (if gdb-thread-number |
| 1768 | (format " [thread %s]" gdb-thread-number) | 1767 | (format " [thread %s]" gdb-thread-number) |
| @@ -1809,7 +1808,8 @@ If NO-PROC is non-nil, do not try to contact the GDB process." | |||
| 1809 | ;; because we may need to update current gud-running value without | 1808 | ;; because we may need to update current gud-running value without |
| 1810 | ;; changing current thread (see gdb-running) | 1809 | ;; changing current thread (see gdb-running) |
| 1811 | (defun gdb-setq-thread-number (number) | 1810 | (defun gdb-setq-thread-number (number) |
| 1812 | "Only this function must be used to change `gdb-thread-number' | 1811 | "Set `gdb-thread-number' to NUMBER. |
| 1812 | Only this function must be used to change `gdb-thread-number' | ||
| 1813 | value to NUMBER, because `gud-running' and `gdb-frame-number' | 1813 | value to NUMBER, because `gud-running' and `gdb-frame-number' |
| 1814 | need to be updated appropriately when current thread changes." | 1814 | need to be updated appropriately when current thread changes." |
| 1815 | ;; GDB 6.8 and earlier always output thread-id="0" when stopping. | 1815 | ;; GDB 6.8 and earlier always output thread-id="0" when stopping. |
| @@ -1824,7 +1824,7 @@ need to be updated appropriately when current thread changes." | |||
| 1824 | 1824 | ||
| 1825 | Note that when `gdb-gud-control-all-threads' is t, `gud-running' | 1825 | Note that when `gdb-gud-control-all-threads' is t, `gud-running' |
| 1826 | cannot be reliably used to determine whether or not execution | 1826 | cannot be reliably used to determine whether or not execution |
| 1827 | control buttons should be shown in menu or toolbar. Use | 1827 | control buttons should be shown in menu or toolbar. Use |
| 1828 | `gdb-running-threads-count' and `gdb-stopped-threads-count' | 1828 | `gdb-running-threads-count' and `gdb-stopped-threads-count' |
| 1829 | instead. | 1829 | instead. |
| 1830 | 1830 | ||
| @@ -1874,23 +1874,337 @@ is running." | |||
| 1874 | (set-window-buffer source-window buffer)) | 1874 | (set-window-buffer source-window buffer)) |
| 1875 | source-window)) | 1875 | source-window)) |
| 1876 | 1876 | ||
| 1877 | (defun gdb-car< (a b) | 1877 | |
| 1878 | (< (car a) (car b))) | 1878 | (defun gdbmi-start-with (str offset match) |
| 1879 | 1879 | "Return non-nil if string STR starts with MATCH, else returns nil. | |
| 1880 | (defvar gdbmi-record-list | 1880 | OFFSET is the position in STR at which the comparison takes place." |
| 1881 | '((gdb-gdb . "(gdb) \n") | 1881 | (let ((match-length (length match)) |
| 1882 | (gdb-done . "\\([0-9]*\\)\\^done,?\\(.*?\\)\n") | 1882 | (str-length (- (length str) offset))) |
| 1883 | (gdb-starting . "\\([0-9]*\\)\\^running\n") | 1883 | (when (>= str-length match-length) |
| 1884 | (gdb-error . "\\([0-9]*\\)\\^error,\\(.*?\\)\n") | 1884 | (string-equal match (substring str offset (+ offset match-length)))))) |
| 1885 | (gdb-console . "~\\(\".*?\"\\)\n") | 1885 | |
| 1886 | (gdb-internals . "&\\(\".*?\"\\)\n") | 1886 | (defun gdbmi-same-start (str offset match) |
| 1887 | (gdb-stopped . "\\*stopped,?\\(.*?\\)\n") | 1887 | "Return non-nil iff STR and MATCH are equal up to the end of either strings. |
| 1888 | (gdb-running . "\\*running,\\(.*?\n\\)") | 1888 | OFFSET is the position in STR at which the comparison takes place." |
| 1889 | (gdb-thread-created . "=thread-created,\\(.*?\n\\)") | 1889 | (let* ((str-length (- (length str) offset)) |
| 1890 | (gdb-thread-selected . "=thread-selected,\\(.*?\\)\n") | 1890 | (match-length (length match)) |
| 1891 | (gdb-thread-exited . "=thread-exited,\\(.*?\n\\)") | 1891 | (compare-length (min str-length match-length))) |
| 1892 | (gdb-ignored-notification . "=[-[:alpha:]]+,?\\(.*?\\)\n") | 1892 | (when (> compare-length 0) |
| 1893 | (gdb-shell . "\\(\\(?:^.+\n\\)+\\)"))) | 1893 | (string-equal (substring str offset (+ offset compare-length)) |
| 1894 | (substring match 0 compare-length))))) | ||
| 1895 | |||
| 1896 | (defun gdbmi-is-number (character) | ||
| 1897 | "Return non-nil iff CHARACTER is a numerical character between 0 and 9." | ||
| 1898 | (and (>= character ?0) | ||
| 1899 | (<= character ?9))) | ||
| 1900 | |||
| 1901 | |||
| 1902 | (defvar-local gdbmi-bnf-state 'gdbmi-bnf-output | ||
| 1903 | "Current GDB/MI output parser state. | ||
| 1904 | The parser is placed in a different state when an incomplete data steam is | ||
| 1905 | received from GDB. | ||
| 1906 | This variable will preserve the state required to resume the parsing | ||
| 1907 | when more data arrives.") | ||
| 1908 | |||
| 1909 | (defvar-local gdbmi-bnf-offset 0 | ||
| 1910 | "Offset in `gud-marker-acc' at which the parser is reading. | ||
| 1911 | This offset is used to be able to parse the GDB/MI message | ||
| 1912 | in-place, without the need of copying the string in a temporary buffer | ||
| 1913 | or discarding parsed tokens by substringing the message.") | ||
| 1914 | |||
| 1915 | (defun gdbmi-bnf-init () | ||
| 1916 | "Initialize the GDB/MI message parser." | ||
| 1917 | (setq gdbmi-bnf-state 'gdbmi-bnf-output) | ||
| 1918 | (setq gdbmi-bnf-offset 0) | ||
| 1919 | (setq gud-marker-acc "")) | ||
| 1920 | |||
| 1921 | |||
| 1922 | (defun gdbmi-bnf-output () | ||
| 1923 | "Implementation of the following GDB/MI output grammar rule: | ||
| 1924 | |||
| 1925 | output ==> | ||
| 1926 | ( out-of-band-record )* [ result-record ] gdb-prompt" | ||
| 1927 | |||
| 1928 | (gdbmi-bnf-skip-unrecognized) | ||
| 1929 | (while (gdbmi-bnf-out-of-band-record)) | ||
| 1930 | (gdbmi-bnf-result-record) | ||
| 1931 | (gdbmi-bnf-gdb-prompt)) | ||
| 1932 | |||
| 1933 | |||
| 1934 | (defun gdbmi-bnf-skip-unrecognized () | ||
| 1935 | "Skip characters until is encounters the beginning of a valid record. | ||
| 1936 | Used as a protection mechanism in case something goes wrong when parsing | ||
| 1937 | a GDB/MI reply message." | ||
| 1938 | (let ((acc-length (length gud-marker-acc)) | ||
| 1939 | (prefix-offset gdbmi-bnf-offset) | ||
| 1940 | (prompt "(gdb) \n")) | ||
| 1941 | |||
| 1942 | (while (and (< prefix-offset acc-length) | ||
| 1943 | (gdbmi-is-number (aref gud-marker-acc prefix-offset))) | ||
| 1944 | (setq prefix-offset (1+ prefix-offset))) | ||
| 1945 | |||
| 1946 | (if (and (< prefix-offset acc-length) | ||
| 1947 | (not (memq (aref gud-marker-acc prefix-offset) | ||
| 1948 | '(?^ ?* ?+ ?= ?~ ?@ ?&))) | ||
| 1949 | (not (gdbmi-same-start gud-marker-acc gdbmi-bnf-offset prompt)) | ||
| 1950 | (string-match "\\([^^*+=~@&]+\\)" gud-marker-acc | ||
| 1951 | gdbmi-bnf-offset)) | ||
| 1952 | (let ((unrecognized-str (match-string 0 gud-marker-acc))) | ||
| 1953 | (setq gdbmi-bnf-offset (match-end 0)) | ||
| 1954 | (if gdbmi-debug-mode | ||
| 1955 | (message "gdbmi-bnf-skip-unrecognized: %s" unrecognized-str)) | ||
| 1956 | (gdb-shell unrecognized-str) | ||
| 1957 | t)))) | ||
| 1958 | |||
| 1959 | |||
| 1960 | (defun gdbmi-bnf-gdb-prompt () | ||
| 1961 | "Implementation of the following GDB/MI output grammar rule: | ||
| 1962 | gdb-prompt ==> | ||
| 1963 | '(gdb)' nl | ||
| 1964 | |||
| 1965 | nl ==> | ||
| 1966 | CR | CR-LF" | ||
| 1967 | |||
| 1968 | (let ((prompt "(gdb) \n")) | ||
| 1969 | (when (gdbmi-start-with gud-marker-acc gdbmi-bnf-offset prompt) | ||
| 1970 | (if gdbmi-debug-mode (message "gdbmi-bnf-gdb-prompt: %s" prompt)) | ||
| 1971 | (gdb-gdb prompt) | ||
| 1972 | (setq gdbmi-bnf-offset (+ gdbmi-bnf-offset (length prompt))) | ||
| 1973 | |||
| 1974 | ;; Returns non-nil to tell gud-gdbmi-marker-filter we've reached | ||
| 1975 | ;; the end of a GDB reply message. | ||
| 1976 | t))) | ||
| 1977 | |||
| 1978 | |||
| 1979 | (defun gdbmi-bnf-result-record () | ||
| 1980 | "Implementation of the following GDB/MI output grammar rule: | ||
| 1981 | |||
| 1982 | result-record ==> | ||
| 1983 | [ token ] '^' result-class ( ',' result )* nl | ||
| 1984 | |||
| 1985 | token ==> | ||
| 1986 | any sequence of digits." | ||
| 1987 | |||
| 1988 | (gdbmi-bnf-result-and-async-record-impl)) | ||
| 1989 | |||
| 1990 | |||
| 1991 | (defun gdbmi-bnf-out-of-band-record () | ||
| 1992 | "Implementation of the following GDB/MI output grammar rule: | ||
| 1993 | |||
| 1994 | out-of-band-record ==> | ||
| 1995 | async-record | stream-record" | ||
| 1996 | |||
| 1997 | (or (gdbmi-bnf-async-record) | ||
| 1998 | (gdbmi-bnf-stream-record))) | ||
| 1999 | |||
| 2000 | |||
| 2001 | (defun gdbmi-bnf-async-record () | ||
| 2002 | "Implementation of the following GDB/MI output grammar rules: | ||
| 2003 | |||
| 2004 | async-record ==> | ||
| 2005 | exec-async-output | status-async-output | notify-async-output | ||
| 2006 | |||
| 2007 | exec-async-output ==> | ||
| 2008 | [ token ] '*' async-output | ||
| 2009 | |||
| 2010 | status-async-output ==> | ||
| 2011 | [ token ] '+' async-output | ||
| 2012 | |||
| 2013 | notify-async-output ==> | ||
| 2014 | [ token ] '=' async-output | ||
| 2015 | |||
| 2016 | async-output ==> | ||
| 2017 | async-class ( ',' result )* nl" | ||
| 2018 | |||
| 2019 | (gdbmi-bnf-result-and-async-record-impl)) | ||
| 2020 | |||
| 2021 | |||
| 2022 | (defun gdbmi-bnf-stream-record () | ||
| 2023 | "Implement the following GDB/MI output grammar rule: | ||
| 2024 | stream-record ==> | ||
| 2025 | console-stream-output | target-stream-output | log-stream-output | ||
| 2026 | |||
| 2027 | console-stream-output ==> | ||
| 2028 | '~' c-string | ||
| 2029 | |||
| 2030 | target-stream-output ==> | ||
| 2031 | '@' c-string | ||
| 2032 | |||
| 2033 | log-stream-output ==> | ||
| 2034 | '&' c-string" | ||
| 2035 | (when (< gdbmi-bnf-offset (length gud-marker-acc)) | ||
| 2036 | (if (and (member (aref gud-marker-acc gdbmi-bnf-offset) '(?~ ?@ ?&)) | ||
| 2037 | (string-match "\\([~@&]\\)\\(\".*?\"\\)\n" gud-marker-acc | ||
| 2038 | gdbmi-bnf-offset)) | ||
| 2039 | (let ((prefix (match-string 1 gud-marker-acc)) | ||
| 2040 | (c-string (match-string 2 gud-marker-acc))) | ||
| 2041 | |||
| 2042 | (setq gdbmi-bnf-offset (match-end 0)) | ||
| 2043 | (if gdbmi-debug-mode (message "gdbmi-bnf-stream-record: %s" | ||
| 2044 | (match-string 0 gud-marker-acc))) | ||
| 2045 | |||
| 2046 | (cond ((string-equal prefix "~") | ||
| 2047 | (gdbmi-bnf-console-stream-output c-string)) | ||
| 2048 | ((string-equal prefix "@") | ||
| 2049 | (gdbmi-bnf-target-stream-output c-string)) | ||
| 2050 | ((string-equal prefix "&") | ||
| 2051 | (gdbmi-bnf-log-stream-output c-string))) | ||
| 2052 | t)))) | ||
| 2053 | |||
| 2054 | (defun gdbmi-bnf-console-stream-output (c-string) | ||
| 2055 | "Handler for the console-stream-output GDB/MI output grammar rule." | ||
| 2056 | (gdb-console c-string)) | ||
| 2057 | |||
| 2058 | (defun gdbmi-bnf-target-stream-output (_c-string) | ||
| 2059 | "Handler for the target-stream-output GDB/MI output grammar rule." | ||
| 2060 | ;; Not currently used. | ||
| 2061 | ) | ||
| 2062 | |||
| 2063 | (defun gdbmi-bnf-log-stream-output (c-string) | ||
| 2064 | "Handler for the log-stream-output GDB/MI output grammar rule." | ||
| 2065 | ;; Suppress "No registers." GDB 6.8 and earlier | ||
| 2066 | ;; duplicates MI error message on internal stream. | ||
| 2067 | ;; Don't print to GUD buffer. | ||
| 2068 | (if (not (string-equal (read c-string) "No registers.\n")) | ||
| 2069 | (gdb-internals c-string))) | ||
| 2070 | |||
| 2071 | |||
| 2072 | (defconst gdbmi-bnf-result-state-configs | ||
| 2073 | '(("^" . (("done" . (gdb-done . progressive)) | ||
| 2074 | ("error" . (gdb-error . progressive)) | ||
| 2075 | ("running" . (gdb-starting . atomic)))) | ||
| 2076 | ("*" . (("stopped" . (gdb-stopped . atomic)) | ||
| 2077 | ("running" . (gdb-running . atomic)))) | ||
| 2078 | ("+" . ()) | ||
| 2079 | ("=" . (("thread-created" . (gdb-thread-created . atomic)) | ||
| 2080 | ("thread-selected" . (gdb-thread-selected . atomic)) | ||
| 2081 | ("thread-existed" . (gdb-ignored-notification . atomic)) | ||
| 2082 | ('default . (gdb-ignored-notification . atomic))))) | ||
| 2083 | "Alist of alists, mapping the type and class of message to a handler function. | ||
| 2084 | Handler functions are all flagged as either `progressive' or `atomic'. | ||
| 2085 | `progressive' handlers are capable of parsing incomplete messages. | ||
| 2086 | They can be called several time with new data chunk as they arrive from GDB. | ||
| 2087 | `progressive' handlers must have an extra argument that is set to a non-nil | ||
| 2088 | value when the message is complete. | ||
| 2089 | |||
| 2090 | Implement the following GDB/MI output grammar rule: | ||
| 2091 | result-class ==> | ||
| 2092 | 'done' | 'running' | 'connected' | 'error' | 'exit' | ||
| 2093 | |||
| 2094 | async-class ==> | ||
| 2095 | 'stopped' | others (where others will be added depending on the needs | ||
| 2096 | --this is still in development).") | ||
| 2097 | |||
| 2098 | (defun gdbmi-bnf-result-and-async-record-impl () | ||
| 2099 | "Common implementation of the result-record and async-record rule. | ||
| 2100 | Both rules share the same syntax. Those records may be very large in size. | ||
| 2101 | For that reason, the \"result\" part of the record is parsed by | ||
| 2102 | `gdbmi-bnf-incomplete-record-result', which will keep | ||
| 2103 | receiving characters as they arrive from GDB until the record is complete." | ||
| 2104 | (let ((acc-length (length gud-marker-acc)) | ||
| 2105 | (prefix-offset gdbmi-bnf-offset)) | ||
| 2106 | |||
| 2107 | (while (and (< prefix-offset acc-length) | ||
| 2108 | (gdbmi-is-number (aref gud-marker-acc prefix-offset))) | ||
| 2109 | (setq prefix-offset (1+ prefix-offset))) | ||
| 2110 | |||
| 2111 | (if (and (< prefix-offset acc-length) | ||
| 2112 | (member (aref gud-marker-acc prefix-offset) '(?* ?+ ?= ?^)) | ||
| 2113 | (string-match "\\([0-9]*\\)\\([*+=^]\\)\\(.+?\\)\\([,\n]\\)" | ||
| 2114 | gud-marker-acc gdbmi-bnf-offset)) | ||
| 2115 | |||
| 2116 | (let ((token (match-string 1 gud-marker-acc)) | ||
| 2117 | (prefix (match-string 2 gud-marker-acc)) | ||
| 2118 | (class (match-string 3 gud-marker-acc)) | ||
| 2119 | (complete (string-equal (match-string 4 gud-marker-acc) "\n")) | ||
| 2120 | class-alist | ||
| 2121 | class-command) | ||
| 2122 | |||
| 2123 | (setq gdbmi-bnf-offset (match-end 0)) | ||
| 2124 | (if gdbmi-debug-mode (message "gdbmi-bnf-result-record: %s" | ||
| 2125 | (match-string 0 gud-marker-acc))) | ||
| 2126 | |||
| 2127 | (setq class-alist | ||
| 2128 | (cdr (assoc prefix gdbmi-bnf-result-state-configs))) | ||
| 2129 | (setq class-command (cdr (assoc class class-alist))) | ||
| 2130 | (if (null class-command) | ||
| 2131 | (setq class-command (cdr (assoc 'default class-alist)))) | ||
| 2132 | |||
| 2133 | (if complete | ||
| 2134 | (if class-command | ||
| 2135 | (if (equal (cdr class-command) 'progressive) | ||
| 2136 | (funcall (car class-command) token "" complete) | ||
| 2137 | (funcall (car class-command) token ""))) | ||
| 2138 | (setq gdbmi-bnf-state | ||
| 2139 | (lambda () | ||
| 2140 | (gdbmi-bnf-incomplete-record-result token class-command))) | ||
| 2141 | (funcall gdbmi-bnf-state)) | ||
| 2142 | t)))) | ||
| 2143 | |||
| 2144 | (defun gdbmi-bnf-incomplete-record-result (token class-command) | ||
| 2145 | "State of the parser used to progressively parse a result-record or async-record | ||
| 2146 | rule from an incomplete data stream. The parser will stay in this state until | ||
| 2147 | the end of the current result or async record is reached." | ||
| 2148 | (when (< gdbmi-bnf-offset (length gud-marker-acc)) | ||
| 2149 | ;; Search the data stream for the end of the current record: | ||
| 2150 | (let* ((newline-pos (string-match "\n" gud-marker-acc gdbmi-bnf-offset)) | ||
| 2151 | (is-progressive (equal (cdr class-command) 'progressive)) | ||
| 2152 | (is-complete (not (null newline-pos))) | ||
| 2153 | result-str) | ||
| 2154 | |||
| 2155 | ;; Update the gdbmi-bnf-offset only if the current chunk of data can | ||
| 2156 | ;; be processed by the class-command handler: | ||
| 2157 | (when (or is-complete is-progressive) | ||
| 2158 | (setq result-str | ||
| 2159 | (substring gud-marker-acc gdbmi-bnf-offset newline-pos)) | ||
| 2160 | (setq gdbmi-bnf-offset (+ 1 newline-pos))) | ||
| 2161 | |||
| 2162 | (if gdbmi-debug-mode | ||
| 2163 | (message "gdbmi-bnf-incomplete-record-result: %s" | ||
| 2164 | (substring gud-marker-acc gdbmi-bnf-offset newline-pos))) | ||
| 2165 | |||
| 2166 | ;; Update the parsing state before invoking the handler in class-command | ||
| 2167 | ;; to make sure it's not left in an invalid state if the handler was | ||
| 2168 | ;; to generate an error. | ||
| 2169 | (if is-complete | ||
| 2170 | (setq gdbmi-bnf-state 'gdbmi-bnf-output)) | ||
| 2171 | |||
| 2172 | (if class-command | ||
| 2173 | (if is-progressive | ||
| 2174 | (funcall (car class-command) token result-str is-complete) | ||
| 2175 | (if is-complete | ||
| 2176 | (funcall (car class-command) token result-str)))) | ||
| 2177 | |||
| 2178 | (unless is-complete | ||
| 2179 | ;; Incomplete gdb response: abort parsing until we receive more data. | ||
| 2180 | (if gdbmi-debug-mode (message "gdbmi-bnf-incomplete-record-result, aborting: incomplete stream")) | ||
| 2181 | (throw 'gdbmi-incomplete-stream nil)) | ||
| 2182 | |||
| 2183 | is-complete))) | ||
| 2184 | |||
| 2185 | |||
| 2186 | ; The following grammar rules are not yet implemented by this GDBMI-BNF parser. | ||
| 2187 | ; The handling of those rules is currently done by the handlers registered | ||
| 2188 | ; in gdbmi-bnf-result-state-configs | ||
| 2189 | ; | ||
| 2190 | ; result ==> | ||
| 2191 | ; variable "=" value | ||
| 2192 | ; | ||
| 2193 | ; variable ==> | ||
| 2194 | ; string | ||
| 2195 | ; | ||
| 2196 | ; value ==> | ||
| 2197 | ; const | tuple | list | ||
| 2198 | ; | ||
| 2199 | ; const ==> | ||
| 2200 | ; c-string | ||
| 2201 | ; | ||
| 2202 | ; tuple ==> | ||
| 2203 | ; "{}" | "{" result ( "," result )* "}" | ||
| 2204 | ; | ||
| 2205 | ; list ==> | ||
| 2206 | ; "[]" | "[" value ( "," value )* "]" | "[" result ( "," result )* "]" | ||
| 2207 | |||
| 1894 | 2208 | ||
| 1895 | (defun gud-gdbmi-marker-filter (string) | 2209 | (defun gud-gdbmi-marker-filter (string) |
| 1896 | "Filter GDB/MI output." | 2210 | "Filter GDB/MI output." |
| @@ -1907,46 +2221,20 @@ is running." | |||
| 1907 | 2221 | ||
| 1908 | ;; Start accumulating output for the GUD buffer. | 2222 | ;; Start accumulating output for the GUD buffer. |
| 1909 | (setq gdb-filter-output "") | 2223 | (setq gdb-filter-output "") |
| 1910 | (let (output-record-list) | ||
| 1911 | |||
| 1912 | ;; Process all the complete markers in this chunk. | ||
| 1913 | (dolist (gdbmi-record gdbmi-record-list) | ||
| 1914 | (while (string-match (cdr gdbmi-record) gud-marker-acc) | ||
| 1915 | (push (list (match-beginning 0) | ||
| 1916 | (car gdbmi-record) | ||
| 1917 | (match-string 1 gud-marker-acc) | ||
| 1918 | (match-string 2 gud-marker-acc) | ||
| 1919 | (match-end 0)) | ||
| 1920 | output-record-list) | ||
| 1921 | (setq gud-marker-acc | ||
| 1922 | (concat (substring gud-marker-acc 0 (match-beginning 0)) | ||
| 1923 | ;; Pad with spaces to preserve position. | ||
| 1924 | (make-string (length (match-string 0 gud-marker-acc)) 32) | ||
| 1925 | (substring gud-marker-acc (match-end 0)))))) | ||
| 1926 | |||
| 1927 | (setq output-record-list (sort output-record-list 'gdb-car<)) | ||
| 1928 | |||
| 1929 | (dolist (output-record output-record-list) | ||
| 1930 | (let ((record-type (cadr output-record)) | ||
| 1931 | (arg1 (nth 2 output-record)) | ||
| 1932 | (arg2 (nth 3 output-record))) | ||
| 1933 | (cond ((eq record-type 'gdb-error) | ||
| 1934 | (gdb-done-or-error arg2 arg1 'error)) | ||
| 1935 | ((eq record-type 'gdb-done) | ||
| 1936 | (gdb-done-or-error arg2 arg1 'done)) | ||
| 1937 | ;; Suppress "No registers." GDB 6.8 and earlier | ||
| 1938 | ;; duplicates MI error message on internal stream. | ||
| 1939 | ;; Don't print to GUD buffer. | ||
| 1940 | ((not (and (eq record-type 'gdb-internals) | ||
| 1941 | (string-equal (read arg1) "No registers.\n"))) | ||
| 1942 | (funcall record-type arg1))))) | ||
| 1943 | 2224 | ||
| 1944 | (setq gdb-output-sink 'user) | 2225 | (let ((acc-length (length gud-marker-acc))) |
| 1945 | ;; Remove padding. | 2226 | (catch 'gdbmi-incomplete-stream |
| 1946 | (string-match "^ *" gud-marker-acc) | 2227 | (while (and (< gdbmi-bnf-offset acc-length) |
| 1947 | (setq gud-marker-acc (substring gud-marker-acc (match-end 0))) | 2228 | (funcall gdbmi-bnf-state))))) |
| 2229 | |||
| 2230 | (when (/= gdbmi-bnf-offset 0) | ||
| 2231 | (setq gud-marker-acc (substring gud-marker-acc gdbmi-bnf-offset)) | ||
| 2232 | (setq gdbmi-bnf-offset 0)) | ||
| 2233 | |||
| 2234 | (when (and gdbmi-debug-mode (> (length gud-marker-acc) 0)) | ||
| 2235 | (message "gud-gdbmi-marker-filter, unparsed string: %s" gud-marker-acc)) | ||
| 1948 | 2236 | ||
| 1949 | gdb-filter-output)) | 2237 | gdb-filter-output) |
| 1950 | 2238 | ||
| 1951 | (defun gdb-gdb (_output-field)) | 2239 | (defun gdb-gdb (_output-field)) |
| 1952 | 2240 | ||
| @@ -1954,13 +2242,13 @@ is running." | |||
| 1954 | (setq gdb-filter-output | 2242 | (setq gdb-filter-output |
| 1955 | (concat output-field gdb-filter-output))) | 2243 | (concat output-field gdb-filter-output))) |
| 1956 | 2244 | ||
| 1957 | (defun gdb-ignored-notification (_output-field)) | 2245 | (defun gdb-ignored-notification (_token _output-field)) |
| 1958 | 2246 | ||
| 1959 | ;; gdb-invalidate-threads is defined to accept 'update-threads signal | 2247 | ;; gdb-invalidate-threads is defined to accept 'update-threads signal |
| 1960 | (defun gdb-thread-created (_output-field)) | 2248 | (defun gdb-thread-created (_token _output-field)) |
| 1961 | (defun gdb-thread-exited (output-field) | 2249 | (defun gdb-thread-exited (_token output-field) |
| 1962 | "Handle =thread-exited async record: unset `gdb-thread-number' | 2250 | "Handle =thread-exited async record. |
| 1963 | if current thread exited and update threads list." | 2251 | Unset `gdb-thread-number' if current thread exited and update threads list." |
| 1964 | (let* ((thread-id (bindat-get-field (gdb-json-string output-field) 'id))) | 2252 | (let* ((thread-id (bindat-get-field (gdb-json-string output-field) 'id))) |
| 1965 | (if (string= gdb-thread-number thread-id) | 2253 | (if (string= gdb-thread-number thread-id) |
| 1966 | (gdb-setq-thread-number nil)) | 2254 | (gdb-setq-thread-number nil)) |
| @@ -1971,7 +2259,7 @@ is running." | |||
| 1971 | (gdb-wait-for-pending | 2259 | (gdb-wait-for-pending |
| 1972 | (gdb-emit-signal gdb-buf-publisher 'update-threads)))) | 2260 | (gdb-emit-signal gdb-buf-publisher 'update-threads)))) |
| 1973 | 2261 | ||
| 1974 | (defun gdb-thread-selected (output-field) | 2262 | (defun gdb-thread-selected (_token output-field) |
| 1975 | "Handler for =thread-selected MI output record. | 2263 | "Handler for =thread-selected MI output record. |
| 1976 | 2264 | ||
| 1977 | Sets `gdb-thread-number' to new id." | 2265 | Sets `gdb-thread-number' to new id." |
| @@ -1988,7 +2276,7 @@ Sets `gdb-thread-number' to new id." | |||
| 1988 | (gdb-wait-for-pending | 2276 | (gdb-wait-for-pending |
| 1989 | (gdb-update)))) | 2277 | (gdb-update)))) |
| 1990 | 2278 | ||
| 1991 | (defun gdb-running (output-field) | 2279 | (defun gdb-running (_token output-field) |
| 1992 | (let* ((thread-id | 2280 | (let* ((thread-id |
| 1993 | (bindat-get-field (gdb-json-string output-field) 'thread-id))) | 2281 | (bindat-get-field (gdb-json-string output-field) 'thread-id))) |
| 1994 | ;; We reset gdb-frame-number to nil if current thread has gone | 2282 | ;; We reset gdb-frame-number to nil if current thread has gone |
| @@ -2006,7 +2294,7 @@ Sets `gdb-thread-number' to new id." | |||
| 2006 | (setq gdb-active-process t) | 2294 | (setq gdb-active-process t) |
| 2007 | (gdb-emit-signal gdb-buf-publisher 'update-threads)) | 2295 | (gdb-emit-signal gdb-buf-publisher 'update-threads)) |
| 2008 | 2296 | ||
| 2009 | (defun gdb-starting (_output-field) | 2297 | (defun gdb-starting (_output-field _result) |
| 2010 | ;; CLI commands don't emit ^running at the moment so use gdb-running too. | 2298 | ;; CLI commands don't emit ^running at the moment so use gdb-running too. |
| 2011 | (setq gdb-inferior-status "running") | 2299 | (setq gdb-inferior-status "running") |
| 2012 | (gdb-force-mode-line-update | 2300 | (gdb-force-mode-line-update |
| @@ -2020,7 +2308,7 @@ Sets `gdb-thread-number' to new id." | |||
| 2020 | 2308 | ||
| 2021 | ;; -break-insert -t didn't give a reason before gdb 6.9 | 2309 | ;; -break-insert -t didn't give a reason before gdb 6.9 |
| 2022 | 2310 | ||
| 2023 | (defun gdb-stopped (output-field) | 2311 | (defun gdb-stopped (_token output-field) |
| 2024 | "Given the contents of *stopped MI async record, select new | 2312 | "Given the contents of *stopped MI async record, select new |
| 2025 | current thread and update GDB buffers." | 2313 | current thread and update GDB buffers." |
| 2026 | ;; Reason is available with target-async only | 2314 | ;; Reason is available with target-async only |
| @@ -2106,7 +2394,13 @@ current thread and update GDB buffers." | |||
| 2106 | (setq gdb-filter-output | 2394 | (setq gdb-filter-output |
| 2107 | (gdb-concat-output gdb-filter-output (read output-field)))) | 2395 | (gdb-concat-output gdb-filter-output (read output-field)))) |
| 2108 | 2396 | ||
| 2109 | (defun gdb-done-or-error (output-field token-number type) | 2397 | (defun gdb-done (token-number output-field is-complete) |
| 2398 | (gdb-done-or-error token-number 'done output-field is-complete)) | ||
| 2399 | |||
| 2400 | (defun gdb-error (token-number output-field is-complete) | ||
| 2401 | (gdb-done-or-error token-number 'error output-field is-complete)) | ||
| 2402 | |||
| 2403 | (defun gdb-done-or-error (token-number type output-field is-complete) | ||
| 2110 | (if (string-equal token-number "") | 2404 | (if (string-equal token-number "") |
| 2111 | ;; Output from command entered by user | 2405 | ;; Output from command entered by user |
| 2112 | (progn | 2406 | (progn |
| @@ -2122,14 +2416,12 @@ current thread and update GDB buffers." | |||
| 2122 | ;; Output from command from frontend. | 2416 | ;; Output from command from frontend. |
| 2123 | (setq gdb-output-sink 'emacs)) | 2417 | (setq gdb-output-sink 'emacs)) |
| 2124 | 2418 | ||
| 2125 | (gdb-clear-partial-output) | ||
| 2126 | |||
| 2127 | ;; The process may already be dead (e.g. C-d at the gdb prompt). | 2419 | ;; The process may already be dead (e.g. C-d at the gdb prompt). |
| 2128 | (let* ((proc (get-buffer-process gud-comint-buffer)) | 2420 | (let* ((proc (get-buffer-process gud-comint-buffer)) |
| 2129 | (no-proc (or (null proc) | 2421 | (no-proc (or (null proc) |
| 2130 | (memq (process-status proc) '(exit signal))))) | 2422 | (memq (process-status proc) '(exit signal))))) |
| 2131 | 2423 | ||
| 2132 | (when gdb-first-done-or-error | 2424 | (when (and is-complete gdb-first-done-or-error) |
| 2133 | (unless (or token-number gud-running no-proc) | 2425 | (unless (or token-number gud-running no-proc) |
| 2134 | (setq gdb-filter-output (concat gdb-filter-output gdb-prompt-name))) | 2426 | (setq gdb-filter-output (concat gdb-filter-output gdb-prompt-name))) |
| 2135 | (gdb-update no-proc) | 2427 | (gdb-update no-proc) |
| @@ -2138,13 +2430,19 @@ current thread and update GDB buffers." | |||
| 2138 | (setq gdb-filter-output | 2430 | (setq gdb-filter-output |
| 2139 | (gdb-concat-output gdb-filter-output output-field)) | 2431 | (gdb-concat-output gdb-filter-output output-field)) |
| 2140 | 2432 | ||
| 2141 | (when token-number | 2433 | ;; We are done concatenating to the output sink. Restore it to user sink: |
| 2434 | (setq gdb-output-sink 'user) | ||
| 2435 | |||
| 2436 | (when (and token-number is-complete) | ||
| 2142 | (with-current-buffer | 2437 | (with-current-buffer |
| 2143 | (gdb-get-buffer-create 'gdb-partial-output-buffer) | 2438 | (gdb-get-buffer-create 'gdb-partial-output-buffer) |
| 2144 | (funcall | 2439 | (funcall |
| 2145 | (cdr (assoc (string-to-number token-number) gdb-handler-alist)))) | 2440 | (cdr (assoc (string-to-number token-number) gdb-handler-alist)))) |
| 2146 | (setq gdb-handler-alist | 2441 | (setq gdb-handler-alist |
| 2147 | (assq-delete-all token-number gdb-handler-alist))))) | 2442 | (assq-delete-all token-number gdb-handler-alist))) |
| 2443 | |||
| 2444 | (when is-complete | ||
| 2445 | (gdb-clear-partial-output)))) | ||
| 2148 | 2446 | ||
| 2149 | (defun gdb-concat-output (so-far new) | 2447 | (defun gdb-concat-output (so-far new) |
| 2150 | (cond | 2448 | (cond |
| @@ -2169,8 +2467,8 @@ Field names are wrapped in double quotes and equal signs are | |||
| 2169 | replaced with semicolons. | 2467 | replaced with semicolons. |
| 2170 | 2468 | ||
| 2171 | If FIX-KEY is non-nil, strip all \"FIX-KEY=\" occurrences from | 2469 | If FIX-KEY is non-nil, strip all \"FIX-KEY=\" occurrences from |
| 2172 | partial output. This is used to get rid of useless keys in lists | 2470 | partial output. This is used to get rid of useless keys in lists |
| 2173 | in MI messages, e.g.: [key=.., key=..]. -stack-list-frames and | 2471 | in MI messages, e.g.: [key=.., key=..]. -stack-list-frames and |
| 2174 | -break-info are examples of MI commands which issue such | 2472 | -break-info are examples of MI commands which issue such |
| 2175 | responses. | 2473 | responses. |
| 2176 | 2474 | ||
| @@ -2337,16 +2635,16 @@ calling `gdb-table-string'." | |||
| 2337 | handler-name | 2635 | handler-name |
| 2338 | &optional signal-list) | 2636 | &optional signal-list) |
| 2339 | "Define a trigger TRIGGER-NAME which sends GDB-COMMAND and sets | 2637 | "Define a trigger TRIGGER-NAME which sends GDB-COMMAND and sets |
| 2340 | HANDLER-NAME as its handler. HANDLER-NAME is bound to current | 2638 | HANDLER-NAME as its handler. HANDLER-NAME is bound to current |
| 2341 | buffer with `gdb-bind-function-to-buffer'. | 2639 | buffer with `gdb-bind-function-to-buffer'. |
| 2342 | 2640 | ||
| 2343 | If SIGNAL-LIST is non-nil, GDB-COMMAND is sent only when the | 2641 | If SIGNAL-LIST is non-nil, GDB-COMMAND is sent only when the |
| 2344 | defined trigger is called with an argument from SIGNAL-LIST. It's | 2642 | defined trigger is called with an argument from SIGNAL-LIST. It's |
| 2345 | not recommended to define triggers with empty SIGNAL-LIST. | 2643 | not recommended to define triggers with empty SIGNAL-LIST. |
| 2346 | Normally triggers should respond at least to 'update signal. | 2644 | Normally triggers should respond at least to 'update signal. |
| 2347 | 2645 | ||
| 2348 | Normally the trigger defined by this command must be called from | 2646 | Normally the trigger defined by this command must be called from |
| 2349 | the buffer where HANDLER-NAME must work. This should be done so | 2647 | the buffer where HANDLER-NAME must work. This should be done so |
| 2350 | that buffer-local thread number may be used in GDB-COMMAND (by | 2648 | that buffer-local thread number may be used in GDB-COMMAND (by |
| 2351 | calling `gdb-current-context-command'). | 2649 | calling `gdb-current-context-command'). |
| 2352 | `gdb-bind-function-to-buffer' is used to achieve this, see | 2650 | `gdb-bind-function-to-buffer' is used to achieve this, see |
| @@ -2375,32 +2673,33 @@ Handlers are normally called from the buffers they put output in. | |||
| 2375 | 2673 | ||
| 2376 | Delete ((current-buffer) . TRIGGER-NAME) from | 2674 | Delete ((current-buffer) . TRIGGER-NAME) from |
| 2377 | `gdb-pending-triggers', erase current buffer and evaluate | 2675 | `gdb-pending-triggers', erase current buffer and evaluate |
| 2378 | CUSTOM-DEFUN. Then `gdb-update-buffer-name' is called. | 2676 | CUSTOM-DEFUN. Then `gdb-update-buffer-name' is called. |
| 2379 | 2677 | ||
| 2380 | If NOPRESERVE is non-nil, window point is not restored after CUSTOM-DEFUN." | 2678 | If NOPRESERVE is non-nil, window point is not restored after CUSTOM-DEFUN." |
| 2381 | `(defun ,handler-name () | 2679 | `(defun ,handler-name () |
| 2382 | (gdb-delete-pending (cons (current-buffer) ',trigger-name)) | 2680 | (gdb-delete-pending (cons (current-buffer) ',trigger-name)) |
| 2383 | (let* ((buffer-read-only nil) | 2681 | (let* ((inhibit-read-only t) |
| 2384 | (window (get-buffer-window (current-buffer) 0)) | 2682 | ,@(unless nopreserve |
| 2385 | (start (window-start window)) | 2683 | '((window (get-buffer-window (current-buffer) 0)) |
| 2386 | (p (window-point window))) | 2684 | (start (window-start window)) |
| 2685 | (p (window-point window))))) | ||
| 2387 | (erase-buffer) | 2686 | (erase-buffer) |
| 2388 | (,custom-defun) | 2687 | (,custom-defun) |
| 2389 | (gdb-update-buffer-name) | 2688 | (gdb-update-buffer-name) |
| 2390 | ,(when (not nopreserve) | 2689 | ,@(when (not nopreserve) |
| 2391 | '(set-window-start window start) | 2690 | '((set-window-start window start) |
| 2392 | '(set-window-point window p))))) | 2691 | (set-window-point window p)))))) |
| 2393 | 2692 | ||
| 2394 | (defmacro def-gdb-trigger-and-handler (trigger-name gdb-command | 2693 | (defmacro def-gdb-trigger-and-handler (trigger-name gdb-command |
| 2395 | handler-name custom-defun | 2694 | handler-name custom-defun |
| 2396 | &optional signal-list) | 2695 | &optional signal-list) |
| 2397 | "Define trigger and handler. | 2696 | "Define trigger and handler. |
| 2398 | 2697 | ||
| 2399 | TRIGGER-NAME trigger is defined to send GDB-COMMAND. See | 2698 | TRIGGER-NAME trigger is defined to send GDB-COMMAND. |
| 2400 | `def-gdb-auto-update-trigger'. | 2699 | See `def-gdb-auto-update-trigger'. |
| 2401 | 2700 | ||
| 2402 | HANDLER-NAME handler uses customization of CUSTOM-DEFUN. See | 2701 | HANDLER-NAME handler uses customization of CUSTOM-DEFUN. |
| 2403 | `def-gdb-auto-update-handler'." | 2702 | See `def-gdb-auto-update-handler'." |
| 2404 | `(progn | 2703 | `(progn |
| 2405 | (def-gdb-auto-update-trigger ,trigger-name | 2704 | (def-gdb-auto-update-trigger ,trigger-name |
| 2406 | ,gdb-command | 2705 | ,gdb-command |
| @@ -2757,37 +3056,38 @@ corresponding to the mode line clicked." | |||
| 2757 | gdb-running-threads-count | 3056 | gdb-running-threads-count |
| 2758 | gdb-stopped-threads-count)) | 3057 | gdb-stopped-threads-count)) |
| 2759 | 3058 | ||
| 2760 | (gdb-table-add-row table | 3059 | (gdb-table-add-row |
| 2761 | (list | 3060 | table |
| 2762 | (bindat-get-field thread 'id) | 3061 | (list |
| 2763 | (concat | 3062 | (bindat-get-field thread 'id) |
| 2764 | (if gdb-thread-buffer-verbose-names | 3063 | (concat |
| 2765 | (concat (bindat-get-field thread 'target-id) " ") "") | 3064 | (if gdb-thread-buffer-verbose-names |
| 2766 | (bindat-get-field thread 'state) | 3065 | (concat (bindat-get-field thread 'target-id) " ") "") |
| 2767 | ;; Include frame information for stopped threads | 3066 | (bindat-get-field thread 'state) |
| 2768 | (if (not running) | 3067 | ;; Include frame information for stopped threads |
| 2769 | (concat | 3068 | (if (not running) |
| 2770 | " in " (bindat-get-field thread 'frame 'func) | 3069 | (concat |
| 2771 | (if gdb-thread-buffer-arguments | 3070 | " in " (bindat-get-field thread 'frame 'func) |
| 2772 | (concat | 3071 | (if gdb-thread-buffer-arguments |
| 2773 | " (" | 3072 | (concat |
| 2774 | (let ((args (bindat-get-field thread 'frame 'args))) | 3073 | " (" |
| 2775 | (mapconcat | 3074 | (let ((args (bindat-get-field thread 'frame 'args))) |
| 2776 | (lambda (arg) | 3075 | (mapconcat |
| 2777 | (apply #'format "%s=%s" | 3076 | (lambda (arg) |
| 2778 | (gdb-get-many-fields arg 'name 'value))) | 3077 | (apply #'format "%s=%s" |
| 2779 | args ",")) | 3078 | (gdb-get-many-fields arg 'name 'value))) |
| 2780 | ")") | 3079 | args ",")) |
| 2781 | "") | 3080 | ")") |
| 2782 | (if gdb-thread-buffer-locations | 3081 | "") |
| 2783 | (gdb-frame-location (bindat-get-field thread 'frame)) "") | 3082 | (if gdb-thread-buffer-locations |
| 2784 | (if gdb-thread-buffer-addresses | 3083 | (gdb-frame-location (bindat-get-field thread 'frame)) "") |
| 2785 | (concat " at " (bindat-get-field thread 'frame 'addr)) "")) | 3084 | (if gdb-thread-buffer-addresses |
| 2786 | ""))) | 3085 | (concat " at " (bindat-get-field thread 'frame 'addr)) "")) |
| 2787 | (list | 3086 | ""))) |
| 2788 | 'gdb-thread thread | 3087 | (list |
| 2789 | 'mouse-face 'highlight | 3088 | 'gdb-thread thread |
| 2790 | 'help-echo "mouse-2, RET: select thread"))) | 3089 | 'mouse-face 'highlight |
| 3090 | 'help-echo "mouse-2, RET: select thread"))) | ||
| 2791 | (when (string-equal gdb-thread-number | 3091 | (when (string-equal gdb-thread-number |
| 2792 | (bindat-get-field thread 'id)) | 3092 | (bindat-get-field thread 'id)) |
| 2793 | (setq marked-line (length gdb-threads-list)))) | 3093 | (setq marked-line (length gdb-threads-list)))) |
| @@ -2803,8 +3103,8 @@ corresponding to the mode line clicked." | |||
| 2803 | "Define a NAME command which will act upon thread on the current line. | 3103 | "Define a NAME command which will act upon thread on the current line. |
| 2804 | 3104 | ||
| 2805 | CUSTOM-DEFUN may use locally bound `thread' variable, which will | 3105 | CUSTOM-DEFUN may use locally bound `thread' variable, which will |
| 2806 | be the value of 'gdb-thread property of the current line. If | 3106 | be the value of 'gdb-thread property of the current line. |
| 2807 | 'gdb-thread is nil, error is signaled." | 3107 | If `gdb-thread' is nil, error is signaled." |
| 2808 | `(defun ,name (&optional event) | 3108 | `(defun ,name (&optional event) |
| 2809 | ,(when doc doc) | 3109 | ,(when doc doc) |
| 2810 | (interactive (list last-input-event)) | 3110 | (interactive (list last-input-event)) |
| @@ -2953,7 +3253,7 @@ line." | |||
| 2953 | (defun gdb-memory-column-width (size format) | 3253 | (defun gdb-memory-column-width (size format) |
| 2954 | "Return length of string with memory unit of SIZE in FORMAT. | 3254 | "Return length of string with memory unit of SIZE in FORMAT. |
| 2955 | 3255 | ||
| 2956 | SIZE is in bytes, as in `gdb-memory-unit'. FORMAT is a string as | 3256 | SIZE is in bytes, as in `gdb-memory-unit'. FORMAT is a string as |
| 2957 | in `gdb-memory-format'." | 3257 | in `gdb-memory-format'." |
| 2958 | (let ((format-base (cdr (assoc format | 3258 | (let ((format-base (cdr (assoc format |
| 2959 | '(("x" . 16) | 3259 | '(("x" . 16) |
| @@ -3455,8 +3755,7 @@ DOC is an optional documentation string." | |||
| 3455 | (error "Not recognized as break/watchpoint line"))))) | 3755 | (error "Not recognized as break/watchpoint line"))))) |
| 3456 | 3756 | ||
| 3457 | (defun gdb-goto-breakpoint (&optional event) | 3757 | (defun gdb-goto-breakpoint (&optional event) |
| 3458 | "Go to the location of breakpoint at current line of | 3758 | "Go to the location of breakpoint at current line of breakpoints buffer." |
| 3459 | breakpoints buffer." | ||
| 3460 | (interactive (list last-input-event)) | 3759 | (interactive (list last-input-event)) |
| 3461 | (if event (posn-set-point (event-end event))) | 3760 | (if event (posn-set-point (event-end event))) |
| 3462 | ;; Hack to stop gdb-goto-breakpoint displaying in GUD buffer. | 3761 | ;; Hack to stop gdb-goto-breakpoint displaying in GUD buffer. |
| @@ -3840,7 +4139,7 @@ member." | |||
| 3840 | 4139 | ||
| 3841 | (defun gdb-get-source-file-list () | 4140 | (defun gdb-get-source-file-list () |
| 3842 | "Create list of source files for current GDB session. | 4141 | "Create list of source files for current GDB session. |
| 3843 | If buffers already exist for any of these files, gud-minor-mode | 4142 | If buffers already exist for any of these files, `gud-minor-mode' |
| 3844 | is set in them." | 4143 | is set in them." |
| 3845 | (goto-char (point-min)) | 4144 | (goto-char (point-min)) |
| 3846 | (while (re-search-forward gdb-source-file-regexp nil t) | 4145 | (while (re-search-forward gdb-source-file-regexp nil t) |
| @@ -3851,8 +4150,8 @@ is set in them." | |||
| 3851 | (gdb-init-buffer))))) | 4150 | (gdb-init-buffer))))) |
| 3852 | 4151 | ||
| 3853 | (defun gdb-get-main-selected-frame () | 4152 | (defun gdb-get-main-selected-frame () |
| 3854 | "Trigger for `gdb-frame-handler' which uses main current | 4153 | "Trigger for `gdb-frame-handler' which uses main current thread. |
| 3855 | thread. Called from `gdb-update'." | 4154 | Called from `gdb-update'." |
| 3856 | (if (not (gdb-pending-p 'gdb-get-main-selected-frame)) | 4155 | (if (not (gdb-pending-p 'gdb-get-main-selected-frame)) |
| 3857 | (progn | 4156 | (progn |
| 3858 | (gdb-input (gdb-current-context-command "-stack-info-frame") | 4157 | (gdb-input (gdb-current-context-command "-stack-info-frame") |
| @@ -3860,7 +4159,7 @@ thread. Called from `gdb-update'." | |||
| 3860 | (gdb-add-pending 'gdb-get-main-selected-frame)))) | 4159 | (gdb-add-pending 'gdb-get-main-selected-frame)))) |
| 3861 | 4160 | ||
| 3862 | (defun gdb-frame-handler () | 4161 | (defun gdb-frame-handler () |
| 3863 | "Sets `gdb-selected-frame' and `gdb-selected-file' to show | 4162 | "Set `gdb-selected-frame' and `gdb-selected-file' to show |
| 3864 | overlay arrow in source buffer." | 4163 | overlay arrow in source buffer." |
| 3865 | (gdb-delete-pending 'gdb-get-main-selected-frame) | 4164 | (gdb-delete-pending 'gdb-get-main-selected-frame) |
| 3866 | (let ((frame (bindat-get-field (gdb-json-partial-output) 'frame))) | 4165 | (let ((frame (bindat-get-field (gdb-json-partial-output) 'frame))) |
| @@ -3921,8 +4220,8 @@ overlay arrow in source buffer." | |||
| 3921 | 4220 | ||
| 3922 | (defun gdb-preempt-existing-or-display-buffer (buf &optional split-horizontal) | 4221 | (defun gdb-preempt-existing-or-display-buffer (buf &optional split-horizontal) |
| 3923 | "Find window displaying a buffer with the same | 4222 | "Find window displaying a buffer with the same |
| 3924 | `gdb-buffer-type' as BUF and show BUF there. If no such window | 4223 | `gdb-buffer-type' as BUF and show BUF there. If no such window |
| 3925 | exists, just call `gdb-display-buffer' for BUF. If the window | 4224 | exists, just call `gdb-display-buffer' for BUF. If the window |
| 3926 | found is already dedicated, split window according to | 4225 | found is already dedicated, split window according to |
| 3927 | SPLIT-HORIZONTAL and show BUF in the new window." | 4226 | SPLIT-HORIZONTAL and show BUF in the new window." |
| 3928 | (if buf | 4227 | (if buf |
| @@ -4310,8 +4609,7 @@ CONTEXT is the text before COMMAND on the line." | |||
| 4310 | (gud-gdb-fetch-lines-break (length context)) | 4609 | (gud-gdb-fetch-lines-break (length context)) |
| 4311 | (gud-gdb-fetched-lines nil) | 4610 | (gud-gdb-fetched-lines nil) |
| 4312 | ;; This filter dumps output lines to `gud-gdb-fetched-lines'. | 4611 | ;; This filter dumps output lines to `gud-gdb-fetched-lines'. |
| 4313 | (gud-marker-filter #'gud-gdbmi-fetch-lines-filter) | 4612 | (gud-marker-filter #'gud-gdbmi-fetch-lines-filter)) |
| 4314 | complete-list) | ||
| 4315 | (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer) | 4613 | (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer) |
| 4316 | (gdb-input (concat "complete " context command) | 4614 | (gdb-input (concat "complete " context command) |
| 4317 | (lambda () (setq gud-gdb-fetch-lines-in-progress nil))) | 4615 | (lambda () (setq gud-gdb-fetch-lines-in-progress nil))) |
diff --git a/lisp/progmodes/idlwave.el b/lisp/progmodes/idlwave.el index ab65933416b..aeaf1acb2ac 100644 --- a/lisp/progmodes/idlwave.el +++ b/lisp/progmodes/idlwave.el | |||
| @@ -27,7 +27,7 @@ | |||
| 27 | ;;; Commentary: | 27 | ;;; Commentary: |
| 28 | 28 | ||
| 29 | ;; IDLWAVE enables feature-rich development and interaction with IDL, | 29 | ;; IDLWAVE enables feature-rich development and interaction with IDL, |
| 30 | ;; the Interactive Data Language. It provides a compelling, | 30 | ;; the Interactive Data Language. It provides a compelling, |
| 31 | ;; full-featured alternative to the IDLDE development environment | 31 | ;; full-featured alternative to the IDLDE development environment |
| 32 | ;; bundled with IDL. | 32 | ;; bundled with IDL. |
| 33 | 33 | ||
| @@ -447,7 +447,7 @@ value of `!DIR'. See also `idlwave-library-path'." | |||
| 447 | 447 | ||
| 448 | ;; Configuration files | 448 | ;; Configuration files |
| 449 | (defcustom idlwave-config-directory | 449 | (defcustom idlwave-config-directory |
| 450 | (convert-standard-filename "~/.idlwave") | 450 | (locate-user-emacs-file "idlwave" ".idlwave") |
| 451 | "Directory for configuration files and user-library catalog." | 451 | "Directory for configuration files and user-library catalog." |
| 452 | :group 'idlwave-routine-info | 452 | :group 'idlwave-routine-info |
| 453 | :type 'file) | 453 | :type 'file) |
diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el index aae5526ea82..fab20102097 100644 --- a/lisp/progmodes/scheme.el +++ b/lisp/progmodes/scheme.el | |||
| @@ -310,7 +310,7 @@ See `run-hooks'." | |||
| 310 | "(" (regexp-opt | 310 | "(" (regexp-opt |
| 311 | '("begin" "call-with-current-continuation" "call/cc" | 311 | '("begin" "call-with-current-continuation" "call/cc" |
| 312 | "call-with-input-file" "call-with-output-file" "case" "cond" | 312 | "call-with-input-file" "call-with-output-file" "case" "cond" |
| 313 | "do" "else" "for-each" "if" "lambda" | 313 | "do" "else" "for-each" "if" "lambda" "λ" |
| 314 | "let" "let*" "let-syntax" "letrec" "letrec-syntax" | 314 | "let" "let*" "let-syntax" "letrec" "letrec-syntax" |
| 315 | ;; SRFI 11 usage comes up often enough. | 315 | ;; SRFI 11 usage comes up often enough. |
| 316 | "let-values" "let*-values" | 316 | "let-values" "let*-values" |
| @@ -410,6 +410,7 @@ that variable's value is a string." | |||
| 410 | (put 'make 'scheme-indent-function 1) | 410 | (put 'make 'scheme-indent-function 1) |
| 411 | (put 'style 'scheme-indent-function 1) | 411 | (put 'style 'scheme-indent-function 1) |
| 412 | (put 'root 'scheme-indent-function 1) | 412 | (put 'root 'scheme-indent-function 1) |
| 413 | (put 'λ 'scheme-indent-function 1) | ||
| 413 | 414 | ||
| 414 | (defvar dsssl-font-lock-keywords | 415 | (defvar dsssl-font-lock-keywords |
| 415 | (eval-when-compile | 416 | (eval-when-compile |
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index 781aa241802..3cf6757d5ec 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | ;; Copyright (C) 1998-2013 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1998-2013 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Alex Schroeder <alex@gnu.org> | 5 | ;; Author: Alex Schroeder <alex@gnu.org> |
| 6 | ;; Maintainer: Michael Mauger <mmaug@yahoo.com> | 6 | ;; Maintainer: Michael Mauger <michael@mauger.com> |
| 7 | ;; Version: 3.1 | 7 | ;; Version: 3.2 |
| 8 | ;; Keywords: comm languages processes | 8 | ;; Keywords: comm languages processes |
| 9 | ;; URL: http://savannah.gnu.org/projects/emacs/ | 9 | ;; URL: http://savannah.gnu.org/projects/emacs/ |
| 10 | 10 | ||
| @@ -209,7 +209,7 @@ | |||
| 209 | ;; nino <nino@inform.dk> | 209 | ;; nino <nino@inform.dk> |
| 210 | ;; Berend de Boer <berend@pobox.com> | 210 | ;; Berend de Boer <berend@pobox.com> |
| 211 | ;; Adam Jenkins <adam@thejenkins.org> | 211 | ;; Adam Jenkins <adam@thejenkins.org> |
| 212 | ;; Michael Mauger <mmaug@yahoo.com> -- improved product support | 212 | ;; Michael Mauger <michael@mauger.com> -- improved product support |
| 213 | ;; Drew Adams <drew.adams@oracle.com> -- Emacs 20 support | 213 | ;; Drew Adams <drew.adams@oracle.com> -- Emacs 20 support |
| 214 | ;; Harald Maier <maierh@myself.com> -- sql-send-string | 214 | ;; Harald Maier <maierh@myself.com> -- sql-send-string |
| 215 | ;; Stefan Monnier <monnier@iro.umontreal.ca> -- font-lock corrections; | 215 | ;; Stefan Monnier <monnier@iro.umontreal.ca> -- font-lock corrections; |
| @@ -218,6 +218,9 @@ | |||
| 218 | ;; Andrew Schein <andrew@andrewschein.com> -- sql-port bug | 218 | ;; Andrew Schein <andrew@andrewschein.com> -- sql-port bug |
| 219 | ;; Ian Bjorhovde <idbjorh@dataproxy.com> -- db2 escape newlines | 219 | ;; Ian Bjorhovde <idbjorh@dataproxy.com> -- db2 escape newlines |
| 220 | ;; incorrectly enabled by default | 220 | ;; incorrectly enabled by default |
| 221 | ;; Roman Scherer <roman.scherer@nugg.ad> -- Connection documentation | ||
| 222 | ;; Mark Wilkinson <wilkinsonmr@gmail.com> -- file-local variables ignored | ||
| 223 | ;; | ||
| 221 | 224 | ||
| 222 | 225 | ||
| 223 | 226 | ||
| @@ -605,11 +608,12 @@ Each element of the alist is as follows: | |||
| 605 | 608 | ||
| 606 | \(CONNECTION \(SQL-VARIABLE VALUE) ...) | 609 | \(CONNECTION \(SQL-VARIABLE VALUE) ...) |
| 607 | 610 | ||
| 608 | Where CONNECTION is a symbol identifying the connection, SQL-VARIABLE | 611 | Where CONNECTION is a case-insensitive string identifying the |
| 609 | is the symbol name of a SQL mode variable, and VALUE is the value to | 612 | connection, SQL-VARIABLE is the symbol name of a SQL mode |
| 610 | be assigned to the variable. The most common SQL-VARIABLE settings | 613 | variable, and VALUE is the value to be assigned to the variable. |
| 611 | associated with a connection are: `sql-product', `sql-user', | 614 | The most common SQL-VARIABLE settings associated with a |
| 612 | `sql-password', `sql-port', `sql-server', and `sql-database'. | 615 | connection are: `sql-product', `sql-user', `sql-password', |
| 616 | `sql-port', `sql-server', and `sql-database'. | ||
| 613 | 617 | ||
| 614 | If a SQL-VARIABLE is part of the connection, it will not be | 618 | If a SQL-VARIABLE is part of the connection, it will not be |
| 615 | prompted for during login. The command `sql-connect' starts a | 619 | prompted for during login. The command `sql-connect' starts a |
| @@ -1299,7 +1303,7 @@ Based on `comint-mode-map'.") | |||
| 1299 | ;; double quotes (") don't delimit strings | 1303 | ;; double quotes (") don't delimit strings |
| 1300 | (modify-syntax-entry ?\" "." table) | 1304 | (modify-syntax-entry ?\" "." table) |
| 1301 | ;; Make these all punctuation | 1305 | ;; Make these all punctuation |
| 1302 | (mapc (lambda (c) (modify-syntax-entry c "." table)) | 1306 | (mapc #'(lambda (c) (modify-syntax-entry c "." table)) |
| 1303 | (string-to-list "!#$%&+,.:;<=>?@\\|")) | 1307 | (string-to-list "!#$%&+,.:;<=>?@\\|")) |
| 1304 | table) | 1308 | table) |
| 1305 | "Syntax table used in `sql-mode' and `sql-interactive-mode'.") | 1309 | "Syntax table used in `sql-mode' and `sql-interactive-mode'.") |
| @@ -1509,7 +1513,7 @@ to add functions and PL/SQL keywords.") | |||
| 1509 | (not (derived-mode-p 'sql-interactive-mode))) | 1513 | (not (derived-mode-p 'sql-interactive-mode))) |
| 1510 | (not sql-buffer) | 1514 | (not sql-buffer) |
| 1511 | (not (eq sql-product 'oracle))) | 1515 | (not (eq sql-product 'oracle))) |
| 1512 | (error "Not an Oracle buffer") | 1516 | (user-error "Not an Oracle buffer") |
| 1513 | 1517 | ||
| 1514 | (let ((b "*RESERVED WORDS*")) | 1518 | (let ((b "*RESERVED WORDS*")) |
| 1515 | (sql-execute sql-buffer b | 1519 | (sql-execute sql-buffer b |
| @@ -1692,7 +1696,7 @@ to add functions and PL/SQL keywords.") | |||
| 1692 | "noswitch" "not" "nothing" "notimeout" "novalidate" "nowait" "null" | 1696 | "noswitch" "not" "nothing" "notimeout" "novalidate" "nowait" "null" |
| 1693 | "nulls" "object" "of" "off" "offline" "oidindex" "old" "on" "online" | 1697 | "nulls" "object" "of" "off" "offline" "oidindex" "old" "on" "online" |
| 1694 | "only" "open" "operator" "optimal" "option" "or" "order" | 1698 | "only" "open" "operator" "optimal" "option" "or" "order" |
| 1695 | "organization" "out" "outer" "outline" "overflow" "overriding" | 1699 | "organization" "out" "outer" "outline" "over" "overflow" "overriding" |
| 1696 | "package" "packages" "parallel" "parallel_enable" "parameters" | 1700 | "package" "packages" "parallel" "parallel_enable" "parameters" |
| 1697 | "parent" "partition" "partitions" "password" "password_grace_time" | 1701 | "parent" "partition" "partitions" "password" "password_grace_time" |
| 1698 | "password_life_time" "password_lock_time" "password_reuse_max" | 1702 | "password_life_time" "password_lock_time" "password_reuse_max" |
| @@ -1745,7 +1749,7 @@ to add functions and PL/SQL keywords.") | |||
| 1745 | ;; Oracle PL/SQL Functions | 1749 | ;; Oracle PL/SQL Functions |
| 1746 | (sql-font-lock-keywords-builder 'font-lock-builtin-face nil | 1750 | (sql-font-lock-keywords-builder 'font-lock-builtin-face nil |
| 1747 | "delete" "trim" "extend" "exists" "first" "last" "count" "limit" | 1751 | "delete" "trim" "extend" "exists" "first" "last" "count" "limit" |
| 1748 | "prior" "next" | 1752 | "prior" "next" "sqlcode" "sqlerrm" |
| 1749 | ) | 1753 | ) |
| 1750 | 1754 | ||
| 1751 | ;; Oracle PL/SQL Reserved words | 1755 | ;; Oracle PL/SQL Reserved words |
| @@ -2402,7 +2406,7 @@ highlighting rules in SQL mode.") | |||
| 2402 | (let ((init (or (and initial (symbol-name initial)) "ansi"))) | 2406 | (let ((init (or (and initial (symbol-name initial)) "ansi"))) |
| 2403 | (intern (completing-read | 2407 | (intern (completing-read |
| 2404 | prompt | 2408 | prompt |
| 2405 | (mapcar (lambda (info) (symbol-name (car info))) | 2409 | (mapcar #'(lambda (info) (symbol-name (car info))) |
| 2406 | sql-product-alist) | 2410 | sql-product-alist) |
| 2407 | nil 'require-match | 2411 | nil 'require-match |
| 2408 | init 'sql-product-history init)))) | 2412 | init 'sql-product-history init)))) |
| @@ -2418,7 +2422,7 @@ configuration." | |||
| 2418 | 2422 | ||
| 2419 | ;; Don't do anything if the product is already supported | 2423 | ;; Don't do anything if the product is already supported |
| 2420 | (if (assoc product sql-product-alist) | 2424 | (if (assoc product sql-product-alist) |
| 2421 | (message "Product `%s' is already defined" product) | 2425 | (user-error "Product `%s' is already defined" product) |
| 2422 | 2426 | ||
| 2423 | ;; Add product to the alist | 2427 | ;; Add product to the alist |
| 2424 | (add-to-list 'sql-product-alist `((,product :name ,display . ,plist))) | 2428 | (add-to-list 'sql-product-alist `((,product :name ,display . ,plist))) |
| @@ -2437,11 +2441,11 @@ configuration." | |||
| 2437 | ;; after this product's name. | 2441 | ;; after this product's name. |
| 2438 | (let ((next-item) | 2442 | (let ((next-item) |
| 2439 | (down-display (downcase display))) | 2443 | (down-display (downcase display))) |
| 2440 | (map-keymap (lambda (k b) | 2444 | (map-keymap #'(lambda (k b) |
| 2441 | (when (and (not next-item) | 2445 | (when (and (not next-item) |
| 2442 | (string-lessp down-display | 2446 | (string-lessp down-display |
| 2443 | (downcase (cadr b)))) | 2447 | (downcase (cadr b)))) |
| 2444 | (setq next-item k))) | 2448 | (setq next-item k))) |
| 2445 | (easy-menu-get-map sql-mode-menu '("Product"))) | 2449 | (easy-menu-get-map sql-mode-menu '("Product"))) |
| 2446 | next-item)) | 2450 | next-item)) |
| 2447 | product)) | 2451 | product)) |
| @@ -2472,7 +2476,7 @@ argument must be a plist keyword accepted by | |||
| 2472 | (symbolp v)) | 2476 | (symbolp v)) |
| 2473 | (set v newvalue) | 2477 | (set v newvalue) |
| 2474 | (setcdr p (plist-put (cdr p) feature newvalue))) | 2478 | (setcdr p (plist-put (cdr p) feature newvalue))) |
| 2475 | (message "`%s' is not a known product; use `sql-add-product' to add it first." product)))) | 2479 | (error "`%s' is not a known product; use `sql-add-product' to add it first." product)))) |
| 2476 | 2480 | ||
| 2477 | (defun sql-get-product-feature (product feature &optional fallback not-indirect) | 2481 | (defun sql-get-product-feature (product feature &optional fallback not-indirect) |
| 2478 | "Lookup FEATURE associated with a SQL PRODUCT. | 2482 | "Lookup FEATURE associated with a SQL PRODUCT. |
| @@ -2502,7 +2506,7 @@ See `sql-product-alist' for a list of products and supported features." | |||
| 2502 | (symbolp v)) | 2506 | (symbolp v)) |
| 2503 | (symbol-value v) | 2507 | (symbol-value v) |
| 2504 | v)) | 2508 | v)) |
| 2505 | (message "`%s' is not a known product; use `sql-add-product' to add it first." product) | 2509 | (error "`%s' is not a known product; use `sql-add-product' to add it first." product) |
| 2506 | nil))) | 2510 | nil))) |
| 2507 | 2511 | ||
| 2508 | (defun sql-product-font-lock (keywords-only imenu) | 2512 | (defun sql-product-font-lock (keywords-only imenu) |
| @@ -2543,13 +2547,13 @@ also be configured." | |||
| 2543 | (font-lock-mode-internal t)) | 2547 | (font-lock-mode-internal t)) |
| 2544 | 2548 | ||
| 2545 | (add-hook 'font-lock-mode-hook | 2549 | (add-hook 'font-lock-mode-hook |
| 2546 | (lambda () | 2550 | #'(lambda () |
| 2547 | ;; Provide defaults for new font-lock faces. | 2551 | ;; Provide defaults for new font-lock faces. |
| 2548 | (defvar font-lock-builtin-face | 2552 | (defvar font-lock-builtin-face |
| 2549 | (if (boundp 'font-lock-preprocessor-face) | 2553 | (if (boundp 'font-lock-preprocessor-face) |
| 2550 | font-lock-preprocessor-face | 2554 | font-lock-preprocessor-face |
| 2551 | font-lock-keyword-face)) | 2555 | font-lock-keyword-face)) |
| 2552 | (defvar font-lock-doc-face font-lock-string-face)) | 2556 | (defvar font-lock-doc-face font-lock-string-face)) |
| 2553 | nil t) | 2557 | nil t) |
| 2554 | 2558 | ||
| 2555 | ;; Setup imenu; it needs the same syntax-alist. | 2559 | ;; Setup imenu; it needs the same syntax-alist. |
| @@ -2592,10 +2596,10 @@ adds a fontification pattern to fontify identifiers ending in | |||
| 2592 | "Iterate through login parameters and return a list of results." | 2596 | "Iterate through login parameters and return a list of results." |
| 2593 | (delq nil | 2597 | (delq nil |
| 2594 | (mapcar | 2598 | (mapcar |
| 2595 | (lambda (param) | 2599 | #'(lambda (param) |
| 2596 | (let ((token (or (car-safe param) param)) | 2600 | (let ((token (or (car-safe param) param)) |
| 2597 | (plist (cdr-safe param))) | 2601 | (plist (cdr-safe param))) |
| 2598 | (funcall body token plist))) | 2602 | (funcall body token plist))) |
| 2599 | login-params))) | 2603 | login-params))) |
| 2600 | 2604 | ||
| 2601 | 2605 | ||
| @@ -2604,8 +2608,8 @@ adds a fontification pattern to fontify identifiers ending in | |||
| 2604 | 2608 | ||
| 2605 | (defun sql-product-syntax-table () | 2609 | (defun sql-product-syntax-table () |
| 2606 | (let ((table (copy-syntax-table sql-mode-syntax-table))) | 2610 | (let ((table (copy-syntax-table sql-mode-syntax-table))) |
| 2607 | (mapc (lambda (entry) | 2611 | (mapc #'(lambda (entry) |
| 2608 | (modify-syntax-entry (car entry) (cdr entry) table)) | 2612 | (modify-syntax-entry (car entry) (cdr entry) table)) |
| 2609 | (sql-get-product-feature sql-product :syntax-alist)) | 2613 | (sql-get-product-feature sql-product :syntax-alist)) |
| 2610 | table)) | 2614 | table)) |
| 2611 | 2615 | ||
| @@ -2613,10 +2617,10 @@ adds a fontification pattern to fontify identifiers ending in | |||
| 2613 | (append | 2617 | (append |
| 2614 | ;; Change all symbol character to word characters | 2618 | ;; Change all symbol character to word characters |
| 2615 | (mapcar | 2619 | (mapcar |
| 2616 | (lambda (entry) (if (string= (substring (cdr entry) 0 1) "_") | 2620 | #'(lambda (entry) (if (string= (substring (cdr entry) 0 1) "_") |
| 2617 | (cons (car entry) | 2621 | (cons (car entry) |
| 2618 | (concat "w" (substring (cdr entry) 1))) | 2622 | (concat "w" (substring (cdr entry) 1))) |
| 2619 | entry)) | 2623 | entry)) |
| 2620 | (sql-get-product-feature sql-product :syntax-alist)) | 2624 | (sql-get-product-feature sql-product :syntax-alist)) |
| 2621 | '((?_ . "w")))) | 2625 | '((?_ . "w")))) |
| 2622 | 2626 | ||
| @@ -2639,7 +2643,7 @@ adds a fontification pattern to fontify identifiers ending in | |||
| 2639 | (list (sql-read-product "SQL product: "))) | 2643 | (list (sql-read-product "SQL product: "))) |
| 2640 | (if (stringp product) (setq product (intern product))) | 2644 | (if (stringp product) (setq product (intern product))) |
| 2641 | (when (not (assoc product sql-product-alist)) | 2645 | (when (not (assoc product sql-product-alist)) |
| 2642 | (error "SQL product %s is not supported; treated as ANSI" product) | 2646 | (user-error "SQL product %s is not supported; treated as ANSI" product) |
| 2643 | (setq product 'ansi)) | 2647 | (setq product 'ansi)) |
| 2644 | 2648 | ||
| 2645 | ;; Save product setting and fontify. | 2649 | ;; Save product setting and fontify. |
| @@ -2765,6 +2769,7 @@ local variable." | |||
| 2765 | (comint-bol nil) | 2769 | (comint-bol nil) |
| 2766 | (looking-at "go\\b"))) | 2770 | (looking-at "go\\b"))) |
| 2767 | (comint-send-input))) | 2771 | (comint-send-input))) |
| 2772 | (put 'sql-magic-go 'delete-selection t) | ||
| 2768 | 2773 | ||
| 2769 | (defun sql-magic-semicolon (arg) | 2774 | (defun sql-magic-semicolon (arg) |
| 2770 | "Insert semicolon and call `comint-send-input'. | 2775 | "Insert semicolon and call `comint-send-input'. |
| @@ -2773,6 +2778,7 @@ local variable." | |||
| 2773 | (self-insert-command (prefix-numeric-value arg)) | 2778 | (self-insert-command (prefix-numeric-value arg)) |
| 2774 | (if (equal sql-electric-stuff 'semicolon) | 2779 | (if (equal sql-electric-stuff 'semicolon) |
| 2775 | (comint-send-input))) | 2780 | (comint-send-input))) |
| 2781 | (put 'sql-magic-semicolon 'delete-selection t) | ||
| 2776 | 2782 | ||
| 2777 | (defun sql-accumulate-and-indent () | 2783 | (defun sql-accumulate-and-indent () |
| 2778 | "Continue SQL statement on the next line." | 2784 | "Continue SQL statement on the next line." |
| @@ -2861,6 +2867,15 @@ appended to the SQLi buffer without disturbing your SQL buffer." | |||
| 2861 | t t doc 0))) | 2867 | t t doc 0))) |
| 2862 | doc) | 2868 | doc) |
| 2863 | 2869 | ||
| 2870 | (defun sql-default-value (var) | ||
| 2871 | "Fetch the value of a variable. | ||
| 2872 | |||
| 2873 | If the current buffer is in `sql-interactive-mode', then fetch | ||
| 2874 | the global value, otherwise use the buffer local value." | ||
| 2875 | (if (derived-mode-p 'sql-interactive-mode) | ||
| 2876 | (default-value var) | ||
| 2877 | (buffer-local-value var (current-buffer)))) | ||
| 2878 | |||
| 2864 | (defun sql-get-login-ext (symbol prompt history-var plist) | 2879 | (defun sql-get-login-ext (symbol prompt history-var plist) |
| 2865 | "Prompt user with extended login parameters. | 2880 | "Prompt user with extended login parameters. |
| 2866 | 2881 | ||
| @@ -2882,7 +2897,7 @@ value. (The property value is used as the PREDICATE argument to | |||
| 2882 | (set-default | 2897 | (set-default |
| 2883 | symbol | 2898 | symbol |
| 2884 | (let* ((default (plist-get plist :default)) | 2899 | (let* ((default (plist-get plist :default)) |
| 2885 | (last-value (default-value symbol)) | 2900 | (last-value (sql-default-value symbol)) |
| 2886 | (prompt-def | 2901 | (prompt-def |
| 2887 | (if default | 2902 | (if default |
| 2888 | (if (string-match "\\(\\):[ \t]*\\'" prompt) | 2903 | (if (string-match "\\(\\):[ \t]*\\'" prompt) |
| @@ -2950,7 +2965,7 @@ function like this: (sql-get-login 'user 'password 'database)." | |||
| 2950 | 2965 | ||
| 2951 | (`password | 2966 | (`password |
| 2952 | (setq-default sql-password | 2967 | (setq-default sql-password |
| 2953 | (read-passwd "Password: " nil sql-password))) | 2968 | (read-passwd "Password: " nil (sql-default-value 'sql-password)))) |
| 2954 | 2969 | ||
| 2955 | (`server | 2970 | (`server |
| 2956 | (sql-get-login-ext 'sql-server "Server: " 'sql-server-history plist)) | 2971 | (sql-get-login-ext 'sql-server "Server: " 'sql-server-history plist)) |
| @@ -2978,10 +2993,10 @@ In order to qualify, the SQLi buffer must be alive, be in | |||
| 2978 | (sql-buffer-live-p buf prod connection) | 2993 | (sql-buffer-live-p buf prod connection) |
| 2979 | buf) | 2994 | buf) |
| 2980 | ;; Look thru each buffer | 2995 | ;; Look thru each buffer |
| 2981 | (car (apply 'append | 2996 | (car (apply #'append |
| 2982 | (mapcar (lambda (b) | 2997 | (mapcar #'(lambda (b) |
| 2983 | (and (sql-buffer-live-p b prod connection) | 2998 | (and (sql-buffer-live-p b prod connection) |
| 2984 | (list (buffer-name b)))) | 2999 | (list (buffer-name b)))) |
| 2985 | (buffer-list))))))) | 3000 | (buffer-list))))))) |
| 2986 | 3001 | ||
| 2987 | (defun sql-set-sqli-buffer-generally () | 3002 | (defun sql-set-sqli-buffer-generally () |
| @@ -3022,10 +3037,10 @@ If you call it from anywhere else, it sets the global copy of | |||
| 3022 | (interactive) | 3037 | (interactive) |
| 3023 | (let ((default-buffer (sql-find-sqli-buffer))) | 3038 | (let ((default-buffer (sql-find-sqli-buffer))) |
| 3024 | (if (null default-buffer) | 3039 | (if (null default-buffer) |
| 3025 | (error "There is no suitable SQLi buffer") | 3040 | (user-error "There is no suitable SQLi buffer") |
| 3026 | (let ((new-buffer (read-buffer "New SQLi buffer: " default-buffer t))) | 3041 | (let ((new-buffer (read-buffer "New SQLi buffer: " default-buffer t))) |
| 3027 | (if (null (sql-buffer-live-p new-buffer)) | 3042 | (if (null (sql-buffer-live-p new-buffer)) |
| 3028 | (error "Buffer %s is not a working SQLi buffer" new-buffer) | 3043 | (user-error "Buffer %s is not a working SQLi buffer" new-buffer) |
| 3029 | (when new-buffer | 3044 | (when new-buffer |
| 3030 | (setq sql-buffer new-buffer) | 3045 | (setq sql-buffer new-buffer) |
| 3031 | (run-hooks 'sql-set-sqli-hook))))))) | 3046 | (run-hooks 'sql-set-sqli-hook))))))) |
| @@ -3038,10 +3053,10 @@ variable `sql-buffer'. See `sql-help' on how to create such a buffer." | |||
| 3038 | (interactive) | 3053 | (interactive) |
| 3039 | (if (or (null sql-buffer) | 3054 | (if (or (null sql-buffer) |
| 3040 | (null (buffer-live-p (get-buffer sql-buffer)))) | 3055 | (null (buffer-live-p (get-buffer sql-buffer)))) |
| 3041 | (message "%s has no SQLi buffer set." (buffer-name (current-buffer))) | 3056 | (user-error "%s has no SQLi buffer set" (buffer-name (current-buffer))) |
| 3042 | (if (null (get-buffer-process sql-buffer)) | 3057 | (if (null (get-buffer-process sql-buffer)) |
| 3043 | (message "Buffer %s has no process." sql-buffer) | 3058 | (user-error "Buffer %s has no process" sql-buffer) |
| 3044 | (message "Current SQLi buffer is %s." sql-buffer)))) | 3059 | (user-error "Current SQLi buffer is %s" sql-buffer)))) |
| 3045 | 3060 | ||
| 3046 | (defun sql-make-alternate-buffer-name () | 3061 | (defun sql-make-alternate-buffer-name () |
| 3047 | "Return a string that can be used to rename a SQLi buffer. | 3062 | "Return a string that can be used to rename a SQLi buffer. |
| @@ -3062,35 +3077,35 @@ server/database name." | |||
| 3062 | 3077 | ||
| 3063 | ;; Build a name using the :sqli-login setting | 3078 | ;; Build a name using the :sqli-login setting |
| 3064 | (setq name | 3079 | (setq name |
| 3065 | (apply 'concat | 3080 | (apply #'concat |
| 3066 | (cdr | 3081 | (cdr |
| 3067 | (apply 'append nil | 3082 | (apply #'append nil |
| 3068 | (sql-for-each-login | 3083 | (sql-for-each-login |
| 3069 | (sql-get-product-feature sql-product :sqli-login) | 3084 | (sql-get-product-feature sql-product :sqli-login) |
| 3070 | (lambda (token plist) | 3085 | #'(lambda (token plist) |
| 3071 | (pcase token | 3086 | (pcase token |
| 3072 | (`user | 3087 | (`user |
| 3073 | (unless (string= "" sql-user) | 3088 | (unless (string= "" sql-user) |
| 3074 | (list "/" sql-user))) | 3089 | (list "/" sql-user))) |
| 3075 | (`port | 3090 | (`port |
| 3076 | (unless (or (not (numberp sql-port)) | 3091 | (unless (or (not (numberp sql-port)) |
| 3077 | (= 0 sql-port)) | 3092 | (= 0 sql-port)) |
| 3078 | (list ":" (number-to-string sql-port)))) | 3093 | (list ":" (number-to-string sql-port)))) |
| 3079 | (`server | 3094 | (`server |
| 3080 | (unless (string= "" sql-server) | 3095 | (unless (string= "" sql-server) |
| 3081 | (list "." | 3096 | (list "." |
| 3082 | (if (plist-member plist :file) | 3097 | (if (plist-member plist :file) |
| 3083 | (file-name-nondirectory sql-server) | 3098 | (file-name-nondirectory sql-server) |
| 3084 | sql-server)))) | 3099 | sql-server)))) |
| 3085 | (`database | 3100 | (`database |
| 3086 | (unless (string= "" sql-database) | 3101 | (unless (string= "" sql-database) |
| 3087 | (list "@" | 3102 | (list "@" |
| 3088 | (if (plist-member plist :file) | 3103 | (if (plist-member plist :file) |
| 3089 | (file-name-nondirectory sql-database) | 3104 | (file-name-nondirectory sql-database) |
| 3090 | sql-database)))) | 3105 | sql-database)))) |
| 3091 | 3106 | ||
| 3092 | ;; (`password nil) | 3107 | ;; (`password nil) |
| 3093 | (_ nil)))))))) | 3108 | (_ nil)))))))) |
| 3094 | 3109 | ||
| 3095 | ;; If there's a connection, use it and the name thus far | 3110 | ;; If there's a connection, use it and the name thus far |
| 3096 | (if sql-connection | 3111 | (if sql-connection |
| @@ -3125,7 +3140,7 @@ NEW-NAME is empty, then the buffer name will be \"*SQL*\"." | |||
| 3125 | (interactive "P") | 3140 | (interactive "P") |
| 3126 | 3141 | ||
| 3127 | (if (not (derived-mode-p 'sql-interactive-mode)) | 3142 | (if (not (derived-mode-p 'sql-interactive-mode)) |
| 3128 | (message "Current buffer is not a SQL interactive buffer") | 3143 | (user-error "Current buffer is not a SQL interactive buffer") |
| 3129 | 3144 | ||
| 3130 | (setq sql-alternate-buffer-name | 3145 | (setq sql-alternate-buffer-name |
| 3131 | (cond | 3146 | (cond |
| @@ -3135,6 +3150,7 @@ NEW-NAME is empty, then the buffer name will be \"*SQL*\"." | |||
| 3135 | sql-alternate-buffer-name)) | 3150 | sql-alternate-buffer-name)) |
| 3136 | (t sql-alternate-buffer-name))) | 3151 | (t sql-alternate-buffer-name))) |
| 3137 | 3152 | ||
| 3153 | (setq sql-alternate-buffer-name (substring-no-properties sql-alternate-buffer-name)) | ||
| 3138 | (rename-buffer (if (string= "" sql-alternate-buffer-name) | 3154 | (rename-buffer (if (string= "" sql-alternate-buffer-name) |
| 3139 | "*SQL*" | 3155 | "*SQL*" |
| 3140 | (format "*SQL: %s*" sql-alternate-buffer-name)) | 3156 | (format "*SQL: %s*" sql-alternate-buffer-name)) |
| @@ -3222,7 +3238,7 @@ Allows the suppression of continuation prompts.") | |||
| 3222 | (defun sql-input-sender (proc string) | 3238 | (defun sql-input-sender (proc string) |
| 3223 | "Send STRING to PROC after applying filters." | 3239 | "Send STRING to PROC after applying filters." |
| 3224 | 3240 | ||
| 3225 | (let* ((product (with-current-buffer (process-buffer proc) sql-product)) | 3241 | (let* ((product (buffer-local-value 'sql-product (process-buffer proc))) |
| 3226 | (filter (sql-get-product-feature product :input-filter))) | 3242 | (filter (sql-get-product-feature product :input-filter))) |
| 3227 | 3243 | ||
| 3228 | ;; Apply filter(s) | 3244 | ;; Apply filter(s) |
| @@ -3232,15 +3248,13 @@ Allows the suppression of continuation prompts.") | |||
| 3232 | ((functionp filter) | 3248 | ((functionp filter) |
| 3233 | (setq string (funcall filter string))) | 3249 | (setq string (funcall filter string))) |
| 3234 | ((listp filter) | 3250 | ((listp filter) |
| 3235 | (mapc (lambda (f) (setq string (funcall f string))) filter)) | 3251 | (mapc #'(lambda (f) (setq string (funcall f string))) filter)) |
| 3236 | (t nil)) | 3252 | (t nil)) |
| 3237 | 3253 | ||
| 3238 | ;; Count how many newlines in the string | 3254 | ;; Count how many newlines in the string |
| 3239 | (setq sql-output-newline-count 0) | 3255 | (setq sql-output-newline-count |
| 3240 | (mapc (lambda (ch) | 3256 | (apply #'+ (mapcar #'(lambda (ch) |
| 3241 | (when (eq ch ?\n) | 3257 | (if (eq ch ?\n) 1 0)) string))) |
| 3242 | (setq sql-output-newline-count (1+ sql-output-newline-count)))) | ||
| 3243 | string) | ||
| 3244 | 3258 | ||
| 3245 | ;; Send the string | 3259 | ;; Send the string |
| 3246 | (comint-simple-send proc string))) | 3260 | (comint-simple-send proc string))) |
| @@ -3320,7 +3334,7 @@ to avoid deleting non-prompt output." | |||
| 3320 | (if sql-send-terminator | 3334 | (if sql-send-terminator |
| 3321 | (sql-send-magic-terminator sql-buffer s sql-send-terminator)) | 3335 | (sql-send-magic-terminator sql-buffer s sql-send-terminator)) |
| 3322 | 3336 | ||
| 3323 | (message "Sent string to buffer %s." sql-buffer))) | 3337 | (message "Sent string to buffer %s" sql-buffer))) |
| 3324 | 3338 | ||
| 3325 | ;; Display the sql buffer | 3339 | ;; Display the sql buffer |
| 3326 | (if sql-pop-to-buffer-after-send-region | 3340 | (if sql-pop-to-buffer-after-send-region |
| @@ -3328,7 +3342,7 @@ to avoid deleting non-prompt output." | |||
| 3328 | (display-buffer sql-buffer))) | 3342 | (display-buffer sql-buffer))) |
| 3329 | 3343 | ||
| 3330 | ;; We don't have no stinkin' sql | 3344 | ;; We don't have no stinkin' sql |
| 3331 | (message "No SQL process started.")))) | 3345 | (user-error "No SQL process started")))) |
| 3332 | 3346 | ||
| 3333 | (defun sql-send-region (start end) | 3347 | (defun sql-send-region (start end) |
| 3334 | "Send a region to the SQL process." | 3348 | "Send a region to the SQL process." |
| @@ -3421,7 +3435,7 @@ list of SQLi command strings." | |||
| 3421 | (when visible | 3435 | (when visible |
| 3422 | (message "Executing SQL command...")) | 3436 | (message "Executing SQL command...")) |
| 3423 | (if (consp command) | 3437 | (if (consp command) |
| 3424 | (mapc (lambda (c) (sql-redirect-one sqlbuf c outbuf save-prior)) | 3438 | (mapc #'(lambda (c) (sql-redirect-one sqlbuf c outbuf save-prior)) |
| 3425 | command) | 3439 | command) |
| 3426 | (sql-redirect-one sqlbuf command outbuf save-prior)) | 3440 | (sql-redirect-one sqlbuf command outbuf save-prior)) |
| 3427 | (when visible | 3441 | (when visible |
| @@ -3498,11 +3512,11 @@ for each match." | |||
| 3498 | (match-string regexp-groups)) | 3512 | (match-string regexp-groups)) |
| 3499 | ;; list of numbers; return the specified matches only | 3513 | ;; list of numbers; return the specified matches only |
| 3500 | ((consp regexp-groups) | 3514 | ((consp regexp-groups) |
| 3501 | (mapcar (lambda (c) | 3515 | (mapcar #'(lambda (c) |
| 3502 | (cond | 3516 | (cond |
| 3503 | ((numberp c) (match-string c)) | 3517 | ((numberp c) (match-string c)) |
| 3504 | ((stringp c) (match-substitute-replacement c)) | 3518 | ((stringp c) (match-substitute-replacement c)) |
| 3505 | (t (error "sql-redirect-value: unknown REGEXP-GROUPS value - %s" c)))) | 3519 | (t (error "sql-redirect-value: unknown REGEXP-GROUPS value - %s" c)))) |
| 3506 | regexp-groups)) | 3520 | regexp-groups)) |
| 3507 | ;; String is specified; return replacement string | 3521 | ;; String is specified; return replacement string |
| 3508 | ((stringp regexp-groups) | 3522 | ((stringp regexp-groups) |
| @@ -3528,15 +3542,15 @@ strings are formatted with ARG and executed. | |||
| 3528 | If the results are empty the OUTBUF is deleted, otherwise the | 3542 | If the results are empty the OUTBUF is deleted, otherwise the |
| 3529 | buffer is popped into a view window." | 3543 | buffer is popped into a view window." |
| 3530 | (mapc | 3544 | (mapc |
| 3531 | (lambda (c) | 3545 | #'(lambda (c) |
| 3532 | (cond | 3546 | (cond |
| 3533 | ((stringp c) | 3547 | ((stringp c) |
| 3534 | (sql-redirect sqlbuf (if arg (format c arg) c) outbuf) t) | 3548 | (sql-redirect sqlbuf (if arg (format c arg) c) outbuf) t) |
| 3535 | ((functionp c) | 3549 | ((functionp c) |
| 3536 | (apply c sqlbuf outbuf enhanced arg nil)) | 3550 | (apply c sqlbuf outbuf enhanced arg nil)) |
| 3537 | (t (error "Unknown sql-execute item %s" c)))) | 3551 | (t (error "Unknown sql-execute item %s" c)))) |
| 3538 | (if (consp command) command (cons command nil))) | 3552 | (if (consp command) command (cons command nil))) |
| 3539 | 3553 | ||
| 3540 | (setq outbuf (get-buffer outbuf)) | 3554 | (setq outbuf (get-buffer outbuf)) |
| 3541 | (if (zerop (buffer-size outbuf)) | 3555 | (if (zerop (buffer-size outbuf)) |
| 3542 | (kill-buffer outbuf) | 3556 | (kill-buffer outbuf) |
| @@ -3551,11 +3565,11 @@ buffer is popped into a view window." | |||
| 3551 | 3565 | ||
| 3552 | (defun sql-execute-feature (sqlbuf outbuf feature enhanced arg) | 3566 | (defun sql-execute-feature (sqlbuf outbuf feature enhanced arg) |
| 3553 | "List objects or details in a separate display buffer." | 3567 | "List objects or details in a separate display buffer." |
| 3554 | (let (command) | 3568 | (let (command |
| 3555 | (with-current-buffer sqlbuf | 3569 | (product (buffer-local-value 'sql-product (get-buffer sqlbuf)))) |
| 3556 | (setq command (sql-get-product-feature sql-product feature))) | 3570 | (setq command (sql-get-product-feature product feature)) |
| 3557 | (unless command | 3571 | (unless command |
| 3558 | (error "%s does not support %s" sql-product feature)) | 3572 | (error "%s does not support %s" product feature)) |
| 3559 | (when (consp command) | 3573 | (when (consp command) |
| 3560 | (setq command (if enhanced | 3574 | (setq command (if enhanced |
| 3561 | (cdr command) | 3575 | (cdr command) |
| @@ -3582,7 +3596,7 @@ The list is maintained in SQL interactive buffers.") | |||
| 3582 | (apply f (current-buffer) (cons schema nil))) | 3596 | (apply f (current-buffer) (cons schema nil))) |
| 3583 | cl) | 3597 | cl) |
| 3584 | (unless (member e cl) (setq cl (cons e cl)))) | 3598 | (unless (member e cl) (setq cl (cons e cl)))) |
| 3585 | (sort cl (function string<))))))) | 3599 | (sort cl #'string<)))))) |
| 3586 | 3600 | ||
| 3587 | (defun sql-build-completions (schema) | 3601 | (defun sql-build-completions (schema) |
| 3588 | "Generate a list of names in the database for use as completions." | 3602 | "Generate a list of names in the database for use as completions." |
| @@ -3646,7 +3660,7 @@ details or extends the listing to include other schemas objects." | |||
| 3646 | (interactive "P") | 3660 | (interactive "P") |
| 3647 | (let ((sqlbuf (sql-find-sqli-buffer))) | 3661 | (let ((sqlbuf (sql-find-sqli-buffer))) |
| 3648 | (unless sqlbuf | 3662 | (unless sqlbuf |
| 3649 | (error "No SQL interactive buffer found")) | 3663 | (user-error "No SQL interactive buffer found")) |
| 3650 | (sql-execute-feature sqlbuf "*List All*" :list-all enhanced nil) | 3664 | (sql-execute-feature sqlbuf "*List All*" :list-all enhanced nil) |
| 3651 | (with-current-buffer sqlbuf | 3665 | (with-current-buffer sqlbuf |
| 3652 | ;; Contains the name of database objects | 3666 | ;; Contains the name of database objects |
| @@ -3662,9 +3676,9 @@ ENHANCED, displays additional details about each column." | |||
| 3662 | current-prefix-arg)) | 3676 | current-prefix-arg)) |
| 3663 | (let ((sqlbuf (sql-find-sqli-buffer))) | 3677 | (let ((sqlbuf (sql-find-sqli-buffer))) |
| 3664 | (unless sqlbuf | 3678 | (unless sqlbuf |
| 3665 | (error "No SQL interactive buffer found")) | 3679 | (user-error "No SQL interactive buffer found")) |
| 3666 | (unless name | 3680 | (unless name |
| 3667 | (error "No table name specified")) | 3681 | (user-error "No table name specified")) |
| 3668 | (sql-execute-feature sqlbuf (format "*List %s*" name) | 3682 | (sql-execute-feature sqlbuf (format "*List %s*" name) |
| 3669 | :list-table enhanced name))) | 3683 | :list-table enhanced name))) |
| 3670 | 3684 | ||
| @@ -3898,7 +3912,7 @@ Sentinels will always get the two parameters PROCESS and EVENT." | |||
| 3898 | "Read a connection name." | 3912 | "Read a connection name." |
| 3899 | (let ((completion-ignore-case t)) | 3913 | (let ((completion-ignore-case t)) |
| 3900 | (completing-read prompt | 3914 | (completing-read prompt |
| 3901 | (mapcar (lambda (c) (car c)) | 3915 | (mapcar #'(lambda (c) (car c)) |
| 3902 | sql-connection-alist) | 3916 | sql-connection-alist) |
| 3903 | nil t initial 'sql-connection-history default))) | 3917 | nil t initial 'sql-connection-history default))) |
| 3904 | 3918 | ||
| @@ -3917,7 +3931,7 @@ is specified in the connection settings." | |||
| 3917 | (if sql-connection-alist | 3931 | (if sql-connection-alist |
| 3918 | (list (sql-read-connection "Connection: " nil '(nil)) | 3932 | (list (sql-read-connection "Connection: " nil '(nil)) |
| 3919 | current-prefix-arg) | 3933 | current-prefix-arg) |
| 3920 | nil)) | 3934 | (user-error "No SQL Connections defined"))) |
| 3921 | 3935 | ||
| 3922 | ;; Are there connections defined | 3936 | ;; Are there connections defined |
| 3923 | (if sql-connection-alist | 3937 | (if sql-connection-alist |
| @@ -3941,27 +3955,27 @@ is specified in the connection settings." | |||
| 3941 | ;; Params in the connection | 3955 | ;; Params in the connection |
| 3942 | (setq set-params | 3956 | (setq set-params |
| 3943 | (mapcar | 3957 | (mapcar |
| 3944 | (lambda (v) | 3958 | #'(lambda (v) |
| 3945 | (pcase (car v) | 3959 | (pcase (car v) |
| 3946 | (`sql-user 'user) | 3960 | (`sql-user 'user) |
| 3947 | (`sql-password 'password) | 3961 | (`sql-password 'password) |
| 3948 | (`sql-server 'server) | 3962 | (`sql-server 'server) |
| 3949 | (`sql-database 'database) | 3963 | (`sql-database 'database) |
| 3950 | (`sql-port 'port) | 3964 | (`sql-port 'port) |
| 3951 | (s s))) | 3965 | (s s))) |
| 3952 | (cdr connect-set))) | 3966 | (cdr connect-set))) |
| 3953 | 3967 | ||
| 3954 | ;; the remaining params (w/o the connection params) | 3968 | ;; the remaining params (w/o the connection params) |
| 3955 | (setq rem-params | 3969 | (setq rem-params |
| 3956 | (sql-for-each-login login-params | 3970 | (sql-for-each-login login-params |
| 3957 | (lambda (token plist) | 3971 | #'(lambda (token plist) |
| 3958 | (unless (member token set-params) | 3972 | (unless (member token set-params) |
| 3959 | (if plist (cons token plist) token))))) | 3973 | (if plist (cons token plist) token))))) |
| 3960 | 3974 | ||
| 3961 | ;; Set the parameters and start the interactive session | 3975 | ;; Set the parameters and start the interactive session |
| 3962 | (mapc | 3976 | (mapc |
| 3963 | (lambda (vv) | 3977 | #'(lambda (vv) |
| 3964 | (set-default (car vv) (eval (cadr vv)))) | 3978 | (set-default (car vv) (eval (cadr vv)))) |
| 3965 | (cdr connect-set)) | 3979 | (cdr connect-set)) |
| 3966 | (setq-default sql-connection connection) | 3980 | (setq-default sql-connection connection) |
| 3967 | 3981 | ||
| @@ -3969,10 +3983,10 @@ is specified in the connection settings." | |||
| 3969 | (eval `(let ((,param-var ',rem-params)) | 3983 | (eval `(let ((,param-var ',rem-params)) |
| 3970 | (sql-product-interactive ',sql-product ',new-name)))) | 3984 | (sql-product-interactive ',sql-product ',new-name)))) |
| 3971 | 3985 | ||
| 3972 | (message "SQL Connection <%s> does not exist" connection) | 3986 | (user-error "SQL Connection <%s> does not exist" connection) |
| 3973 | nil))) | 3987 | nil))) |
| 3974 | 3988 | ||
| 3975 | (message "No SQL Connections defined") | 3989 | (user-error "No SQL Connections defined") |
| 3976 | nil)) | 3990 | nil)) |
| 3977 | 3991 | ||
| 3978 | (defun sql-save-connection (name) | 3992 | (defun sql-save-connection (name) |
| @@ -3984,7 +3998,7 @@ optionally is saved to the user's init file." | |||
| 3984 | (interactive "sNew connection name: ") | 3998 | (interactive "sNew connection name: ") |
| 3985 | 3999 | ||
| 3986 | (unless (derived-mode-p 'sql-interactive-mode) | 4000 | (unless (derived-mode-p 'sql-interactive-mode) |
| 3987 | (error "Not in a SQL interactive mode!")) | 4001 | (user-error "Not in a SQL interactive mode!")) |
| 3988 | 4002 | ||
| 3989 | ;; Capture the buffer local settings | 4003 | ;; Capture the buffer local settings |
| 3990 | (let* ((buf (current-buffer)) | 4004 | (let* ((buf (current-buffer)) |
| @@ -4009,18 +4023,18 @@ optionally is saved to the user's init file." | |||
| 4009 | 4023 | ||
| 4010 | ;; Add the new connection if it doesn't exist | 4024 | ;; Add the new connection if it doesn't exist |
| 4011 | (if (assoc name alist) | 4025 | (if (assoc name alist) |
| 4012 | (message "Connection <%s> already exists" name) | 4026 | (user-error "Connection <%s> already exists" name) |
| 4013 | (setq connect | 4027 | (setq connect |
| 4014 | (cons name | 4028 | (cons name |
| 4015 | (sql-for-each-login | 4029 | (sql-for-each-login |
| 4016 | `(product ,@login) | 4030 | `(product ,@login) |
| 4017 | (lambda (token _plist) | 4031 | #'(lambda (token _plist) |
| 4018 | (pcase token | 4032 | (pcase token |
| 4019 | (`product `(sql-product ',product)) | 4033 | (`product `(sql-product ',product)) |
| 4020 | (`user `(sql-user ,user)) | 4034 | (`user `(sql-user ,user)) |
| 4021 | (`database `(sql-database ,database)) | 4035 | (`database `(sql-database ,database)) |
| 4022 | (`server `(sql-server ,server)) | 4036 | (`server `(sql-server ,server)) |
| 4023 | (`port `(sql-port ,port))))))) | 4037 | (`port `(sql-port ,port))))))) |
| 4024 | 4038 | ||
| 4025 | (setq alist (append alist (list connect))) | 4039 | (setq alist (append alist (list connect))) |
| 4026 | 4040 | ||
| @@ -4033,21 +4047,20 @@ optionally is saved to the user's init file." | |||
| 4033 | "Generate menu entries for using each connection." | 4047 | "Generate menu entries for using each connection." |
| 4034 | (append | 4048 | (append |
| 4035 | (mapcar | 4049 | (mapcar |
| 4036 | (lambda (conn) | 4050 | #'(lambda (conn) |
| 4037 | (vector | 4051 | (vector |
| 4038 | (format "Connection <%s>\t%s" (car conn) | 4052 | (format "Connection <%s>\t%s" (car conn) |
| 4039 | (let ((sql-user "") (sql-database "") | 4053 | (let ((sql-user "") (sql-database "") |
| 4040 | (sql-server "") (sql-port 0)) | 4054 | (sql-server "") (sql-port 0)) |
| 4041 | (eval `(let ,(cdr conn) (sql-make-alternate-buffer-name))))) | 4055 | (eval `(let ,(cdr conn) (sql-make-alternate-buffer-name))))) |
| 4042 | (list 'sql-connect (car conn)) | 4056 | (list 'sql-connect (car conn)) |
| 4043 | t)) | 4057 | t)) |
| 4044 | sql-connection-alist) | 4058 | sql-connection-alist) |
| 4045 | tail)) | 4059 | tail)) |
| 4046 | 4060 | ||
| 4047 | 4061 | ||
| 4048 | 4062 | ||
| 4049 | ;;; Entry functions for different SQL interpreters. | 4063 | ;;; Entry functions for different SQL interpreters. |
| 4050 | |||
| 4051 | ;;;###autoload | 4064 | ;;;###autoload |
| 4052 | (defun sql-product-interactive (&optional product new-name) | 4065 | (defun sql-product-interactive (&optional product new-name) |
| 4053 | "Run PRODUCT interpreter as an inferior process. | 4066 | "Run PRODUCT interpreter as an inferior process. |
| @@ -4140,7 +4153,7 @@ the call to \\[sql-product-interactive] with | |||
| 4140 | ;; All done. | 4153 | ;; All done. |
| 4141 | (message "Login...done") | 4154 | (message "Login...done") |
| 4142 | (pop-to-buffer new-sqli-buffer))))) | 4155 | (pop-to-buffer new-sqli-buffer))))) |
| 4143 | (message "No default SQL product defined. Set `sql-product'."))) | 4156 | (user-error "No default SQL product defined. Set `sql-product'."))) |
| 4144 | 4157 | ||
| 4145 | (defun sql-comint (product params) | 4158 | (defun sql-comint (product params) |
| 4146 | "Set up a comint buffer to run the SQL processor. | 4159 | "Set up a comint buffer to run the SQL processor. |
| @@ -4164,7 +4177,7 @@ passed as command line arguments." | |||
| 4164 | (setq buf-name (format "SQL-%s%d" product i)))) | 4177 | (setq buf-name (format "SQL-%s%d" product i)))) |
| 4165 | (setq i (1+ i)))))) | 4178 | (setq i (1+ i)))))) |
| 4166 | (set-buffer | 4179 | (set-buffer |
| 4167 | (apply 'make-comint buf-name program nil params)))) | 4180 | (apply #'make-comint buf-name program nil params)))) |
| 4168 | 4181 | ||
| 4169 | ;;;###autoload | 4182 | ;;;###autoload |
| 4170 | (defun sql-oracle (&optional buffer) | 4183 | (defun sql-oracle (&optional buffer) |
| @@ -4256,7 +4269,7 @@ The default comes from `process-coding-system-alist' and | |||
| 4256 | ;; | 4269 | ;; |
| 4257 | 4270 | ||
| 4258 | (append | 4271 | (append |
| 4259 | ;; (apply 'concat (append | 4272 | ;; (apply #'concat (append |
| 4260 | ;; '("SET") | 4273 | ;; '("SET") |
| 4261 | 4274 | ||
| 4262 | ;; option value... | 4275 | ;; option value... |
| @@ -4304,8 +4317,8 @@ The default comes from `process-coding-system-alist' and | |||
| 4304 | 4317 | ||
| 4305 | ;; Remove any settings that haven't changed | 4318 | ;; Remove any settings that haven't changed |
| 4306 | (mapc | 4319 | (mapc |
| 4307 | (lambda (one-cur-setting) | 4320 | #'(lambda (one-cur-setting) |
| 4308 | (setq saved-settings (delete one-cur-setting saved-settings))) | 4321 | (setq saved-settings (delete one-cur-setting saved-settings))) |
| 4309 | (sql-oracle-save-settings sqlbuf)) | 4322 | (sql-oracle-save-settings sqlbuf)) |
| 4310 | 4323 | ||
| 4311 | ;; Restore the changed settings | 4324 | ;; Restore the changed settings |
| @@ -4822,10 +4835,10 @@ Try to set `comint-output-filter-functions' like this: | |||
| 4822 | (sql-redirect sqlbuf "\\a")) | 4835 | (sql-redirect sqlbuf "\\a")) |
| 4823 | 4836 | ||
| 4824 | ;; Return the list of table names (public schema name can be omitted) | 4837 | ;; Return the list of table names (public schema name can be omitted) |
| 4825 | (mapcar (lambda (tbl) | 4838 | (mapcar #'(lambda (tbl) |
| 4826 | (if (string= (car tbl) "public") | 4839 | (if (string= (car tbl) "public") |
| 4827 | (cadr tbl) | 4840 | (cadr tbl) |
| 4828 | (format "%s.%s" (car tbl) (cadr tbl)))) | 4841 | (format "%s.%s" (car tbl) (cadr tbl)))) |
| 4829 | cl)))) | 4842 | cl)))) |
| 4830 | 4843 | ||
| 4831 | 4844 | ||