emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 40e73bc 123/215: Merge pull request #92 from cpitclaudel/8


From: Rocky Bernstein
Subject: [elpa] master 40e73bc 123/215: Merge pull request #92 from cpitclaudel/82-add-safe-mode
Date: Sat, 30 Jul 2016 14:48:59 +0000 (UTC)

branch: master
commit 40e73bc005407accadfc4fa9933695358a31dc64
Merge: 75737a0 78d9901
Author: R. Bernstein <address@hidden>
Commit: R. Bernstein <address@hidden>

    Merge pull request #92 from cpitclaudel/82-add-safe-mode
    
    Add a "safe mode" setting (on by default)
---
 realgud/common/cmds.el |   27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/realgud/common/cmds.el b/realgud/common/cmds.el
index 72eebd5..5eeb45f 100644
--- a/realgud/common/cmds.el
+++ b/realgud/common/cmds.el
@@ -31,6 +31,24 @@
 (declare-function realgud:terminate 'realgud-core)
 (declare-function realgud:terminate-srcbuf 'realdgud-core)
 
+(defcustom realgud-safe-mode t
+  "Confirm certain commands before running them.
+Similar to GDB's “set confirm”."
+  :type 'boolean
+  :group 'realgud)
+
+(defun realgud:prompt-if-prefix-or-safe-mode(message)
+  "Ask use to confirm current command if in safe mode.
+Use MESSAGE plus a space as the prompt string.  Do not confirm
+when command was run from a menu."
+  (if (and realgud-safe-mode last-nonmenu-event)
+      (when (y-or-n-p (concat message " "))
+        (run-with-timer
+         0 nil #'message
+         "Customize `realgud-safe-mode' to disable confirmation prompts.")
+        t)
+    t))
+
 (defun realgud:cmd-remap(arg cmd-name default-cmd-template key
                             &optional no-record? frame-switch?
                             realgud-prompts?)
@@ -89,11 +107,14 @@ a shortcut for that key."
 
 (defun realgud:cmd-continue(&optional arg)
     "Continue execution.
-With prefix argument, prompt for argument to \"continue\"
-command."
+With prefix argument ARG, prompt for argument to \"continue\"
+command.  In safe mode (or with prefix arg), confirm before
+running."
     (interactive (when (consp current-prefix-arg)
                    (list (read-string "Continue args: " nil nil nil t))))
-    (realgud:cmd-remap arg "continue" "continue" "c"))
+    (when (or arg (realgud:prompt-if-prefix-or-safe-mode
+                   "Continue to next breakpoint?"))
+      (realgud:cmd-remap arg "continue" "continue" "c")))
 
 (defun realgud:cmd-delete(&optional arg)
     "Delete breakpoint by number."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]