Emacs

From WxWiki
Jump to: navigation, search

Emacs needs some clues about indenting for wxWidgets code: mostly around event tables.

Here are the magic lines in my ~/.emacs

(require 'cc-mode)

(add-to-list  'c++-font-lock-extra-types
  "\\bwx[A-Z][a-z][a-zA-Z]*?\\b")

(defun c-wx-lineup-topmost-intro-cont (langelem)
  (save-excursion
    (beginning-of-line)
    (if (re-search-forward "EVT_" (line-end-position) t)
	'c-basic-offset
      (c-lineup-topmost-intro-cont langelem))))
		   

(setq c++-mode-hook 
	 (lambda ()
	   (c-set-offset 'topmost-intro-cont 'c-wx-lineup-topmost-intro-cont)))

Also, [[1][exuberant ctags]] can be used to generate a tags file for wxWidgets, allowing hypertext like navigation of code (use M-x apropos tags to find out more), but ctags does not include a macro preprocessor and so the EVT_* macros tend to confuse it. To get around it, you need to feed it a configuration file of macros to skip..something like this

-I IMPLEMENT_ABSTRACT_CLASS+
-I IMPLEMENT_CLASS+
-I IMPLEMENT_DYNAMIC_CLASS+
-I DEFINE_ABSTRACT_CLASS+
-I DEFINE_CLASS+
-I DEFINE_DYNAMIC_CLASS+
-I BEGIN_PROJECT_EVENT_HANDLER+
-I END_PROJECT_EVENT_HANDLER+
-I HANDLE_PROJECT_EVENT+
-I END_EVENT_TABLE+
-I BEGIN_EVENT_TABLE+
-I EVT_COMMAND_SCROLL_ENDSCROLL+
-I EVT_COMMAND_SCROLL_CHANGED+
-I EVT_JOY_DOWN+
-I EVT_JOY_UP+
-I EVT_SCROLL_ENDSCROLL 
-I EVT_SCROLL_CHANGED
-I EVT_ACTIVATE+
-I EVT_ACTIVATE_APP+
-I EVT_ACTIVEX+
-I EVT_AUINOTEBOOK_ALLOW_DND+
-I EVT_AUINOTEBOOK_BEGIN_DRAG+
-I EVT_AUINOTEBOOK_BUTTON+
-I EVT_AUINOTEBOOK_DRAG_MOTION+
-I EVT_AUINOTEBOOK_END_DRAG+
-I EVT_AUINOTEBOOK_PAGE_CHANGED+
-I EVT_AUINOTEBOOK_PAGE_CHANGING+
-I EVT_AUINOTEBOOK_PAGE_CLOSE+
-I EVT_AUI_PANEBUTTON+
-I EVT_AUI_PANECLOSE+
-I EVT_AUI_PANEMAXIMIZE+
-I EVT_AUI_PANERESTORE+
-I EVT_AUI_RENDER+
-I EVT_BOOKCTRL_PAGE_CHANGED+
-I EVT_BOOKCTRL_PAGE_CHANGED+
-I EVT_BOOKCTRL_PAGE_CHANGING+
-I EVT_BOOKCTRL_PAGE_CHANGING+
-I EVT_CALCULATE_LAYOUT+
-I EVT_CALENDAR+
-I EVT_CALENDAR_DAY+
-I EVT_CALENDAR_MONTH+
-I EVT_CALENDAR_SEL_CHANGED+
-I EVT_CALENDAR_WEEKDAY_CLICKED+
-I EVT_CALENDAR_YEAR+
-I EVT_CHAR+
-I EVT_CHAR_HOOK+
-I EVT_CHECKBOX+
-I EVT_CHECKLISTBOX+
-I EVT_CHILD_FOCUS+
-I EVT_CHOICE+
-I EVT_CHOICEBOOK_PAGE_CHANGED+
-I EVT_CHOICEBOOK_PAGE_CHANGING+
-I EVT_CLOSE+
-I EVT_COLLAPSIBLEPANE_CHANGED+
-I EVT_COLOURPICKER_CHANGED+
-I EVT_COMBOBOX+
-I EVT_COMMAND+
-I EVT_COMMAND_CONTEXT_MENU+
-I EVT_COMMAND_ENTER+
-I EVT_COMMAND_KILL_FOCUS+
-I EVT_COMMAND_LEFT_CLICK+
-I EVT_COMMAND_LEFT_DCLICK+
-I EVT_COMMAND_RANGE+
-I EVT_COMMAND_RIGHT_CLICK+
-I EVT_COMMAND_RIGHT_DCLICK+
-I EVT_COMMAND_SCROLL+
-I EVT_COMMAND_SCROLL_BOTTOM+
-I EVT_COMMAND_SCROLL_CHANGED+
-I EVT_COMMAND_SCROLL_LINEDOWN+
-I EVT_COMMAND_SCROLL_LINEUP+
-I EVT_COMMAND_SCROLL_PAGEDOWN+
-I EVT_COMMAND_SCROLL_PAGEUP+
-I EVT_COMMAND_SCROLL_THUMBRELEASE+
-I EVT_COMMAND_SCROLL_THUMBTRACK+
-I EVT_COMMAND_SCROLL_TOP+
-I EVT_COMMAND_SET_FOCUS+
-I EVT_CONTEXT_MENU+
-I EVT_CUSTOM+
-I EVT_CUSTOM_RANGE+
-I EVT_DATAVIEW_COLUMN_HEADER_CLICK+
-I EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED+
-I EVT_DATAVIEW_ROW_ACTIVATED+
-I EVT_DATAVIEW_ROW_SELECTED+
-I EVT_DATE_CHANGED+
-I EVT_DETAILED_HELP+
-I EVT_DETAILED_HELP_RANGE+
-I EVT_DIALUP_CONNECTED+
-I EVT_DIALUP_DISCONNECTED+
-I EVT_DIRPICKER_CHANGED+
-I EVT_DISPLAY_CHANGED+
-I EVT_DROP_FILES+
-I EVT_END_PROCESS+
-I EVT_END_SESSION+
-I EVT_END_SESSION+
-I EVT_ENTER_WINDOW+
-I EVT_ERASE_BACKGROUND+
-I EVT_FILEPICKER_CHANGED+
-I EVT_FIND+
-I EVT_FIND_CLOSE+
-I EVT_FIND_NEXT+
-I EVT_FIND_REPLACE+
-I EVT_FIND_REPLACE_ALL+
-I EVT_FONTPICKER_CHANGED+
-I EVT_GRID_CELL_BEGIN_DRAG+
-I EVT_GRID_CELL_CHANGE+
-I EVT_GRID_CELL_LEFT_CLICK+
-I EVT_GRID_CELL_LEFT_DCLICK+
-I EVT_GRID_CELL_RIGHT_CLICK+
-I EVT_GRID_CELL_RIGHT_DCLICK+
-I EVT_GRID_CHANGE_LABELS+
-I EVT_GRID_CHANGE_SEL_LABEL+
-I EVT_GRID_CMD_CELL_BEGIN_DRAG+
-I EVT_GRID_CMD_CELL_CHANGE+
-I EVT_GRID_CMD_CELL_LEFT_CLICK+
-I EVT_GRID_CMD_CELL_LEFT_DCLICK+
-I EVT_GRID_CMD_CELL_RIGHT_CLICK+
-I EVT_GRID_CMD_CELL_RIGHT_DCLICK+
-I EVT_GRID_CMD_COL_SIZE+
-I EVT_GRID_CMD_EDITOR_CREATED+
-I EVT_GRID_CMD_EDITOR_HIDDEN+
-I EVT_GRID_CMD_EDITOR_SHOWN+
-I EVT_GRID_CMD_LABEL_LEFT_CLICK+
-I EVT_GRID_CMD_LABEL_LEFT_DCLICK+
-I EVT_GRID_CMD_LABEL_RIGHT_CLICK+
-I EVT_GRID_CMD_LABEL_RIGHT_DCLICK+
-I EVT_GRID_CMD_RANGE_SELECT+
-I EVT_GRID_CMD_ROW_SIZE+
-I EVT_GRID_CMD_SELECT_CELL+
-I EVT_GRID_COL_SIZE+
-I EVT_GRID_CREATE_CELL+
-I EVT_GRID_EDITOR_CREATED+
-I EVT_GRID_EDITOR_HIDDEN+
-I EVT_GRID_EDITOR_SHOWN+
-I EVT_GRID_LABEL_LEFT_CLICK+
-I EVT_GRID_LABEL_LEFT_DCLICK+
-I EVT_GRID_LABEL_RIGHT_CLICK+
-I EVT_GRID_LABEL_RIGHT_DCLICK+
-I EVT_GRID_RANGE_SELECT+
-I EVT_GRID_ROW_SIZE+
-I EVT_GRID_SELECT_CELL+
-I EVT_HELP+
-I EVT_HELP_RANGE+
-I EVT_HIBERNATE+
-I EVT_HOTKEY+
-I EVT_HTML_CELL_CLICKED+
-I EVT_HTML_CELL_HOVER+
-I EVT_HTML_LINK_CLICKED+
-I EVT_HYPERLINK+
-I EVT_ICONIZE+
-I EVT_IDLE+
-I EVT_INIT_DIALOG+
-I EVT_JOYSTICK_EVENTS+
-I EVT_JOY_BUTTON_DOWN+
-I EVT_JOY_BUTTON_UP+
-I EVT_JOY_MOVE+
-I EVT_JOY_ZMOVE+
-I EVT_KEY_DOWN+
-I EVT_KEY_UP+
-I EVT_KILL_FOCUS+
-I EVT_LEAVE_WINDOW+
-I EVT_LEFT_DCLICK+
-I EVT_LEFT_DOWN+
-I EVT_LEFT_UP+
-I EVT_LISTBOOK_PAGE_CHANGED+
-I EVT_LISTBOOK_PAGE_CHANGING+
-I EVT_LISTBOX+
-I EVT_LISTBOX_DCLICK+
-I EVT_LIST_BEGIN_DRAG+
-I EVT_LIST_BEGIN_LABEL_EDIT+
-I EVT_LIST_BEGIN_RDRAG+
-I EVT_LIST_CACHE_HINT+
-I EVT_LIST_COL_BEGIN_DRAG+
-I EVT_LIST_COL_CLICK+
-I EVT_LIST_COL_DRAGGING+
-I EVT_LIST_COL_END_DRAG+
-I EVT_LIST_COL_RIGHT_CLICK+
-I EVT_LIST_DELETE_ALL_ITEMS+
-I EVT_LIST_DELETE_ITEM+
-I EVT_LIST_END_LABEL_EDIT+
-I EVT_LIST_GET_INFO+
-I EVT_LIST_INSERT_ITEM+
-I EVT_LIST_ITEM_ACTIVATED+
-I EVT_LIST_ITEM_DESELECTED+
-I EVT_LIST_ITEM_FOCUSED+
-I EVT_LIST_ITEM_MIDDLE_CLICK+
-I EVT_LIST_ITEM_RIGHT_CLICK+
-I EVT_LIST_ITEM_SELECTED+
-I EVT_LIST_KEY_DOWN+
-I EVT_LIST_SET_INFO+
-I EVT_MAXIMIZE+
-I EVT_MEDIA_FINISHED+
-I EVT_MEDIA_STOP+
-I EVT_MENU+
-I EVT_MENU_CLOSE+
-I EVT_MENU_HIGHLIGHT+
-I EVT_MENU_HIGHLIGHT_ALL+
-I EVT_MENU_OPEN+
-I EVT_MENU_RANGE+
-I EVT_MIDDLE_DCLICK+
-I EVT_MIDDLE_DOWN+
-I EVT_MIDDLE_UP+
-I EVT_MOTION+
-I EVT_MOUSEWHEEL+
-I EVT_MOUSE_CAPTURE_CHANGED+
-I EVT_MOUSE_CAPTURE_LOST+
-I EVT_MOUSE_EVENTS+
-I EVT_MOVE+
-I EVT_MOVING+
-I EVT_NAVIGATION_KEY+
-I EVT_NC_PAINT+
-I EVT_NOTEBOOK_PAGE_CHANGING+
-I EVT_NOTIFY+
-I EVT_NOTIFY_RANGE+
-I EVT_PAINT+
-I EVT_PALETTE_CHANGED+
-I EVT_POWER_RESUME+
-I EVT_POWER_SUSPENDED+
-I EVT_POWER_SUSPENDING+
-I EVT_POWER_SUSPEND_CANCEL+
-I EVT_QUERY_END_SESSION+
-I EVT_QUERY_END_SESSION+
-I EVT_QUERY_LAYOUT_INFO+
-I EVT_QUERY_NEW_PALETTE+
-I EVT_RADIOBOX+
-I EVT_RADIOBUTTON+
-I EVT_RICHTEXT_ITEM_DESELECTED+
-I EVT_RICHTEXT_ITEM_SELECTED+
-I EVT_RICHTEXT_LEFT_CLICK+
-I EVT_RICHTEXT_LEFT_DCLICK+
-I EVT_RICHTEXT_MIDDLE_CLICK+
-I EVT_RICHTEXT_RETURN+
-I EVT_RICHTEXT_RIGHT_CLICK+
-I EVT_RICHTEXT_STYLESHEET_CHANGED+
-I EVT_RICHTEXT_STYLESHEET_CHANGING+
-I EVT_RICHTEXT_STYLESHEET_REPLACED+
-I EVT_RICHTEXT_STYLESHEET_REPLACING+
-I EVT_RIGHT_DCLICK+
-I EVT_RIGHT_DOWN+
-I EVT_RIGHT_UP+
-I EVT_SASH_DRAGGED+
-I EVT_SASH_DRAGGED_RANGE+
-I EVT_SCROLL+
-I EVT_SCROLLBAR+
-I EVT_SCROLLWIN+
-I EVT_SCROLLWIN_BOTTOM+
-I EVT_SCROLLWIN_LINEDOWN+
-I EVT_SCROLLWIN_LINEUP+
-I EVT_SCROLLWIN_PAGEDOWN+
-I EVT_SCROLLWIN_PAGEUP+
-I EVT_SCROLLWIN_THUMBRELEASE+
-I EVT_SCROLLWIN_THUMBTRACK+
-I EVT_SCROLLWIN_TOP+
-I EVT_SCROLL_BOTTOM+
-I EVT_SCROLL_CHANGED+
-I EVT_SCROLL_LINEDOWN+
-I EVT_SCROLL_LINEUP+
-I EVT_SCROLL_PAGEDOWN+
-I EVT_SCROLL_PAGEUP+
-I EVT_SCROLL_THUMBRELEASE+
-I EVT_SCROLL_THUMBTRACK+
-I EVT_SCROLL_TOP+
-I EVT_SET_CURSOR+
-I EVT_SET_FOCUS+
-I EVT_SHOW+
-I EVT_SIZE+
-I EVT_SIZING+
-I EVT_SLIDER+
-I EVT_SOCKET+
-I EVT_SPIN+
-I EVT_SPINCTRL+
-I EVT_SPIN_DOWN+
-I EVT_SPIN_UP+
-I EVT_SPLITTER_DCLICK+
-I EVT_SPLITTER_SASH_POS_CHANGED+
-I EVT_SPLITTER_SASH_POS_CHANGING+
-I EVT_SPLITTER_UNSPLIT+
-I EVT_SYS_COLOUR_CHANGED+
-I EVT_TAB_SEL_CHANGED+
-I EVT_TASKBAR_LEFT_DCLICK+
-I EVT_TASKBAR_LEFT_DOWN+
-I EVT_TASKBAR_LEFT_UP+
-I EVT_TASKBAR_MOVE+
-I EVT_TASKBAR_RIGHT_DCLICK+
-I EVT_TASKBAR_RIGHT_DOWN+
-I EVT_TASKBAR_RIGHT_UP+
-I EVT_TEXT+
-I EVT_TEXT_COPY+
-I EVT_TEXT_CUT+
-I EVT_TEXT_ENTER+
-I EVT_TEXT_MAXLEN+
-I EVT_TEXT_PASTE+
-I EVT_TEXT_URL+
-I EVT_TIMER+
-I EVT_TOGGLEBUTTON+
-I EVT_TOOL+
-I EVT_TOOLBOOK_PAGE_CHANGED+
-I EVT_TOOLBOOK_PAGE_CHANGING+
-I EVT_TOOL_ENTER+
-I EVT_TOOL_RANGE+
-I EVT_TOOL_RCLICKED+
-I EVT_TOOL_RCLICKED_RANGE+
-I EVT_TREEBOOK_NODE_COLLAPSED+
-I EVT_TREEBOOK_NODE_EXPANDED+
-I EVT_TREEBOOK_PAGE_CHANGED+
-I EVT_TREEBOOK_PAGE_CHANGING+
-I EVT_TREE_BEGIN_DRAG+
-I EVT_TREE_BEGIN_LABEL_EDIT+
-I EVT_TREE_BEGIN_RDRAG+
-I EVT_TREE_DELETE_ITEM+
-I EVT_TREE_END_DRAG+
-I EVT_TREE_END_LABEL_EDIT+
-I EVT_TREE_GET_INFO+
-I EVT_TREE_ITEM_ACTIVATED+
-I EVT_TREE_ITEM_COLLAPSED+
-I EVT_TREE_ITEM_COLLAPSING+
-I EVT_TREE_ITEM_EXPANDED+
-I EVT_TREE_ITEM_EXPANDING+
-I EVT_TREE_ITEM_GETTOOLTIP+
-I EVT_TREE_ITEM_MENU+
-I EVT_TREE_ITEM_MIDDLE_CLICK+
-I EVT_TREE_ITEM_RIGHT_CLICK+
-I EVT_TREE_KEY_DOWN+
-I EVT_TREE_SEL_CHANGED+
-I EVT_TREE_SEL_CHANGING+
-I EVT_TREE_SET_INFO+
-I EVT_TREE_STATE_IMAGE_CLICK+
-I EVT_UPDATE_UI+
-I EVT_UPDATE_UI_RANGE+
-I EVT_VLBOX+
-I EVT_WEBKIT_BEFORE_LOAD+
-I EVT_WEBKIT_STATE_CHANGED+
-I EVT_WINDOW_CREATE+
-I EVT_WINDOW_DESTROY+
-I EVT_WIZARD_CANCEL+
-I EVT_WIZARD_FINISHED+
-I EVT_WIZARD_HELP+
-I EVT_WIZARD_PAGE_CHANGED+
-I EVT_WIZARD_PAGE_CHANGING+

And then invoke ctags thusly:

 
find wxwidgets-2.8.0/include -name '*.h' | ctags --options=.ctags.cnf -e -L -

JEdit, NEdit and Vi users can use ctags, also: just drop the -e from the options.

Anjuta also uses ctags, and this is likely applicable in some way.

Also, for context-sensitive help on Windows (via the winhelp .hlp file) - bind it to whatever key you like -

(defun wxhelp ()
  (interactive)
  (message (concat "Looking up " (current-word)))
  (start-process
   "Wx Help" nil
   "C:\\WINDOWS\\WINHLP32.EXE" "-k" (current-word)
   "D:\\wxWidgets-2.8.0-rc1\\docs\\winhelp\\wx.hlp"))

For context-sensitive help in Emacs (and wxWidgets docs in devhelp format) see BadByteBootstrapBlues

For viewing HTML manual at Linux/Mac: see wxwidgets-help. It's a Emacs plugin which can be installed through Emacs package manager. The set up is just one line of elisp. It uses the Emacs embedded browser w3m which is very convenient. For example, if you open the the section about "wxPanel", wxPanel's method names will be auto-completed immediately by using Emacs hippie-expand.