emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/iedit 6f80f88134 106/301: Differentiate lib keymap and occ


From: ELPA Syncer
Subject: [nongnu] elpa/iedit 6f80f88134 106/301: Differentiate lib keymap and occurrence keymap
Date: Mon, 10 Jan 2022 22:58:54 -0500 (EST)

branch: elpa/iedit
commit 6f80f881342088c09941006966eca8985be8bd96
Author: Victor Ren <victorhge@gmail.com>
Commit: Victor Ren <victorhge@gmail.com>

    Differentiate lib keymap and occurrence keymap
---
 iedit-lib.el  | 46 ++++++++++++++++------------------------------
 iedit-rect.el | 13 +++++++------
 iedit.el      | 40 ++++++++++++++++++----------------------
 3 files changed, 41 insertions(+), 58 deletions(-)

diff --git a/iedit-lib.el b/iedit-lib.el
index 420016686c..7ef9214281 100644
--- a/iedit-lib.el
+++ b/iedit-lib.el
@@ -3,7 +3,7 @@
 
 ;; Copyright (C) 2010, 2011, 2012 Victor Ren
 
-;; Time-stamp: <2012-08-13 11:19:08 Victor Ren>
+;; Time-stamp: <2012-08-24 09:38:53 Victor Ren>
 ;; Author: Victor Ren <victorhge@gmail.com>
 ;; Keywords: occurrence region simultaneous rectangle refactoring
 ;; Version: 0.97
@@ -28,7 +28,7 @@
 
 ;;; Commentary:
 
-;; This package is APIs library that allow you to write your own minor mode.
+;; This package is iedit APIs library that allow you to write your own minor 
mode.
 
 ;;; todo:
 ;; - Update comments for APIs
@@ -70,7 +70,8 @@
   "The occurrences slot contains a list of overlays used to
 indicate the position of each occurrence.  In addition, the
 occurrence overlay is used to provide a different face
-configurable via `iedit-occurrence-face'.")
+configurable via `iedit-occurrence-face'.  The list is sorted by
+the position of overlays.")
 
 (defvar iedit-case-sensitive-local iedit-case-sensitive-default
   "This is buffer local variable.
@@ -112,9 +113,6 @@ insertion against a zero-width occurrence.")
 buffering, which means the modification to the current occurrence
 is not applied to other occurrences when it is true.")
 
-;; (defvar iedit-occurrence-keymap 'iedit-occurrence-keymap
-;;   "The current keymap, `iedit-occurrence-keymap'")
-
 (defvar iedit-occurrence-context-lines 1
   "The number of lines before or after the occurrence.")
 
@@ -127,7 +125,6 @@ is not applied to other occurrences when it is true.")
 (make-variable-buffer-local 'iedit-skip-modification-once)
 (make-variable-buffer-local 'iedit-aborting)
 (make-variable-buffer-local 'iedit-buffering)
-;; (make-variable-buffer-local 'iedit-occurrence-keymap)
 (make-variable-buffer-local 'iedit-occurrence-context-lines)
 
 (defconst iedit-occurrence-overlay-name 'iedit-occurrence-overlay-name)
@@ -203,9 +200,8 @@ This is like `describe-bindings', but displays only Iedit 
keys."
     map)
   "Keymap used while Iedit mode is enabled.")
 
-(defvar iedit-occurrence-keymap
+(defvar iedit-occurrence-keymap-default
   (let ((map (make-sparse-keymap)))
-    (set-keymap-parent map iedit-lib-keymap)
     (define-key map (kbd "M-U") 'iedit-upcase-occurrences)
     (define-key map (kbd "M-L") 'iedit-downcase-occurrences)
     (define-key map (kbd "M-R") 'iedit-replace-occurrences)
@@ -218,10 +214,10 @@ This is like `describe-bindings', but displays only Iedit 
keys."
     (define-key map (kbd "M->") 'iedit-last-occurrence)
     (define-key map (kbd "C-?") 'iedit-help-for-occurrences)
     map)
-  "Keymap used within overlays in Iedit mode.")
+  "Default keymap used within overlays.")
 
 (defun iedit-help-for-occurrences ()
-  "Display `iedit-occurrence-keymap'"
+  "Display `iedit-occurrence-keymap-default'"
   (interactive)
   (message (concat (substitute-command-keys "\\[iedit-upcase-occurrences]") "/"
                    (substitute-command-keys "\\[iedit-downcase-occurrences]") 
":up/downcase "
@@ -235,18 +231,20 @@ This is like `describe-bindings', but displays only Iedit 
keys."
                    (substitute-command-keys "\\[iedit-last-occurrence]") 
":first/last "
                    )))
 
-(defun iedit-make-occurrences-overlays (occurrence-exp beg end)
+(defun iedit-make-occurrences-overlays (occurrence-exp beg end &optional 
keymap)
   "Create occurrence overlays for `occurrence-exp' in a region.
 Return the number of occurrences."
   (setq iedit-aborting nil)
   (setq iedit-occurrences-overlays nil)
+  (unless keymap
+    (setq keymap iedit-occurrence-keymap-default))
   ;; Find and record each occurrence's markers and add the overlay to the 
occurrences
   (let ((counter 0)
         (case-fold-search (not iedit-case-sensitive-local)))
     (save-excursion
       (goto-char beg)
       (while (re-search-forward occurrence-exp end t)
-        (push (iedit-make-occurrence-overlay (match-beginning 0) (match-end 0))
+        (push (iedit-make-occurrence-overlay (match-beginning 0) (match-end 0) 
keymap)
               iedit-occurrences-overlays)
         (setq counter (1+ counter)))
       (message "%d matches for \"%s\"" counter (iedit-printable 
occurrence-exp))
@@ -264,14 +262,14 @@ there are."
       (error "No region"))
   (if (null iedit-occurrences-overlays)
       (push
-       (iedit-make-occurrence-overlay beg end)
+       (iedit-make-occurrence-overlay beg end iedit-occurrence-keymap-default)
        iedit-occurrences-overlays)
     (or (= (- end beg) (iedit-occurrence-string-length))
         (error "Wrong region."))
     (if (or (iedit-find-overlay-at-point beg 'iedit-occurrence-overlay-name)
             (iedit-find-overlay-at-point end 'iedit-occurrence-overlay-name))
         (error "Conflict region."))
-    (push (iedit-make-occurrence-overlay beg end)
+    (push (iedit-make-occurrence-overlay beg end 
iedit-occurrence-keymap-default)
           iedit-occurrences-overlays)
     (sort iedit-occurrences-overlays
           (lambda (left right)
@@ -279,26 +277,14 @@ there are."
 
 (defun iedit-cleanup ()
   "Clean up occurrence overlay, invisible overlay and local variables."
-  ;; (when iedit-buffering
-  ;;     (iedit-stop-buffering))
-  ;; (setq iedit-last-occurrence-local (iedit-current-occurrence-string))
-  ;; (setq iedit-last-occurrence-global iedit-last-occurrence-local)
-  ;; (setq iedit-last-initial-string-global iedit-initial-string-local)
-  ;; (setq iedit-case-sensitive-global iedit-case-sensitive-local)
   (remove-overlays nil nil iedit-occurrence-overlay-name t)
   (iedit-show-all)
   (setq iedit-occurrences-overlays nil)
   (setq iedit-aborting nil)
   (setq iedit-before-modification-string "")
-  (setq iedit-before-modification-undo-list nil)
-  ;; (setq iedit-mode nil)
-  ;; (force-mode-line-update)
-  ;; (remove-hook 'kbd-macro-termination-hook 'iedit-done t)
-  ;; (remove-hook 'change-major-mode-hook 'iedit-done t)
-  ;; (run-hooks 'iedit-mode-end-hook)
-  )
+  (setq iedit-before-modification-undo-list nil))
 
-(defun iedit-make-occurrence-overlay (begin end)
+(defun iedit-make-occurrence-overlay (begin end keymap)
   "Create an overlay for an occurrence in Iedit mode.
 Add the properties for the overlay: a face used to display a
 occurrence's default value, and modification hooks to update
@@ -306,7 +292,7 @@ occurrences if the user starts typing."
   (let ((occurrence (make-overlay begin end (current-buffer) nil t)))
     (overlay-put occurrence iedit-occurrence-overlay-name t)
     (overlay-put occurrence 'face iedit-occurrence-face)
-    (overlay-put occurrence 'keymap iedit-occurrence-keymap)
+    (overlay-put occurrence 'keymap keymap)
     (overlay-put occurrence 'insert-in-front-hooks '(iedit-occurrence-update))
     (overlay-put occurrence 'insert-behind-hooks '(iedit-occurrence-update))
     (overlay-put occurrence 'modification-hooks '(iedit-occurrence-update))
diff --git a/iedit-rect.el b/iedit-rect.el
index 6d12f86d96..e60f6098d4 100644
--- a/iedit-rect.el
+++ b/iedit-rect.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2010, 2011, 2012 Victor Ren
 
-;; Time-stamp: <2012-08-10 16:20:22 Victor Ren>
+;; Time-stamp: <2012-08-23 15:30:08 Victor Ren>
 ;; Author: Victor Ren <victorhge@gmail.com>
 ;; Keywords: occurrence region simultaneous rectangle refactoring
 ;; Version: 0.97
@@ -28,8 +28,8 @@
 ;;; Commentary:
 
 ;; This package also provides rectangle support with *visible rectangle*
-;; highlighting, which is similar with cua mode rectangle support, but still
-;; quite different.
+;; highlighting, which is similar with cua mode rectangle support. But it's
+;; lighter weight and uses iedit mechanisms.
 
 ;; The code was developed and fully tested on Gnu Emacs 24.0.93, partially
 ;; tested on Gnu Emacs 22. If you have any compatible problem, please let me
@@ -69,14 +69,14 @@ current mode is iedit-rect. Otherwise it is nil.
 ;;; Define Iedit rect mode map
 (defvar iedit-rect-keymap
   (let ((map (make-sparse-keymap)))
-    (set-keymap-parent map iedit-occurrence-keymap)
+    (set-keymap-parent map iedit-occurrence-keymap-default)
     (define-key map (kbd "M-K") 'iedit-kill-rectangle)
     map)
   "Keymap used within overlays in iedit-RECT mode.")
 
 (or (assq 'iedit-rectangle-mode minor-mode-map-alist)
     (setq minor-mode-map-alist
-          (cons (cons 'iedit-rectangle-mode iedit-rect-keymap) 
minor-mode-map-alist)))
+          (cons (cons 'iedit-rectangle-mode iedit-lib-keymap) 
minor-mode-map-alist)))
 
 
 ;; Avoid to restore Iedit-rect mode when restoring desktop
@@ -115,7 +115,8 @@ current mode is iedit-rect. Otherwise it is nil.
                           (point))
                         (progn
                           (move-to-column end-col t)
-                          (point)))
+                          (point))
+                        iedit-rect-keymap)
                        iedit-occurrences-overlays)
                  (forward-line 1))
             until (> (point) end))
diff --git a/iedit.el b/iedit.el
index 75952144ba..90c467e8ed 100644
--- a/iedit.el
+++ b/iedit.el
@@ -2,9 +2,9 @@
 
 ;; Copyright (C) 2010, 2011, 2012 Victor Ren
 
-;; Time-stamp: <2012-08-10 11:13:42 Victor Ren>
+;; Time-stamp: <2012-08-24 09:40:07 Victor Ren>
 ;; Author: Victor Ren <victorhge@gmail.com>
-;; Keywords: occurrence region simultaneous rectangle refactoring
+;; Keywords: occurrence region simultaneous refactoring
 ;; Version: 0.97
 ;; X-URL: http://www.emacswiki.org/emacs/Iedit
 ;; Compatibility: GNU Emacs: 22.x, 23.x, 24.x
@@ -34,19 +34,15 @@
 ;; Normal scenario of iedit-mode is like:
 ;;
 ;; - Highlight certain contents - by press C-;
-;;   All occurrences of a symbol, string or a rectangle in the buffer or a
-;;   region may be highlighted corresponding to current mark, point and prefix
-;;   argument.  Refer to the document of `iedit-mode' for details.
+;;   All occurrences of a symbol, string in the buffer or a region may be
+;;   highlighted corresponding to current mark, point and prefix argument.
+;;   Refer to the document of `iedit-mode' for details.
 ;;
 ;; - Edit one of the occurrences
 ;;   The change is applied to other occurrences simultaneously.
 ;;
 ;; - Finish - by pressing C-; again
 ;;
-;; This package also provides rectangle support with *visible rectangle*
-;; highlighting, which is similar with cua mode rectangle support, but still
-;; quite different.
-
 ;; You can also use Iedit mode as a quick way to temporarily show only the
 ;; buffer lines that match the current text being edited.  This gives you the
 ;; effect of a temporary `keep-lines' or `occur'.  To get this effect, hit C-'
@@ -83,15 +79,8 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl))
-(require 'rect) ;; kill rectangle
 (require 'iedit-lib)
 
-(defgroup iedit nil
-  "Edit multiple regions in the same way simultaneously."
-  :prefix "iedit-"
-  :group 'replace
-  :group 'convenience)
-
 (defcustom iedit-current-symbol-default t
   "If no-nil, use current symbol by default for the occurrence."
   :type 'boolean
@@ -138,6 +127,7 @@ Iedit mode is turned off last time.")
 (make-variable-buffer-local 'iedit-mode)
 (make-variable-buffer-local 'iedit-only-complete-symbol-local)
 (make-variable-buffer-local 'iedit-last-occurrence-local)
+(make-variable-buffer-local 'iedit-initial-string-local)
 
 (or (assq 'iedit-mode minor-mode-alist)
     (nconc minor-mode-alist
@@ -162,14 +152,20 @@ Iedit mode is turned off last time.")
 ;;; Define iedit help map.
 (eval-when-compile (require 'help-macro))
 
-(defvar iedit-mode-keymap
+(defvar iedit-mode-occurrence-keymap
   (let ((map (make-sparse-keymap)))
-    (set-keymap-parent map iedit-occurrence-keymap)
+    (set-keymap-parent map iedit-occurrence-keymap-default)
     (define-key map (kbd "M-H") 'iedit-restrict-function)
     (define-key map (kbd "M-C") 'iedit-toggle-case-sensitive)
     map)
   "Keymap used within overlays in Iedit mode.")
 
+(defvar iedit-mode-keymap
+  (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map iedit-lib-keymap)
+    (define-key map (kbd "C-'") 'iedit-toggle-unmatched-lines-visible)
+    map)
+  "Keymap used while Iedit mode is enabled.")
 
 ;;; Define Iedit mode map
 (or (assq 'iedit-mode minor-mode-map-alist)
@@ -220,8 +216,8 @@ as occurrence.  If region active, Iedit mode is limited 
within
 the current region.
 
 If Iedit mode is on and region is active, Iedit mode is
-restricted in the region, e.g. the occurrences outside of the region
-is excluded.
+restricted in the region, e.g. the occurrences outside of the
+region is excluded.
 
 If Iedit mode is on and region is active, with an universal
 prefix argument, Iedit mode is restricted outside of the region,
@@ -298,7 +294,7 @@ Commands:
         (propertize
          (concat " Iedit:"
                  (number-to-string
-                  (iedit-make-occurrences-overlays occurrence-exp beg end)))
+                  (iedit-make-occurrences-overlays occurrence-exp beg end 
iedit-mode-occurrence-keymap)))
          'face
          'font-lock-warning-face))
   (force-mode-line-update))
@@ -415,7 +411,7 @@ Todo: how about region"
 ;;; iedit.el ends here
 
 ;;  LocalWords:  iedit el MERCHANTABILITY kbd isearch todo ert Lindberg Tassilo
-;;  LocalWords:  eval rect defgroup defcustom boolean defvar assq alist nconc
+;;  LocalWords:  eval defgroup defcustom boolean defvar assq alist nconc
 ;;  LocalWords:  substring cadr keymap defconst purecopy bkm defun princ prev
 ;;  LocalWords:  iso lefttab backtab upcase downcase concat setq autoload arg
 ;;  LocalWords:  refactoring propertize cond goto nreverse progn rotatef eq elp



reply via email to

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