Update app/regex + TODO
This commit is contained in:
parent
e071545d36
commit
84a73b3d38
4 changed files with 55 additions and 13 deletions
14
modules/app/regex/autoload/export.el
Normal file
14
modules/app/regex/autoload/export.el
Normal file
|
@ -0,0 +1,14 @@
|
|||
;;; app/regex/autoload/export.el
|
||||
|
||||
;;;###autoload
|
||||
(defun +regex/export () (interactive)) ; TODO +regex/export
|
||||
|
||||
|
||||
;;
|
||||
(defun +regex-export-python ()) ; import (re|regex)
|
||||
|
||||
(defun +regex-export-php ()) ; preg_(match(_all)?|replace)
|
||||
|
||||
(defun +regex-export-ruby ()) ; %r[.+]
|
||||
|
||||
(defun +regex-export-js ()) ; /.+/
|
|
@ -1,4 +1,4 @@
|
|||
;;; app/regex/autoload.el
|
||||
;;; app/regex/autoload/regex.el
|
||||
|
||||
(defvar +regex--text-buffer nil)
|
||||
(defvar +regex--expr-buffer nil)
|
||||
|
@ -7,17 +7,17 @@
|
|||
;;
|
||||
(defface +regex-match-0-face
|
||||
'((t (:foreground "Black" :background "Red" :bold t)))
|
||||
""
|
||||
"TODO"
|
||||
:group 'doom)
|
||||
|
||||
(defface +regex-match-1-face
|
||||
'((t (:foreground "Black" :background "Blue" :bold t)))
|
||||
""
|
||||
"TODO"
|
||||
:group 'doom)
|
||||
|
||||
(defface +regex-match-2-face
|
||||
'((t (:foreground "Black" :background "Green" :bold t)))
|
||||
""
|
||||
"TODO"
|
||||
:group 'doom)
|
||||
|
||||
(defvar +regex-faces
|
||||
|
@ -33,6 +33,7 @@
|
|||
map)
|
||||
"TODO")
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode +regex-mode
|
||||
"TODO"
|
||||
:init-value nil
|
||||
|
@ -98,15 +99,16 @@
|
|||
(ignore-errors
|
||||
(goto-char (point-min))
|
||||
(pcase +regex-default-backend
|
||||
('emacs (+regex-backend-emacs regex))
|
||||
('perl (+regex-backend-perl regex))))))
|
||||
('emacs (+regex-backend-emacs regex))
|
||||
('perl (+regex-backend-generic (+regex-backend-perl regex)))
|
||||
('python (+regex-backend-generic (+regex-backend-python regex)))))))
|
||||
(with-current-buffer +regex--groups-buffer
|
||||
(goto-char (point-min))))))
|
||||
|
||||
|
||||
;; --- backends ---------------------------
|
||||
|
||||
(defun +regex--render-perl (regex sample)
|
||||
(defun +regex--backend-perl (regex sample)
|
||||
"From <https://github.com/jwiegley/regex-tool>"
|
||||
(with-temp-buffer
|
||||
(unless (string-match-p "^/.+/[gm]*$" regex)
|
|
@ -1,14 +1,28 @@
|
|||
;;; app/regex/config.el
|
||||
|
||||
;; Provides a Regex IDE, invoked by `=regex'. If opened with C-u, opens in a
|
||||
;; separate frame with a dummy text buffer.
|
||||
;; Often, I find myself writing regular expressions that could terrify seasoned
|
||||
;; programmers (or little children). To hone my regex fu, I need a regex
|
||||
;; playground. Sure, there's regexr.com, but don't be silly, that's not Emacs.
|
||||
;;
|
||||
;; Sadly, the Emacs' regex syntax is niche and lacks support for a few
|
||||
;; questionably useful features, like lookaround assertions, conditionals, case
|
||||
;; modifiers or backreferences, among others. No, I want PCRE. I am going to
|
||||
;; have my cake and eat it too, damn it!
|
||||
;;
|
||||
;; Workflow:
|
||||
;; + Invoke `=regex' (if opened with C-u, opens in separate workspace with a
|
||||
;; dummy text buffer).
|
||||
;; + A regex window will popup up. Any matches will be highlighted in the
|
||||
;; original buffer.
|
||||
;; + C-c C-k to close it
|
||||
;; + TODO C-c C-e to export to various langauges
|
||||
;;
|
||||
;; WARNING: THIS IS A WORK IN PROGRESS
|
||||
|
||||
(defvar +regex-workspace-name "*regex*"
|
||||
"TODO")
|
||||
|
||||
(defvar +regex-default-backend 'emacs
|
||||
(defvar +regex-default-backend 'perl
|
||||
"The backend used to process regular expressions.
|
||||
The `emacs' backend handles regular expressions directly.
|
||||
The `perl' backend talks to a perl subprocess to do the handling.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue