all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Occur lite
@ 2012-07-15 14:06 B. T. Raven
  2012-07-15 16:41 ` Raffaele Ricciardi
  0 siblings, 1 reply; 9+ messages in thread
From: B. T. Raven @ 2012-07-15 14:06 UTC (permalink / raw)
  To: help-gnu-emacs

Ignutians:

Is there an Emacs function that extracts only words matching a regexp
and writes them to another buffer? This would work exactly like the
"occur" function but would write only the words to the *Occur* buffer
instead of the whole line. I have looked at the code for "occur" in
replace.el but I'm afraid it's over my head to try and modify it into a
custom function.

Thanks,

Ed


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

* Re: Occur lite
  2012-07-15 14:06 Occur lite B. T. Raven
@ 2012-07-15 16:41 ` Raffaele Ricciardi
  2012-07-15 16:45   ` Raffaele Ricciardi
  0 siblings, 1 reply; 9+ messages in thread
From: Raffaele Ricciardi @ 2012-07-15 16:41 UTC (permalink / raw)
  To: help-gnu-emacs

On 07/15/2012 03:06 PM, B. T. Raven wrote:> Ignutians:
 >
 > Is there an Emacs function that extracts only words matching a regexp
 > and writes them to another buffer? This would work exactly like the
 > "occur" function but would write only the words to the *Occur* buffer
 > instead of the whole line. I have looked at the code for "occur" in
 > replace.el but I'm afraid it's over my head to try and modify it into a
 > custom function.

An indirect solution: run occur and then run a regexp over the *Occur* 
buffer to capture each word. Something like:

(call-interactively #'occur)
(switch-to-buffer "*Occur*") ;; Or with-current-buffer
(goto-char (point-min))
;; etc.


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

* Re: Occur lite
  2012-07-15 16:41 ` Raffaele Ricciardi
@ 2012-07-15 16:45   ` Raffaele Ricciardi
  2012-07-15 17:12     ` B. T. Raven
  0 siblings, 1 reply; 9+ messages in thread
From: Raffaele Ricciardi @ 2012-07-15 16:45 UTC (permalink / raw)
  To: help-gnu-emacs

On 07/15/2012 05:41 PM, Raffaele Ricciardi wrote:
> An indirect solution: run occur and then run a regexp over the *Occur*
> buffer to capture each word. Something like:
>
> (call-interactively #'occur)
> (switch-to-buffer "*Occur*") ;; Or with-current-buffer
> (goto-char (point-min))
> ;; etc.

I spoke too fast. RTFM, e.g. the documentation of occur provides exactly 
what you need.




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

* Re: Occur lite
  2012-07-15 16:45   ` Raffaele Ricciardi
@ 2012-07-15 17:12     ` B. T. Raven
  2012-07-15 17:30       ` Raffaele Ricciardi
  0 siblings, 1 reply; 9+ messages in thread
From: B. T. Raven @ 2012-07-15 17:12 UTC (permalink / raw)
  To: help-gnu-emacs

Thanks, Raffaele. The Emacs manual doesn't have a menu item for Occur
and I don't find it under the "Search" topics. Do you mean that this
capability is built in or does it require another package? At

http://emacswiki.org/emacs/OccurMode#toc12

under "View matches only" there is code for an "occurences" function
that looks like it might work but I don't understand it and don't need
much of its functionality (text properties, etc.) but it would be nice
to retain the line number and colon and have the occurences printed one
per line. Anyway, I can try it if the line

(interactive (occur-read-primary-args))

means that I can invoke it as M-x occurences.

Thanks again,

Ed


> On 07/15/2012 05:41 PM, Raffaele Ricciardi wrote:
>> An indirect solution: run occur and then run a regexp over the *Occur*
>> buffer to capture each word. Something like:
>>
>> (call-interactively #'occur)
>> (switch-to-buffer "*Occur*") ;; Or with-current-buffer
>> (goto-char (point-min))
>> ;; etc.
> 
> I spoke too fast. RTFM, e.g. the documentation of occur provides exactly
> what you need.
> 
> 



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

* Re: Occur lite
  2012-07-15 17:12     ` B. T. Raven
@ 2012-07-15 17:30       ` Raffaele Ricciardi
  2012-07-15 17:59         ` B. T. Raven
  0 siblings, 1 reply; 9+ messages in thread
From: Raffaele Ricciardi @ 2012-07-15 17:30 UTC (permalink / raw)
  To: help-gnu-emacs

On 07/15/2012 06:12 PM, B. T. Raven wrote:
 > Thanks, Raffaele. The Emacs manual doesn't have a menu item for Occur
 > and I don't find it under the "Search" topics. Do you mean that this
 > capability is built in or does it require another package?

I mean that "C-h f occur RET" displays the documentation of occur, where 
you can find an example of how to capture function names in a Lisp file. 
It seems what you are looking for.

Cheers.


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

* Re: Occur lite
  2012-07-15 17:30       ` Raffaele Ricciardi
@ 2012-07-15 17:59         ` B. T. Raven
  2012-07-15 18:44           ` Raffaele Ricciardi
  0 siblings, 1 reply; 9+ messages in thread
From: B. T. Raven @ 2012-07-15 17:59 UTC (permalink / raw)
  To: help-gnu-emacs


> On 07/15/2012 06:12 PM, B. T. Raven wrote:
>> Thanks, Raffaele. The Emacs manual doesn't have a menu item for Occur
>> and I don't find it under the "Search" topics. Do you mean that this
>> capability is built in or does it require another package?
> 
> I mean that "C-h f occur RET" displays the documentation of occur, where
> you can find an example of how to capture function names in a Lisp file.
> It seems what you are looking for.
> 
> Cheers.

Thanks for the fast reply. On ver. 23.3 the function docs are these:
"
occur is an interactive compiled Lisp function in `replace.el'.

It is bound to M-s o.

(occur REGEXP &optional NLINES)

Show all lines in the current buffer containing a match for REGEXP.
This function can not handle matches that span more than one line.

Each line is displayed with NLINES lines before and after, or -NLINES
before if NLINES is negative.
NLINES defaults to `list-matching-lines-default-context-lines'.
Interactively it is the prefix arg.

The lines are shown in a buffer named `*Occur*'.
It serves as a menu to find any of the occurrences in this buffer.
C-h m in that buffer will explain how.

If REGEXP contains upper case characters (excluding those preceded by `\')
and `search-upper-case' is non-nil, the matching is case-sensitive.
"

In general I use Emacs for general text manipulation, not programming,
so, no, I'm not trying to get function names. Anyway, that code from
emacwiki seems to work and I can toggle-read-only on the buffer and use
rectangle to extract the matches only.

Ed




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

* Re: Occur lite
  2012-07-15 17:59         ` B. T. Raven
@ 2012-07-15 18:44           ` Raffaele Ricciardi
  2012-07-15 21:11             ` B. T. Raven
  0 siblings, 1 reply; 9+ messages in thread
From: Raffaele Ricciardi @ 2012-07-15 18:44 UTC (permalink / raw)
  To: help-gnu-emacs

On 07/15/2012 06:59 PM, B. T. Raven wrote:
> Thanks for the fast reply. On ver. 23.3 the function docs are these:

Then occur has been improved on Emacs 24.1, as the documentation 
contains a further paragraph, and occur can send to the *Occur* buffer 
matches instead of whole lines. That doesn't work on Emacs 23.2.


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

* Re: Occur lite
  2012-07-15 18:44           ` Raffaele Ricciardi
@ 2012-07-15 21:11             ` B. T. Raven
  2012-07-15 22:55               ` Aurélien Aptel
  0 siblings, 1 reply; 9+ messages in thread
From: B. T. Raven @ 2012-07-15 21:11 UTC (permalink / raw)
  To: help-gnu-emacs

Die Sun Jul 15 2012 13:44:19 GMT-0500 (Central Daylight Time) Raffaele
Ricciardi <rfflrccrd@gmail.com> scripsit:

> On 07/15/2012 06:59 PM, B. T. Raven wrote:
>> Thanks for the fast reply. On ver. 23.3 the function docs are these:
> 
> Then occur has been improved on Emacs 24.1, as the documentation
> contains a further paragraph, and occur can send to the *Occur* buffer
> matches instead of whole lines. That doesn't work on Emacs 23.2.

Just another reason to upgrade. I was going to wait for 64-bit Emacs
before upgrading (for no good reason since the biggest file I have ever
edited was only a few megabytes). A better reason might be to check out
the added features, especially bidi and new input methods.


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

* Re: Occur lite
  2012-07-15 21:11             ` B. T. Raven
@ 2012-07-15 22:55               ` Aurélien Aptel
  0 siblings, 0 replies; 9+ messages in thread
From: Aurélien Aptel @ 2012-07-15 22:55 UTC (permalink / raw)
  To: B. T. Raven; +Cc: help-gnu-emacs

On Sun, Jul 15, 2012 at 11:11 PM, B. T. Raven <btraven@nihilo.net> wrote:
> edited was only a few megabytes). A better reason might be to check out
> the added features, especially bidi and new input methods.

There's also the new package manager and lexical scoping!



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

end of thread, other threads:[~2012-07-15 22:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-15 14:06 Occur lite B. T. Raven
2012-07-15 16:41 ` Raffaele Ricciardi
2012-07-15 16:45   ` Raffaele Ricciardi
2012-07-15 17:12     ` B. T. Raven
2012-07-15 17:30       ` Raffaele Ricciardi
2012-07-15 17:59         ` B. T. Raven
2012-07-15 18:44           ` Raffaele Ricciardi
2012-07-15 21:11             ` B. T. Raven
2012-07-15 22:55               ` Aurélien Aptel

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.