* Does word under cursor match pattern?
@ 2010-08-23 11:18 Paulo J. Matos
2010-08-23 11:56 ` Lennart Borgman
2010-08-23 12:37 ` Deniz Dogan
0 siblings, 2 replies; 5+ messages in thread
From: Paulo J. Matos @ 2010-08-23 11:18 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
I am trying to know if a word under the cursor matched a pattern
([Bb]-?[0-9]+). My idea was:
- Select region with word under cursor
- Transform region into string
- Apply regexp on string
This has one problem: I can't seem to find a function to transform a
region into a string. On the other hand maybe I can work with the region
directly.
Any tips on how to do this?
Cheers,
--
PMatos
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Does word under cursor match pattern?
2010-08-23 11:18 Does word under cursor match pattern? Paulo J. Matos
@ 2010-08-23 11:56 ` Lennart Borgman
2010-08-23 12:43 ` Paulo J. Matos
2010-08-23 12:37 ` Deniz Dogan
1 sibling, 1 reply; 5+ messages in thread
From: Lennart Borgman @ 2010-08-23 11:56 UTC (permalink / raw)
To: Paulo J. Matos; +Cc: help-gnu-emacs
On Mon, Aug 23, 2010 at 1:18 PM, Paulo J. Matos <pocmatos@gmail.com> wrote:
>
> This has one problem: I can't seem to find a function to transform a
> region into a string.
buffer-substring-no-properties?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Does word under cursor match pattern?
2010-08-23 11:56 ` Lennart Borgman
@ 2010-08-23 12:43 ` Paulo J. Matos
0 siblings, 0 replies; 5+ messages in thread
From: Paulo J. Matos @ 2010-08-23 12:43 UTC (permalink / raw)
To: help-gnu-emacs
Lennart Borgman <lennart.borgman@gmail.com> writes:
> On Mon, Aug 23, 2010 at 1:18 PM, Paulo J. Matos <pocmatos@gmail.com> wrote:
>>
>> This has one problem: I can't seem to find a function to transform a
>> region into a string.
>
> buffer-substring-no-properties?
>
That's it! Thanks. :)
Cheers,
--
PMatos
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Does word under cursor match pattern?
2010-08-23 11:18 Does word under cursor match pattern? Paulo J. Matos
2010-08-23 11:56 ` Lennart Borgman
@ 2010-08-23 12:37 ` Deniz Dogan
1 sibling, 0 replies; 5+ messages in thread
From: Deniz Dogan @ 2010-08-23 12:37 UTC (permalink / raw)
To: Paulo J. Matos; +Cc: help-gnu-emacs
2010/8/23 Paulo J. Matos <pocmatos@gmail.com>:
> Hi,
>
> I am trying to know if a word under the cursor matched a pattern
> ([Bb]-?[0-9]+). My idea was:
> - Select region with word under cursor
> - Transform region into string
> - Apply regexp on string
>
> This has one problem: I can't seem to find a function to transform a
> region into a string. On the other hand maybe I can work with the region
> directly.
>
> Any tips on how to do this?
>
You can use e.g. (thing-at-point 'word). This would return the string
with properties and such, if you want that.
--
Deniz Dogan
^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <mailman.6.1282562668.29657.help-gnu-emacs@gnu.org>]
* Re: Does word under cursor match pattern?
[not found] <mailman.6.1282562668.29657.help-gnu-emacs@gnu.org>
@ 2010-08-23 11:58 ` Marc Mientki
0 siblings, 0 replies; 5+ messages in thread
From: Marc Mientki @ 2010-08-23 11:58 UTC (permalink / raw)
To: help-gnu-emacs
Am 23.08.2010 13:18, schrieb Paulo J. Matos:
> Hi,
>
> I am trying to know if a word under the cursor matched a pattern
> ([Bb]-?[0-9]+).
>
> Any tips on how to do this?
This is a job for looking-at.
,----[ C-h f looking-at RET ]
| looking-at is a built-in function in `C source code'.
|
| (looking-at REGEXP)
|
| Return t if text after point matches regular expression REGEXP.
| This function modifies the match data that `match-beginning',
| `match-end' and `match-data' access; save and restore the match
| data if you want to preserve them.
`----
regards
Marc
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-08-23 12:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-23 11:18 Does word under cursor match pattern? Paulo J. Matos
2010-08-23 11:56 ` Lennart Borgman
2010-08-23 12:43 ` Paulo J. Matos
2010-08-23 12:37 ` Deniz Dogan
[not found] <mailman.6.1282562668.29657.help-gnu-emacs@gnu.org>
2010-08-23 11:58 ` Marc Mientki
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.