Subject: 24.3; Doxygen comments trigger anomalous C++ major mode behavior

From: Sam Varshavchik <[email-masked]>
Date: Mon, 28 Jul 2014 08:47:25 -0400

I am seeing anomalous behavior in C++ major mode that's triggered by
long, but not excessively long -- only a few hundred lines -- Doxygen-style
comments.

Cursor navigation at the end of the Doxygen comment block in the
following file (just before the first typedef), and trying to add some
additional text there, results in 3-5 seconds' worth of delays for
nearly typed character.

Highlighting the entire Doxygen comment block: M-x indent-region takes
several minutes (!) with emacs consuming 100% CPU.

Sample file to open in C++ major mode.

====================================cut here=================================
#ifndef x_w_layoutmanager_H
#define x_w_layoutmanager_H

#include <x/ref.H>
#include <x/w/layoutmanagerfwd.H>
#include <x/w/layoutmanagerobj.H>
#include <x/namespace.h>

namespace LIBCXX_NAMESPACE {

	namespace w {
#if 0
	};
};
#endif

//! Base class for \ref layoutmanager "layoutmanager"s.

class layoutmanagerBase : public ptrrefBase {

public:

	//! A display element factory created by a \ref layoutmanager "layout manager".

	//! Refer to this class as \c INSERT_LIBX_NAMESPACE::w::layoutmanager::base::factory
	//!
	//! Obtain this factory from its \ref layoutmanager "layout manager".
	//! Calling one of
	//! \ref layoutmanagerObj::factoryObj "this factory's methods" adds a
	//! new display element
	//! to the container, in the manner controlled by the container's
	//! layout manager.
	//!
	//! The layout manager keeps its own reference on all ref handles
	//! returned by this factory. Generally, the layout manager will also
	//! have a mechanism by which a display element, created by this
	//! factory, gets removed from the container, releasing the layout
	//! manager's reference on the display element. If the last reference
	//! to the container goes out of scope, the container destroys the
	//! layout manager, which removes any remaining display elements from
	//! the container, automatically.
	//!
	//! \par Primitive display elements
	//!
	//! These methods create various primitive display elements. They are
	//! available when none of the more standard display elements fit the
	//! bill.
	//!
	//! \code
	//! #include <INSERT_LIBX_NAMESPACE/w/label.H>
	//! #include <unicode.h>
	//!
	//! INSERT_LIBX_NAMESPACE::w::const_font font=window->label_font().font();
	//!
	//! std::string str;
	//! std::vector<unicode_char> ustr;
	//! INSERT_LIBX_NAMESPACE::w::richtextmetamap_t markup;
	//! INSERT_LIBX_NAMESPACE::w::dim_t initial_width;
	//!
	//! INSERT_LIBX_NAMESPACE::w::label l=factory->create_label(font, str);
	//!
	//! INSERT_LIBX_NAMESPACE::w::label l=factory->create_label(font, str, unicode::utf_8);
	//!
	//! INSERT_LIBX_NAMESPACE::w::label l=factory->create_label(font, ustr);
	//!
	//! INSERT_LIBX_NAMESPACE::w::label l=factory->create_label(ustr, markup);
	//!
	//! INSERT_LIBX_NAMESPACE::w::label l=factory->create_wrappable_label(font, str, initial_width);
	//!
	//! INSERT_LIBX_NAMESPACE::w::label l=factory->create_wrappable_label(font, str, unicode::utf_8, initial_width);
	//!
	//! INSERT_LIBX_NAMESPACE::w::label l=factory->create_wrappable_label(font, ustr, initial_width);
	//!
	//! INSERT_LIBX_NAMESPACE::w::label l=factory->create_wrappable_label(ustr, markup, initial_width);
	//! \endcode
	//!
	//! Creates a \ref label "label" display element.
	//!
	//! \code
	//! #include <INSERT_LIBX_NAMESPACE/w/canvas.H>
	//!
	//! INSERT_LIBX_NAMESPACE::w::const_picture pic;

	//! INSERT_LIBX_NAMESPACE::w::canvas c=factory->create_canvas(width, height);
	//!
	//! INSERT_LIBX_NAMESPACE::w::canvas c=factory->create_canvas(width, height, INSERT_LIBX_NAMESPACE::w::rgb(0, 0, 0));
	//!
	//! INSERT_LIBX_NAMESPACE::w::canvas c=factory->create_canvas(pic);
	//!
	//! INSERT_LIBX_NAMESPACE::w::canvas c=factory->create_canvas(pic, INSERT_LIBX_NAMESPACE::w::rgb(0, 0, 0));
	//! \endcode
	//!
	//! Creates a \ref canvas "canvas" display element.
	//!
	//! \code
	//! #include <INSERT_LIBX_NAMESPACE/w/button.H>
	//!
	//! INSERT_LIBX_NAMESPACE::w::button b=factory->create_checkbox();
	//!
	//! INSERT_LIBX_NAMESPACE::w::button b=factory->create_radio();
	//!
	//! INSERT_LIBX_NAMESPACE::w::button b=factory->create_standard_button("name");
	//! \endcode
	//!
	//! Creates a \ref button "button" display element.
	//! create_standard_button() loads a standard button image, specified
	//! by name. create_checkbox() loads a standard checkbox button image,
	//! create_radio() loads a standard radio button image and additionally
	//! invokes the new button's oneshot() method.
	//!
	//! \code
	//! #include <INSERT_LIBX_NAMESPACE/w/inputfocus.H>
	//!
	//! INSERT_LIBX_NAMESPACE::w::focusable element;
	//!
	//! INSERT_LIBX_NAMESPACE::w::inputfocus focus=factory->create_inputfocus(element);
	//!
	//! INSERT_LIBX_NAMESPACE::w::inputfocus focus=factory->create_inputfocus(element, INSERT_LIBX_NAMESPACE::w::rgb(0,0,0));
	//!
	//! std::pair<INSERT_LIBX_NAMESPACE::w::inputfocus,
	//!           INSERT_LIBX_NAMESPACE::w::focusable> focuspair=factory->create_standalone_inputfocus([]
	//!    (const INSERT_LIBX_NAMESPACE::w::gridlayout &layout)
	//!    {
	//!        return layout->create_checkbox();
	//!    });
	//!
	//! std::pair<INSERT_LIBX_NAMESPACE::w::inputfocus,
	//!           INSERT_LIBX_NAMESPACE::w::focusable> focuspair=factory->create_standalone_inputfocus([]
	//!    (const INSERT_LIBX_NAMESPACE::w::gridlayout &layout)
	//!    {
	//!        return layout->create_checkbox();
	//!    }, INSERT_LIBX_NAMESPACE::w::rgb(0,0,0));
	//! \endcode
	//!
	//! Creates an \ref inputfocus "input focus frame" with the default or
	//! an explicit background color. create_inputfocus() attached an
	//! input focus frame to an existing display element.
	//!
	//! create_standalone_inputfocus() creates a new input focus to an
	//! element that gets returned by the lambda parameter, which receives
	//! the new input focus frame's grid layout manager, and must return
	//! a focusable display element. This allows the input focus frame to
	//! be created for a display element contained by the same input focus
	//! frame. create_standalone_inputfocus() returns a \c std::pair
	//! containing the new input focus frame display element and the
	//! focusable display element, returned by the lambda, that the input
	//! focus frame got attached to.
	//!
	//! \code
	//! #include <INSERT_LIBX_NAMESPACE/w/xcontainer.H>
	//! #include <INSERT_LIBX_NAMESPACE/w/xfocusablecontainer.H>
	//!
	//! INSERT_LIBX_NAMESPACE::w::xcontainer container=
	//!     layout->create_generic_container();
	//!
	//! INSERT_LIBX_NAMESPACE::w::xcontainer container=
	//!     layout->create_generic_container(INSERT_LIBX_NAMESPACE::rgb(0, 0 ,0));
	//!
	//! INSERT_LIBX_NAMESPACE::w::xfocusablecontainer container=
	//!     layout->create_focusable_container();
	//!
	//! INSERT_LIBX_NAMESPACE::w::xfocusablecontainer container=
	//!     layout->create_focusable_container(INSERT_LIBX_NAMESPACE::rgb(0, 0 ,0));
	//! \endcode
	//!
	//! create_generic_container() creates a generic
	//! \ref xcontainer "container object",
	//! create_focusable_container() creates a generic container that's
	//! also \ref focusable "focusable". The generic container
	//! creates an inner focusable scope. Display elements
	//! added to the focusable container have their own independent
	//! tabbing order that starts at 0. Tabbing into the focusable
	//! container sets input focus to the first enabled display element
	//! in the container. Back-tabbing sets the input focus to the last
	//! enabled display element. So the tabbing flow appears to be
	//! ordinary, however the tabbing order of the elements inside the
	//! focusable container is independent and separate (a display
	//! element inside the focusable container cannot be set to tab
	//! between the outside elements, and vice versa).
	//!
	//! The new container either inherits its parent container's
	//! background color, or uses an explicit one, for its own
	//! background. An optional second parameter selects
	//! the new container's \ref layout "layout manager", and
	//! defaults to the \ref gridlayout "grid layout manager".
	//!
	//! \code
	//! #include <INSERT_LIBX_NAMESPACE/w/actionbutton.H>
	//!
	//! INSERT_LIBX_NAMESPACE::w::actionbutton button=
	//!     layout->create_normal_actionbutton();
	//!
	//! INSERT_LIBX_NAMESPACE::w::actionbutton_style style(INSERT_LIBX_NAMESPACE::w::rgb(0, 0, 0),
	//!         INSERT_LIBX_NAMESPACE::w::rgb(INSERT_LIBX_NAMESPACE::w::rgb::maximum, INSERT_LIBX_NAMESPACE::w::rgb::maximum, INSERT_LIBX_NAMESPACE::w::rgb::maximum);
	//! INSERT_LIBX_NAMESPACE::w::actionbutton button=
	//!     layout->create_normal_actionbutton(style);
	//!
	//! INSERT_LIBX_NAMESPACE::w::actionbutton button=
	//!     layout->create_special_actionbutton();
	//!
	//! INSERT_LIBX_NAMESPACE::w::actionbutton button=
	//!     layout->create_special_actionbutton(style);
	//! \endcode
	//!
	//! create_normal_actionbutton() creates an
	//! \ref actionbutton "action button", a button with a border,
	//! that changes background colors when clicked; using the default
	//! button color for the normal and the clicked background, or
	//! \ref actionbutton_style "custom colors".
	//!
	//! create_special_actionbutton() creates a action button with
	//! a slighly thicker border.
	//!
	//! \par Standard display elements
	//!
	//! The following methods combine several primitive display elements together
	//! to form convenient traditional UI objects:
	//!
	//! \code
	//! std::pair<INSERT_LIBX_NAMESPACE::w::inputfocus, INSERT_LIBX_NAMESPACE::w::button> button=layout->
	//!      create_checkbox_with_label("Label");
	//!
	//! std::pair<INSERT_LIBX_NAMESPACE::w::inputfocus, INSERT_LIBX_NAMESPACE::w::button> button=layout->
	//!      create_radio_with_label("Label");
	//! \endcode
	//!
	//! create_checkbox_with_label() and create_radio_with_label() creates
	//! an input focus frame containing either a checkbox or a radio button,
	//! and a text label to the right of it.
	//!
	//! The returned \ref inputfocus "input focus frame" is the actual display
	//! element that gets added to the layout manager's container. The
	//! button object is the button inside it.
	//!
	//! \code
	//! std::pair<INSERT_LIBX_NAMESPACE::w::actionbutton, INSERT_LIBX_NAMESPACE::w::ref<INSERT_LIBX_NAMESPACE::w::obj>> button=layout->
	//!      create_normal_actionbutton_with_label([]
	//!          {
	//!             // ...
	//!          }, "Label");
	//!
	//! std::pair<INSERT_LIBX_NAMESPACE::w::actionbutton, INSERT_LIBX_NAMESPACE::w::ref<INSERT_LIBX_NAMESPACE::w::obj>> button=layout->
	//!      create_special_actionbutton_with_label([]
	//!          {
	//!             // ...
	//!          }, "Label");
	//!
	//! \endcode
	//!
	//! Creates an action button with a label, and a callback. The first
	//! parameter is the callback lambda that gets invoked on_activate()-ion.
	//! The second parameter is the button's label. Optional parameters
	//! follow: a character set designator, like unicode::utf_8
	//! (from <unicode.h>), non-default regular and activated background color.
	//! \par Text input fields
	//!
	//! \code
	//! INSERT_LIBX_NAMESPACE::w::text_input_style style=w->default_text_input_style();
	//!
	//! std::string initial_value;
	//!
	//! INSERT_LIBX_NAMESPACE::w::textinputfield input=layout->create_text_input(style, initial_value, 41, 40);
	//!
	//! INSERT_LIBX_NAMESPACE::w::textinputfield input=layout->create_text_input(style, initial_value, unicode::utf_8, 41);
	//! \endcode
	//!
	//! create_text_input() creates a single line text input field. Use
	//! the parent window's default_text_input_style() to obtain a default
	//! \ref drawableObj::text_input_style "text_input_style".
	//!
	//! The initial value of the text input file gets specified using the
	//! current locale's codeset, or by explicitly specifying the character
	//! string's codeset. The initial value can also be given as a
	//! \c std::vector<unicode_char>.
	//!
	//! The third (or the fourth) parameter is the text input field's width,
	//! given in character columns. The actual width gets computed based on the
	//! text input style's font width, that gets multiple by the column character,
	//! deriving the actual width in pixels.
	//!
	//! An optional parameter after the text input field's width specifies the
	//! maximum number of characters that can be entered. The first example
	//! specifies a 41 character wide text input that accepts up to a 40
	//! character text string (the additional character column accomodates the
	//! cursor at the end of the full text string, without scrolling).
	//!
	//! \par Selection lists
	//!
	//! \code
	//!
	//! INSERT_LIBX_NAMESPACE::w::xfocusablecontainer container=create_selection_list_rows(4);
	//!
	//! INSERT_LIBX_NAMESPACE::w::listlayoutstyle custom_style=INSERT_LIBX_NAMESPACE::w::listlayoutstyle::create(parent_window);
	//!
	//! INSERT_LIBX_NAMESPACE::w::xfocusablecontainer container=create_selection_list_rows(4, custom_style);
	//! \endcode
	//!
	//! create_selection_list() creates a focusable container with a
	//! \ref listlayoutmanager "list layout manager". The first parameter
	//! specifies the number of rows in the list, if the list contains only
	//! simple text labels.
	//!
	//! The optional second parameter specifies a custom
	//! \ref listlayoutstyle "list layout style".

	typedef ref<layoutmanagerObj::factoryObj> factory;

	//! A nullable pointer reference to a layout manager's factory

	//! Refer to this class as \c INSERT_LIBX_NAMESPACE::w::layoutmanager::base::factoryptr
	typedef ptr<layoutmanagerObj::factoryObj> factoryptr;
};

#if 0
{
	{
#endif
	}
}

#endif
====================================cut here=================================

In GNU Emacs 24.3.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.10.9)
 of 2014-05-21 on buildvm-07.phx2.fedoraproject.org
Windowing system distributor `Fedora Project', version 11.0.11404000
Configured using:
 `configure '--build=x86_64-redhat-linux-gnu'
 '--host=x86_64-redhat-linux-gnu' '--program-prefix='
 '--disable-dependency-tracking' '--prefix=/usr' '--exec-prefix=/usr'
 '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc'
 '--datadir=/usr/share' '--includedir=/usr/include'
 '--libdir=/usr/lib64' '--libexecdir=/usr/libexec'
 '--localstatedir=/var' '--sharedstatedir=/var/lib'
 '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--with-dbus'
 '--with-gif' '--with-jpeg' '--with-png' '--with-rsvg' '--with-tiff'
 '--with-xft' '--with-xpm' '--with-x-toolkit=gtk3' '--with-gpm=no'
 'build_alias=x86_64-redhat-linux-gnu'
 'host_alias=x86_64-redhat-linux-gnu' 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g
 -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
 -fstack-protector-strong --param=ssp-buffer-size=4
 -grecord-gcc-switches -m64 -mtune=generic' 'LDFLAGS=-Wl,-z,relro ''

Important settings:
  value of $LANG: en_US.utf8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: C++/l

Minor modes in effect:
  tooltip-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
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t

Recent input:
<right> <right> <right> <right> <right> <right> <right> 
<backspace> <end> SPC s [ p e <backspace> <backspace> 
<backspace> p e c i f i e s SPC a SPC c u s t o m SPC 
l i s t SPC l a y <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> <return> / / ! SPC \ r e f SPC l i s t 
l a y o u t s t y l e SPC " l i s t SPC l a y o u t 
SPC s t y l e " . <return> C-SPC <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <escape> w C-x C-b C-x 
o <down> <down> <return> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <down> <down> <down> 
C-y <prior> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <return> <up> / / ! <right> 
C-SPC <next> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <escape> x i n d e n t - r e g 
i o n <return> <help-echo> C-x 1 <prior> <prior> <prior> 
<prior> <prior> <prior> <prior> <prior> <prior> <prior> 
<prior> <prior> <next> <next> <next> <next> <next> 
<next> <next> <next> <next> <next> <next> <next> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
C-x C-s <prior> <help-echo> <escape> x r e p o r t 
- e m a c s - b u g <return>

Recent messages:
Mark set [6 times]
Saved text until "ef listlayoutstyle "list layout style".
"
Mark set [2 times]
Indenting region... done
scroll-down-command: Beginning of buffer
scroll-up-command: End of buffer
Auto-saving...done
Saving file /home/mrsam/src/libcxxw-work/includes/x/w/layoutmanager.H...
Wrote /home/mrsam/src/libcxxw-work/includes/x/w/layoutmanager.H

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message cl-macs gv format-spec
rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils mule-util misearch multi-isearch vc-git
cc-langs cl cl-lib cc-mode cc-fonts easymenu cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs time-date tooltip
ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd
fontset image regexp-opt fringe tabulated-list newcomment lisp-mode
register page menu-bar rfn-eshadow timer select scroll-bar mouse
jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer loaddefs button faces cus-face macroexp files text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty emacs)