From: jan via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 41185@debbugs.gnu.org
Subject: bug#41185: highlight-regexp not working properly
Date: Mon, 11 May 2020 12:24:55 +0100 [thread overview]
Message-ID: <CADJx9LcLOrbbUmL4VvqWoMDWc9Mt2D2b8sY3Kg=dPTJuwo84ng@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 6058 bytes --]
Hi,
was trying to pick out relevant preprocessor bits using highlight
regexp. Unexpected result. To reproduce
start emacs -Q
create a buffer, put it in C mode (M-x c-mode)
Yank in
# ifdef VDW_CUTOFF_CHECK
wco_vdw_S0 = (rsq_S0 < rcvdw2_S);
wco_vdw_S1 = (rsq_S1 < rcvdw2_S);
# ifndef HALF_LJ
wco_vdw_S2 = (rsq_S2 < rcvdw2_S);
wco_vdw_S3 = (rsq_S3 < rcvdw2_S);
# endif
# else
# define wco_vdw_S0 wco_S0
# define wco_vdw_S1 wco_S1
# define wco_vdw_S2 wco_S2
# define wco_vdw_S3 wco_S3
# endif
Try to regexp-highlight particular preprocessor use:
M-s h r def HALF_LJ[^^]+?# endif RET
(the [^^] is because I want it to match multiline, and I don't expect
any carets in the text, so I negate that to allow newline matches and
make it lazy to pick out the shortest +? It's sloppy but ok here)
Does not highlight anything (see
highlight-requested-but-no-highliting-occurred.PNG) - NOPE! MY
MISTAKE! Found out why while writing this - see note at end about lax
whitespace matching - my misunderstanding - the following still
applies though.
Now manually *type in* some text that should match above it:
def HALF_LJ
hello buglist
# endif
That doesn't get highlighted either.
Now put the cursor straight after the HALF_LJ and press delete to
remove the carriage return and get this:
def HALF_LJhello buglist
# endif
and highlight appears.
Press return to restore it to
def HALF_LJ
hello buglist
# endif
and the whole phrase stays highlighted (See
2.highlighted-after-delete-return-then-add-return.PNG)
It's possible to get it partially highlighted, which doesn't make
sense, see 3. improperly-partially-highlighted.PNG
Perhaps this is happening just in C-mode? Try it in scratch. It also
works intermittently, can also get incorrect partial highlight, see 4.
Similarly-in-scratch-buffer (note that the # endif is not yellow).
Note that the matching text further down (the lump of code I said to
yank in, above) *may* or *may not* get highlighted.
If I play with it, deleteing and adding back stuff, sometimes it will,
sometimes it gets partially highlighted - this is so even if I correct
for my misunderstanding - see next para.
(Note if you're playing around, I relied on lax whitespace matching
<https://www.emacswiki.org/emacs/RegularExpression>
"Idiosyncrasies of Emacs Regular Expressions - In an interactive
search, a space character stands for one or more whitespace
characters..."
however I got tripped up by the fact that lax whitespace matching does
not apply to highlight-regexp).
I can also get some degree of similar weirdness in ubuntu 19.10
(started normally, that is without -Q) in both *scratch* and c-mode.
jan
In GNU Emacs 26.3 (build 1, x86_64-w64-mingw32)
of 2019-08-29 built on CIRROCUMULUS
Repository revision: 96dd0196c28bc36779584e47fffcca433c9309cd
Windowing system distributor 'Microsoft Corp.', version 6.1.7601
Recent messages:
Mark set [3 times]
Auto-saving...done
Mark set [4 times]
Auto-saving...done
Auto-saving...done
Auto-saving...done
Mark set [2 times]
Auto-saving...done
Saving file c:/Users/jan/Desktop/highlight-regexp-bug/bug.txt...
Wrote c:/Users/jan/Desktop/highlight-regexp-bug/bug.txt
Configured using:
'configure --without-dbus --host=x86_64-w64-mingw32
--without-compress-install 'CFLAGS=-O2 -static -g3''
Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS THREADS LCMS2
Important settings:
value of $LANG: ENG
locale-coding-system: cp1252
Major mode: Text
Minor modes in effect:
desktop-save-mode: t
tooltip-mode: t
global-eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
Load-path shadows:
None found.
Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg gnus-util rmail rmail-loaddefs
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr
mail-utils misearch multi-isearch dabbrev browse-url url-util elec-pair
helm-gtags subr-x pulse which-func imenu helm-files helm-buffers
helm-occur helm-tags helm-locate helm-grep helm-regexp format-spec
helm-utils helm-help helm-types helm easy-mmode helm-source eieio-compat
helm-multi-match helm-lib async edmacro kmacro desktop frameset
cus-start cus-load finder-inf info package easymenu epg-config
url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache url-vars seq byte-opt gv bytecomp
byte-compile cconv cl-loaddefs cl-lib time-date mule-util tooltip eldoc
electric uniquify ediff-hook vc-hooks lisp-float-type mwheel dos-w32
ls-lisp disp-table term/w32-win w32-win w32-vars term/common-win
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock
font-lock syntax facemenu font-core term/tty-colors frame cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote threads w32notify w32
lcms2 multi-tty make-network-process emacs)
Memory information:
((conses 16 162243 12928)
(symbols 48 26155 1)
(miscs 40 61 209)
(strings 32 49502 1493)
(string-bytes 1 1501682)
(vectors 16 23149)
(vector-slots 8 594667 6206)
(floats 8 89 268)
(intervals 56 242 0)
(buffers 992 12))
[-- Attachment #2: 1. highlight-requested-but-no-highliting-occurred.PNG --]
[-- Type: image/png, Size: 18847 bytes --]
[-- Attachment #3: 2.highlighted-after-delete-return-then-add-return.PNG --]
[-- Type: image/png, Size: 17923 bytes --]
[-- Attachment #4: 3. improperly-partially-highlighted.PNG --]
[-- Type: image/png, Size: 12195 bytes --]
[-- Attachment #5: 4. Similarly-in-scratch-buffer.PNG --]
[-- Type: image/png, Size: 8445 bytes --]
next reply other threads:[~2020-05-11 11:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-11 11:24 jan via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2020-05-11 22:55 ` bug#41185: highlight-regexp not working properly Michael Heerdegen
2021-06-13 11:37 ` bug#41185: highlight-regexp not working properly for multiline-matching regexps Lars Ingebrigtsen
2021-06-13 16:37 ` Michael Heerdegen
2021-06-13 17:11 ` Lars Ingebrigtsen
2021-06-15 13:25 ` jan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-06-15 23:37 ` Michael Heerdegen
2021-06-16 5:20 ` jan via Bug reports for GNU Emacs, the Swiss army knife of text editors
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='CADJx9LcLOrbbUmL4VvqWoMDWc9Mt2D2b8sY3Kg=dPTJuwo84ng@mail.gmail.com' \
--to=bug-gnu-emacs@gnu.org \
--cc=41185@debbugs.gnu.org \
--cc=rtm443x@googlemail.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.
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).