aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias EngdegÄrd2020-10-26 22:02:55 +0100
committerMattias EngdegÄrd2020-10-27 19:10:25 +0100
commit3a6d55b7922ff2d71b91b54812219ee9dcc33649 (patch)
tree54724c2a899996e826bde4e20155549b58fa567e
parent5a2b03043c767f219dcf5b14819cb8dede0e6e0c (diff)
downloademacs-3a6d55b7922ff2d71b91b54812219ee9dcc33649.tar.gz
emacs-3a6d55b7922ff2d71b91b54812219ee9dcc33649.zip
gdb-mi: use lexical lambdas
* lisp/progmodes/gdb-mi.el (gdb-tooltip-print-1, gud-watch) (gdb-var-list-children, gdb-edit-value) (gdb-bind-function-to-buffer, gdb-place-breakpoints) (gdb-preempt-existing-or-display-buffer): Expose lambdas to the compiler as lexical closures instead of building them the old-fashioned way. Remove #' before lambda.
-rw-r--r--lisp/progmodes/gdb-mi.el58
1 files changed, 29 insertions, 29 deletions
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index aadfb7c2215..f0262c23151 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -1139,7 +1139,7 @@ no input, and GDB is waiting for input."
1139 (if (search-forward "expands to: " nil t) 1139 (if (search-forward "expands to: " nil t)
1140 (unless (looking-at "\\S-+.*(.*).*") 1140 (unless (looking-at "\\S-+.*(.*).*")
1141 (gdb-input (concat "-data-evaluate-expression \"" expr "\"") 1141 (gdb-input (concat "-data-evaluate-expression \"" expr "\"")
1142 `(lambda () (gdb-tooltip-print ,expr))))))) 1142 (lambda () (gdb-tooltip-print expr)))))))
1143 1143
1144(defun gdb-init-buffer () 1144(defun gdb-init-buffer ()
1145 (set (make-local-variable 'gud-minor-mode) 'gdbmi) 1145 (set (make-local-variable 'gud-minor-mode) 'gdbmi)
@@ -1259,7 +1259,7 @@ With arg, enter name of variable to be watched in the minibuffer."
1259 (tooltip-identifier-from-point (point))))))) 1259 (tooltip-identifier-from-point (point)))))))
1260 (set-text-properties 0 (length expr) nil expr) 1260 (set-text-properties 0 (length expr) nil expr)
1261 (gdb-input (concat "-var-create - * " expr "") 1261 (gdb-input (concat "-var-create - * " expr "")
1262 `(lambda () (gdb-var-create-handler ,expr)))))) 1262 (lambda () (gdb-var-create-handler expr))))))
1263 (message "gud-watch is a no-op in this mode.")))) 1263 (message "gud-watch is a no-op in this mode."))))
1264 1264
1265(defsubst gdb-mi--field (value field) 1265(defsubst gdb-mi--field (value field)
@@ -1303,7 +1303,7 @@ With arg, enter name of variable to be watched in the minibuffer."
1303(defun gdb-var-list-children (varnum) 1303(defun gdb-var-list-children (varnum)
1304 (gdb-input (concat "-var-update " varnum) 'ignore) 1304 (gdb-input (concat "-var-update " varnum) 'ignore)
1305 (gdb-input (concat "-var-list-children --all-values " varnum) 1305 (gdb-input (concat "-var-list-children --all-values " varnum)
1306 `(lambda () (gdb-var-list-children-handler ,varnum)))) 1306 (lambda () (gdb-var-list-children-handler varnum))))
1307 1307
1308(defun gdb-var-list-children-handler (varnum) 1308(defun gdb-var-list-children-handler (varnum)
1309 (let* ((var-list nil) 1309 (let* ((var-list nil)
@@ -1366,7 +1366,7 @@ With arg, enter name of variable to be watched in the minibuffer."
1366 (varnum (car var)) 1366 (varnum (car var))
1367 (value (read-string "New value: "))) 1367 (value (read-string "New value: ")))
1368 (gdb-input (concat "-var-assign " varnum " " value) 1368 (gdb-input (concat "-var-assign " varnum " " value)
1369 `(lambda () (gdb-edit-value-handler ,value))))) 1369 (lambda () (gdb-edit-value-handler value)))))
1370 1370
1371(defconst gdb-error-regexp "\\^error,msg=\\(\".+\"\\)") 1371(defconst gdb-error-regexp "\\^error,msg=\\(\".+\"\\)")
1372 1372
@@ -1574,9 +1574,9 @@ this trigger is subscribed to `gdb-buf-publisher' and called with
1574 1574
1575(defun gdb-bind-function-to-buffer (expr buffer) 1575(defun gdb-bind-function-to-buffer (expr buffer)
1576 "Return a function which will evaluate EXPR in BUFFER." 1576 "Return a function which will evaluate EXPR in BUFFER."
1577 `(lambda (&rest args) 1577 (lambda (&rest args)
1578 (with-current-buffer ,buffer 1578 (with-current-buffer buffer
1579 (apply ',expr args)))) 1579 (apply expr args))))
1580 1580
1581;; Used to display windows with thread-bound buffers 1581;; Used to display windows with thread-bound buffers
1582(defmacro def-gdb-preempt-display-buffer (name buffer &optional doc 1582(defmacro def-gdb-preempt-display-buffer (name buffer &optional doc
@@ -3085,8 +3085,8 @@ See `def-gdb-auto-update-handler'."
3085 (when (setq file (gdb-mi--field breakpoint 'file)) 3085 (when (setq file (gdb-mi--field breakpoint 'file))
3086 (gdb-input (concat "list " file ":1") 'ignore) 3086 (gdb-input (concat "list " file ":1") 'ignore)
3087 (gdb-input "-file-list-exec-source-file" 3087 (gdb-input "-file-list-exec-source-file"
3088 `(lambda () (gdb-get-location 3088 (lambda () (gdb-get-location
3089 ,bptno ,line ,flag)))) 3089 bptno line flag))))
3090 (with-current-buffer (find-file-noselect file 'nowarn) 3090 (with-current-buffer (find-file-noselect file 'nowarn)
3091 (gdb-init-buffer) 3091 (gdb-init-buffer)
3092 ;; Only want one breakpoint icon at each location. 3092 ;; Only want one breakpoint icon at each location.
@@ -4547,17 +4547,17 @@ SPLIT-HORIZONTAL and show BUF in the new window."
4547 (let* ((buf-type (gdb-buffer-type buf)) 4547 (let* ((buf-type (gdb-buffer-type buf))
4548 (existing-window 4548 (existing-window
4549 (get-window-with-predicate 4549 (get-window-with-predicate
4550 #'(lambda (w) 4550 (lambda (w)
4551 (and (eq buf-type 4551 (and (eq buf-type
4552 (gdb-buffer-type (window-buffer w))) 4552 (gdb-buffer-type (window-buffer w)))
4553 (not (window-dedicated-p w))))))) 4553 (not (window-dedicated-p w)))))))
4554 (if existing-window 4554 (if existing-window
4555 (set-window-buffer existing-window buf) 4555 (set-window-buffer existing-window buf)
4556 (let ((dedicated-window 4556 (let ((dedicated-window
4557 (get-window-with-predicate 4557 (get-window-with-predicate
4558 #'(lambda (w) 4558 (lambda (w)
4559 (eq buf-type 4559 (eq buf-type
4560 (gdb-buffer-type (window-buffer w))))))) 4560 (gdb-buffer-type (window-buffer w)))))))
4561 (if dedicated-window 4561 (if dedicated-window
4562 (set-window-buffer 4562 (set-window-buffer
4563 (split-window dedicated-window nil split-horizontal) buf) 4563 (split-window dedicated-window nil split-horizontal) buf)
@@ -4622,7 +4622,7 @@ SPLIT-HORIZONTAL and show BUF in the new window."
4622 4622
4623(let ((menu (make-sparse-keymap "GDB-MI"))) 4623(let ((menu (make-sparse-keymap "GDB-MI")))
4624 (define-key menu [gdb-customize] 4624 (define-key menu [gdb-customize]
4625 '(menu-item "Customize" (lambda () (interactive) (customize-group 'gdb)) 4625 `(menu-item "Customize" ,(lambda () (interactive) (customize-group 'gdb))
4626 :help "Customize Gdb Graphical Mode options.")) 4626 :help "Customize Gdb Graphical Mode options."))
4627 (define-key menu [gdb-many-windows] 4627 (define-key menu [gdb-many-windows]
4628 '(menu-item "Display Other Windows" gdb-many-windows 4628 '(menu-item "Display Other Windows" gdb-many-windows
@@ -4631,26 +4631,26 @@ SPLIT-HORIZONTAL and show BUF in the new window."
4631 (define-key menu [sep1] 4631 (define-key menu [sep1]
4632 '(menu-item "--")) 4632 '(menu-item "--"))
4633 (define-key menu [all-threads] 4633 (define-key menu [all-threads]
4634 '(menu-item "GUD controls all threads" 4634 `(menu-item "GUD controls all threads"
4635 (lambda () 4635 ,(lambda ()
4636 (interactive) 4636 (interactive)
4637 (setq gdb-gud-control-all-threads t)) 4637 (setq gdb-gud-control-all-threads t))
4638 :help "GUD start/stop commands apply to all threads" 4638 :help "GUD start/stop commands apply to all threads"
4639 :button (:radio . gdb-gud-control-all-threads))) 4639 :button (:radio . gdb-gud-control-all-threads)))
4640 (define-key menu [current-thread] 4640 (define-key menu [current-thread]
4641 '(menu-item "GUD controls current thread" 4641 `(menu-item "GUD controls current thread"
4642 (lambda () 4642 ,(lambda ()
4643 (interactive) 4643 (interactive)
4644 (setq gdb-gud-control-all-threads nil)) 4644 (setq gdb-gud-control-all-threads nil))
4645 :help "GUD start/stop commands apply to current thread only" 4645 :help "GUD start/stop commands apply to current thread only"
4646 :button (:radio . (not gdb-gud-control-all-threads)))) 4646 :button (:radio . (not gdb-gud-control-all-threads))))
4647 (define-key menu [sep2] 4647 (define-key menu [sep2]
4648 '(menu-item "--")) 4648 '(menu-item "--"))
4649 (define-key menu [gdb-customize-reasons] 4649 (define-key menu [gdb-customize-reasons]
4650 '(menu-item "Customize switching..." 4650 `(menu-item "Customize switching..."
4651 (lambda () 4651 ,(lambda ()
4652 (interactive) 4652 (interactive)
4653 (customize-option 'gdb-switch-reasons)))) 4653 (customize-option 'gdb-switch-reasons))))
4654 (define-key menu [gdb-switch-when-another-stopped] 4654 (define-key menu [gdb-switch-when-another-stopped]
4655 (menu-bar-make-toggle-command 4655 (menu-bar-make-toggle-command
4656 gdb-toggle-switch-when-another-stopped 4656 gdb-toggle-switch-when-another-stopped