all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#54086: Occur should offer more interactive input options
@ 2022-02-21 10:36 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 ` bug#54086: [External] : " Drew Adams
  0 siblings, 2 replies; 3+ messages in thread
From: emacsq via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-21 10:36 UTC (permalink / raw)
  To: 54086

[-- Attachment #1: Type: text/plain, Size: 470 bytes --]

In my experience it is often that I search for something under the cursor, so it
makes sense for occur to pick up the word at point and offer that for search.

Also, if a region is selected occur could offer this as input.

I did these for myself long ago and it's a pretty useful hack which could improve
built in occur too.

So something like this for initial input :

(if (use-region-p)
(buffer-substring (region-beginning) (region-end))
(thing-at-point 'symbol))))))

[-- Attachment #2: Type: text/html, Size: 1327 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#54086: Occur should offer more interactive input options
  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 ` bug#54086: [External] : " Drew Adams
  1 sibling, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-21 14:14 UTC (permalink / raw)
  To: emacsq; +Cc: 54086

emacsq <laszlomail@protonmail.com> writes:

> In my experience it is often that I search for something under the cursor, so it 
> makes sense for occur to pick up the word at point and offer that for search.

It does -- it's put in the future history, so you can hit `M-n' to get
at it.

> Also, if a region is selected occur could offer this as input.

Same with this.

So this works as designed, and I'm therefore closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#54086: [External] : bug#54086: Occur should offer more interactive input options
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Drew Adams @ 2022-02-21 17:13 UTC (permalink / raw)
  To: emacsq, 54086@debbugs.gnu.org

> 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-21 17:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` bug#54086: [External] : " Drew Adams

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.