[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/xr dc6d6e3 1/3: Escape control chars in all warnings bu
From: |
Mattias Engdegård |
Subject: |
[elpa] externals/xr dc6d6e3 1/3: Escape control chars in all warnings but not double quote |
Date: |
Tue, 5 Mar 2019 05:08:20 -0500 (EST) |
branch: externals/xr
commit dc6d6e3cab769ef85fb7a386769a499b6404c3de
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>
Escape control chars in all warnings but not double quote
---
xr.el | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/xr.el b/xr.el
index 7f8d4e5..9db27b3 100644
--- a/xr.el
+++ b/xr.el
@@ -87,7 +87,7 @@
(push (vector ?\] end (point)) intervals)
(xr--report warnings (point)
(format "Reversed range `%s' matches nothing"
- (match-string 0)))))
+ (xr--escape-string (match-string 0) nil)))))
(goto-char (match-end 0)))
;; Initial ]
((looking-at "]")
@@ -119,7 +119,7 @@
(t
(xr--report warnings (point)
(format "Reversed range `%s' matches nothing"
- (match-string 0)))))
+ (xr--escape-string (match-string 0) nil)))))
(goto-char (match-end 0))))
((looking-at (rx eos))
(error "Unterminated character alternative"))
@@ -634,8 +634,8 @@ in RE-STRING."
(sort (car warnings) #'car-less-than-car)))
;; Escape non-printing characters in a string for maximum readability.
-;; If ESCAPE-BACKSLASH, also escape \, otherwise don't.
-(defun xr--escape-string (string escape-backslash)
+;; If ESCAPE-PRINTABLE, also escape \ and ", otherwise don't.
+(defun xr--escape-string (string escape-printable)
;; Translate control and raw chars to escape sequences for readability.
;; We prefer hex escapes (\xHH) since that is usually what the user wants,
;; but use octal (\OOO) if a legitimate hex digit follows, as
@@ -646,8 +646,7 @@ in RE-STRING."
(let* ((c (logand (string-to-char s) #xff))
(xdigit (substring s 1))
(transl (assq c
- '((?\" . "\\\"")
- (?\b . "\\b")
+ '((?\b . "\\b")
(?\t . "\\t")
(?\n . "\\n")
(?\v . "\\v")
@@ -656,8 +655,8 @@ in RE-STRING."
(?\e . "\\e")))))
(concat
(cond (transl (cdr transl))
- ((eq c ?\\)
- (if escape-backslash "\\\\" "\\"))
+ ((memq c '(?\\ ?\"))
+ (if escape-printable (string ?\\ c) (string c)))
((zerop (length xdigit)) (format "\\x%02x" c))
(t (format (format "\\%03o" c))))
xdigit)))