unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Why does this re-search forward fail?
@ 2021-04-20 13:56 Arthur Miller
  2021-04-20 14:13 ` Andreas Schwab
  2021-04-20 14:49 ` Stefan Monnier
  0 siblings, 2 replies; 5+ messages in thread
From: Arthur Miller @ 2021-04-20 13:56 UTC (permalink / raw)
  To: emacs-devel

[-- 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 --]

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

end of thread, other threads:[~2021-04-20 16:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-20 13:56 Why does this re-search forward fail? Arthur Miller
2021-04-20 14:13 ` Andreas Schwab
2021-04-20 14:55   ` Arthur Miller
2021-04-20 14:49 ` Stefan Monnier
2021-04-20 16:46   ` Arthur Miller

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).