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

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

[elpa] externals/realgud d00539e 030/140: Merge branch 'print' of https:


From: Rocky Bernstein
Subject: [elpa] externals/realgud d00539e 030/140: Merge branch 'print' of https://github.com/jodonnell/realgud into print
Date: Sat, 25 May 2019 19:35:25 -0400 (EDT)

branch: externals/realgud
commit d00539eba2340eb23973970c9ebe5861b740156e
Merge: df03ba5 57eed60
Author: rocky <address@hidden>
Commit: rocky <address@hidden>

    Merge branch 'print' of https://github.com/jodonnell/realgud into print
---
 realgud/common/track.el | 54 ++++++++++++++++++++++++++++++++++++++++++++++--
 realgud/common/utils.el |  6 ++++++
 test/test-track.el      | 55 ++++++++++++++++++++++++++++++++++++++++---------
 test/test-utils.el      |  4 ++++
 4 files changed, 107 insertions(+), 12 deletions(-)

diff --git a/realgud/common/track.el b/realgud/common/track.el
index f75efe9..eeeb3e9 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,32 @@ 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."
+  (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 +226,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 +775,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 +808,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..e6aec5a 100644
--- a/realgud/common/utils.el
+++ b/realgud/common/utils.el
@@ -30,6 +30,12 @@
    (t
     (append (realgud:flatten (car mylist)) (realgud:flatten (cdr mylist))))))
 
+;; From 
https://stackoverflow.com/questions/12999530/is-there-a-function-that-joins-a-string-into-a-delimited-string
+(defun realgud:join-string (list joiner)
+  (if (< emacs-major-version 25)
+      (mapconcat 'identity list joiner)
+    (string-join list joiner)))
+
 (defun realgud:canonic-major-mode()
   "Return
     - 'eshell if we are in eshell-mode,
diff --git a/test/test-track.el b/test/test-track.el
index 5e98fec..c3f8f9d 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,34 @@ 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))
+(puthash "eval" "eval" test-command-name-hash)
+(set (make-local-variable 'realgud-command-name-hash) 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]