GNU bug report logs - #21957
24.5; Make occur search within regions when there is one

Previous Next

Package: emacs;

Reported by: b4283 <at> itsuwa.org

Date: Thu, 19 Nov 2015 07:03:01 UTC

Severity: wishlist

Found in version 24.5

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

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 21957 in the body.
You can then email your comments to 21957 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#21957; Package emacs. (Thu, 19 Nov 2015 07:03:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to b4283 <at> itsuwa.org:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 19 Nov 2015 07:03:02 GMT) Full text and rfc822 format available.

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

From: b4283 <at> itsuwa.org
To: bug-gnu-emacs <at> gnu.org
Subject: 24.5; Make occur search within regions when there is one
Date: Thu, 19 Nov 2015 14:39:37 +0800
This is a wish request.

The current occur implementation doesn't include a `region' version
which search only within the current region mark by user, instead it
operates on the entire buffer.

It would come in handy if occur searchs within regions as well. Such
behavior is desired, for example, when listing the occurances of a
symbol in the body of a function definition.



In GNU Emacs 24.5.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.16.6)
 of 2015-09-10 on foutrelis
Windowing system distributor `The X.Org Foundation', version 11.0.11704000
System Description:	Arch Linux

Configured using:
 `configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --with-x-toolkit=gtk3 --with-xft
 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong
 --param=ssp-buffer-size=4' CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro'

Important settings:
  value of $LC_CTYPE: zh_TW.UTF-8
  value of $LANG: zh_TW.UTF-8
  value of $XMODIFIERS: @im=gcin
  locale-coding-system: utf-8-unix

Major mode: C++/l

Minor modes in effect:
  shell-dirtrack-mode: t
  nyan-mode: t
  global-linum-mode: t
  linum-mode: t
  ido-everywhere: t
  show-paren-mode: t
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  global-prettify-symbols-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t

Recent messages:

Load-path shadows:

Features:
(shadow sort gnus-util mail-extr emacsbug message idna format-spec
rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils shell pcomplete grep+ grep compile comint
ansi-color etags ring misearch multi-isearch cc-langs cc-mode-expansions
cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
cc-vars cc-defs smooth-scrolling vc-git quail help-mode jka-compr
expand-region text-mode-expansions er-basic-expansions thingatpt
expand-region-core expand-region-custom nyan-mode buffer-move linum
edmacro kmacro cl-loaddefs cl-lib ido xemacs-theme paren delsel
cus-start cus-load windmove afternoon-theme-autoloads
cherry-blossom-theme-autoloads colorsarenice-theme-autoloads
geiser-autoloads helm-autoloads js2-mode-autoloads info easymenu
php-mode-autoloads rust-mode-autoloads advice help-fns
toml-mode-autoloads package epg-config time-date china-util tooltip
electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment
lisp-mode prog-mode register page menu-bar rfn-eshadow timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese hebrew greek romanian slovak czech european ethiopic
indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple
abbrev minibuffer nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
dbusbind gfilenotify dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)

Memory information:
((conses 16 727609 127367)
 (symbols 48 27690 0)
 (miscs 40 1313 683)
 (strings 32 121297 25891)
 (string-bytes 1 1561851)
 (vectors 16 91267)
 (vector-slots 8 1181120 133080)
 (floats 8 89 446)
 (intervals 56 7376 3100)
 (buffers 960 23)
 (heap 1024 75181 2588))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21957; Package emacs. (Fri, 20 Nov 2015 00:07:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: b4283 <at> itsuwa.org
Cc: 21957 <at> debbugs.gnu.org
Subject: Re: bug#21957: 24.5;
 Make occur search within regions when there is one
Date: Fri, 20 Nov 2015 02:04:53 +0200
> This is a wish request.
>
> The current occur implementation doesn't include a `region' version
> which search only within the current region mark by user, instead it
> operates on the entire buffer.
>
> It would come in handy if occur searchs within regions as well. Such
> behavior is desired, for example, when listing the occurances of a
> symbol in the body of a function definition.

Do you think it would suit your needs when you first narrow the buffer
(e.g. to the body of a function with C-x n d) before running occur?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21957; Package emacs. (Sat, 21 Nov 2015 05:30:04 GMT) Full text and rfc822 format available.

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

From: Li Ian-Xue <b4283 <at> itsuwa.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 21957 <at> debbugs.gnu.org
Subject: Re: bug#21957: 24.5; Make occur search within regions when there is
 one
Date: Sat, 21 Nov 2015 13:29:13 +0800
Yes, that is what I did when I found out `occur' doesn't do regions. A
friend of mine suggested
that a combination of narrowing (C-x n w) and M-s o should do the trick,
and it did.

Nevertheless still I would still prefer `occur' to accept a regional
parameter,
as it would be much straight forward mode of operation.

Thank you.

Juri Linkov 於 西元2015年11月20日 08:04 寫道:
>> This is a wish request.
>>
>> The current occur implementation doesn't include a `region' version
>> which search only within the current region mark by user, instead it
>> operates on the entire buffer.
>>
>> It would come in handy if occur searchs within regions as well. Such
>> behavior is desired, for example, when listing the occurances of a
>> symbol in the body of a function definition.
> Do you think it would suit your needs when you first narrow the buffer
> (e.g. to the body of a function with C-x n d) before running occur?





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21957; Package emacs. (Sun, 22 Nov 2015 12:14:01 GMT) Full text and rfc822 format available.

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

From: Artur Malabarba <bruce.connor.am <at> gmail.com>
To: Li Ian-Xue <b4283 <at> itsuwa.org>
Cc: 21957 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#21957: 24.5;
 Make occur search within regions when there is one
Date: Sun, 22 Nov 2015 12:13:31 +0000
[Message part 1 (text/plain, inline)]
I've been thinking it might be nice to have an occur-dwim command.

1. If the selected region has multiple lines, it would search only inside
the region.
2. If the selected region has one line or less, it would use the region as
the search string.
3. If there's no selection it do the usual occur.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21957; Package emacs. (Mon, 23 Nov 2015 00:28:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Artur Malabarba <bruce.connor.am <at> gmail.com>
Cc: 21957 <at> debbugs.gnu.org, Drew Adams <drew.adams <at> oracle.com>,
 Li Ian-Xue <b4283 <at> itsuwa.org>
Subject: Re: bug#21957: 24.5;
 Make occur search within regions when there is one
Date: Mon, 23 Nov 2015 02:22:59 +0200
> I've been thinking it might be nice to have an occur-dwim command.
>
> 1. If the selected region has multiple lines, it would search only inside
> the region.
> 2. If the selected region has one line or less, it would use the region as
> the search string.
> 3. If there's no selection it do the usual occur.

This is a useful heuristic, not sure how intuitive it is.

BTW, I recall Drew asked how to do the same in Isearch, but I see no way
because in Isearch it's useful to mark the beginning of the region, and
extend it using Isearch commands by putting the end of the region where
Isearch ends.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21957; Package emacs. (Mon, 23 Nov 2015 00:55:02 GMT) Full text and rfc822 format available.

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

From: Artur Malabarba <bruce.connor.am <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 21957 <at> debbugs.gnu.org, Drew Adams <drew.adams <at> oracle.com>,
 Li Ian-Xue <b4283 <at> itsuwa.org>
Subject: Re: bug#21957: 24.5;
 Make occur search within regions when there is one
Date: Mon, 23 Nov 2015 00:53:52 +0000
[Message part 1 (text/plain, inline)]
> BTW, I recall Drew asked how to do the same in Isearch, but I see no way
> because in Isearch it's useful to mark the beginning of the region, and
> extend it using Isearch commands by putting the end of the region where
> Isearch ends.

Technically that's not necessary. Isearch always pushes the mark for you
anyway, even though it doesn't activate the region. But most people don't
know that, and even though I know it I frequently forget and activate
region before isearch.

Anyway, I don't see why it would be a problem. Just add an item to do a
regular search if the region is empty.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21957; Package emacs. (Mon, 23 Nov 2015 01:30:05 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Juri Linkov <juri <at> linkov.net>, Artur Malabarba <bruce.connor.am <at> gmail.com>
Cc: 21957 <at> debbugs.gnu.org, Li Ian-Xue <b4283 <at> itsuwa.org>
Subject: RE: bug#21957: 24.5; Make occur search within regions when there is
 one
Date: Sun, 22 Nov 2015 17:29:26 -0800 (PST)
> > 1. If the selected region has multiple lines, it would search only
> >    inside the region.
> > 2. If the selected region has one line or less, it would use the
> >    region as the search string.
> > 3. If there's no selection it do the usual occur.
> 
> This is a useful heuristic, not sure how intuitive it is.
> 
> BTW, I recall Drew asked how to do the same in Isearch, but I see no way
> because in Isearch it's useful to mark the beginning of the region, and
> extend it using Isearch commands by putting the end of the region where
> Isearch ends.

No, I don't think that was me.  Or not quite, if by that you
mean something I might have said about searching the region.

I'm not in favor of things such as the automatic switching
among #1, #2, and #3, above.  I prefer to let users pick
whether to search the region, regardless of its size or
whether it contains a newline char.  The combination of 1,2,3
above is _not_ a useful heuristic, IMO.  It can be useful to
do any of those things, but I don't think it is useful to
couple them together in a "dwimish" way.

I'm also not in favor of Isearch just picking up the region as
the search string (regardless of whether it contains newlines).
I prefer that users yank the region into the search string if
they want to search with it.  (I also give them another command
('C-M-y') to yank the secondary selection, which is typically
not at point, and which doesn't change until you change it
explicitly.)

IOW, I think it is better to have users explicitly say what
behavior they want, instead of dwimming them around.

FWIW, in Isearch+ these features are related to the region:

1. Option 'isearchp-restrict-to-region-flag' restricts
   searching to the active region (regardless of its size or
   the presence of a newline).  You can toggle this during
   Isearch using 'C-x n'.

2. Option 'isearchp-deactivate-region-flag' causes the active
   region to be deactivated (removing highlighting).  That
   makes it easier to see what is being searched.

3. If you also use library `modeline-posn.el' then when you
   search the active region you can keep that restriction for
   query-replacement invoked from Isearch.

4. Non-nil option 'isearchp-set-region-flag' selects the
   last search target as the region when you exit Isearch.
   You can toggle this during Isearch using 'C-SPC'.  If you
   also use library `replace+.el' then you can similarly
   select the last replacement as the region when you
   query-replace etc.

5. You can put a text or overlay property on the text in the
   region, and then later search the zones of text that have
   that property (they need not be contiguous).

6. If you also use library `zones.el' then you can search
   multiple zones defined by their limits (buffer positions
   or markers in any buffers), instead of by properties.
   You can add the active region to a set of such zones,
   using 'C-x n a'.  You can coalesce such zones, uniting
   their overlaps.  (That happens anyway when you search a
   set of zones.)

7. When you search zones of any kind, non-nil option
   'isearchp-dim-non-prop-zones-flag' dims the pieces of
   text that are not being searched.  You can toggle this
   during Isearch using 'C-M-D' (aka 'C-M-S-d').

8. You can search zones defined by text/overlays/buffer
   limits as described above, or you can search the
   complement.  You can toggle searching the complement
   using 'C-M-~' during Isearch.

http://www.emacswiki.org/emacs/IsearchPlus
http://www.emacswiki.org/emacs/Zones
http://www.emacswiki.org/emacs/ReplacePlus
http://www.emacswiki.org/emacs/ModeLinePosition




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21957; Package emacs. (Mon, 24 Jan 2022 13:44:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Li Ian-Xue <b4283 <at> itsuwa.org>
Cc: 21957 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#21957: 24.5; Make occur search within regions when there is
 one
Date: Mon, 24 Jan 2022 14:43:28 +0100
Li Ian-Xue <b4283 <at> itsuwa.org> writes:

> Yes, that is what I did when I found out `occur' doesn't do regions. A
> friend of mine suggested
> that a combination of narrowing (C-x n w) and M-s o should do the trick,
> and it did.
>
> Nevertheless still I would still prefer `occur' to accept a regional
> parameter, as it would be much straight forward mode of operation.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

occur now works as requested in the current Emacs version -- it does the
operation on the active region, so I'm closing this bug report.

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




bug closed, send any further explanations to 21957 <at> debbugs.gnu.org and b4283 <at> itsuwa.org Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 24 Jan 2022 13:44:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 22 Feb 2022 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 63 days ago.

Previous Next


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