[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Major mode and implementation of expected editing facilities

From: Clément Pit-Claudel
Subject: Re: Major mode and implementation of expected editing facilities
Date: Wed, 29 May 2019 00:11:38 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

On 2019-05-28 22:33, Eli Zaretskii wrote:
> If you or someone else want to suggest improvements for that chapter
> of the manual, please do, and thanks in advance.

To get the ball rolling, I'll mention a few facilities that I like major modes 
to hook into.  Others can likely point out many omissions:

* Syntax tables: see Syntax Tables in the ELisp manual (this helps with 
font-locking and motion) and syntax-propertize-function

* Font-locking: see font-lock-defaults and font-lock-keywords, and often 
font-lock-extra-managed-props and font-lock-syntactic-face-function

* Completion: see completion-at-point-functions, or (in ELPA) company-mode

* Outline: See outline-level, outline-regexp, and outline-heading-end-regexp; 
or hs-special-modes-alist; or both; or (in ELPA) many other packages

* Jump to definition: See xref-backend-functions

* Project: See project-find-functions

* On-the-fly errors: See flymake-mode, or (in ELPA) flycheck-mode

* Filling: See fill-paragraph-function, adaptive-fill-regexp, 
adaptive-fill-first-line-regexp, and fill-paragraph-handle-comment

* Comments: See comment-start-skip, comment-use-syntax, and comment-multi-line

* Indentation: See indent-line-function, indent-tabs-mode, 
indent-region-function, and possibly electric-indent-inhibit and 

* Prettification: See prettify-symbols-alist.

* Auto-insert: See auto-insert-alist

* Eldoc: See eldoc-documentation-function

* Current function: See which-func-functions and add-log-current-defun-function

* Toolbars and menus: See tool-bar-map, easy-menu-define, and 

* Compilation: compilation-error-regexp-alist

* Navigation: See forward-sexp-function, parse-sexp-lookup-properties, 
parse-sexp-ignore-comments, paragraph-start, beginning-of-defun-function, and 

* Snippets: See skeleton.el, or (in ELPA) yasnippet.

* Key bindings: You don't usually need to define or override many of these, 
because most keys that are supposed to operate consistently across modes call 
standardized functions or hooks that your major mode can configure (instead of 
redefining the corresponding key).  This is the case for M-q or TAB, for 
example (and even, despite what the manual say, for C-M-a as well).  If you 
override or create keybindings, please please don't forget the 
'delete-selection property, to ensure that the overridden key works well with 

Btw, a good place to find these things is existing mode functions; look for 
setq-local or (set (make-local-variable …) …) in define-derived-mode blocks.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]