[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/iedit d7db0e5d19 279/301: Replace `iedit-lib-aborting-hook
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/iedit d7db0e5d19 279/301: Replace `iedit-lib-aborting-hook' with a callback function |
Date: |
Mon, 10 Jan 2022 22:59:10 -0500 (EST) |
branch: elpa/iedit
commit d7db0e5d19a31ab24d44e6c2d1d1176f4c9d1ad7
Author: Victor Ren <victorhge@gmail.com>
Commit: Victor <victorhge@gmail.com>
Replace `iedit-lib-aborting-hook' with a callback function
---
iedit-lib.el | 43 +++++++++++++++++++++++--------------------
iedit-rect.el | 8 +++-----
iedit.el | 9 +++------
3 files changed, 29 insertions(+), 31 deletions(-)
diff --git a/iedit-lib.el b/iedit-lib.el
index 7d8b45a208..96055699c5 100755
--- a/iedit-lib.el
+++ b/iedit-lib.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2010 - 2019, 2020 Victor Ren
-;; Time-stamp: <2021-01-04 14:07:43 Victor Ren>
+;; Time-stamp: <2021-01-06 11:23:22 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous rectangle refactoring
;; Version: 0.9.9.9
@@ -160,8 +160,9 @@ insertion against a zero-width occurrence.")
(defvar iedit-aborting nil
"This is buffer local variable which indicates Iedit mode is aborting.")
-(defvar iedit-lib-aborting-hook nil
- "Functions to call before iedit-abort. Normally it should be mode exit
function.")
+(defvar iedit-lib-quit-func nil
+ "Function to call to exit mode using `iedit-lib'.
+Should be set in `iedit-lib-start'.")
(defvar iedit-post-undo-hook-installed nil
"This is buffer local variable which indicated if
@@ -206,7 +207,7 @@ It replaces `inhibit-modification-hooks' which prevents
calling
(make-variable-buffer-local 'iedit-post-undo-hook-installed)
(make-variable-buffer-local 'iedit-occurrence-context-lines)
(make-variable-buffer-local 'iedit-occurrence-index)
-(make-variable-buffer-local 'iedit-lib-aborting-hook)
+(make-variable-buffer-local 'iedit-lib-quit-func)
(defconst iedit-occurrence-overlay-name 'iedit-occurrence-overlay-name)
(defconst iedit-invisible-overlay-name 'iedit-invisible-overlay-name)
@@ -243,8 +244,8 @@ It replaces `inhibit-modification-hooks' which prevents
calling
(define-key map (kbd "M-<") 'iedit-goto-first-occurrence)
(define-key map (kbd "M->") 'iedit-goto-last-occurrence)
(define-key map (kbd "C-?") 'iedit-help-for-occurrences)
- (define-key map [remap keyboard-escape-quit] 'iedit-quit)
- (define-key map [remap keyboard-quit] 'iedit-quit)
+ (define-key map [remap keyboard-escape-quit] 'iedit--quit)
+ (define-key map [remap keyboard-quit] 'iedit--quit)
map)
"Default keymap used within occurrence overlays.")
@@ -268,7 +269,7 @@ cursors."
(goto-char (+ (overlay-start occurrence) offset))
(unless (= master (point))
(mc/create-fake-cursor-at-point))))
- (run-hooks 'iedit-lib-aborting-hook)
+ (iedit--quit)
(multiple-cursors-mode 1)))
;; `multiple-cursors-mode' runs `post-command-hook' function on all the
;; cursors for updating them . `iedit-switch-to-mc-mode' is not supposed to
@@ -295,10 +296,10 @@ It should be set before occurrence overlay is created.")
(substitute-command-keys "\\[iedit-goto-last-occurrence]")
":first/last "
)))
-(defun iedit-quit ()
- "Quit the current mode."
+(defun iedit--quit ()
+ "Quit the current mode by calling mode exit function."
(interactive)
- (run-hooks 'iedit-lib-aborting-hook))
+ (funcall iedit-lib-quit-func))
(defun iedit-make-markers-overlays (markers)
"Create occurrence overlays on a list of markers."
@@ -406,12 +407,13 @@ there are."
(iedit-update-index)
)) ;; todo test this function
-(defun iedit-lib-start ()
+(defun iedit-lib-start (mode-exit-func)
"Initialize the hooks."
+ (setq iedit-lib-quit-func mode-exit-func)
(add-hook 'post-command-hook 'iedit-update-occurrences-2 nil t)
- (add-hook 'before-revert-hook 'iedit-quit nil t)
- (add-hook 'kbd-macro-termination-hook 'iedit-quit nil t)
- (add-hook 'change-major-mode-hook 'iedit-quit nil t)
+ (add-hook 'before-revert-hook iedit-lib-quit-func nil t)
+ (add-hook 'kbd-macro-termination-hook iedit-lib-quit-func nil t)
+ (add-hook 'change-major-mode-hook iedit-lib-quit-func nil t)
(setq iedit-after-change-list nil))
(defun iedit-lib-cleanup ()
@@ -419,9 +421,10 @@ there are."
(remove-hook 'post-command-hook 'iedit-update-occurrences-2 t)
(remove-overlays nil nil iedit-occurrence-overlay-name t)
(iedit-show-all)
- (remove-hook 'before-revert-hook 'iedit-quit t)
- (remove-hook 'kbd-macro-termination-hook 'iedit-quit t)
- (remove-hook 'change-major-mode-hook 'iedit-quit t)
+ (remove-hook 'before-revert-hook iedit-lib-quit-func t)
+ (remove-hook 'kbd-macro-termination-hook iedit-lib-quit-func t)
+ (remove-hook 'change-major-mode-hook iedit-lib-quit-func t)
+ (setq iedit-lib-quit-func nil)
(setq iedit-occurrences-overlays nil)
(setq iedit-read-only-occurrences-overlays nil)
(setq iedit-aborting nil)
@@ -470,7 +473,7 @@ This is added to `post-command-hook' when undo command is
executed
in occurrences."
(if (iedit-same-length)
nil
- (run-hooks 'iedit-lib-aborting-hook))
+ (iedit--quit))
(remove-hook 'post-command-hook 'iedit-post-undo t)
(setq iedit-post-undo-hook-installed nil))
@@ -478,10 +481,10 @@ in occurrences."
"Turning Iedit mode off and reset `iedit-aborting'.
This is added to `post-command-hook' when aborting Iedit mode is
-decided. `iedit-lib-aborting-hook' is postponed after the current
+decided. `iedit-lib-quit-func' is postponed after the current
command is executed for avoiding `iedit-update-occurrences'
is called for a removed overlay."
- (run-hooks 'iedit-lib-aborting-hook)
+ (iedit--quit)
(remove-hook 'post-command-hook 'iedit-reset-aborting t)
(setq iedit-aborting nil))
diff --git a/iedit-rect.el b/iedit-rect.el
index 28be7c71f8..689dfe0931 100644
--- a/iedit-rect.el
+++ b/iedit-rect.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010 - 2019, 2020 Victor Ren
-;; Time-stamp: <2021-01-04 14:10:02 Victor Ren>
+;; Time-stamp: <2021-01-06 11:17:35 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous rectangle refactoring
;; Version: 0.9.9.9
@@ -146,8 +146,7 @@ Commands:
(number-to-string (length iedit-occurrences-overlays)))
'face
'font-lock-warning-face))
- (add-hook 'iedit-aborting-hook 'iedit-rectangle-done nil t)
- (iedit-lib-start)
+ (iedit-lib-start 'iedit-rectangle-done)
(force-mode-line-update))
(defun iedit-rectangle-done ()
@@ -158,8 +157,7 @@ the initial string globally."
(iedit-stop-buffering))
(iedit-lib-cleanup)
(setq iedit-rectangle-mode nil)
- (force-mode-line-update)
- (remove-hook 'iedit-lib-aborting-hook 'iedit-rectangle-done t))
+ (force-mode-line-update))
(defun iedit-kill-rectangle(&optional fill)
"Kill the rectangle.
diff --git a/iedit.el b/iedit.el
index fd1a410850..e2f0c4a39e 100644
--- a/iedit.el
+++ b/iedit.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010 - 2019, 2020 Victor Ren
-;; Time-stamp: <2021-01-04 13:52:50 Victor Ren>
+;; Time-stamp: <2021-01-06 11:14:51 Victor Ren>
;; Author: Victor Ren <victorhge@gmail.com>
;; Keywords: occurrence region simultaneous refactoring
;; Version: 0.9.9.9
@@ -483,10 +483,8 @@ Keymap used within overlays:
(setq iedit-mode t))
(when iedit-auto-buffering
(iedit-start-buffering))
- (add-hook 'iedit-lib-aborting-hook 'iedit-done nil t)
- (iedit-lib-start)
- (run-hooks 'iedit-mode-hook)
- )
+ (iedit-lib-start 'iedit-done)
+ (run-hooks 'iedit-mode-hook))
(defun iedit-default-occurrence()
"This function returns a string as occurrence candidate.
@@ -590,7 +588,6 @@ the initial string globally."
(setq iedit-initial-string-local nil)
(setq iedit-mode nil)
(force-mode-line-update)
- (remove-hook 'iedit-lib-aborting-hook 'iedit-done t)
(run-hooks 'iedit-mode-end-hook))
(defun iedit-mode-on-action (&optional arg)
- [nongnu] elpa/iedit c2763baaf6 168/301: Do not enable iedit from a failing isearch, (continued)
- [nongnu] elpa/iedit c2763baaf6 168/301: Do not enable iedit from a failing isearch, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 4e8b9453ac 261/301: Update occurrences in `post-command-hook', ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 3c305620ae 250/301: Optimize iedit-mode-from-isearch, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 85fad4a3b7 233/301: Merge pull request #73 from lionel-/feature-mode-line, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit a7f5ed7cf9 257/301: Turn off iedit-mode at running `iedit-mode-toggle-on-function` twice, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 5050b7e88e 260/301: Fix a failed test case when Emacs is compiled without GUI, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit afca4e6bbf 213/301: Rename hook functions, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 7ab2509231 225/301: Expand iedit-regexp-quote with passthrough, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit efe98b2015 248/301: fix `iedit-mode-on-fuction problem, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 01fa1e5925 217/301: Fix error if sgml-electric-tag-pair-mode not bound, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit d7db0e5d19 279/301: Replace `iedit-lib-aborting-hook' with a callback function,
ELPA Syncer <=
- [nongnu] elpa/iedit dbf3f9a0e3 290/301: Add iedit-update-key-bindings, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 351bee5e0d 292/301: New iedit-record-changes, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 070775fb85 296/301: New feature: apply kmacro on occurrences, ELPA Syncer, 2022/01/10
- [nongnu] elpa/iedit 3c7159a107 298/301: Avoid calling `iedit-lib-cleanup` twice, ELPA Syncer, 2022/01/10