help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bounds for strings with - between subwords


From: Christopher Dimech
Subject: Re: bounds for strings with - between subwords
Date: Fri, 7 May 2021 01:37:54 +0200


> Sent: Friday, May 07, 2021 at 10:49 AM
> From: "Emanuel Berg via Users list for the GNU Emacs text editor" 
> <help-gnu-emacs@gnu.org>
> To: help-gnu-emacs@gnu.org
> Subject: Re: bounds for strings with - between subwords
>
> steve-humphreys wrote:
>
> > I am using the following function that gets me the bounds
> > for each word.
> >
> > But I have strings like
> >
> > bibl-bellerive-etal-2016
> >
> > which I want to get the bounds for strings with -
> > between subwords.
>
> I'm not following 100% but you can add digits and a dash to
> your below work if that helps?
>
> (skip-chars-forward "[:alnum:]-")
>
> > (defun alpha-bounds ()
> >    "Gets bounds of a subword unit defined by regular expression [a-zA-Z]."
> >    (let ( ($bounds nil) $ma $mb )
> >       (skip-chars-backward "[:alpha:]")
> >       (setq $ma (point))
> >       (skip-chars-forward "[:alpha:]")
> >       (setq $mb (point))
> >       (setq $bounds (bounds-of-thing-at-point 'word))
> >       (cons $ma $mb) ))
>
> You can put all that in the `let' to avoid the use of `setq'.
>
> Also $bounds doesn't seem to do anything?

bounds are used in another function.  You can see there is (cons $ma $mb) at 
the end,
which is used as output when you call "alpha-bounds".

> And what's the purpose of the $?

I use $ no tell me the variable is local and not being modified from outside.
It is coming from the $1, $2, $3, ... function parameter idea.

> --
> underground experts united
> https://dataswamp.org/~incal
>
>
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]