[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/mheerdegen-preview df2132a 21/35: WIP: Improvements for c
From: |
Michael Heerdegen |
Subject: |
[elpa] scratch/mheerdegen-preview df2132a 21/35: WIP: Improvements for change and changed |
Date: |
Mon, 29 Oct 2018 22:24:07 -0400 (EDT) |
branch: scratch/mheerdegen-preview
commit df2132a0c2a4c6979de90102e48d2f45566fbcd0
Author: Michael Heerdegen <address@hidden>
Commit: Michael Heerdegen <address@hidden>
WIP: Improvements for change and changed
squash! WIP: change, changed: only user-error in interactive case
---
packages/el-search/el-search-x.el | 72 ++++++++++++++++++++++-----------------
1 file changed, 41 insertions(+), 31 deletions(-)
diff --git a/packages/el-search/el-search-x.el
b/packages/el-search/el-search-x.el
index 30190c1..1a40322 100644
--- a/packages/el-search/el-search-x.el
+++ b/packages/el-search/el-search-x.el
@@ -307,37 +307,41 @@ Uses variable `el-search--cached-changes' for caching."
(defun el-search--change-p (posn revision)
;; Non-nil when sexp after POSN is part of a change
- (when (buffer-modified-p)
- (user-error "Buffer is modified - please save"))
- (save-restriction
- (widen)
- (let ((changes (el-search--changes-from-diff-hl revision))
- (sexp-end (el-search--end-of-sexp posn))
- (atomic? (thunk-delay (el-search--atomic-p
- (save-excursion (goto-char posn)
- (el-search-read
(current-buffer)))))))
- (while (and changes (or (< (cdar changes) posn)
- (and
- ;; a string spanning multiple lines is a change
even when not all
- ;; lines are changed
- (< (cdar changes) sexp-end)
- (not (thunk-force atomic?)))))
- (pop changes))
- (and changes (or (<= (caar changes) posn)
- (and (thunk-force atomic?)
- (<= (caar changes) sexp-end)))))))
+ (if (buffer-modified-p)
+ (if (eq this-command 'el-search-pattern)
+ (user-error "Buffer is modified - please save")
+ nil)
+ (save-restriction
+ (widen)
+ (let ((changes (el-search--changes-from-diff-hl revision))
+ (sexp-end (el-search--end-of-sexp posn))
+ (atomic? (thunk-delay (el-search--atomic-p
+ (save-excursion (goto-char posn)
+ (el-search-read
(current-buffer)))))))
+ (while (and changes (or (< (cdar changes) posn)
+ (and
+ ;; a string spanning multiple lines is a
change even when not all
+ ;; lines are changed
+ (< (cdar changes) sexp-end)
+ (not (thunk-force atomic?)))))
+ (pop changes))
+ (and changes (or (<= (caar changes) posn)
+ (and (thunk-force atomic?)
+ (<= (caar changes) sexp-end))))))))
(defun el-search--changed-p (posn revision)
;; Non-nil when sexp after POSN contains a change
- (when (buffer-modified-p)
- (user-error "Buffer is modified - please save"))
- (save-restriction
- (widen)
- (let ((changes (el-search--changes-from-diff-hl revision)))
- (while (and changes (<= (cdar changes) posn))
- (pop changes))
- (and changes
- (< (caar changes) (el-search--end-of-sexp posn))))))
+ (if (buffer-modified-p)
+ (if (eq this-command 'el-search-pattern)
+ (user-error "Buffer is modified - please save")
+ nil)
+ (save-restriction
+ (widen)
+ (let ((changes (el-search--changes-from-diff-hl revision)))
+ (while (and changes (<= (cdar changes) posn))
+ (pop changes))
+ (and changes
+ (< (caar changes) (el-search--end-of-sexp posn)))))))
(defun el-search-change--heuristic-matcher (&optional revision)
(let* ((revision (or revision "HEAD"))
@@ -369,6 +373,10 @@ Uses variable `el-search--cached-changes' for caching."
revision file))))))))))
(lambda (file-name-or-buffer _) (funcall file-changed-p
file-name-or-buffer))))
+(el-search-defpattern change--1 (&optional revision)
+ (declare (heuristic-matcher #'el-search-change--heuristic-matcher))
+ `(guard (el-search--change-p (point) ,(or revision "HEAD"))))
+
(el-search-defpattern change (&optional revision)
"Matches the object if its text is part of a file change.
@@ -379,8 +387,11 @@ REVISION is interpreted.
This pattern-type does currently only work for git versioned
files."
+ `(and (filename) (change--1 ,revision)))
+
+(el-search-defpattern changed--1 (&optional revision)
(declare (heuristic-matcher #'el-search-change--heuristic-matcher))
- `(guard (el-search--change-p (point) ,(or revision "HEAD"))))
+ `(guard (el-search--changed-p (point) ,(or revision "HEAD"))))
(el-search-defpattern changed (&optional revision)
"Matches the object if its text contains a file change.
@@ -392,8 +403,7 @@ REVISION is interpreted.
This pattern-type does currently only work for git versioned
files."
- (declare (heuristic-matcher #'el-search-change--heuristic-matcher))
- `(guard (el-search--changed-p (point) ,(or revision "HEAD"))))
+ `(and (filename) (changed--1 ,revision)))
;;;; `outermost' and `top-level'
- [elpa] scratch/mheerdegen-preview f2ec15d 13/35: WIP [el-search] Fix more "redundant _ pattern" cases, (continued)
- [elpa] scratch/mheerdegen-preview f2ec15d 13/35: WIP [el-search] Fix more "redundant _ pattern" cases, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview f025458 12/35: WIP [el-search] Add quick help command, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview f23fe5e 17/35: WIP: Optimize caching, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview b4b94b0 11/35: WIP [el-search] Implement 'el-search-keyboard-quit', Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview 44715aa 05/35: WIP: New package "gnus-article-notes", Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview 5057b57 14/35: WIP [el-search] Discourage using symbols as LPATS in `append' and `l', Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview 5e2aea1 20/35: WIP [el-search] Adjust prev/next match commands for search and occur, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview 38def8b 25/35: WIP: Test: Make mouse clicks not abort the search, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview feede7d 23/35: WIP: [el-search] Fine tune separator for splicing replace, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview 82abecf 16/35: WIP: Additions to "Mb hints", Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview df2132a 21/35: WIP: Improvements for change and changed,
Michael Heerdegen <=
- [elpa] scratch/mheerdegen-preview 2ec7a9e 22/35: WIP: More colorful match count, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview 91f5bd3 18/35: WIP [el-search] Fix C-j with numeric arg in error case, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview 237c2c6 33/35: WIP: [el-search] Enhance doc of el-search-occur-mode, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview 99782c3 19/35: WIP [el-search] Fix search setup when occur flag bound, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview acc2594 24/35: WIP: Improvise eldoc support for search pattern prompt, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview f1dde5c 28/35: WIP: Include leading comments in occur defun context, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview e557155 31/35: WIP: Small fix in 'el-search--reset-wrap-flag', Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview 1f85214 32/35: WIP: Small fix in el-search--changed-files-in-repo, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview 869266f 15/35: WIP [el-search] Minibuffer hints when entering pattern, Fix case when search pattern fails for some sexps, Michael Heerdegen, 2018/10/29
- [elpa] scratch/mheerdegen-preview 7c82465 30/35: WIP: Fix C-A and C-J after finished single-buffer search, Michael Heerdegen, 2018/10/29