Skip to content

Commit aba273d

Browse files
committed
Commit some minor fixes in emit and capture
There are still issues but they will likely require more thought and a deeper refactoring.
1 parent 1fa409f commit aba273d

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

symex-primitives-lisp.el

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@
170170
(defvar symex--re-whitespace "[[:space:]|\n]+"
171171
"Whitespace that may extend over many lines.")
172172

173+
(defvar symex--re-optional-whitespace "[[:space:]|\n]*"
174+
"Optional whitespace that may extend over many lines.")
175+
173176
(defvar symex--re-symex-line "^[[:space:]]*[^;[:space:]\n]"
174177
"A line that isn't blank and isn't a comment line.")
175178

@@ -247,7 +250,7 @@
247250
"Check if we're looking at an empty list."
248251
(looking-at-p
249252
(concat symex--re-left
250-
symex--re-whitespace
253+
symex--re-optional-whitespace
251254
symex--re-right)))
252255

253256
(defun symex-empty-string-p ()
@@ -260,10 +263,10 @@
260263
(defun symex-inside-empty-form-p ()
261264
"Check if point is inside an empty form."
262265
(and (looking-back (concat symex--re-left
263-
symex--re-whitespace)
266+
symex--re-optional-whitespace)
264267
(line-beginning-position))
265268
(looking-at-p
266-
(concat symex--re-whitespace
269+
(concat symex--re-optional-whitespace
267270
symex--re-right))))
268271

269272
(defun symex--racket-syntax-object-p ()

symex-transformations-lisp.el

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,18 @@ text, on the respective side."
179179
((and before
180180
(string-match-p (concat symex--re-whitespace "$")
181181
(symex--current-kill)))
182+
;; if the text to be pasted before includes whitespace already,
183+
;; then don't add more
182184
"")
183185
(t " ")))))
184186

185187
(defun symex-lisp--paste-before ()
186188
"Paste before symex."
187189
(interactive)
190+
(when (symex-inside-empty-form-p)
191+
(symex--kill-ring-push
192+
(string-trim-right
193+
(symex--kill-ring-pop))))
188194
(symex-lisp--paste ""
189195
(symex-lisp--padding t)))
190196

@@ -217,10 +223,10 @@ If a symex is currently selected, then paste after the end of the
217223
selected expression. Otherwise, paste in place."
218224
(interactive)
219225
(let ((padding (symex-lisp--padding nil)))
220-
(if (symex-lisp--point-at-last-symex-p)
221-
(symex--kill-ring-push
222-
(string-trim-right
223-
(symex--kill-ring-pop))))
226+
(when (symex-lisp--point-at-last-symex-p)
227+
(symex--kill-ring-push
228+
(string-trim-right
229+
(symex--kill-ring-pop))))
224230
(save-excursion
225231
(condition-case nil
226232
(forward-sexp)

0 commit comments

Comments
 (0)