unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Christopher Dimech <dimech@gmx.com>
To: Jean Louis <bugs@gnu.support>
Cc: Eric Abrahamsen <eric@ericabrahamsen.net>,
	Skip Montanaro <skip.montanaro@gmail.com>,
	Help Gnu Emacs <help-gnu-emacs@gnu.org>
Subject: Re: Determining existence of text following point
Date: Tue, 18 May 2021 12:08:42 +0200	[thread overview]
Message-ID: <trinity-02e5c765-73a4-42ad-82ed-f4446927204c-1621332522549@3c-app-mailcom-bs13> (raw)
In-Reply-To: <YKOO77V7sZg/8tRU@protected.localdomain>

How is it that the following returns nil?

(setq sa (string-match "[^[:blank:]]" "     "))


> Sent: Tuesday, May 18, 2021 at 9:54 PM
> From: "Jean Louis" <bugs@gnu.support>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: "Eric Abrahamsen" <eric@ericabrahamsen.net>, "Skip Montanaro" <skip.montanaro@gmail.com>, "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
> Subject: Re: Determining existence of text following point
>
> * Christopher Dimech <dimech@gmx.com> [2021-05-18 12:31]:
> > > Sent: Tuesday, May 18, 2021 at 8:56 PM
> > > From: "Jean Louis" <bugs@gnu.support>
> > > To: "Eric Abrahamsen" <eric@ericabrahamsen.net>
> > > Cc: "Skip Montanaro" <skip.montanaro@gmail.com>, "Help Gnu Emacs" <help-gnu-emacs@gnu.org>, michael-franzese@gmx.com
> > > Subject: Re: Determining existence of text following point
> > >
> > > * Eric Abrahamsen <eric@ericabrahamsen.net> [2021-05-18 03:09]:
> > > > michael-franzese@gmx.com writes:
> > > >
> > > > > But if there are only empty spaces it is ok too.
> > >
> > > (defun my-insert-on-empty-end-of-line (s)
> > >   (let ((line-cut (buffer-substring-no-properties (point) (line-end-position))))
> > >     (when (or (not (string-match "[^[:blank:]]" line-cut)) (eolp))
> > >       (insert s))))
> > 
> > I understand that "string-match" returns index of start of first blank match.
> > 
> > Suppose the cursor is just after the first period.  Then because there is still
> > text left on the line, the string "s" is not inserted.  The text should only be
> > inserted when the rest of the line is blank.
> > 
> > A neutrino is a fermion.  Some more text here.
> 
> That (not (string-match "[^[:blank:]]" line-cut)) means it is true if
> nothing is found that is not blank space.
> 
> Test it here where is the block (remove block):
> 
> (string-match "[^[:blank:]]" 
> 	      (buffer-substring-no-properties (point) (line-end-position)))█   ;; something
> 
> (not (string-match "[^[:blank:]]" 
> 		   (buffer-substring-no-properties (point) (line-end-position))))█   ;; something
> 
> (not (string-match "[^[:blank:]]" 
> 		   (buffer-substring-no-properties (point) (line-end-position))))█ ⇒ t
> 
> There is blank space after last parenthesis here, you can test:
> 
> (not (string-match "[^[:blank:]]" 
> 		   (buffer-substring-no-properties (point) (line-end-position))))        
> 
> -- 
> Jean
> 
> Take action in Free Software Foundation campaigns:
> https://www.fsf.org/campaigns
> 
> Sign an open letter in support of Richard M. Stallman
> https://stallmansupport.org/
> https://rms-support-letter.github.io/
> 
>



  reply	other threads:[~2021-05-18 10:08 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-17 21:46 Determining existence of text following point michael-franzese
2021-05-17 22:02 ` Skip Montanaro
2021-05-17 22:31   ` michael-franzese
2021-05-17 23:05     ` Eric Abrahamsen
2021-05-17 23:15       ` michael-franzese
2021-05-17 23:36         ` Skip Montanaro
2021-05-18  0:09         ` Eric Abrahamsen
2021-05-18  0:37           ` michael-franzese
2021-05-18  8:24           ` michael-franzese
2021-05-18  8:56           ` Jean Louis
2021-05-18  9:31             ` Christopher Dimech
2021-05-18  9:42               ` Jean Louis
2021-05-18  9:54               ` Jean Louis
2021-05-18 10:08                 ` Christopher Dimech [this message]
2021-05-18 11:07                   ` tomas
2021-05-18 11:26                     ` Christopher Dimech
2021-05-18 11:56                       ` Jean Louis
2021-05-18 12:23                         ` Christopher Dimech
2021-05-18 12:35                           ` tomas
2021-05-18 12:50                             ` Christopher Dimech
2021-05-18 12:02                       ` tomas
2021-05-18 12:15                         ` Christopher Dimech
2021-05-18 12:27                           ` tomas
2021-05-18 12:43                             ` Christopher Dimech
2021-05-18 12:44                             ` Jean Louis
2021-05-18 12:28                         ` Christopher Dimech
2021-05-18 12:47                           ` Jean Louis
2021-05-18 20:50             ` michael-franzese
2021-05-18 22:04               ` Jean Louis
2021-05-18 22:17               ` Jean Louis
2021-05-19  7:28                 ` michael-franzese
2021-05-19  8:05                   ` michael-franzese
2021-05-19 10:23                   ` Jean Louis
2021-05-19 10:32                     ` michael-franzese
2021-05-19 12:31                     ` michael-franzese
2021-05-17 23:53       ` michael-franzese
2021-05-18  8:47     ` Jean Louis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=trinity-02e5c765-73a4-42ad-82ed-f4446927204c-1621332522549@3c-app-mailcom-bs13 \
    --to=dimech@gmx.com \
    --cc=bugs@gnu.support \
    --cc=eric@ericabrahamsen.net \
    --cc=help-gnu-emacs@gnu.org \
    --cc=skip.montanaro@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).