bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#20687: 25.0.50; `perform-replace' should invoke a key that you have


From: Kaushal
Subject: bug#20687: 25.0.50; `perform-replace' should invoke a key that you have bound in `query-replace-map'
Date: Tue, 2 Jun 2015 09:08:51 -0400

Hi guys,

I tried the fix as Drew suggested and it works great.

Patch:

--- replace.el 2015-06-02 09:04:57.944380000 -0400
+++ replace-editted.el 2015-06-02 09:08:22.038682000 -0400
@@ -2099,12 +2099,11 @@
          ;; Data for the next match.  If a cons, it has the same format as
          ;; (match-data); otherwise it is t if a match is possible at point.
          (match-again t)
-
          (message
           (if query-flag
               (apply 'propertize
                      (substitute-command-keys
-                      "Query replacing %s with %s: (\\<query-replace-map>\\[help] for help) ")
+                      "%sQuery replacing %s with %s: (\\<query-replace-map>\\[help] for help) ")
                      minibuffer-prompt-properties))))
 
     ;; If region is active, in Transient Mark mode, operate on region.
@@ -2275,6 +2274,8 @@
      nocasify literal))
    next-replacement)))
     (message message
+                             ;; Show whether `case-fold-search' is `t' or `nil'
+                             (if case-fold-search "[case] " "[CaSe] ")
                              (query-replace-descr from-string)
                              (query-replace-descr replacement-presentation)))
   (setq key (read-event))
@@ -2404,6 +2405,7 @@
  (replace-dehighlight)
  (save-excursion (recursive-edit))
  (setq replaced t))
+                        (def (call-interactively def)) ; User-defined key - invoke it.
  ;; Note: we do not need to treat `exit-prefix'
  ;; specially here, since we reread
  ;; any unrecognized character.


Here is then how I add a new binding to the query-replace-map:

;; http://emacs.stackexchange.com/a/12781/115
(defun drew/toggle-case ()
  "Toggle the value of `case-fold-search' between `nil' and non-nil."
  (interactive)
  ;; `case-fold-search' automatically becomes buffer-local when set
  (setq case-fold-search (not case-fold-search)))
(define-key query-replace-map (kbd "C") #'drew/toggle-case)

https://github.com/kaushalmodi/.emacs.d/blob/e690fddc7176368b3d25b0d34ec02510ee92503a/setup-files/setup-search.el#L22-L28 )


--
Kaushal Modi

reply via email to

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