* bug#59953: 28.2; c type modifiers only work as prefixes for font-lock, cc-mode
@ 2022-12-10 22:31 Chris Hecker
2023-10-14 15:52 ` Alan Mackenzie
0 siblings, 1 reply; 3+ messages in thread
From: Chris Hecker @ 2022-12-10 22:31 UTC (permalink / raw)
To: 59953
[-- Attachment #1.1: Type: text/plain, Size: 6676 bytes --]
cc-mode doesn't seem to recognize that c type specifiers can come in any
order (and I prefer them after so they're modifying the base type), so
the highlighting doesn't work right for the variable name. Here's an
example in a struct, works the same way in a function:
struct foo {
unsigned int One;
int unsigned Two;
};
emacs -Q results:
I couldn't see an easy way of fixing this (besides just adding all the
combos to *-font-lock-extra-types). Seems like there needs to be a
c-primitive-type-postfix-kwds variable to do this right?
Thanks,
Chris
In GNU Emacs 28.2 (build 2, x86_64-w64-mingw32)
of 2022-09-13 built on AVALON
Windowing system distributor 'Microsoft Corp.', version 10.0.19044
System Description: Microsoft Windows 10 Home (v10.0.2009.19044.2251)
Configured using:
'configure --with-modules --without-dbus --with-native-compilation
--without-compress-install CFLAGS=-O2'
Configured features:
ACL GIF GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP
NOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
XPM ZLIB
Important settings:
value of $LANG: ENU
locale-coding-system: cp1252
Major mode: ELisp/l
Minor modes in effect:
hexl-follow-ascii: t
minibuffer-depth-indicate-mode: t
icicle-mode: t
which-function-mode: t
shell-dirtrack-mode: t
winner-mode: t
global-eldoc-mode: t
eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
buffer-read-only: t
column-number-mode: t
line-number-mode: t
indent-tabs-mode: t
Load-path shadows:
~/emacs/lisp/json hides
c:/apps/emacs/emacs-28.2/share/emacs/28.2/lisp/json
~/emacs/lisp/css-mode hides
c:/apps/emacs/emacs-28.2/share/emacs/28.2/lisp/textmodes/css-mode
Features:
(shadow sort emacsbug make-mode js align goto-addr nroff-mode lpr
realgud-gdb realgud:gdb-track-mode realgud:gdb-init realgud-track-mode
realgud-backtrace-mode realgud:gdb-core realgud:run realgud-track
realgud-shortkey realgud-menu realgud-eval realgud-init realgud-file
esh-mode realgud-cmds realgud-core realgud-reset realgud-bp
realgud-bp-image-data realgud-lang realgud-send realgud-window
realgud-buffer-helper realgud-buffer-breakpoint realgud-buffer-backtrace
realgud-locals realgud-buffer-locals realgud-buffer-command
realgud-buffer-info realgud-regexp realgud-lochist realgud-loc
realgud-buffer-source realgud-key realgud-custom key realgud-follow
loc-changes org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro
org-footnote org-src ob-comint org-pcomplete org-list org-faces
org-entities org-version ob-emacs-lisp ob-core ob-eval org-table
oc-basic bibtex ol org-keys oc org-compat org-macs org-loaddefs cal-menu
calendar cal-loaddefs realgud-fringe realgud-helper realgud-utils eshell
esh-cmd esh-ext esh-opt esh-proc esh-io esh-arg esh-module esh-groups
esh-util load-relative cl-print eieio-opt speedbar ezimage dframe
shortdoc help-fns nhexl-mode noutline outline pcase find-func autoload
radix-tree lisp-mnt mm-archive gnutls network-stream url-http url-gw nsm
url-cache url-auth ruler-mode hl-line mule-util hexl bat-mode mail-extr
meson-mode smie conf-mode find-file dabbrev calc-arith calccomp calc-bin
calc-alg calc-menu misearch multi-isearch add-log vc-bzr cap-words
superword subword face-remap etags-select etags fileloop generator xref
project mb-depth two-column bookmark icicles icicles-mode comp comp-cstr
cl-extra icicles-cmd2 icicles-cmd1 warnings icicles-mcmd doremi
icicles-fn icicles-var icicles-opt edmacro ffap kmacro cus-theme
thingatpt icicles-face hexrgb calc-vec calc-forms calc-misc calc-aent
calc-prog calc-ext calc calc-loaddefs rect calc-macs vcl-mode cc-langs
mel-mode prop-mode pfx-mode message rmc puny help-mode easy-mmode dired+
image-dired image-mode exif image-file image-converter dired-aux dired-x
dired dired-loaddefs rfc822 mml mml-sec epa epg rfc6068 epg-config
gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader smtpmail sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils ibuffer
ibuffer-loaddefs caml-font 7z-arc-mode cperl-mode rx facemenu fakecygpty
matlab derived tempo which-func cus-edit pp wid-edit grep cus-load
cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
cc-vars cc-defs compile text-property-search vc vc-dispatcher imenu
browse-kill-ring view ediff ediff-merg ediff-mult ediff-wind ediff-diff
ediff-help ediff-init ediff-util checker-allout checker-outline hex-util
hmac-sha1 tramp tramp-loaddefs trampver tramp-integration files-x
tramp-compat shell pcomplete comint ansi-color parse-time iso8601
time-date format-spec web-mode advice tex-site server info winner ring
yaml-mode ispell finder-inf realgud-recursive-autoloads package
browse-url url url-proxy url-privacy url-expand url-methods url-history
url-cookie url-domsuf url-util mailcap url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache json subr-x map url-vars seq byte-opt gv bytecomp
byte-compile cconv cl-loaddefs cl-lib iso-transl tooltip eldoc paren
electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode 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 lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer 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 emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window 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 native-compile emacs)
Memory information:
((conses 16 2583460 283035)
(symbols 48 48033 35)
(strings 32 332543 29010)
(string-bytes 1 11657043)
(vectors 16 124331)
(vector-slots 8 2675678 261302)
(floats 8 559 942)
(intervals 56 280393 2040)
(buffers 992 101))
[-- Attachment #1.2: Type: text/html, Size: 9119 bytes --]
[-- Attachment #2: lg3yhp5z.png --]
[-- Type: image/png, Size: 9201 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#59953: 28.2; c type modifiers only work as prefixes for font-lock, cc-mode
2022-12-10 22:31 bug#59953: 28.2; c type modifiers only work as prefixes for font-lock, cc-mode Chris Hecker
@ 2023-10-14 15:52 ` Alan Mackenzie
2023-11-24 12:29 ` Alan Mackenzie
0 siblings, 1 reply; 3+ messages in thread
From: Alan Mackenzie @ 2023-10-14 15:52 UTC (permalink / raw)
To: Chris Hecker; +Cc: 59953, acm
[-- Attachment #1: Type: text/plain, Size: 1982 bytes --]
Hello, Chris.
Thanks for taking the trouble to file this bug, but sorry it's been such
a long time without a response.
I've now looked at the bug and it wasn't that difficult to patch. If you
don't mind too much, I'll put your test file into the CC Mode test suite,
having added one line ("long int unsigned Three;") to it.
Would you please now apply the attached patch to your current Emacs (the
file cc-engine.el is in lisp/progmodes), byte compile cc-engine.el (or
just the whole of CC Mode), load the result into your Emacs and try it
out on your real source code. Then please confirm to me that the bug is
fixed, or tell me what's still not right. Thanks! (If you want any help
in the patching of byte compilation, feel free to send me private email.)
On Sat, Dec 10, 2022 at 22:31:18 +0000, Chris Hecker wrote:
> cc-mode doesn't seem to recognize that c type specifiers can come in
> any order (and I prefer them after so they're modifying the base type),
> so the highlighting doesn't work right for the variable name. Here's
> an example in a struct, works the same way in a function:
> struct foo {
> unsigned int One;
> int unsigned Two;
> };
> emacs -Q results:
> [cid:emf20eaa32-35e0-4df0-a1fb-4e6ad9397939@checker-blade15]
> I couldn't see an easy way of fixing this (besides just adding all the
> combos to *-font-lock-extra-types). Seems like there needs to be a
> c-primitive-type-postfix-kwds variable to do this right?
> Thanks,
> Chris
> In GNU Emacs 28.2 (build 2, x86_64-w64-mingw32)
> Â of 2022-09-13 built on AVALON
> Windowing system distributor 'Microsoft Corp.', version 10.0.19044
> System Description: Microsoft Windows 10 Home (v10.0.2009.19044.2251)
> Configured using:
> Â 'configure --with-modules --without-dbus --with-native-compilation
> Â --without-compress-install CFLAGS=-O2'
> Configured features:
[ .... ]
--
Alan Mackenzie (Nuremberg, Germany).
[-- Attachment #2: diff.20231014.diff --]
[-- Type: text/plain, Size: 2574 bytes --]
diff -r 97876aef276f cc-engine.el
--- a/cc-engine.el Fri Oct 13 14:13:43 2023 +0000
+++ b/cc-engine.el Sat Oct 14 15:51:43 2023 +0000
@@ -9461,37 +9461,47 @@
(or c-promote-possible-types (eq res t)))
(c-record-type-id (cons (match-beginning 1) (match-end 1))))
- (if (and c-opt-type-component-key
+ (cond
+ ((and c-opt-type-component-key
(save-match-data
(looking-at c-opt-type-component-key)))
;; There might be more keywords for the type.
- (let (safe-pos)
- (c-forward-keyword-clause 1 t)
- (while (progn
- (setq safe-pos (point))
- (c-forward-syntactic-ws)
- (looking-at c-opt-type-component-key))
- (when (and c-record-type-identifiers
- (looking-at c-primitive-type-key))
- (c-record-type-id (cons (match-beginning 1)
- (match-end 1))))
- (c-forward-keyword-clause 1 t))
- (if (looking-at c-primitive-type-key)
- (progn
- (when c-record-type-identifiers
- (c-record-type-id (cons (match-beginning 1)
- (match-end 1))))
- (c-forward-keyword-clause 1 t)
- (setq res t))
- (goto-char safe-pos)
- (setq res 'prefix))
- (setq pos (point)))
- (if (save-match-data (c-forward-keyword-clause 1 t))
- (setq pos (point))
- (if pos
- (goto-char pos)
- (goto-char (match-end 1))
- (setq pos (point)))))
+ (let (safe-pos)
+ (c-forward-keyword-clause 1 t)
+ (while (progn
+ (setq safe-pos (point))
+ (c-forward-syntactic-ws)
+ (looking-at c-opt-type-component-key))
+ (when (and c-record-type-identifiers
+ (looking-at c-primitive-type-key))
+ (c-record-type-id (cons (match-beginning 1)
+ (match-end 1))))
+ (c-forward-keyword-clause 1 t))
+ (if (looking-at c-primitive-type-key)
+ (progn
+ (when c-record-type-identifiers
+ (c-record-type-id (cons (match-beginning 1)
+ (match-end 1))))
+ (c-forward-keyword-clause 1 t)
+ (setq res t)
+ (while (progn
+ (setq safe-pos (point))
+ (c-forward-syntactic-ws)
+ (looking-at c-opt-type-component-key))
+ (c-forward-keyword-clause 1 t)))
+ (goto-char safe-pos)
+ (setq res 'prefix))
+ (setq pos (point))))
+ ((save-match-data (c-forward-keyword-clause 1 t))
+ (while (progn
+ (setq pos (point))
+ (c-forward-syntactic-ws)
+ (and c-opt-type-component-key
+ (looking-at c-opt-type-component-key)))
+ (c-forward-keyword-clause 1 t)))
+ (pos (goto-char pos))
+ (t (goto-char (match-end 1))
+ (setq pos (point))))
(c-forward-syntactic-ws))
((and (eq name-res t)
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#59953: 28.2; c type modifiers only work as prefixes for font-lock, cc-mode
2023-10-14 15:52 ` Alan Mackenzie
@ 2023-11-24 12:29 ` Alan Mackenzie
0 siblings, 0 replies; 3+ messages in thread
From: Alan Mackenzie @ 2023-11-24 12:29 UTC (permalink / raw)
To: Chris Hecker; +Cc: 59953-done, acm
Hello, Chris.
I've committed the patch, and I'm closing the bug with this post.
On Sat, Oct 14, 2023 at 15:52:34 +0000, Alan Mackenzie wrote:
> Thanks for taking the trouble to file this bug, but sorry it's been such
> a long time without a response.
> I've now looked at the bug and it wasn't that difficult to patch. If you
> don't mind too much, I'll put your test file into the CC Mode test suite,
> having added one line ("long int unsigned Three;") to it.
> Would you please now apply the attached patch to your current Emacs (the
> file cc-engine.el is in lisp/progmodes), byte compile cc-engine.el (or
> just the whole of CC Mode), load the result into your Emacs and try it
> out on your real source code. Then please confirm to me that the bug is
> fixed, or tell me what's still not right. Thanks! (If you want any help
> in the patching of byte compilation, feel free to send me private email.)
> On Sat, Dec 10, 2022 at 22:31:18 +0000, Chris Hecker wrote:
> > cc-mode doesn't seem to recognize that c type specifiers can come in
> > any order (and I prefer them after so they're modifying the base type),
> > so the highlighting doesn't work right for the variable name. Here's
> > an example in a struct, works the same way in a function:
> > struct foo {
> > unsigned int One;
> > int unsigned Two;
> > };
> > emacs -Q results:
> > [cid:emf20eaa32-35e0-4df0-a1fb-4e6ad9397939@checker-blade15]
> > I couldn't see an easy way of fixing this (besides just adding all the
> > combos to *-font-lock-extra-types). Seems like there needs to be a
> > c-primitive-type-postfix-kwds variable to do this right?
> > Thanks,
> > Chris
> > In GNU Emacs 28.2 (build 2, x86_64-w64-mingw32)
> > Â of 2022-09-13 built on AVALON
> > Windowing system distributor 'Microsoft Corp.', version 10.0.19044
> > System Description: Microsoft Windows 10 Home (v10.0.2009.19044.2251)
> > Configured using:
> > Â 'configure --with-modules --without-dbus --with-native-compilation
> > Â --without-compress-install CFLAGS=-O2'
> > Configured features:
[ .... ]
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-24 12:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-10 22:31 bug#59953: 28.2; c type modifiers only work as prefixes for font-lock, cc-mode Chris Hecker
2023-10-14 15:52 ` Alan Mackenzie
2023-11-24 12:29 ` Alan Mackenzie
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).