unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to detect end of buffer? [was: Deleting a word using keybinding]
@ 2020-10-15 21:46 Drew Adams
  2020-10-15 22:12 ` Christopher Dimech
  0 siblings, 1 reply; 8+ messages in thread
From: Drew Adams @ 2020-10-15 21:46 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: Help Gnu Emacs, Thien-Thi Nguyen

> >    Is there a way to detect end of buffer?
> 
> Function `eobp'

FYI, for asking Emacs itself:

`C-h d end buffer' or `C-h d buffer end'
finds `eobp' for you.  That's command
`apropos-documentation'.  It searches doc
strings for the words or regexp you give it.

(Actually, it doesn't find it with Emacs 26,
for some reason.  But it does with Emacs 27.)



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

* Re: How to detect end of buffer? [was: Deleting a word using keybinding]
  2020-10-15 21:46 How to detect end of buffer? [was: Deleting a word using keybinding] Drew Adams
@ 2020-10-15 22:12 ` Christopher Dimech
  2020-10-15 22:38   ` Stephen Berman
  2020-10-15 23:02   ` Drew Adams
  0 siblings, 2 replies; 8+ messages in thread
From: Christopher Dimech @ 2020-10-15 22:12 UTC (permalink / raw)
  To: Drew Adams; +Cc: Help Gnu Emacs, Thien-Thi Nguyen


   I think I have done it now.  But I would be happy should someone spot
   some problem.

   Regarding the condition below, I think it takes care of the ranges
   appropriately,
   so that I can go to the beginning of the word. It should determine
   whether the
   current point is on a number or a letter.

   if (looking-at "[0-9a-zA-Z]")

   Sent: Thursday, October 15, 2020 at 11:46 PM
   From: "Drew Adams" <drew.adams@oracle.com>
   To: "Christopher Dimech" <dimech@gmx.com>
   Cc: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>, "Thien-Thi Nguyen"
   <ttn@gnuvola.org>
   Subject: How to detect end of buffer? [was: Deleting a word using
   keybinding]
   > > Is there a way to detect end of buffer?
   >
   > Function `eobp'
   FYI, for asking Emacs itself:
   `C-h d end buffer' or `C-h d buffer end'
   finds `eobp' for you. That's command
   `apropos-documentation'. It searches doc
   strings for the words or regexp you give it.
   (Actually, it doesn't find it with Emacs 26,
   for some reason. But it does with Emacs 27.)


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

* Re: How to detect end of buffer? [was: Deleting a word using keybinding]
  2020-10-15 22:12 ` Christopher Dimech
@ 2020-10-15 22:38   ` Stephen Berman
  2020-10-16  4:12     ` Stefan Monnier
  2020-10-15 23:02   ` Drew Adams
  1 sibling, 1 reply; 8+ messages in thread
From: Stephen Berman @ 2020-10-15 22:38 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: Help Gnu Emacs, Thien-Thi Nguyen

On Fri, 16 Oct 2020 00:12:01 +0200 Christopher Dimech <dimech@gmx.com> wrote:

>    I think I have done it now.  But I would be happy should someone spot
>    some problem.
>
>    Regarding the condition below, I think it takes care of the ranges
>    appropriately,
>    so that I can go to the beginning of the word. It should determine
>    whether the
>    current point is on a number or a letter.
>
>    if (looking-at "[0-9a-zA-Z]")

That regexp recognizes only ASCII letters.  If you want any letters
supported by the current locale, use [[:alnum:]].

Steve Beramn



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

* RE: How to detect end of buffer? [was: Deleting a word using keybinding]
  2020-10-15 22:12 ` Christopher Dimech
  2020-10-15 22:38   ` Stephen Berman
@ 2020-10-15 23:02   ` Drew Adams
  2020-10-15 23:54     ` Christopher Dimech
  1 sibling, 1 reply; 8+ messages in thread
From: Drew Adams @ 2020-10-15 23:02 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: Help Gnu Emacs, Thien-Thi Nguyen

> determine whether the
current point is on a number or a letter.

> if (looking-at "[0-9a-zA-Z]")

As Stephen said, that matches only a decimal numeral or an ASCII letter.  Dunno whether that's what you want.

And if you just want a test, and don't need to also set the match data for some ulterior purpose, then use `looking-at-p', not `looking-at'.



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

* Re: RE: How to detect end of buffer? [was: Deleting a word using keybinding]
  2020-10-15 23:02   ` Drew Adams
@ 2020-10-15 23:54     ` Christopher Dimech
  2020-10-16  1:39       ` Drew Adams
  0 siblings, 1 reply; 8+ messages in thread
From: Christopher Dimech @ 2020-10-15 23:54 UTC (permalink / raw)
  To: Drew Adams; +Cc: Help Gnu Emacs, Thien-Thi Nguyen

   It should be ok, because I am usihg the check to know if I am in the
   middle of a word
   rather than at the beginning. I then just move to the beginning of the
   word before
   killing the work. Otherwise I simply call (kill word).

   Sent: Friday, October 16, 2020 at 1:02 AM
   From: "Drew Adams" <drew.adams@oracle.com>
   To: "Christopher Dimech" <dimech@gmx.com>
   Cc: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>, "Thien-Thi Nguyen"
   <ttn@gnuvola.org>
   Subject: RE: How to detect end of buffer? [was: Deleting a word using
   keybinding]
   > determine whether the
   current point is on a number or a letter.
   > if (looking-at "[0-9a-zA-Z]")
   As Stephen said, that matches only a decimal numeral or an ASCII
   letter. Dunno whether that's what you want.
   And if you just want a test, and don't need to also set the match data
   for some ulterior purpose, then use `looking-at-p', not `looking-at'.


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

* RE: RE: How to detect end of buffer? [was: Deleting a word using keybinding]
  2020-10-15 23:54     ` Christopher Dimech
@ 2020-10-16  1:39       ` Drew Adams
  0 siblings, 0 replies; 8+ messages in thread
From: Drew Adams @ 2020-10-16  1:39 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: Help Gnu Emacs, Thien-Thi Nguyen

> It should be ok, because I am usihg the check to know if I am in the middle of a word rather than at the beginning. I then just move to the beginning of the word before killing the work. Otherwise I simply call (kill word).

Then it sounds like you don't need `looking-at' and you can just use `looking-at-p'.



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

* Re: How to detect end of buffer? [was: Deleting a word using keybinding]
  2020-10-15 22:38   ` Stephen Berman
@ 2020-10-16  4:12     ` Stefan Monnier
  2020-10-16 12:18       ` Stephen Berman
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2020-10-16  4:12 UTC (permalink / raw)
  To: help-gnu-emacs

> That regexp recognizes only ASCII letters.  If you want any letters
> supported by the current locale, use [[:alnum:]].

Actually, Emacs's character classes aren't quite like POSIX's: they
don't pay attention to the locale (at least, by and large).


        Stefan




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

* Re: How to detect end of buffer? [was: Deleting a word using keybinding]
  2020-10-16  4:12     ` Stefan Monnier
@ 2020-10-16 12:18       ` Stephen Berman
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen Berman @ 2020-10-16 12:18 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

On Fri, 16 Oct 2020 00:12:07 -0400 Stefan Monnier <monnier@iro.umontreal.ca> wrote:

>> That regexp recognizes only ASCII letters.  If you want any letters
>> supported by the current locale, use [[:alnum:]].
>
> Actually, Emacs's character classes aren't quite like POSIX's: they
> don't pay attention to the locale (at least, by and large).

Thanks, didn't know that.  I'd just tested that [[:alnum:]] recognizes
non-ASCII characters and assumed it was because of the locale
(en_US.UTF-8), but now I checked the code and IIUC it uses
unicode-category-table without reference to the locale.

Steve Berman



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

end of thread, other threads:[~2020-10-16 12:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-15 21:46 How to detect end of buffer? [was: Deleting a word using keybinding] Drew Adams
2020-10-15 22:12 ` Christopher Dimech
2020-10-15 22:38   ` Stephen Berman
2020-10-16  4:12     ` Stefan Monnier
2020-10-16 12:18       ` Stephen Berman
2020-10-15 23:02   ` Drew Adams
2020-10-15 23:54     ` Christopher Dimech
2020-10-16  1:39       ` Drew Adams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).