[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/realgud 6706358 073/140: Add format specifier %q a la k
From: |
Rocky Bernstein |
Subject: |
[elpa] externals/realgud 6706358 073/140: Add format specifier %q a la ksh... |
Date: |
Sat, 25 May 2019 19:35:36 -0400 (EDT) |
branch: externals/realgud
commit 6706358aa7adbfc6b551d8a2fd394287b01070e5
Author: rocky <address@hidden>
Commit: rocky <address@hidden>
Add format specifier %q a la ksh...
Used in nodejs exec(%q) for example
---
realgud/common/send.el | 23 +++++++++++++++++++----
realgud/debugger/nodejs/init.el | 2 +-
realgud/debugger/trepanjs/init.el | 4 ++--
test/gcd.js | 3 +--
test/test-send.el | 3 +++
5 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/realgud/common/send.el b/realgud/common/send.el
index 81edf16..4c112c1 100644
--- a/realgud/common/send.el
+++ b/realgud/common/send.el
@@ -1,4 +1,4 @@
-;; Copyright (C) 2015-2016 Free Software Foundation, Inc
+;; Copyright (C) 2015-2016, 2018 Free Software Foundation, Inc
;; Author: Rocky Bernstein <address@hidden>
@@ -140,6 +140,7 @@ taken from current buffer, or OPT-BUFFER if non-nil. Some
%c -- Fully qualified class name derived from the expression
surrounding point.
%p -- Value of OPT-STR, converted to string using `int-to-string'
+ %q -- Value of OPT-STR with string escapes (as ksh, bash, and zsh do).
%s -- Value of OPT-STR.
%p and %s are replaced by an empty string if OPT-STR is nil."
@@ -149,7 +150,7 @@ taken from current buffer, or OPT-BUFFER if non-nil. Some
result)
(while (and fmt-str
(let ((case-fold-search nil))
- (string-match "\\([^%]*\\)%\\([dfFlpxXs]\\)" fmt-str)))
+ (string-match "\\([^%]*\\)%\\([dfFlpqxXs]\\)" fmt-str)))
(let* ((key-str (match-string 2 fmt-str))
(key (string-to-char key-str)))
(setq result
@@ -179,20 +180,34 @@ taken from current buffer, or OPT-BUFFER if non-nil. Some
(+ (count-lines (point-min) (point))
(if (bolp) 1 0)))))
"source-buffer-not-found-for-%l"))
+
+ ((eq key ?p) (if opt-str (int-to-string opt-str) ""))
+
+ ;; String with escapes. %q follows shell (ksh, bash, zsh)
+ ;; The other possibility was Python's %r, !r or "repr".
+ ;; That isn't as perfect a fit though.
+ ((eq key ?q) (if opt-str
+ (let ((print-escape-newlines t))
+ (prin1-to-string opt-str))
+ ""))
+
+ ;; String
+ ((eq key ?s) (or opt-str ""))
+
((eq key ?x)
(or (and src-file-name src-file-name)
"*source-file-not-found-for-%x"))
((eq key ?X)
(or (and src-file-name (expand-file-name src-file-name))
"*source-file-not-found-for-%X"))
+
;; ((eq key ?e)
;; (gud-find-expr))
;; ((eq key ?a)
;; (gud-read-address))
;; ((eq key ?c)
;; (gud-find-class srcbuf))
- ((eq key ?p) (if opt-str (int-to-string opt-str) ""))
- ((eq key ?s) (or opt-str ""))
+
(t key)))))
(setq fmt-str (substring fmt-str (match-end 2))))
;; There might be text left in FMT-STR when the loop ends.
diff --git a/realgud/debugger/nodejs/init.el b/realgud/debugger/nodejs/init.el
index 14b23ac..a095dec 100644
--- a/realgud/debugger/nodejs/init.el
+++ b/realgud/debugger/nodejs/init.el
@@ -167,7 +167,7 @@ realgud-loc-pat struct")
(setf (gethash "quit" realgud:nodejs-command-hash) "quit")
(setf (gethash "finish" realgud:nodejs-command-hash) "out")
(setf (gethash "shell" realgud:nodejs-command-hash) "repl")
-(setf (gethash "eval" realgud:nodejs-command-hash) "exec('%s')")
+(setf (gethash "eval" realgud:nodejs-command-hash) "exec(%q)")
;; We need aliases for step and next because the default would
;; do step 1 and nodejs doesn't handle this. And if it did,
diff --git a/realgud/debugger/trepanjs/init.el
b/realgud/debugger/trepanjs/init.el
index 9f37b6f..881fcff 100644
--- a/realgud/debugger/trepanjs/init.el
+++ b/realgud/debugger/trepanjs/init.el
@@ -1,4 +1,4 @@
-;; Copyright (C) 2015-2016 Free Software Foundation, Inc
+;; Copyright (C) 2015-2016, 2018 Free Software Foundation, Inc
;; Author: Rocky Bernstein <address@hidden>
@@ -153,7 +153,7 @@ realgud-loc-pat struct")
;; We need aliases for step and next because the default would
;; do step 1 and trepanjs doesn't handle this. Or when it does,
;; it will probably look like step(1)
-(setf (gethash "eval" realgud:trepanjs-command-hash) "eval('%s')")
+(setf (gethash "eval" realgud:trepanjs-command-hash) "eval(%q)")
(setf (gethash "quit" realgud:trepanjs-command-hash) "quit()")
;; Unsupported features:
diff --git a/test/gcd.js b/test/gcd.js
index ee56555..901bb96 100644
--- a/test/gcd.js
+++ b/test/gcd.js
@@ -40,6 +40,5 @@ function gcd(a, b) {
var a = parseInt(process.argv[0]) || 24,
b = parseInt(process.argv[0]) || 5;
-console.log(util.format("The GCD of %d and %d is %d", a, b,
- gcd(a, b)));
+console.log(util.format("The GCD of %d and %d is %d", a, b, gcd(a, b)));
process.exit();
diff --git a/test/test-send.el b/test/test-send.el
index 5eec304..5337a41 100644
--- a/test/test-send.el
+++ b/test/test-send.el
@@ -44,6 +44,9 @@
(realgud-expand-format "h%s!" "i, rocky")
"format %s")
+(assert-equal "\"\\\"fake\\\" news\"!"
+ (realgud-expand-format "%q!" "\"fake\" news"))
+
(setup)
;; Current buffer is now set up as a source buffer
(setq file-name (buffer-file-name))
- [elpa] externals/realgud 388a650 077/140: Sync with savanah ELPA, (continued)
- [elpa] externals/realgud 388a650 077/140: Sync with savanah ELPA, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud f851166 089/140: Bug in kshdb initialization, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 0ea8a13 094/140: Track breakpoing deletion, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud bb967ed 096/140: Add tbreak as per break, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 555282f 084/140: TravisCI 3rd try, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 542e51c 097/140: Merge pull request #220 from MaskRay/tbreak, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 51979d2 099/140: Merge pull request #221 from MaskRay/ex, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 4bcbb89 095/140: Last commit introduced a couple of bugs, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud ba85207 103/140: Add realgud:js-file-line-loc-pat, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 9f9c772 087/140: Remove debug message, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 6706358 073/140: Add format specifier %q a la ksh...,
Rocky Bernstein <=
- [elpa] externals/realgud aa76fb0 085/140: Tidy a bit, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 1a69faf 083/140: CircleCI 2nd try, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud cbcacd8 098/140: gdb: parse -ex --eval-command, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 3904510 074/140: Large change to allow blacklisted files, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud b8b587b 109/140: ipdb need ANSI schmutz removed..., Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 0b5ebbf 104/140: Merge pull request #223 from realgud/better-bp-track, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 446c26b 102/140: Adds ource-path to cmdbuf..., Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud f4c4ccd 118/140: Fix improper breakpoint file-callback function parameters, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 1da5f2b 113/140: Merge branch 'master' of github.com:realgud/realgud, Rocky Bernstein, 2019/05/25
- [elpa] externals/realgud 131ad58 122/140: Disable breakpoint file finding callback function for noww, Rocky Bernstein, 2019/05/25