all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Arthur Miller <arthur.miller@live.com>
To: emacs-devel@gnu.org
Subject: Why does this re-search forward fail?
Date: Tue, 20 Apr 2021 15:56:07 +0200	[thread overview]
Message-ID: <AM9PR09MB4977A8A5A22A490D5B1C62E296489@AM9PR09MB4977.eurprd09.prod.outlook.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1557 bytes --]


Hello,

in rare and spare moments when I am not feeding the cutiest best of all
cute beasts or changing her diapers, I was playing with a little idea to
hide org-babel markers in my init file. I wrote a small minor mode for
this, which I have attached in this mail. There is a small problem with
the loop, where the main action is happening:

#+begin_src emacs-lisp
(while (re-search-forward hbm--src-marker-re (eobp) t)
          (hbm--update-line visibility))
#+end_src

The RE I search for is:

(defvar hbm--src-marker-re "^[ \t]*#\\+\\|begin_src\\|end_src")

What is happeneing is that for some strange reason, the search jumps
over some lines or stop working. If I disable/enable the mode, same
lines that failed, work.

I also wrote a small aritificial test, that will generate 200 src blocks
in a test file, and what I see there is that search fails after ~ 55
blocks, every time. Since all 200 blocks are machine generated I see no
reason why search would fail.

I also tested to iterate through the file with more explicit loop that
went line by line through entire line, but with same result.

#+begin-src emacs-lisp
(defun hbm--update-markers (visibility)
  (save-excursion
    (goto-char (point-min))
    (with-silent-modifications
      (while (not (eobp))
        (beginning-of-line)
        (when (re-search-forward hbm--src-marker-re (eobp) t)
          (hbm--update-line visibility))
        (forward-line)))))
#+end_src

Any idea?

The Emacs at hand is 27.1 (build 1, x86_64-w64-mingw32) of
2020-08-21. The test was done with -Q option.


[-- Attachment #2: ob-hide-markers.el --]
[-- Type: application/emacs-lisp, Size: 4953 bytes --]

             reply	other threads:[~2021-04-20 13:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-20 13:56 Arthur Miller [this message]
2021-04-20 14:13 ` Why does this re-search forward fail? Andreas Schwab
2021-04-20 14:55   ` Arthur Miller
2021-04-20 14:49 ` Stefan Monnier
2021-04-20 16:46   ` Arthur Miller

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

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

  git send-email \
    --in-reply-to=AM9PR09MB4977A8A5A22A490D5B1C62E296489@AM9PR09MB4977.eurprd09.prod.outlook.com \
    --to=arthur.miller@live.com \
    --cc=emacs-devel@gnu.org \
    /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.
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.