-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaph-smartparens.el
executable file
·57 lines (43 loc) · 2.06 KB
/
aph-smartparens.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
;;; aph-page.el --- Extensions for `smartparens' -*- lexical-binding: t; -*-
;; Copyright (C) 2016 Aaron Harris
;; Author: Aaron Harris <[email protected]>
;; Keywords: convenience editing
;; Dependencies: `smartparens'
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Extensions for `smartparens'.
;;; Code:
(require 'smartparens)
;;;###autoload
(defun aph/sp-kill-sentence (&optional arg)
"As `kill-sentence', but don't kill past end of current context.
In a string or comment, kill either to the end of sentence (as
`kill-sentence') or to the end of the string or comment,
whichever is nearer. Do not kill a closing string or comment
delimiter. Treat ARG in the same way as `kill-sentence'.
Outside of strings and comments, this should generally behave as
`kill-sentence', but no guarantees are made."
(interactive "p")
(let* ((arg (or arg 1))
(context (sp--get-context))
(compare (if (< arg 0) #'> #'<))
(end-of-sentence (save-excursion (forward-sentence arg))))
(kill-region (point)
(progn
(while (and (funcall compare (point) end-of-sentence)
(eq (sp--get-context) context))
(forward-char (sp--signum arg)))
(unless (eq (sp--get-context) context)
(backward-char (sp--signum arg)))
(point)))))
(provide 'aph-smartparens)
;;; aph-smartparens.el ends here