unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: emacsq <laszlomail@protonmail.com>,
	"54086@debbugs.gnu.org" <54086@debbugs.gnu.org>
Subject: bug#54086: [External] : bug#54086: Occur should offer more interactive input options
Date: Mon, 21 Feb 2022 17:13:18 +0000	[thread overview]
Message-ID: <SJ0PR10MB54882EC2B3A390A896CA917BF33A9@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <OAYaCVHoyaN0nLXgdG00QDzBqZ4lTK7bLRSBsP_qsBcQ883kNVN1kxHGS5yjKD5Arp-ZSx0TT7DcUftFfwRDc5E59U8R3mSa5BZwOx26dzA=@protonmail.com>

> something like this for initial input :
> (if (use-region-p)
>     (buffer-substring (region-beginning) (region-end))
>   (thing-at-point 'symbol))

As Lars pointed out, you can use `M-n' to
retrieve such a default input (and there can
be multiple reasonable default inputs - repeat
`M-n' to access them).

However, when the region is active there are
two different (i.e., alternative) behaviors
that can be useful:

 1. Use the region content as the text to find.
    (This is what you suggested.)
 2. Limit searching to the region.

#2 is very useful.  (You can of course narrow
to the region and then search, but it helps to
be able to see the surrounding text while you
search only the region text.)

Users should have a way to choose which of the
behaviors they prefer by default and to change
to the other alternative on the fly (without
having to change their default choice by, e.g.,
flipping an option value).

With library `isearch+.el' you can limit
searching to the region: use non-nil option
`search/replace-region-as-default-flag'.

And not only Isearch.  If you also use library
`replace+.el' then `occur' and all replace
commands also respect the option.

To prefer using the region content as what to
search for, leave the option as nil and use a
function that does what your `if' does as the
value of option `search/replace-default-fn'.
___

isearch+.el:

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

replace+.el:

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


      parent reply	other threads:[~2022-02-21 17:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-21 10:36 bug#54086: Occur should offer more interactive input options emacsq via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-21 14:14 ` Lars Ingebrigtsen
2022-02-21 17:13 ` Drew Adams [this message]

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=SJ0PR10MB54882EC2B3A390A896CA917BF33A9@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=54086@debbugs.gnu.org \
    --cc=laszlomail@protonmail.com \
    /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).