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

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

[elpa] externals/objed db542e0 127/216: Add replace inside object op


From: Stefan Monnier
Subject: [elpa] externals/objed db542e0 127/216: Add replace inside object op
Date: Tue, 8 Jan 2019 12:29:25 -0500 (EST)

branch: externals/objed
commit db542e0cceb6824847571c1b13bdae63f7970af7
Author: Clemera <address@hidden>
Commit: Clemera <address@hidden>

    Add replace inside object op
---
 README.asc |  6 +++---
 objed.el   | 18 +++++++++++++++++-
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/README.asc b/README.asc
index 56c18cd..1484836 100644
--- a/README.asc
+++ b/README.asc
@@ -254,9 +254,6 @@ Commands to switch to other objects (and move point to its 
start):
 |kbd:[_]
 |Switch to symbol object.
 
-|kbd:[%]
-|Switch to content object (defined by textual content of current object).
-
 |kbd:[c]
 |Prefix to switch to other objects, see `objed-object-map` for available 
objects and `objed-define-object` to add your own.
 |===
@@ -321,6 +318,9 @@ commands" below):
 |kbd:[:]
 |Comment and duplicate object.
 
+|kbd:[%]
+|Query replace narrowed to current object.
+
 |kbd:[$]
 |Flyspell textual content of object.
 
diff --git a/objed.el b/objed.el
index d3d8e9b..48f8af5 100644
--- a/objed.el
+++ b/objed.el
@@ -336,7 +336,6 @@ See also `objed-disabled-p'"
     (yank-pop . region)
     ;; misc
     (which-key-C-h-dispatch . char)
-    (recenter-top-bottom . line)
     )
   "Entry commands and associated objects."
   :group 'objed
@@ -361,6 +360,7 @@ be used to restore previous states."
     undo-only
     delete-other-windows
     reposition-window
+    recenter-top-bottom
     )
   "Regular Emacs commands which should not exit modal edit state.
 
@@ -463,6 +463,7 @@ To avoid loading `avy' set this var before activating 
`objed-mode.'"
 (declare-function avy-goto-char "ext:avy")
 (declare-function edit-indirect-region "ext:edit-indirect")
 (declare-function electric-pair-syntax-info "ext:elec-pair")
+(declare-function hl-line-unhighlight "ext:hl-line")
 
 
 
@@ -766,6 +767,9 @@ cons of guessed object and its state."
     (define-key map "z" 'objed-ace)
     ;; swiper like object search
     (define-key map "j" 'objed-occur)
+    ;; TODO: start query replace in current object,
+    ;; or for all
+    (define-key map "%" (objed-define-op nil objed-replace current))
 
     ;; prefix keys
     (define-key map "x" 'objed-op-map)
@@ -776,6 +780,7 @@ cons of guessed object and its state."
     ;; direct object switches
     (define-key map "." 'objed-identifier-object)
     (define-key map "_" 'objed-symbol-object)
+
     ;;(define-key map "%" 'objed-contents-object)
      ;; not regular objects, selection
     ;; (define-key map (kbd "M-SPC") 'objed-select-object)
@@ -2582,6 +2587,17 @@ c: capitalize."
       (undo-tree-undo '(4))
     (undo '(4))))
 
+(defun objed-replace (beg end)
+  "Query replace narrowed to region BEG, END."
+  (interactive "r")
+  (save-excursion
+    (save-restriction
+      (narrow-to-region beg end)
+      (goto-char (point-min))
+      (hl-line-unhighlight)
+      (deactivate-mark)
+      (call-interactively 'query-replace-regexp))))
+
 
 ;; * OP execution
 



reply via email to

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