diff options
author | Ulrich Müller <ulm@gentoo.org> | 2020-02-08 14:00:37 +0100 |
---|---|---|
committer | Ulrich Müller <ulm@gentoo.org> | 2020-02-08 14:00:37 +0100 |
commit | 4fa58a743c95907c3d5b1b096abbc1b652393966 (patch) | |
tree | 2b017c7db0fc1a248bd811747f6d44e22b374f78 | |
parent | Update copyright years. (diff) | |
download | ebuild-mode-4fa58a743c95907c3d5b1b096abbc1b652393966.tar.gz ebuild-mode-4fa58a743c95907c3d5b1b096abbc1b652393966.tar.bz2 ebuild-mode-4fa58a743c95907c3d5b1b096abbc1b652393966.zip |
New devbook-mode for editing the Gentoo Devmanual.
* devbook-mode.el: New file. Major mode for editing the
Gentoo Devmanual, derived mode of nxml-mode.
* ebuild-mode.texi (devbook-mode): Document it.
* Makefile (DISTFILES): Add devbook-mode.el.
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | devbook-mode.el | 78 | ||||
-rw-r--r-- | ebuild-mode.texi | 19 |
4 files changed, 105 insertions, 4 deletions
@@ -1,3 +1,10 @@ +2020-02-08 Ulrich Müller <ulm@gentoo.org> + + * devbook-mode.el: New file. Major mode for editing the + Gentoo Devmanual, derived mode of nxml-mode. + * ebuild-mode.texi (devbook-mode): Document it. + * Makefile (DISTFILES): Add devbook-mode.el. + 2019-12-21 Ulrich Müller <ulm@gentoo.org> * Version 1.49 released. @@ -6,8 +6,9 @@ PV = $(shell sed '/^;.*[Vv]ersion/!d;s/[^0-9.]*\([^ \t]*\).*/\1/;q' \ ebuild-mode.el) P = $(PN)-$(PV) -DISTFILES = ebuild-mode.el ebuild-mode-keywords.el gentoo-newsitem-mode.el \ - glep-mode.el ebuild-mode.texi keyword-generation.sh ChangeLog +DISTFILES = ebuild-mode.el ebuild-mode-keywords.el \ + devbook-mode.el gentoo-newsitem-mode.el glep-mode.el \ + ebuild-mode.texi keyword-generation.sh ChangeLog .PHONY: all dist clean diff --git a/devbook-mode.el b/devbook-mode.el new file mode 100644 index 0000000..5978258 --- /dev/null +++ b/devbook-mode.el @@ -0,0 +1,78 @@ +;;; devbook-mode.el --- edit the Gentoo Devmanual + +;; Copyright 2020 Gentoo Authors + +;; Author: Ulrich Müller <ulm@gentoo.org> +;; Maintainer: <emacs@gentoo.org> +;; Keywords: languages + +;; This file is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 2 of the License, or +;; (at your option) any later version. + +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. + +;;; Commentary: + +;;; Code: + +(require 'nxml-mode) +(require 'easymenu) +(require 'skeleton) + +;;;###autoload +(define-derived-mode devbook-mode nxml-mode "DevBook" + "Major mode for editing the Gentoo Devmanual." + ;; The style guide says 80 characters. Set to 79 to keep diff output + ;; within the limit (and arguably, 80 includes the newline). + (setq fill-column 79) + (setq indent-tabs-mode nil) + ;; *** FIXME *** The style guide says no indentation, except inside + ;; <tr>, <ul>, <ol> and <dl>, where it must be 2 spaces. There is no + ;; easy way to achieve this, so set to 0 which is right more often. + (setq nxml-child-indent 0)) + +(define-skeleton devbook-insert-skeleton + "Insert a skeleton for a DevBook XML document." + nil + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<guide " + (let* ((dirname (file-name-directory buffer-file-name)) + (path (if (string-match ".*/devmanual[^/]*/\\(.*\\)" dirname) + (match-string 1 dirname) + (skeleton-read "Path: ")))) + (if (string= path "") + "root=\"true\"" + (concat "self=\"" (file-name-as-directory path) "\""))) + ">\n" + "<chapter>\n" + "<title>" (skeleton-read "Title: ") "</title>\n" + - "\n" + "</chapter>\n" + "</guide>\n") + +(define-key devbook-mode-map + "\C-c\C-n" 'devbook-insert-skeleton) + +(easy-menu-define devbook-mode-menu devbook-mode-map + "Menu for devbook-mode." + `("DevBook" + ["Insert skeleton" devbook-insert-skeleton])) + +;;;###autoload +(add-to-list 'auto-mode-alist '("/devmanual.*\\.xml\\'" . devbook-mode)) + +(provide 'devbook-mode) + +;; Local Variables: +;; coding: utf-8 +;; End: + +;;; devbook-mode.el ends here diff --git a/ebuild-mode.texi b/ebuild-mode.texi index c524a83..418050a 100644 --- a/ebuild-mode.texi +++ b/ebuild-mode.texi @@ -61,6 +61,7 @@ by skeleton support. * Commands:: What ebuild-mode provides. * ebuild-mode:: Editing ebuilds. * eclass-mode:: Editing eclasses. +* devbook-mode:: Editing the Gentoo Devmanual. * gentoo-newsitem-mode:: Editing GLEP 42 news items. * glep-mode:: Editing Gentoo Linux Enhancement Proposals. @end menu @@ -174,12 +175,26 @@ Run Portage's ebuild command, you are prompted for the phase you want. Create a ChangeLog entry. @end table -@node eclass-mode, gentoo-newsitem-mode, ebuild-mode, Top +@node eclass-mode, devbook-mode, ebuild-mode, Top @chapter eclass-mode There is no special eclass-mode but ebuild-mode is used without the commands that make no sense in eclasses. -@node gentoo-newsitem-mode, glep-mode, eclass-mode, Top +@node devbook-mode, gentoo-newsitem-mode, eclass-mode, Top +@chapter devbook-mode for the Gentoo Devmanual +This is a very simple derived major mode for editing the Devmanual. +Because the Devmanual is written in DevBook XML, this mode is derived +from @code{nxml-mode} and inherits its syntax highlighting and editing +functions. A skeleton for a new Devmanual file can be inserted via +the @code{devbook-insert-skeleton} function bound to @kbd{C-c C-n}. + +It is recommended to install the @code{app-emacs/nxml-gentoo-schemas} +package in addition, which will enable on-the-fly syntax validation. + +Currently @code{devbook-mode} works with GNU Emacs only, because the +underlying @code{nxml-mode} does not support XEmacs. + +@node gentoo-newsitem-mode, glep-mode, devbook-mode, Top @chapter gentoo-newsitem-mode for GLEP 42 news items This mode supports the highlighting of relevant keywords for GLEP 42 news items. These news items get displayed if special criteria for |