[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/annotate 4372e9ea20 147/372: - changed escaping mechanism;
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/annotate 4372e9ea20 147/372: - changed escaping mechanism; |
Date: |
Fri, 4 Feb 2022 16:58:37 -0500 (EST) |
branch: elpa/annotate
commit 4372e9ea20ce89d311aa97e553e003eac1cecc6a
Author: cage <cage-invalid@invalid>
Commit: cage <cage-invalid@invalid>
- changed escaping mechanism;
- changed regex for checking if a file is in info format.
---
annotate.el | 137 ++++++++++++++++++++++++++++++++++++------------------------
1 file changed, 83 insertions(+), 54 deletions(-)
diff --git a/annotate.el b/annotate.el
index 78504688d5..37cd4fc769 100644
--- a/annotate.el
+++ b/annotate.el
@@ -1291,8 +1291,8 @@ sophisticated way than plain text"
(t
(let* ((file-contents (file-contents))
(has-info-p (string-match "info"
filename))
- (has-separator-p (string-match "\\(
\\)?\\(\\)?$"
-
file-contents))
+ (separator-re "\^L?\^_\^L?\^J")
+ (has-separator-p (string-match
separator-re file-contents))
(has-node-p (string-match "Node:"
file-contents)))
(if (or (annotate-info-root-dir-p filename)
(and has-separator-p
@@ -1511,39 +1511,47 @@ when `look-ahead-p' is not nil the token is recognized
but not cut away from
example:
'a and b' -> 'a and b', '(re \"a\" 0 1)
"
- (cl-labels ((build-results (token-symbol register-num)
+ (cl-labels ((build-token (token-symbol token-string token-beginning
token-end)
(list token-symbol
- (match-string register-num
annotate-summary-query)
- (match-beginning register-num)
- (match-end register-num)))
+ token-string
+ token-beginning
+ token-end))
+ (build-results (token-symbol register-num)
+ (build-token token-symbol
+ (match-string register-num
annotate-summary-query)
+ (match-beginning register-num)
+ (match-end register-num)))
(cut-query (match-results)
(setf annotate-summary-query
(cl-subseq annotate-summary-query
(annotate-summary-query-lexer-end match-results)))))
- (let ((re
"\\([^\\](\\)\\|\\([^\\])\\)\\|\\([^\\]?and\\)\\|\\([^\\]?not\\)\\|\\([^\\]?or\\)\\|\\([^[:space:]]+\\)"))
- (save-match-data
- (let* ((matchedp (string-match re annotate-summary-query))
- (res (if matchedp
- (cond
- ((match-string 1 annotate-summary-query)
- (build-results 'open-par 1))
- ((match-string 2 annotate-summary-query)
- (build-results 'close-par 2))
- ((match-string 3 annotate-summary-query)
- (build-results 'and 3))
- ((match-string 4 annotate-summary-query)
- (build-results 'not 4))
- ((match-string 5 annotate-summary-query)
- (build-results 'or 5))
- ((match-string 6 annotate-summary-query)
- (build-results 're 6))
- (t
- :no-more-tokens))
- :no-more-tokens)))
- (when (and (listp res)
- (not look-ahead-p))
- (cut-query res))
- res)))))
+ (let ((re (concat "\\((\\)\\|\\()\\)\\|\\(and\\)\\|\\(not\\)\\|"
+ "\\(or\\)\\|\\(\".*\"\\)\\|\\([^[:space:]]+\\)")))
+ (save-match-data
+ (let* ((matchedp (string-match re annotate-summary-query))
+ (res (if matchedp
+ (cond
+ ((match-string 1 annotate-summary-query)
+ (build-results 'open-par 1))
+ ((match-string 2 annotate-summary-query)
+ (build-results 'close-par 2))
+ ((match-string 3 annotate-summary-query)
+ (build-results 'and 3))
+ ((match-string 4 annotate-summary-query)
+ (build-results 'not 4))
+ ((match-string 5 annotate-summary-query)
+ (build-results 'or 5))
+ ((match-string 6 annotate-summary-query)
+ (build-results 'escaped-re 6))
+ ((match-string 7 annotate-summary-query)
+ (build-results 're 7))
+ (t
+ :no-more-tokens))
+ :no-more-tokens)))
+ (when (and (listp res)
+ (not look-ahead-p))
+ (cut-query res))
+ res)))))
(defun annotate-summary-query-parse-end-input-p (token)
"Non nil if there are no more tokens in
@@ -1553,19 +1561,27 @@ example:
(cl-defun annotate-summary-query-parse-note (filter-fn annotation &optional
(res nil))
"Parser rule for note:
-This function will parse the following production rule
+This function will parse the following production rules
NOTE := '(' NOTE ')'
- | NOTE OPERATOR NOTE
- | NOT NOTE
- | RE
- | epsilon
-
+ | NOTE OPERATOR NOTE
+ | NOT NOTE
+ | RE
+ | ESCAPED-RE
+ | epsilon
OPERATOR := AND | OR
-RE := a regular expression
+FILE-MASK := RE
+RE := [^[:space:]] ; as regular expression
+ESCAPED-RE := DELIMITER
+ ANYTHING
+ DELIMITER
+ANYTHING := .* ; as a regualar expression
AND := 'and'
OR := 'or'
NOT := 'not'
+DELIMITER := \" ; ASCII 34 (dec) 22 (hex)
+
+Arguments:
- filter-fn is a function that accept two parameters: the regular
expression to match (a token of type 're, see the lexer
@@ -1584,11 +1600,6 @@ NOT := 'not'
(cl-labels ((token-symbol-match-p (looking-symbol token)
(eq looking-symbol
(annotate-summary-query-lexer-symbol
token)))
- (unescape (escaped)
- (replace-regexp-in-string
-
"\\\\\\(\\(not\\)\\|\\(and\\)\\|\\(or\\)\\|\\((\\)\\|\\()\\)\\)"
- (lambda (a) (cl-subseq a 1))
- escaped))
;; this function will parse the rule operator
;; OPERATOR := AND | OR
;; where
@@ -1679,19 +1690,30 @@ NOT := 'not'
(if (eq :error rhs)
(error "No more input after 'or'")
(or lhs rhs)))) ; either lhs or rhs match as this is a
logic or
+ ((token-symbol-match-p 'escaped-re look-ahead)
+ ;; here we match the rule:
+ ;; NOTE := ESCAPED-RE
+ ;; ESCAPED-RE is a delimited string like "foo bar"
+ ;; we first unescape the protected token
+ ;; "\"foo bar\"" -> "foo bar" (yes, just remove the delimiters)
+ ;; then we apply the filter function (see the docstring)
+ (let* ((escaped (annotate-summary-query-lexer-string
(annotate-summary-lexer)))
+ (unescaped (substring escaped 1 (1- (length escaped)))) ;
remove delimiters
+ (matchp (funcall filter-fn unescaped annotation))) ;
apply the filter funcrion
+ ;; and finally continue the parsing saving the results
+ ;; of applying the filter-fn function
+ (operator escaped filter-fn annotation matchp)))
(t
;; here we match the rule:
;; NOTE := RE
;; RE := a regular expression
- ;; we first unescape the protected tokens
- ;; \not -> not, \( -> ( etc.
- ;; then we apply the filter function (see the docstring)
- (let* ((escaped (annotate-summary-query-lexer-string
(annotate-summary-lexer)))
- (unescaped (unescape escaped))
- (matchp (funcall filter-fn unescaped annotation)))
+ ;; first just get the RE token
+ (let* ((regex (annotate-summary-query-lexer-string
(annotate-summary-lexer)))
+ ;; then apply the filter function (see the docstring)
+ (matchp (funcall filter-fn regex annotation)))
;; and finally continue the parsing saving the results
;; of applying the filter-fn function
- (operator escaped filter-fn annotation matchp)))))
+ (operator regex filter-fn annotation matchp)))))
;; if we are here the lexer can not find any more tokens in the query
;; just return the value of res
res)))) ; end of (if (not (annotate-summary-query-parse-end-input-p
look-ahead))
@@ -1710,15 +1732,22 @@ NOTE := '(' NOTE ')'
| NOTE OPERATOR NOTE
| NOT NOTE
| RE
+ | ESCAPED-RE
| epsilon
OPERATOR := AND | OR
FILE-MASK := RE
-RE := a regular expression
+RE := [^[:space:]] ; as regular expression
+ESCAPED-RE := DELIMITER
+ ANYTHING
+ DELIMITER
+ANYTHING := .* ; as a regualar expression
AND := 'and'
OR := 'or'
NOT := 'not'
+DELIMITER := \" ; ASCII 34 (dec) 22 (hex)
-This function return the annotation of the record
+Note: this function return the annotation part of the record, see
+`annotate-load-annotations'.
"
(lambda (annotation query file-filter-fn note-filter-fn)
@@ -1808,7 +1837,7 @@ This function return the annotation of the record
The argument `query' is a string that respect a simple syntax:
-[file-mask] (and | or) [not] regex-note (and | or) [not] regexp-note ...
+- [file-mask] (and | or) [not] regex-note (and | or) [not] regexp-note ...
where
@@ -1836,8 +1865,8 @@ annotation, like this:
matches all the annotation that refers to file in the directory
`/home/foo' and that not contains the text `minor'.
-- .* and \not
- the backslash can be used to escape the operators
+- .* and \"not\"
+ the \" can be used to escape strings
"
(let* ((parser (annotate-summary-query-parse-expression))
(filter-file (lambda (file-mask annotation-dump)
- [nongnu] elpa/annotate d46d5afd34 122/372: - made two arguments of annotate-create-annotation non optional;, (continued)
- [nongnu] elpa/annotate d46d5afd34 122/372: - made two arguments of annotate-create-annotation non optional;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate b180248ddc 113/372: - fixed bug with multiline annotation, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 14ef3fb140 126/372: - fixed docstring., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate bae16321fc 117/372: - using a customizable variable for region where to look for annotated, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 7ff18171a6 112/372: - fixed typos., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 7ebddc73a0 144/372: - enabled filtering of annotation database when a summary window is shown., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 50ba1d719c 143/372: - used a better regex when checking if a file is in info format., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 50bc634f6b 140/372: - placed the cursor in the right place (on the annotated text) when an, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 1f9899071f 138/372: - made recongnizable code that refers to info file annotation. (3/3), ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 4629a0ad34 148/372: Merge pull request #51 from cage2/filter-summary-window-results, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 4372e9ea20 147/372: - changed escaping mechanism;,
ELPA Syncer <=
- [nongnu] elpa/annotate 6948bfe686 146/372: - minor fix in comments., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate b116d3125a 149/372: - added the chance to delete annotation and modify the annotated text, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 3e76557cf7 154/372: Merge pull request #53 from cage2/summary-win-delete-replace-annotation, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 9cc55145de 150/372: - shown, when editing annotation in summary window and asking user to, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate a370187f0b 151/372: - initial working on placing an annotation on its own line if too long., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 2292d5c6c8 160/372: - changed variable name from: 'text' to a more meaningful 'annotated text'., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 54d112e8d3 174/372: [bugfix] mitigated bug that prevented rendering of annotation when, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 91412e5d65 175/372: - removed multiple, consecutive, spaces in comments., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate ed6a7dd7cc 180/372: - prevented fails of fontification of annotated regions, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate e4a7750e8c 183/372: - prevented overlapping of annotations when a symbol is already, ELPA Syncer, 2022/02/04