mirror of
https://github.com/m00natic/vlfi.git
synced 2025-01-18 20:10:47 +00:00
Check for unsaved changes before search query and don't enable undo if
it was previously disabled.
This commit is contained in:
parent
f34986a9b8
commit
a65f3a431d
38
vlf.el
38
vlf.el
@ -272,16 +272,18 @@ Ask for confirmation if NOCONFIRM is nil."
|
||||
|
||||
(defmacro vlf-with-undo-disabled (&rest body)
|
||||
"Execute BODY with temporarily disabled undo."
|
||||
(declare (indent defun))
|
||||
`(progn (buffer-disable-undo)
|
||||
`(let ((undo-enabled (not (eq buffer-undo-list t))))
|
||||
(if undo-enabled
|
||||
(buffer-disable-undo))
|
||||
(unwind-protect (progn ,@body)
|
||||
(buffer-enable-undo))))
|
||||
(if undo-enabled
|
||||
(buffer-enable-undo)))))
|
||||
|
||||
(defmacro vlf-no-modifications (&rest body)
|
||||
"Ensure there are no modifications and execute BODY."
|
||||
`(if (buffer-modified-p)
|
||||
(defun vlf-no-modifications ()
|
||||
"Ensure there are no buffer modifications."
|
||||
(if (buffer-modified-p)
|
||||
(error "Save or discard your changes first")
|
||||
,@body))
|
||||
t))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; batch movement
|
||||
@ -596,27 +598,27 @@ successful. Return nil if nothing found."
|
||||
(defun vlf-re-search-forward (regexp count)
|
||||
"Search forward for REGEXP prefix COUNT number of times.
|
||||
Search is performed chunk by chunk in `vlf-batch-size' memory."
|
||||
(interactive (list (read-regexp "Search whole file"
|
||||
(interactive (if (vlf-no-modifications)
|
||||
(list (read-regexp "Search whole file"
|
||||
(if regexp-history
|
||||
(car regexp-history)))
|
||||
(or current-prefix-arg 1)))
|
||||
(vlf-no-modifications
|
||||
(vlf-re-search regexp count nil (/ vlf-batch-size 8))))
|
||||
(or current-prefix-arg 1))))
|
||||
(vlf-re-search regexp count nil (/ vlf-batch-size 8)))
|
||||
|
||||
(defun vlf-re-search-backward (regexp count)
|
||||
"Search backward for REGEXP prefix COUNT number of times.
|
||||
Search is performed chunk by chunk in `vlf-batch-size' memory."
|
||||
(interactive (list (read-regexp "Search whole file backward"
|
||||
(interactive (if (vlf-no-modifications)
|
||||
(list (read-regexp "Search whole file backward"
|
||||
(if regexp-history
|
||||
(car regexp-history)))
|
||||
(or current-prefix-arg 1)))
|
||||
(vlf-no-modifications
|
||||
(vlf-re-search regexp count t (/ vlf-batch-size 8))))
|
||||
(or current-prefix-arg 1))))
|
||||
(vlf-re-search regexp count t (/ vlf-batch-size 8)))
|
||||
|
||||
(defun vlf-goto-line (n)
|
||||
"Go to line N. If N is negative, count from the end of file."
|
||||
(interactive "nGo to line: ")
|
||||
(vlf-no-modifications
|
||||
(interactive (if (vlf-no-modifications)
|
||||
(list (read-number "Go to line: "))))
|
||||
(let ((start-pos vlf-start-pos)
|
||||
(end-pos vlf-end-pos)
|
||||
(pos (point))
|
||||
@ -633,7 +635,7 @@ Search is performed chunk by chunk in `vlf-batch-size' memory."
|
||||
(if success
|
||||
(message "Onto line %s" n)
|
||||
(vlf-move-to-chunk start-pos end-pos)
|
||||
(goto-char pos))))))
|
||||
(goto-char pos)))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; occur
|
||||
|
Loading…
x
Reference in New Issue
Block a user