From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#59468: 29.0.50; c-ts-mode cannot fontify after macros are encountered Date: Tue, 22 Nov 2022 09:50:44 +0800 Message-ID: <87k03n4v0r.fsf@yahoo.com> References: <87k03n4v0r.fsf.ref@yahoo.com> Reply-To: Po Lu Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17299"; mail-complaints-to="usenet@ciao.gmane.io" To: 59468@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 22 02:52:42 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oxISo-0004NO-54 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 22 Nov 2022 02:52:42 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oxIST-00065K-V0; Mon, 21 Nov 2022 20:52:22 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxISL-00064W-QL for bug-gnu-emacs@gnu.org; Mon, 21 Nov 2022 20:52:14 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oxISA-0004kI-Il for bug-gnu-emacs@gnu.org; Mon, 21 Nov 2022 20:52:12 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oxISA-0007ck-8C for bug-gnu-emacs@gnu.org; Mon, 21 Nov 2022 20:52:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 22 Nov 2022 01:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 59468 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.166908186429226 (code B ref -1); Tue, 22 Nov 2022 01:52:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 22 Nov 2022 01:51:04 +0000 Original-Received: from localhost ([127.0.0.1]:49248 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxIRD-0007bJ-9V for submit@debbugs.gnu.org; Mon, 21 Nov 2022 20:51:04 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:39716) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oxIRA-0007au-W4 for submit@debbugs.gnu.org; Mon, 21 Nov 2022 20:51:02 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxIRA-0005yq-Mq for bug-gnu-emacs@gnu.org; Mon, 21 Nov 2022 20:51:00 -0500 Original-Received: from sonic304-22.consmr.mail.ne1.yahoo.com ([66.163.191.148]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oxIR8-0004X3-AU for bug-gnu-emacs@gnu.org; Mon, 21 Nov 2022 20:51:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1669081856; bh=0HpSLWwddf74poIYt41np/mmoJ142x9gwnYnf90++WU=; h=From:To:Subject:Date:References:From:Subject:Reply-To; b=QZub2adF04BfHndQmPlqd5Zk0krLSIztXjtYl++XUxbK9NvfOvycF88sZWztKlSHsg1MxADqU0lqOdbMec4ROQO55KOTGQLo9fMUB5+CERALXHeEkDSVGJlBLWU1T9llG3w9UUA70vJMwoEiKEDN93gOQzmNrV+l6lYrI4fQyL3m+/RtFQJMEPnfptEpyMtfckc6VpOdFxxUpPMdQTDKrYE4oIh/Jelfl0h3S6TLUr4lc7w3jUfzzsF87NdOA9f/v2ecvooDKfemuvIB0X0ZwDTCXVEqlJ++8lJlbrIcw/xQ0WwwR940FIf1vtSQTNip3z9NUxJvlgUuKLfaFpk5TQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1669081856; bh=9Gwx9744hkGuck7XhqcL2p15w9YKmY0g6wn+olGgNhy=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=oFj28620ZouD9WB2Ij4qyhaeXJwTehUF4PqlIq0tYsOeinbDLry+7xZId19a4PPnaKJ+oXdHEu69wc2TGQ5b4xjjFgE/hV+Xy4DvnWwy7xTbyeIN+1bXgoFV7x5YrnPa5s1grpRc7PnxyCHtsjuG9kpXjyoxzF4FTGb2k4l3Bx6AkmAXeM+t08G8zS7KC4MofGrEU+9nSDXufSMp1e9Q3619cRF+qaICNfGhSQXSxcMu6HSHrynEVv4cHoLffpApongP/aJPB/EUSx8SKl+CjpC45iDSqv9og+0s4q+6lnx2iC+8PcyuAHK1MaSa13zZO5RorOBvJYtVui3QoVHtoQ== X-YMail-OSG: fNEDXcsVM1km2Cw3we3bQ5FwsyLWT0rRrWpKmZCStmQ.TUylSP8x_wtjAqlprtx 8oVv0rxkCP62jYitXyv4RfNXmaQlVgG39M9AphhGUUkeY581uBWqx6NKrokqFdFhNVUmBhknlClL 9i8rrPKa5_DQ80JisGiXcPIQo2S6V2t70XIezsmzvC9CEfqv3dBBdV9TrrdQUzx_XvzVgHIRA.L4 hiMThxVBorNmk5IEpgBMPdelZAiQ.dvl9DkKrxqjuRR.0O.uqUzd0jb69bG2R_p2L_2ETzrdIwRr xq_96GVjbA8jQVGh0rwpAdSqC0iXluTDdvEfSqYPKRq_RYLCHDxNpqHWG6yEpJeoAvuyUTqVBIdp unvutStsGdtqP7Kxa2PH02mqCKtjCjiNYc4lvFTBYOKeTjgNiia05KDfPF7UAjnhP7smNNTE9uAn .3HpqIafifCUvqQy3yhtzxRjDA4Eecc3Q0xYPXvr7jqbe.u7TlY5l3xIzRGDiPlOA5UZFvGTNOXF YmAjO3mQz_wKbRQx5PmGUi9C2I_ZjPaqfNhpmkCuWbUUTl3VYS9NJrSotbQFnZ9g1t2ONFRXmJSR jcniFbUH1UM6iEZyThJbhPjUFEmHFVwqkNGMp9qkL4xev09OOzoSrsMgX8xjlTgZ_S9W3XCMpde6 lOUEJP029zEStInZCh7ErmZpp2wBovO42ut0mSxPD2cto7BfujMZ9nmMWXM0mFFpR9AYw7ZqMXdA Ktz0_.KFJnPqNiEgwvRYjJ5y_ddIpvJFwBro7tppgwrTs4SC4BPtaeIK8DttUUSJw6edO8ksDn90 UoZsoX2nsjtZBaWi0vNHcxfwu6xpFOeSkKluhV0UQZ X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.ne1.yahoo.com with HTTP; Tue, 22 Nov 2022 01:50:56 +0000 Original-Received: by hermes--production-sg3-6c8895b545-lgf2t (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 0c3ffce398a4b18a230799e0f57208dd; Tue, 22 Nov 2022 01:50:49 +0000 (UTC) X-Mailer: WebService/1.1.20863 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.191.148; envelope-from=luangruo@yahoo.com; helo=sonic304-22.consmr.mail.ne1.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:248591 Archived-At: Insert the following code in a buffer, and enable c-ts-mode. #define CheckExtension(name) \ if (!name) \ { \ if (display) \ eglTerminate (display); \ fprintf (stderr, "Missing: egl%s\n", #name + 1); \ return False; \ } #define CheckExtensionGl(name) \ if (!name) \ { \ /* If the context remains current, then nothing \ will get released upon eglTerminate. */ \ eglMakeCurrent (display, EGL_NO_SURFACE, \ EGL_NO_SURFACE, EGL_NO_CONTEXT); \ eglTerminate (display); \ fprintf (stderr, "Missing: gl%s\n", #name + 1); \ return False; \ } #define LoadProc(name, ext, extname) \ if (HaveEglExtension (extname)) \ I##name \ = (void *) eglGetProcAddress ("egl" #name ext) #define LoadProcGl(name, ext, extname) \ if (HaveGlExtension (extname)) \ I##name \ = (void *) eglGetProcAddress ("gl" #name ext) #define CheckGlExtension(name) \ if (!HaveGlExtension (name)) \ { \ fprintf (stderr, "Missing %s\n", name); \ \ eglMakeCurrent (display, EGL_NO_SURFACE, \ EGL_NO_SURFACE, \ EGL_NO_CONTEXT); \ eglTerminate (display); \ return False; \ } There will be no fontification of types or string constants inside the macro bodies. CC Mode works fine. Now, insert the following code below the macro definition: static Visual * FindVisual (VisualID visual, int *depth) { XVisualInfo vinfo, *visuals; Visual *value; int nvisuals; const char *override; } visual, depth, visuals, value and override are not fontified as identifiers. Line feed characters below the macros are also fontfied as "errors". Within the following code: static BufferActivityRecord * FindBufferActivityRecord (PictureBuffer *buffer, PictureTarget *target) { BufferActivityRecord *record; /* Look through the global activity list for a record matching the given values. */ record = all_activity.global_next; while (record != &all_activity) { if (record->buffer == buffer && record->target == target) return record; record = record->global_next; } return NULL; } "record" is fontified as an identifier, but not within the condition in the while loop. Within the following code: static void compare_single_row_8bpc4 (unsigned char *data, unsigned char *xdata, size_t size, struct image_difference_statistics *statistics) { unsigned char channel_a, channel_b; int diff; size_t i; for (i = 0; i < size; ++i) { channel_a = data[i]; channel_b = xdata[i]; diff = (int) channel_b - (int) channel_a; statistics->min_diff = MIN (statistics->min_diff, diff); statistics->max_diff = MAX (statistics->max_diff, diff); } } the "i" in "size_t i" is fontified as an identifier the first time, but not in future appearances in the function. Within src/xterm.c, every appearance of ATOM_REFS_INIT is fontified in the error face. Also, inside `xm_setup_dnd_targets', xm_targets_table_header header; xm_targets_table_rec **recs UNINIT; xm_byte_order byteorder; "recs" is fontified in the error face. recs = xmalloc (sizeof *recs); recs[0] = xmalloc (FLEXSIZEOF (struct xm_targets_table_rec, targets, ntargets * 4)); recs[0]->n_targets = ntargets; "struct" is fontified in the error face. Within x_sync_note_frame_times: #ifdef FRAME_DEBUG uint_fast64_t last_frame_ms = output->last_frame_time / 1000; fprintf (stderr, "Drawing the last frame took: %"PRIuFAST64" ms (%"PRIuFAST64")\n", last_frame_ms, time); #endif "PRIuFAST64" is fontified in the error face. Within x_dnd_begin_drag_and_drop: if (x_dnd_movement_frame /* FIXME: how come this can end up with movement frames from other displays on GTK builds? */ && (FRAME_X_DISPLAY (x_dnd_movement_frame) == FRAME_X_DISPLAY (f)) /* If both those variables are false, then F is no longer protected from deletion by Lisp code. This can only happen during the final iteration of the DND event loop. */ && (x_dnd_in_progress || x_dnd_waiting_for_finish)) { XSETFRAME (frame_object, x_dnd_movement_frame); is fontified incorrectly: the "if" is not fontified at all, and the last three lines show up in the error faces. In addition: Lisp_Object x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction, Lisp_Object return_frame, Atom *ask_action_list, const char **ask_action_names, size_t n_ask_actions, bool allow_current_frame, Atom *target_atoms, int ntargets, Lisp_Object selection_target_list, bool follow_tooltip) "Lisp_Object" and "x_dnd_begin_drag_and_drop" are not fontified at all. Here: /* Select for input extension events used by scroll bars. This will result in the corresponding core events not being generated for SCROLL_BAR. */ MAYBE_UNUSED static void xi_select_scroll_bar_events (struct x_display_info *dpyinfo, Window scroll_bar) "void" is fontified in the error face. Here, in handle_one_xevent: #ifdef HAVE_XINPUT2 if (event->type != GenericEvent) #endif any = x_any_window_to_frame (dpyinfo, event->xany.window); #ifdef HAVE_XINPUT2 else any = NULL; #endif the "else" is fontified as a type. static int handle_one_xevent (struct x_display_info *dpyinfo, #ifndef HAVE_XINPUT2 const XEvent *event, #else XEvent *event, #endif int *finish, struct input_event *hold_quit) the "const XEvent *" is fontified in the error face. Here: case GraphicsExpose: /* This occurs when an XCopyArea's source area was obscured or not available. */ f = x_window_to_frame (dpyinfo, event->xgraphicsexpose.drawable); if (f) { expose_frame (f, event->xgraphicsexpose.x, event->xgraphicsexpose.y, event->xgraphicsexpose.width, event->xgraphicsexpose.height); #ifndef USE_TOOLKIT_SCROLL_BARS x_scroll_bar_handle_exposure (f, (XEvent *) event); #endif #ifdef USE_GTK x_clear_under_internal_border (f); #endif #ifdef HAVE_XDBE show_back_buffer (f); #endif } #ifdef USE_X_TOOLKIT else goto OTHER; #endif /* USE_X_TOOLKIT */ break; "goto OTHER" is fontified in the error face, and "else" as a type. Here: #ifdef HAVE_XINPUT2 if (event->xkey.time == pending_keystroke_time) { source = xi_device_from_id (dpyinfo, dpyinfo->pending_keystroke_source); if (source) inev.ie.device = source->name; } #endif "inev" is fontified in the error face. Here: #ifdef USE_GTK /* See comment in EnterNotify above */ else if (dpyinfo->last_mouse_glyph_frame) x_note_mouse_movement (dpyinfo->last_mouse_glyph_frame, &event->xmotion, Qnil); #endif "else" and "dpyinfo" are fontified as types. #ifdef USE_MOTIF Widget widget; widget = XtWindowToWidget (dpyinfo->display, event->xbutton.window); if (widget && XmIsCascadeButton (widget) && XtIsSensitive (widget)) { #endif if (!f->output_data.x->saved_menu_event) f->output_data.x->saved_menu_event = xmalloc (sizeof *event); *f->output_data.x->saved_menu_event = *event; inev.ie.kind = MENU_BAR_ACTIVATE_EVENT; XSETFRAME (inev.ie.frame_or_window, f); *finish = X_EVENT_DROP; #ifdef USE_MOTIF } #endif here, the last closing brace is fontified in the error face. Here: static void NO_INLINE x_error_quitter (Display *display, XErrorEvent *event) { char buf[256], buf1[400 + INT_STRLEN_BOUND (int) + INT_STRLEN_BOUND (unsigned long)]; "NO_INLINE" and "unsigned long" are fontified in the error face. CC mode fontifies all of the examples above fine, and they are not even pre-standard C. Would someone please fix c-ts-mode to fontify them correctly as well? In GNU Emacs 29.0.50 (build 238, x86_64-pc-linux-gnu) of 2022-11-22 built on trinity Repository revision: aeadba1418d8fc18f17b4ae415cde35e9e272e7a Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101099 System Description: Fedora Linux 37 (Workstation Edition) Configured using: 'configure --with-x --with-x-toolkit=no --without-cairo --with-dumping=unexec --cache-file=/tmp/ccache' Configured features: ACL DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY OLDXMENU PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TREE_SITTER UNEXEC WEBP X11 XDBE XFT XIM XINPUT2 XPM ZLIB Important settings: value of $LANG: en_GB.utf8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: C/*l Minor modes in effect: tooltip-mode: t global-eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t line-number-mode: t indent-tabs-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t abbrev-mode: t Load-path shadows: None found. Features: (shadow sort emacsbug mail-extr message sendmail mailcap yank-media puny rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util time-date mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils mailheader reporter find-dired ffap url-parse auth-source eieio eieio-core cl-macs password-cache json subr-x map byte-opt gv bytecomp byte-compile url-vars thingatpt files-x grep compile text-property-search comint ansi-osc ansi-color ring c-ts-mode rx treesit cl-seq vc-dispatcher vc-svn cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs misearch multi-isearch dired-aux cl-loaddefs cl-lib dired dired-loaddefs rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd 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 nadvice seq simple cl-generic indonesian philippine 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 abbrev obarray oclosure cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting xinput2 x multi-tty make-network-process emacs) Memory information: ((conses 16 171735 10469) (symbols 48 26041 14) (strings 32 45784 1739) (string-bytes 1 1373049) (vectors 16 26115) (vector-slots 8 653341 15564) (floats 8 75 179) (intervals 56 3663 0) (buffers 992 18))