GNU bug report logs - #20687
25.0.50; `perform-replace' should invoke a key that you have bound in `query-replace-map'

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Thu, 28 May 2015 21:13:02 UTC

Severity: wishlist

Tags: fixed

Found in version 25.0.50

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 20687 <at> debbugs.gnu.org (full text, mbox):

From: Kaushal <kaushal.modi <at> gmail.com>
To: 20687 <at> debbugs.gnu.org
Cc: Drew Adams <drew.adams <at> oracle.com>, juri <at> linkov.net
Subject: 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
[Message part 1 (text/plain, inline)]
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
[Message part 2 (text/html, inline)]

This bug report was last modified 4 years and 251 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.