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

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

[elpa] externals/realgud 8480545 041/140: Merge branch 'master' of githu


From: Rocky Bernstein
Subject: [elpa] externals/realgud 8480545 041/140: Merge branch 'master' of github.com:realgud/realgud
Date: Sat, 25 May 2019 19:35:27 -0400 (EDT)

branch: externals/realgud
commit 84805456f2da21e724c1c6ec91bee733aa1b22b9
Merge: 53b0c1a c64a4fd
Author: rocky <address@hidden>
Commit: rocky <address@hidden>

    Merge branch 'master' of github.com:realgud/realgud
---
 INSTALL.md                         | 14 +++++++--
 realgud/common/buffer/backtrace.el | 15 ++++++++--
 realgud/common/cmds.el             |  5 ++++
 realgud/common/shortkey.el         |  1 +
 realgud/common/track.el            | 55 +++++++++++++++++++++++++++++++++--
 realgud/common/utils.el            | 10 +++++++
 realgud/debugger/gdb/init.el       |  4 ++-
 test/test-bt-trepan2.el            | 34 ++++++++++++++++++++++
 test/test-track.el                 | 59 +++++++++++++++++++++++++++++++-------
 test/test-utils.el                 |  4 +++
 10 files changed, 183 insertions(+), 18 deletions(-)

diff --git a/INSTALL.md b/INSTALL.md
index cc7f7dd..3990d1c 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -1,5 +1,15 @@
 * Have `test-simple`, `loc-changes`, `cl-lib` and `load-relative` installed.
 * From inside emacs, evaluate:
 ```lisp
-  (compile (format "EMACSLOADPATH=:%s:%s ./autogen.sh" (file-name-directory 
(locate-library "test-simple.elc")) (file-name-directory (locate-library 
"realgud.elc"))))
-```
+  (compile (format "EMACSLOADPATH=:%s:%s:%s:%s ./autogen.sh" 
(file-name-directory (locate-library "test-simple.elc")) (file-name-directory 
(locate-library "load-relative.elc")) (file-name-directory (locate-library 
"loc-changes.elc")) (file-name-directory (locate-library "realgud.elc")) ))
+  ```
+
+After this you should be able to run:
+
+    $ make         # byte compile everything
+    $ make check   # run unit tests
+    $ make install # may need to prefix with sudo
+
+
+Also you can run from the source directory by running `eval-current-buffer`
+when inside to top level `realgud.el` (that's the one that is in this folder).
diff --git a/realgud/common/buffer/backtrace.el 
b/realgud/common/buffer/backtrace.el
index 2b68bb0..30f3a59 100644
--- a/realgud/common/buffer/backtrace.el
+++ b/realgud/common/buffer/backtrace.el
@@ -407,6 +407,15 @@ filename, line number, whether the frame is selected as 
text properties."
            ;; FIXME: Remove hack that group 1 is always the frame indicator.
            (frame-indicator
             (substring stripped-string (match-beginning 1) (match-end 1)))
+           ;; From https://github.com/realgud/realgud/pull/192
+           ;; Each frame of backtrace is searched via string-match
+           ;; invocation and a position of the current frame is
+           ;; updated via (setq last-pos (match-end 0)) in the end of
+           ;; the loop. But somewhere in the body of the loop (I do
+           ;; not know exactly where), there is another call to
+           ;; string-match and it messes up all positions.
+           (whole-match-begin (match-beginning 0))
+           (whole-match-end (match-end 0))
            (frame-num-pos)
 
            )
@@ -462,12 +471,12 @@ filename, line number, whether the frame is selected as 
text properties."
 
        (when (and (stringp filename) (numberp line-num))
          (let ((loc (realgud:file-loc-from-line filename line-num cmdbuf)))
-           (put-text-property (match-beginning 0) (match-end 0)
+           (put-text-property whole-match-begin whole-match-end
                               'loc loc string)
            ))
-       (put-text-property (match-beginning 0) (match-end 0)
+       (put-text-property whole-match-begin whole-match-end
                           'frame-num  frame-num string)
-       (setq last-pos (match-end 0))
+       (setq last-pos whole-match-end)
 
        (if (string-match frame-indicator-re frame-indicator)
          (setq selected-frame-num frame-num))
diff --git a/realgud/common/cmds.el b/realgud/common/cmds.el
index 0696ec9..06a202f 100644
--- a/realgud/common/cmds.el
+++ b/realgud/common/cmds.el
@@ -288,6 +288,11 @@ EVENT should be a mouse click on the left fringe or 
margin."
                           #'realgud:cmd-eval-region
                         #'realgud:cmd-eval)))
 
+(defun realgud:cmd-eval-at-point()
+  "Eval symbol under point."
+  (interactive)
+  (realgud:cmd-run-command (thing-at-point 'symbol) "eval"))
+
 (defun realgud:cmd-finish(&optional arg)
     "Run until the completion of the current stack frame.
 
diff --git a/realgud/common/shortkey.el b/realgud/common/shortkey.el
index 43c741f..364bfda 100644
--- a/realgud/common/shortkey.el
+++ b/realgud/common/shortkey.el
@@ -62,6 +62,7 @@
     (define-key map "j"        'realgud:cmd-jump)
     (define-key map "c"        'realgud:cmd-continue)
     (define-key map "e"        'realgud:cmd-eval-dwim)
+    (define-key map "E"        'realgud:cmd-eval-at-point)
     (define-key map "U"        'realgud:cmd-until)
     (define-key map [mouse-2]  'realgud:tooltip-eval)
     (define-key map [left-fringe mouse-1] #'realgud-cmds--mouse-add-remove-bp)
diff --git a/realgud/common/track.el b/realgud/common/track.el
index f75efe9..088e1cc 100644
--- a/realgud/common/track.el
+++ b/realgud/common/track.el
@@ -29,10 +29,11 @@
 (require-relative-list
  '("core"           "file"     "fringe"
    "helper"         "init"     "loc"    "lochist"
-   "regexp"         "shortkey" "window"
+   "regexp"         "shortkey" "window" "utils"
    "bp"
    ) "realgud-")
 
+
 (require-relative-list
  '("buffer/command" "buffer/helper" "buffer/source") "realgud-buffer-")
 
@@ -41,6 +42,11 @@
   :type 'symbolp
   :group 'realgud)
 
+(defcustom realgud-eval-message-print-length 1000
+"If non-nil, truncate eval output into the echo area"
+  :type 'symbolp
+  :group 'realgud)
+
 (declare-function buffer-killed?                      'realgud-helper)
 (declare-function fn-p-to-fn?-alias                   'realgud-helper)
 (declare-function realgud-bp-add-info                 'realgud-bp)
@@ -77,6 +83,7 @@
 (declare-function realgud-window-src                  'realgud-window)
 (declare-function realgud-window-src-undisturb-cmd    'realgud-window)
 (declare-function realgud-window-update-position      'realgud-window)
+(declare-function realgud:join-string                 'realgud-utils)
 
 (make-variable-buffer-local  (defvar realgud-track-mode))
 (fn-p-to-fn?-alias 'realgud-loc-p)
@@ -168,6 +175,33 @@ message."
              "Buffer %s is not a debugger command buffer" buf)
     t))
 
+(defun realgud:get-output-command(text)
+  "Splits the TEXT by newline."
+  (car (split-string text "\n")))
+
+(defun realgud:get-eval-output(text)
+  "Gets the output stripping the command and debugger prompt from the TEXT."
+  (realgud:join-string (butlast (cdr (split-string text "\n"))) "\n"))
+
+(defun realgud:get-command-name(command-name)
+  "Gets the COMMAND-NAME for this particular debugger."
+  (gethash command-name (buffer-local-value 'realgud-command-name-hash 
(current-buffer))))
+
+(defun realgud:eval-command-p(text)
+  "Checks the TEXT if the command that was ran was an eval command."
+  (let ((cmd-name (realgud:get-command-name "eval")))
+       (and (stringp cmd-name) (string-prefix-p (realgud:get-command-name 
"eval") (realgud:get-output-command text)))))
+
+(defun realgud:truncate-eval-message(text)
+  "Truncates the TEXT to the size of realgud-eval-message-print-length."
+  (if (< realgud-eval-message-print-length (length text))
+      (substring text 0 realgud-eval-message-print-length)
+    text))
+
+(defun realgud:message-eval-results(text)
+  "Output the TEXT to the message area."
+  (message (realgud:truncate-eval-message (realgud:get-eval-output text))))
+
 (defun realgud:track-from-region(from to &optional cmd-mark opt-cmdbuf
                                      shortkey-on-tracing? no-warn-if-no-match?)
   "Find and position a buffer at the location found in the marked region.
@@ -193,6 +227,9 @@ evaluating (realgud-cmdbuf-info-loc-regexp 
realgud-cmdbuf-info)"
         (cmdbuf (or opt-cmdbuf (current-buffer)))
         )
     (unless (realgud:track-complain-if-not-in-cmd-buffer cmdbuf t)
+      (if (realgud:eval-command-p text)
+          (realgud:message-eval-results text))
+
        (if (not (equal "" text))
            (with-current-buffer cmdbuf
              (if (realgud-sget 'cmdbuf-info 'divert-output?)
@@ -739,7 +776,18 @@ find a location. non-nil if we can find a location.
        (if loc (or (realgud-track-loc-action loc cmdbuf) 't)
          nil))
       ))
-    )
+  )
+
+(defun realgud:populate-command-hash(key value)
+  "Adds a KEY and VALUE to the realgud-command-name-hash the command name to a 
debugger specific command."
+  (puthash key
+           (replace-regexp-in-string "%.*" "" (car (split-string value " ")))
+           realgud-command-name-hash))
+
+(defun realgud-set-command-name-hash-to-buffer-local (command-hash)
+  "Sets the eval string as a buffer local variable from the COMMAND-HASH."
+  (set (make-local-variable 'realgud-command-name-hash) (make-hash-table :test 
'equal))
+  (maphash 'realgud:populate-command-hash command-hash))
 
 (defun realgud:track-set-debugger (debugger-name)
   "Set debugger name and information associated with that
@@ -761,6 +809,9 @@ we can't find a debugger with that information.`.
       (setq regexp-hash (gethash base-variable-name realgud-pat-hash))
       (setq command-hash (gethash base-variable-name realgud-command-hash))
       )
+
+    (realgud-set-command-name-hash-to-buffer-local command-hash)
+
     (if regexp-hash
        (let* (
               (mode-name (concat " " (capitalize base-variable-name) "-Track"))
diff --git a/realgud/common/utils.el b/realgud/common/utils.el
index bc2eee0..1971e98 100644
--- a/realgud/common/utils.el
+++ b/realgud/common/utils.el
@@ -30,6 +30,16 @@
    (t
     (append (realgud:flatten (car mylist)) (realgud:flatten (cdr mylist))))))
 
+(if (or (< emacs-major-version 24)
+       (and (= emacs-major-version 24) (<= emacs-minor-version 3)))
+    ;; From
+    ;; 
https://stackoverflow.com/questions/12999530/is-there-a-function-that-joins-a-string-into-a-delimited-string
+    (defun realgud:join-string (list joiner)
+      (mapconcat 'identity list joiner))
+  (progn
+    (require 'subr-x)
+    (defalias 'realgud:join-string 'string-join)))
+
 (defun realgud:canonic-major-mode()
   "Return
     - 'eshell if we are in eshell-mode,
diff --git a/realgud/debugger/gdb/init.el b/realgud/debugger/gdb/init.el
index 92bb5d6..e2c4a80 100644
--- a/realgud/debugger/gdb/init.el
+++ b/realgud/debugger/gdb/init.el
@@ -1,4 +1,4 @@
-;; Copyright (C) 2015-2016 Free Software Foundation, Inc
+;; Copyright (C) 2015-2017 Free Software Foundation, Inc
 
 ;; Author: Rocky Bernstein <address@hidden>
 
@@ -132,10 +132,12 @@ realgud-loc-pat struct")
 (setf (gethash "break"    realgud:gdb-command-hash) "break %X:%l")
 (setf (gethash "clear"    realgud:gdb-command-hash) "clear %X:%l")
 (setf (gethash "continue" realgud:gdb-command-hash) "continue")
+(setf (gethash "delete"   realgud:gdb-command-hash) "delete %p")
 (setf (gethash "eval"     realgud:gdb-command-hash) "print %s")
 (setf (gethash "quit"     realgud:gdb-command-hash) "quit")
 (setf (gethash "run"      realgud:gdb-command-hash) "run")
 (setf (gethash "step"     realgud:gdb-command-hash) "step %p")
+
 (setf (gethash "gdb" realgud-command-hash) realgud:gdb-command-hash)
 
 (setf (gethash "gdb" realgud-pat-hash) realgud:gdb-pat-hash)
diff --git a/test/test-bt-trepan2.el b/test/test-bt-trepan2.el
index d3d3d0f..e1be16e 100644
--- a/test/test-bt-trepan2.el
+++ b/test/test-bt-trepan2.el
@@ -4,15 +4,19 @@
 (require 'test-simple)
 (require 'load-relative)
 (load-file "./bt-helper.el")
+(load-file "./regexp-helper.el")
 (load-file "../realgud/debugger/trepan2/init.el")
 
 (declare-function setup-bt 'realgud-bt-helper)
+(declare-function setup-regexp-vars 'regexp-helper)
 (declare-function __FILE__ 'load-relative)
 
 (test-simple-start)
 
 (eval-when-compile
   (defvar temp-bt)
+  (defvar realgud-pat-bt)
+  (defvar realgud:trepan2-pat-hash)
 )
 
 (setq temp-bt
@@ -40,4 +44,34 @@
                  (get-text-property (point) 'face))
     )
   )
+
+
+(setup-regexp-vars realgud:trepan2-pat-hash)
+(setq realgud-pat-bt  (gethash "debugger-backtrace"
+                               realgud:trepan2-pat-hash))
+
+
+(let* ((triple
+        (realgud:backtrace-add-text-properties
+         realgud-pat-bt ""
+         "->0 gcd(a=3, b=5) called from file '/test/gcd.py' at line 28
+##1 <module> exec() '/test/gcd.py' at line 41"
+         "->"))
+       (string-with-props (car triple)))
+  (dolist (pair
+           '(
+             ("->0" . (0 . 28) )
+             ("##1" . (1 . 41) )
+             ))
+    (string-match (car pair) string-with-props)
+    (assert-equal (cddr pair)
+                  (realgud-loc-line-number (get-text-property
+                                            (match-beginning 0) 'loc
+                                            string-with-props)))
+
+    (assert-equal (cadr pair)
+                  (get-text-property
+                   (match-beginning 0) 'frame-num
+                   string-with-props))))
+
 (end-tests)
diff --git a/test/test-track.el b/test/test-track.el
index 5e98fec..cbc4da0 100644
--- a/test/test-track.el
+++ b/test/test-track.el
@@ -7,19 +7,26 @@
 (load-file "../realgud/common/track.el")
 (load-file "../realgud/common/core.el")
 (load-file "../realgud/common/loc.el")
+(load-file "../realgud/common/utils.el")
 (load-file "../realgud/debugger/trepan/core.el")
 (load-file "../realgud/debugger/trepan/init.el")
 
-(declare-function __FILE__                     'load-relative)
-(declare-function realgud-cmdbuf-init          'realgud-buffer-command)
-(declare-function realgud-loc-filename         'realgud-loc)
-(declare-function realgud-loc-p                'realgud-loc)
-(declare-function realgud-loc-line-number      'realgud-loc)
-(declare-function realgud:track-from-region    'realgud-track)
-(declare-function realgud-track-loc            'realgud-track)
-(declare-function realgud-track-loc-remaining  'realgud-track)
-(declare-function realgud-track-selected-frame 'realgud-track)
-(declare-function realgud-track-termination?   'realgud-track)
+(declare-function __FILE__                                      'load-relative)
+(declare-function realgud-cmdbuf-init                           
'realgud-buffer-command)
+(declare-function realgud-loc-filename                          'realgud-loc)
+(declare-function realgud-loc-p                                 'realgud-loc)
+(declare-function realgud-loc-line-number                       'realgud-loc)
+(declare-function realgud:track-from-region                     'realgud-track)
+(declare-function realgud-track-loc                             'realgud-track)
+(declare-function realgud-track-loc-remaining                   'realgud-track)
+(declare-function realgud-track-selected-frame                  'realgud-track)
+(declare-function realgud-track-termination?                    'realgud-track)
+(declare-function realgud:get-eval-output                       'realgud-track)
+(declare-function realgud:get-output-command                    'realgud-track)
+(declare-function realgud:eval-command-p                        'realgud-track)
+(declare-function realgud-set-command-name-hash-to-buffer-local 'realgud-track)
+(declare-function realgud:truncate-eval-message                 'realgud-track)
+
 
 (test-simple-start)
 
@@ -88,6 +95,38 @@ trepan: That's all, folks...
 (assert-t (realgud-track-termination? debugger-output))
 
 
+(note "realgud:get-eval-output")
+(assert-equal "'cow'" (realgud:get-eval-output "eval 'cow'\n'cow'\n(pdb)"))
+(assert-equal "" (realgud:get-eval-output "weird output"))
+
+(note "realgud:get-output-command")
+(assert-equal "eval bang" (realgud:get-output-command "eval bang\noutput"))
+(assert-equal "" (realgud:get-output-command ""))
+
+(note "realgud:eval-command-p")
+(setq test-command-name-hash (make-hash-table :test 'equal))
+(set (make-local-variable 'realgud-command-name-hash) test-command-name-hash)
+
+;; We haven't set "eval" in command-name-hash so this should fail
+(assert-nil (realgud:eval-command-p "eval 'cow'\n'cow'\n(pdb)"))
+
+(puthash "eval" "eval" test-command-name-hash)
+(assert-t (realgud:eval-command-p "eval 'cow'\n'cow'\n(pdb)"))
+(assert-nil (realgud:eval-command-p "next 1"))
+
+(note "realgud-set-command-name-hash-to-buffer-local")
+(setq test-command-hash (make-hash-table :test 'equal))
+(puthash "eval" "!%s" test-command-hash)
+(realgud-set-command-name-hash-to-buffer-local test-command-hash)
+(assert-equal "!" (gethash "eval" (buffer-local-value 
'realgud-command-name-hash (current-buffer))))
+
+(note "realgud:truncate-eval-message")
+(let ((realgud-eval-message-print-length 500))
+  (assert-equal (realgud:truncate-eval-message (make-string 501 ?x)) 
(make-string 500 ?x)))
+(let ((realgud-eval-message-print-length 500))
+  (assert-equal (realgud:truncate-eval-message "cat") "cat"))
+
+
 ;; (setq debugger-bp-output (format "Breakpoint %d set at line %d\n\tin file 
%s.\n"
 ;;                               bp-num line-number test-filename))
 ;; (setq bp-loc (realgud-track-bp-loc debugger-bp-output nil))
diff --git a/test/test-utils.el b/test/test-utils.el
index 47d9958..3fc0f42 100644
--- a/test/test-utils.el
+++ b/test/test-utils.el
@@ -12,6 +12,7 @@
 (declare-function realgud:strip              'realgud-regexp)
 (declare-function __FILE__                   'load-relative)
 (declare-function realgud:canonic-major-mode 'realgud-utils)
+(declare-function realgud:join-string        'realgud-utils)
 
 (test-simple-start)
 
@@ -23,6 +24,9 @@
 (assert-equal "abc" (realgud:strip "abc"))
 (assert-equal "def" (realgud:strip "\n  def\t  "))
 
+(note "realgud:join-string")
+(assert-equal "a b c" (realgud:join-string '("a" "b" "c") " "))
+
 (note "realgud:flatten")
 (assert-equal '(abc) (realgud:flatten '(abc)))
 (assert-equal '(abc def h i j) (realgud:flatten '(abc (def (h) i) j)))



reply via email to

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