[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 49/77: Work with `sexp' and `list' in nxml mode
From: |
Leo Liu |
Subject: |
[elpa] 49/77: Work with `sexp' and `list' in nxml mode |
Date: |
Sat, 05 Apr 2014 04:08:21 +0000 |
leoliu pushed a commit to branch master
in repository elpa.
commit c6519c0fad38cebe782df49508038d351d31e038
Author: Leo Liu <address@hidden>
Date: Mon Oct 14 16:16:29 2013 +0800
Work with `sexp' and `list' in nxml mode
---
easy-kill.el | 45 +++++++++++++++++++++++++++++++++++++--------
1 files changed, 37 insertions(+), 8 deletions(-)
diff --git a/easy-kill.el b/easy-kill.el
index d2338e3..37ee6c8 100644
--- a/easy-kill.el
+++ b/easy-kill.el
@@ -387,11 +387,13 @@ inspected."
(easy-kill-adjust-candidate 'url url)
(return url)))))))
+(defvar up-list-fn) ; Dynamically bound
+
(defun easy-kill-backward-up ()
(let ((ppss (syntax-ppss)))
(condition-case nil
(progn
- (up-list -1)
+ (funcall (or up-list-fn #'up-list) -1)
;; `up-list' may jump to another string.
(when (and (nth 3 ppss) (< (point) (nth 8 ppss)))
(goto-char (nth 8 ppss))))
@@ -417,17 +419,44 @@ inspected."
(_ (error "Unsupported argument `%s'" n)))
(bounds-of-thing-at-point 'sexp)))
-(defun easy-kill-on-list (n)
- (if (memq n '(+ -))
+(defvar nxml-sexp-element-flag)
+
+(defun easy-kill-on-nxml-element (n)
+ (let ((nxml-sexp-element-flag t)
+ (up-list-fn (when (derived-mode-p 'nxml-mode)
+ #'nxml-up-element)))
+ (cond
+ ((memq n '(+ -))
(let ((bounds (easy-kill-bounds-of-list n)))
(when bounds
- (easy-kill-adjust-candidate 'list (car bounds) (cdr bounds))))
- (easy-kill-thing 'list n nil t)))
+ (easy-kill-adjust-candidate 'list (car bounds) (cdr bounds)))))
+ ((eq 'list (overlay-get easy-kill-candidate 'thing))
+ (let ((new-end (save-excursion
+ (goto-char (overlay-end easy-kill-candidate))
+ (forward-sexp n)
+ (point))))
+ (when (and new-end (/= new-end (overlay-end easy-kill-candidate)))
+ (easy-kill-adjust-candidate 'list nil new-end))))
+ (t (save-excursion
+ (ignore-errors (easy-kill-backward-up))
+ (easy-kill-thing 'sexp n nil t)
+ (overlay-put easy-kill-candidate 'thing 'list))))))
+
+(defun easy-kill-on-list (n)
+ (cond
+ ((derived-mode-p 'nxml-mode)
+ (easy-kill-on-nxml-element n))
+ ((memq n '(+ -))
+ (let ((bounds (easy-kill-bounds-of-list n)))
+ (when bounds
+ (easy-kill-adjust-candidate 'list (car bounds) (cdr bounds)))))
+ (t (easy-kill-thing 'list n nil t))))
(defun easy-kill-on-sexp (n)
- (if (memq n '(+ -))
- (easy-kill-on-list n)
- (easy-kill-thing 'sexp n nil t)))
+ (let ((nxml-sexp-element-flag t))
+ (if (memq n '(+ -))
+ (easy-kill-on-list n)
+ (easy-kill-thing 'sexp n nil t))))
(provide 'easy-kill)
;;; easy-kill.el ends here
- [elpa] 38/77: Fix #3: Add command easy-mark for marking, (continued)
- [elpa] 38/77: Fix #3: Add command easy-mark for marking, Leo Liu, 2014/04/05
- [elpa] 39/77: Fix doc and buglets in last change, Leo Liu, 2014/04/05
- [elpa] 40/77: Some improvements based on comments in #3, Leo Liu, 2014/04/05
- [elpa] 42/77: Must reference the actual object in easy-kill-candidate, Leo Liu, 2014/04/05
- [elpa] 43/77: Add new command easy-mark-sexp, Leo Liu, 2014/04/05
- [elpa] 41/77: Tell easy-kill-append to deactivate-mark, Leo Liu, 2014/04/05
- [elpa] 44/77: Fix #7: Add new command easy-kill-abort for key C-g, Leo Liu, 2014/04/05
- [elpa] 45/77: Better origin indicator by easy-kill-indicate-origin, Leo Liu, 2014/04/05
- [elpa] 46/77: Teach easy-kill-abort to deactivate mark immediately, Leo Liu, 2014/04/05
- [elpa] 47/77: Doc fix and small tweaks, Leo Liu, 2014/04/05
- [elpa] 49/77: Work with `sexp' and `list' in nxml mode,
Leo Liu <=
- [elpa] 52/77: Use filter-buffer-substring, Leo Liu, 2014/04/05
- [elpa] 51/77: Fix quoting error in face definitions, Leo Liu, 2014/04/05
- [elpa] 50/77: Fix last change to easy-kill-backward-up, Leo Liu, 2014/04/05
- [elpa] 55/77: Fix easy-kill-backward-down to handle prefix chars, Leo Liu, 2014/04/05
- [elpa] 48/77: Make command easy-kill-append work for easy-mark, Leo Liu, 2014/04/05
- [elpa] 57/77: Fix to always display the string candidate, Leo Liu, 2014/04/05
- [elpa] 58/77: Emacs 24.x compatibility, Leo Liu, 2014/04/05
- [elpa] 53/77: Destroy after-string before goto-char in easy-kill-abort, Leo Liu, 2014/04/05
- [elpa] 54/77: Better control of message emission in an easy-kill session, Leo Liu, 2014/04/05
- [elpa] 63/77: Teach easy-kill-activate-keymap to handle command remapping, Leo Liu, 2014/04/05