[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)))
- [elpa] externals/realgud 7242eea 048/140: whitespace, (continued)
- [elpa] externals/realgud 7242eea 048/140: whitespace, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 7cc1230 047/140: extract method for breakpoint stuff in realgud:track-from-region, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud aa933eb 038/140: Merge pull request #194 from jodonnell/print, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 2fad0c4 020/140: Add test case for an error when realgud:backtrace-init is hanging at startup, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 59b2563 023/140: Add gdb "delete" template, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud d9a3a92 046/140: Administrivia, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud bfabb0e 034/140: I am really bad with Elisp syntax, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 4692821 051/140: fixed an error, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 57eed60 027/140: making eval output truncate and saving all the current command hash, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 6986293 035/140: I am also bad at match relations, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud d00539e 030/140: Merge branch 'print' of https://github.com/jodonnell/realgud into print,
Rocky Bernstein <=
- [elpa] externals/realgud 90fe351 033/140: More Emacs-gaurded handling of realgud:join-string, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 53b0c1a 040/140: Be Explicit about eval command ..., Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 4babac3 042/140: Track changes in elpa:, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 348f73a 049/140: Merge pull request #198 from jodonnell/refactor, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 3804711 045/140: Get ready for 1.4.4 release. Admnistrivia, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 61fbadb 052/140: Merge pull request #199 from jodonnell/whoops, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 3a2e300 055/140: Merge pull request #200 from jodonnell/move-bps, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud b86a9df 054/140: refactor breakpoints further, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud ba91d87 058/140: Add realgud-populate-common-fn-keys-none to not set function keys..., Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 210bd76 053/140: moving breakpoint functions to more central locations, Rocky Bernstein, 2019/05/25