[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 25da7c6 6/7: Improve `change' and `changed'

From: Michael Heerdegen
Subject: [elpa] master 25da7c6 6/7: Improve `change' and `changed'
Date: Thu, 11 Aug 2016 05:21:38 +0000 (UTC)

branch: master
commit 25da7c618e4da930d616a165b8a0e2b31c915204
Author: Michael Heerdegen <address@hidden>
Commit: Michael Heerdegen <address@hidden>

    Improve `change' and `changed'
    - Renew cache when saved file version has changed.
    - Use markers as region boundaries so that replacing inside changed
    expressions works.
 packages/el-search/el-search-x.el |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/packages/el-search/el-search-x.el 
index 8b8c10b..7c050cf 100644
--- a/packages/el-search/el-search-x.el
+++ b/packages/el-search/el-search-x.el
@@ -47,8 +47,10 @@
 Use variable `el-search--cached-changes' for caching."
   (if (and (consp el-search--cached-changes)
            (equal (car el-search--cached-changes)
-                  revision))
+                  (list revision (visited-file-modtime))))
       (cdr el-search--cached-changes)
+    (when (buffer-modified-p)
+      (error "Buffer is modified - please save"))
     (require 'diff-hl)
     ;; `diff-hl-changes' returns line numbers.  We must convert them into 
@@ -58,20 +60,19 @@ Use variable `el-search--cached-changes' for caching."
               (current-line-nbr 1) change-beg)
           (goto-char 1)
           (cdr (setq el-search--cached-changes
-                     (cons revision
+                     (cons (list revision (visited-file-modtime))
                            (delq nil (mapcar (pcase-lambda (`(,start-line 
,nbr-lines ,kind))
                                                (if (eq kind 'delete) nil
                                                  (forward-line (- start-line 
                                                  (setq change-beg (point))
                                                  (forward-line (1- nbr-lines))
                                                  (setq current-line-nbr (+ 
start-line nbr-lines -1))
-                                                 (cons change-beg 
+                                                 (cons (copy-marker change-beg)
+                                                       (copy-marker 
 (defun el-search--change-p (posn &optional revision)
   ;; Non-nil when sexp after POSN is part of a change
-  (when (buffer-modified-p)
-    (error "Buffer is modified - please save"))
     (let ((changes (el-search--changes-from-diff-hl revision))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]