unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Juri Linkov <juri@linkov.net>
Cc: 41692@debbugs.gnu.org
Subject: bug#41692: 26.3; Enhancement request, `query-replace': let user use text at point as default
Date: Thu, 4 Jun 2020 16:01:21 -0700 (PDT)	[thread overview]
Message-ID: <39e06665-8ab7-4b81-a481-9a8ccf3a15e1@default> (raw)
In-Reply-To: <878sh2lctc.fsf@mail.linkov.net>

> Currently `query-replace-read-from' has:
>   (if regexp-flag
>       (read-regexp prompt nil 'minibuffer-history)
>     (read-from-minibuffer
>       prompt nil nil nil nil (car search-ring) t))
> 
> It's easy to extend `read-regexp' with more options,
> but what to do for non-regexp case?
> 
> Maybe to try to use `read-string' and extend it with
> more M-n options like in `read-regexp'.

I don't understand the question.  `read-from-minibuffer'
accepts a list of default values.  Or maybe I don't
understand what you mean by "more options".

I think I referred you to my code in `replace+.el'.
Here it is, in case I didn't:

https://www.emacswiki.org/emacs/download/replace%2b.el

In my code for `query-replace-read-from' I determine
the default value(s) by evaluating this:
(search/replace-default
  (symbol-value query-replace-from-history-variable))

I use function `search/replace-default' in lots of
search and replace functions.  It's the place where
this logic is used to get default values:

 Return a default value or list of such for search &
 replace functions.
 A list of default input strings is computed and
 returned.  The possible strings are, in order:

 * The active region, if option
   `search/replace-region-as-default-flag' is non-nil.

 * The secondary selection, if option
   `search/replace-2nd-sel-as-default-flag' is non-nil.

 * The result of calling the value of option
   `search/replace-default-fn', if non-nil.

 * The first entry in the history list HISTORY.

Option `search/replace-default-fn' lets users decide
what function to use, to grab buffer text as the
default.  The option's default value is a function
that grabs the non-nil symbol name that's nearest point.
If that function isn't available then the default value
is `word-at-point'.

HTH.





  reply	other threads:[~2020-06-04 23:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-03 18:35 bug#41692: 26.3; Enhancement request, `query-replace': let user use text at point as default Drew Adams
2020-06-03 22:54 ` Juri Linkov
2020-06-03 23:22   ` Drew Adams
2020-06-04 22:05     ` Juri Linkov
2020-06-04 23:01       ` Drew Adams [this message]
2020-06-11 22:58         ` Juri Linkov
2020-06-12  0:34           ` Drew Adams
2020-06-12  0:46             ` Drew Adams
2021-01-27 18:33               ` Juri Linkov
2021-01-27 18:55                 ` bug#41692: [External] : " Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=39e06665-8ab7-4b81-a481-9a8ccf3a15e1@default \
    --to=drew.adams@oracle.com \
    --cc=41692@debbugs.gnu.org \
    --cc=juri@linkov.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).