Skip to content
Snippets Groups Projects
Commit 00adbd6b authored by Jörg Bornemann's avatar Jörg Bornemann
Browse files

Initial revision

parents
No related branches found
No related tags found
No related merge requests found
# qdoc-mode
Emacs major mode for .qdoc files.
\ No newline at end of file
;;; qdoc-mode.el --- Major mode for editing qdoc files. -*- coding: utf-8; lexical-binding: t; -*-
;; Copyright © 2021, by Jörg Bornemann
;; Author: Jörg Bornemann <joerg.bornemann@qt.io>
;; Version: 1.0.0
;; Created: 11.08.2021
;; Keywords: languages
;; Homepage: n/a
;; This file is not part of GNU Emacs.
;;; License:
;; You can redistribute this program and/or modify it under the terms of the GNU General Public License version 2.
;;; Commentary:
;; This file provides a major mode for editing qdoc files.
;;; Code:
;;; TODO Suggest the replacements somehow
(defvar qdoc-deprecated-commands
'(("bold" . "b")
("i" . "e")
("o" . "li")
("qmlclass" . "qmltype"))
"List of deprecated qdoc commands.
Each entry of this list is a cons (\"deprecated_command\" . \"replacement\").")
(defvar qdoc-known-commands
'("a"
"abstract"
"annotatedlist"
"b"
"badcode"
"brief"
"c"
"caption"
"class"
"code"
"codeline"
"default"
"div"
"dots"
"e"
"else"
"endcode"
"endif"
"endlist"
"endtable"
"enum"
"example"
"externalpage"
"fn"
"footnote"
"generatelist"
"group"
"header"
"headerfile"
"if"
"image"
"include"
"ingroup"
"inheaderfile"
"inherits"
"inlineimage"
"inmodule"
"inqmlmodule"
"instantiates"
"internal"
"keyword"
"l"
"legalese"
"li"
"list"
"macro"
"meta"
"module"
"namespace"
"newcode"
"nextpage"
"noautolist"
"nonreentrant"
"note"
"obsolete"
"oldcode"
"omit"
"omitvalue"
"overload"
"page"
"preliminary"
"previouspage"
"printline"
"printto"
"printuntil"
"property"
"qml"
"qmlabstract"
"qmlattachedproperty"
"qmlattachedsignal"
"qmlbasictype"
"qmlmethod"
"qmlmodule"
"qmlproperty"
"qmlsignal"
"qmltype"
"quotation"
"quotefile"
"quotefromfile"
"raw"
"readonly"
"reentrant"
"reimp"
"relates"
"row"
"sa"
"section1"
"section2"
"section3"
"section4"
"since"
"skipline"
"skipto"
"skipuntil"
"snippet"
"span"
"startpage"
"sub"
"subtitle"
"sup"
"table"
"tableofcontents"
"target"
"threadsafe"
"title"
"tt"
"typealias"
"typedef"
"uicontrol"
"underline"
"value"
"variable"
"warning")
"Plain list of known qdoc commands, excluding deprecated commands.")
(defun qdoc--create-command-regexp (command-list)
"Turn COMMAND-LIST (command names without backslash) into a regular expression."
(concat "\\\\" (regexp-opt command-list 'symbols)))
(defvar qdoc-builtin-command-regexp (qdoc--create-command-regexp qdoc-known-commands))
(defvar qdoc-user-command-regexp "\\\\[[:alpha:]][[:alnum:]]+")
(defvar qdoc-deprecated-command-regexp (qdoc--create-command-regexp
(mapcar #'car qdoc-deprecated-commands)))
(defvar qdoc-font-lock-default
`((,qdoc-builtin-command-regexp . font-lock-builtin-face)
(,qdoc-deprecated-command-regexp . font-lock-warning-face)
(,qdoc-user-command-regexp . font-lock-function-name-face)))
;;;###autoload
(define-derived-mode qdoc-mode text-mode "qdoc"
"Major mode for editing Qt's .qdoc files."
(setq font-lock-defaults '(qdoc-font-lock-default))
(setq fill-column 80)
(setq-local sentence-end-double-space nil)
(qdoc-imenu-setup))
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.qdoc\\'" . qdoc-mode))
(defun qdoc-imenu-setup ()
"Set up imenu for qdoc-mode."
(setq imenu-case-fold-search t)
(setq imenu-generic-expression
'(("\\page" "\\\\page \\(.*$\\)" 1)
("\\title" "\\\\title \\(.*$\\)" 1)))
)
(provide 'qdoc-mode)
;;; qdoc-mode.el ends here
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment