Add gist for using xr
This commit is contained in:
parent
11d536f407
commit
3556a128ec
132
gists.org
132
gists.org
|
@ -170,6 +170,138 @@ My vertico-repeat setup.
|
||||||
(crux-with-region-or-line comment-or-uncomment-region))
|
(crux-with-region-or-line comment-or-uncomment-region))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
* Use xr for more readable regular expressions :emacs:
|
||||||
|
|
||||||
|
#+begin_src org :tangle gists/xr-for-readable-regular-expressions.org
|
||||||
|
If you look for the value of =org-link-any-re=, you'll see this beauty:
|
||||||
|
|
||||||
|
,#+begin_example
|
||||||
|
"\\(\\[\\[\\(\\(?:[^][\\]\\|\\\\\\(?:\\\\\\\\\\)*[][]\\|\\\\+[^][]\\)+\\)]\\(?:\\[\\([^z-a]+?\\)]\\)?]\\)\\|\\(<\\(bibtex\\|elisp\\|f\\(?:ile\\(?:\\+\\(?:\\(?:emac\\|sy\\)s\\)\\)?\\|tp\\)\\|h\\(?:elp\\|ttps?\\)\\|id\\|mai\\(?:lto\\|rix\\)\\|news\\|org-ql-search\\|shell\\):\\([^>
|
||||||
|
]*\\(?:
|
||||||
|
[ ]*[^>
|
||||||
|
][^>
|
||||||
|
]*\\)*\\)>\\)\\|\\(\\(?:\\<\\(?:\\(bibtex\\|elisp\\|f\\(?:ile\\(?:\\+\\(?:\\(?:emac\\|sy\\)s\\)\\)?\\|tp\\)\\|h\\(?:elp\\|ttps?\\)\\|id\\|mai\\(?:lto\\|rix\\)\\|news\\|org-ql-search\\|shell\\)\\):\\(\\(?:[^][
|
||||||
|
()<>]\\|(\\(?:[^][
|
||||||
|
()<>]\\|([^][
|
||||||
|
()<>]*)\\)*)\\)+\\(?:[^[:punct:]
|
||||||
|
]\\|/\\|(\\(?:[^][
|
||||||
|
()<>]\\|([^][
|
||||||
|
()<>]*)\\)*)\\)\\)\\)\\)"
|
||||||
|
,#+end_example
|
||||||
|
|
||||||
|
[[https://github.com/mattiase/xr][xr]] to the rescue:
|
||||||
|
|
||||||
|
,#+begin_src elisp
|
||||||
|
(pp-to-string (xr org-link-any-re))
|
||||||
|
,#+end_src
|
||||||
|
|
||||||
|
,#+RESULTS:
|
||||||
|
,#+begin_example
|
||||||
|
(or
|
||||||
|
(group "[["
|
||||||
|
(group
|
||||||
|
(one-or-more
|
||||||
|
(or
|
||||||
|
(not
|
||||||
|
(any "[\\]"))
|
||||||
|
(seq "\\"
|
||||||
|
(zero-or-more "\\\\")
|
||||||
|
(any "[]"))
|
||||||
|
(seq
|
||||||
|
(one-or-more "\\")
|
||||||
|
(not
|
||||||
|
(any "[]"))))))
|
||||||
|
"]"
|
||||||
|
(opt "["
|
||||||
|
(group
|
||||||
|
(+\? anything))
|
||||||
|
"]")
|
||||||
|
"]")
|
||||||
|
(group "<"
|
||||||
|
(group
|
||||||
|
(or "bibtex" "elisp"
|
||||||
|
(seq "f"
|
||||||
|
(or
|
||||||
|
(seq "ile"
|
||||||
|
(opt "+"
|
||||||
|
(or "emac" "sy")
|
||||||
|
"s"))
|
||||||
|
"tp"))
|
||||||
|
(seq "h"
|
||||||
|
(or "elp"
|
||||||
|
(seq "ttp"
|
||||||
|
(opt "s"))))
|
||||||
|
"id"
|
||||||
|
(seq "mai"
|
||||||
|
(or "lto" "rix"))
|
||||||
|
"news" "org-ql-search" "shell"))
|
||||||
|
":"
|
||||||
|
(group
|
||||||
|
(zero-or-more
|
||||||
|
(not
|
||||||
|
(any "\n>")))
|
||||||
|
(zero-or-more "\n"
|
||||||
|
(zero-or-more
|
||||||
|
(any " "))
|
||||||
|
(not
|
||||||
|
(any " \n >"))
|
||||||
|
(zero-or-more
|
||||||
|
(not
|
||||||
|
(any "\n>")))))
|
||||||
|
">")
|
||||||
|
(group bow
|
||||||
|
(group
|
||||||
|
(or "bibtex" "elisp"
|
||||||
|
(seq "f"
|
||||||
|
(or
|
||||||
|
(seq "ile"
|
||||||
|
(opt "+"
|
||||||
|
(or "emac" "sy")
|
||||||
|
"s"))
|
||||||
|
"tp"))
|
||||||
|
(seq "h"
|
||||||
|
(or "elp"
|
||||||
|
(seq "ttp"
|
||||||
|
(opt "s"))))
|
||||||
|
"id"
|
||||||
|
(seq "mai"
|
||||||
|
(or "lto" "rix"))
|
||||||
|
"news" "org-ql-search" "shell"))
|
||||||
|
":"
|
||||||
|
(group
|
||||||
|
(one-or-more
|
||||||
|
(or
|
||||||
|
(not
|
||||||
|
(any " \n ()<>[]"))
|
||||||
|
(seq "("
|
||||||
|
(zero-or-more
|
||||||
|
(or
|
||||||
|
(not
|
||||||
|
(any " \n ()<>[]"))
|
||||||
|
(seq "("
|
||||||
|
(zero-or-more
|
||||||
|
(not
|
||||||
|
(any " \n ()<>[]")))
|
||||||
|
")")))
|
||||||
|
")")))
|
||||||
|
(or
|
||||||
|
(not
|
||||||
|
(any " \n " punct))
|
||||||
|
"/"
|
||||||
|
(seq "("
|
||||||
|
(zero-or-more
|
||||||
|
(or
|
||||||
|
(not
|
||||||
|
(any " \n ()<>[]"))
|
||||||
|
(seq "("
|
||||||
|
(zero-or-more
|
||||||
|
(not
|
||||||
|
(any " \n ()<>[]")))
|
||||||
|
")")))
|
||||||
|
")")))))
|
||||||
|
,#+end_example
|
||||||
|
#+end_src
|
||||||
|
|
||||||
* Meta
|
* Meta
|
||||||
** License
|
** License
|
||||||
|
|
||||||
|
|
127
gists/xr-for-readable-regular-expressions.org
Normal file
127
gists/xr-for-readable-regular-expressions.org
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
If you look for the value of =org-link-any-re=, you'll see this beauty:
|
||||||
|
|
||||||
|
#+begin_example
|
||||||
|
"\\(\\[\\[\\(\\(?:[^][\\]\\|\\\\\\(?:\\\\\\\\\\)*[][]\\|\\\\+[^][]\\)+\\)]\\(?:\\[\\([^z-a]+?\\)]\\)?]\\)\\|\\(<\\(bibtex\\|elisp\\|f\\(?:ile\\(?:\\+\\(?:\\(?:emac\\|sy\\)s\\)\\)?\\|tp\\)\\|h\\(?:elp\\|ttps?\\)\\|id\\|mai\\(?:lto\\|rix\\)\\|news\\|org-ql-search\\|shell\\):\\([^>
|
||||||
|
]*\\(?:
|
||||||
|
[ ]*[^>
|
||||||
|
][^>
|
||||||
|
]*\\)*\\)>\\)\\|\\(\\(?:\\<\\(?:\\(bibtex\\|elisp\\|f\\(?:ile\\(?:\\+\\(?:\\(?:emac\\|sy\\)s\\)\\)?\\|tp\\)\\|h\\(?:elp\\|ttps?\\)\\|id\\|mai\\(?:lto\\|rix\\)\\|news\\|org-ql-search\\|shell\\)\\):\\(\\(?:[^][
|
||||||
|
()<>]\\|(\\(?:[^][
|
||||||
|
()<>]\\|([^][
|
||||||
|
()<>]*)\\)*)\\)+\\(?:[^[:punct:]
|
||||||
|
]\\|/\\|(\\(?:[^][
|
||||||
|
()<>]\\|([^][
|
||||||
|
()<>]*)\\)*)\\)\\)\\)\\)"
|
||||||
|
#+end_example
|
||||||
|
|
||||||
|
[[https://github.com/mattiase/xr][xr]] to the rescue:
|
||||||
|
|
||||||
|
#+begin_src elisp
|
||||||
|
(pp-to-string (xr org-link-any-re))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+RESULTS:
|
||||||
|
#+begin_example
|
||||||
|
(or
|
||||||
|
(group "[["
|
||||||
|
(group
|
||||||
|
(one-or-more
|
||||||
|
(or
|
||||||
|
(not
|
||||||
|
(any "[\\]"))
|
||||||
|
(seq "\\"
|
||||||
|
(zero-or-more "\\\\")
|
||||||
|
(any "[]"))
|
||||||
|
(seq
|
||||||
|
(one-or-more "\\")
|
||||||
|
(not
|
||||||
|
(any "[]"))))))
|
||||||
|
"]"
|
||||||
|
(opt "["
|
||||||
|
(group
|
||||||
|
(+\? anything))
|
||||||
|
"]")
|
||||||
|
"]")
|
||||||
|
(group "<"
|
||||||
|
(group
|
||||||
|
(or "bibtex" "elisp"
|
||||||
|
(seq "f"
|
||||||
|
(or
|
||||||
|
(seq "ile"
|
||||||
|
(opt "+"
|
||||||
|
(or "emac" "sy")
|
||||||
|
"s"))
|
||||||
|
"tp"))
|
||||||
|
(seq "h"
|
||||||
|
(or "elp"
|
||||||
|
(seq "ttp"
|
||||||
|
(opt "s"))))
|
||||||
|
"id"
|
||||||
|
(seq "mai"
|
||||||
|
(or "lto" "rix"))
|
||||||
|
"news" "org-ql-search" "shell"))
|
||||||
|
":"
|
||||||
|
(group
|
||||||
|
(zero-or-more
|
||||||
|
(not
|
||||||
|
(any "\n>")))
|
||||||
|
(zero-or-more "\n"
|
||||||
|
(zero-or-more
|
||||||
|
(any " "))
|
||||||
|
(not
|
||||||
|
(any " \n >"))
|
||||||
|
(zero-or-more
|
||||||
|
(not
|
||||||
|
(any "\n>")))))
|
||||||
|
">")
|
||||||
|
(group bow
|
||||||
|
(group
|
||||||
|
(or "bibtex" "elisp"
|
||||||
|
(seq "f"
|
||||||
|
(or
|
||||||
|
(seq "ile"
|
||||||
|
(opt "+"
|
||||||
|
(or "emac" "sy")
|
||||||
|
"s"))
|
||||||
|
"tp"))
|
||||||
|
(seq "h"
|
||||||
|
(or "elp"
|
||||||
|
(seq "ttp"
|
||||||
|
(opt "s"))))
|
||||||
|
"id"
|
||||||
|
(seq "mai"
|
||||||
|
(or "lto" "rix"))
|
||||||
|
"news" "org-ql-search" "shell"))
|
||||||
|
":"
|
||||||
|
(group
|
||||||
|
(one-or-more
|
||||||
|
(or
|
||||||
|
(not
|
||||||
|
(any " \n ()<>[]"))
|
||||||
|
(seq "("
|
||||||
|
(zero-or-more
|
||||||
|
(or
|
||||||
|
(not
|
||||||
|
(any " \n ()<>[]"))
|
||||||
|
(seq "("
|
||||||
|
(zero-or-more
|
||||||
|
(not
|
||||||
|
(any " \n ()<>[]")))
|
||||||
|
")")))
|
||||||
|
")")))
|
||||||
|
(or
|
||||||
|
(not
|
||||||
|
(any " \n " punct))
|
||||||
|
"/"
|
||||||
|
(seq "("
|
||||||
|
(zero-or-more
|
||||||
|
(or
|
||||||
|
(not
|
||||||
|
(any " \n ()<>[]"))
|
||||||
|
(seq "("
|
||||||
|
(zero-or-more
|
||||||
|
(not
|
||||||
|
(any " \n ()<>[]")))
|
||||||
|
")")))
|
||||||
|
")")))))
|
||||||
|
#+end_example
|
Loading…
Reference in a new issue