Skip to content

Commit

Permalink
Commit some minor fixes in emit and capture
Browse files Browse the repository at this point in the history
There are still issues but they will likely require more thought and a
deeper refactoring.
  • Loading branch information
countvajhula committed Sep 18, 2024
1 parent 418169f commit a6578b5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
9 changes: 6 additions & 3 deletions symex-primitives-lisp.el
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@
(defvar symex--re-whitespace "[[:space:]|\n]+"
"Whitespace that may extend over many lines.")

(defvar symex--re-optional-whitespace "[[:space:]|\n]*"
"Optional whitespace that may extend over many lines.")

(defvar symex--re-symex-line "^[[:space:]]*[^;[:space:]\n]"
"A line that isn't blank and isn't a comment line.")

Expand Down Expand Up @@ -247,7 +250,7 @@
"Check if we're looking at an empty list."
(looking-at-p
(concat symex--re-left
symex--re-whitespace
symex--re-optional-whitespace
symex--re-right)))

(defun symex-empty-string-p ()
Expand All @@ -260,10 +263,10 @@
(defun symex-inside-empty-form-p ()
"Check if point is inside an empty form."
(and (looking-back (concat symex--re-left
symex--re-whitespace)
symex--re-optional-whitespace)
(line-beginning-position))
(looking-at-p
(concat symex--re-whitespace
(concat symex--re-optional-whitespace
symex--re-right))))

(defun symex--racket-syntax-object-p ()
Expand Down
14 changes: 10 additions & 4 deletions symex-transformations-lisp.el
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,18 @@ text, on the respective side."
((and before
(string-match-p (concat symex--re-whitespace "$")
(symex--current-kill)))
;; if the text to be pasted before includes whitespace already,
;; then don't add more
"")
(t " ")))))

(defun symex-lisp--paste-before ()
"Paste before symex."
(interactive)
(when (symex-inside-empty-form-p)
(symex--kill-ring-push
(string-trim-right
(symex--kill-ring-pop))))
(symex-lisp--paste ""
(symex-lisp--padding t)))

Expand Down Expand Up @@ -217,10 +223,10 @@ If a symex is currently selected, then paste after the end of the
selected expression. Otherwise, paste in place."
(interactive)
(let ((padding (symex-lisp--padding nil)))
(if (symex-lisp--point-at-last-symex-p)
(symex--kill-ring-push
(string-trim-right
(symex--kill-ring-pop))))
(when (symex-lisp--point-at-last-symex-p)
(symex--kill-ring-push
(string-trim-right
(symex--kill-ring-pop))))
(save-excursion
(condition-case nil
(forward-sexp)
Expand Down

0 comments on commit a6578b5

Please sign in to comment.