Skip to content

Commit

Permalink
Merge pull request #1167 from ROCKTAKEY/add-delete-sexp
Browse files Browse the repository at this point in the history
Add commands named `sp-(backward-)?delete-sexp`
  • Loading branch information
Fuco1 authored Oct 20, 2023
2 parents ba7818a + 4485293 commit 3afd9af
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions smartparens.el
Original file line number Diff line number Diff line change
Expand Up @@ -6619,6 +6619,23 @@ Note: prefix argument is shown after the example in
(when (= 0 sp-successive-kill-preserve-whitespace)
(kill-append sp-last-kill-whitespace nil)))))))))

(defun sp-delete-sexp (&optional arg)
"Delete the balanced expression following point.

This is exactly like calling `sp-kill-sexp'
except deleted sexp does not go to the clipboard or kill ring.

With ARG being positive number N, repeat that many times.

With ARG being Negative number -N, repeat that many times in
backward direction.

See also `sp-kill-sexp' examples."
(interactive "*p")
(let* ((kill-ring nil)
(select-enable-clipboard nil))
(sp-kill-sexp arg)))

(defun sp--cleanup-after-kill ()
(unless (save-match-data (looking-back "^[\t\s]+" (1- (line-beginning-position))))
(let ((bdel (save-excursion
Expand Down Expand Up @@ -6673,6 +6690,23 @@ Examples:
(interactive "*P")
(sp-kill-sexp (sp--negate-argument arg) dont-kill))

(defun sp-backward-delete-sexp (&optional arg)
"Delete the balanced expression preceding point.

This is exactly like calling `sp-backword-kill-sexp'
except deleted sexp does not go to the clipboard or kill ring.

With ARG being positive number N, repeat that many times.

With ARG being Negative number -N, repeat that many times in
forward direction.

See also `sp-backward-kill-sexp' examples."
(interactive "*p")
(let* ((kill-ring nil)
(select-enable-clipboard nil))
(sp-backward-kill-sexp arg)))

(defun sp-copy-sexp (&optional arg)
"Copy the following ARG expressions to the kill-ring.

Expand Down

0 comments on commit 3afd9af

Please sign in to comment.