]> code.delx.au - gnu-emacs/blobdiff - lisp/textmodes/texinfo.el
Add new function dom-remove-node
[gnu-emacs] / lisp / textmodes / texinfo.el
index 44e839d2474527a8212b2d928e17965fa77b8c74..db9944d9b0ec5954b85545fc7a10c7373cae36a5 100644 (file)
@@ -1,11 +1,11 @@
-;;; texinfo.el --- major mode for editing Texinfo files -*- coding: utf-8 -*-
+;;; texinfo.el --- major mode for editing Texinfo files
 
-;; Copyright (C) 1985, 1988-1993, 1996-1997, 2000-2013 Free Software
+;; Copyright (C) 1985, 1988-1993, 1996-1997, 2000-2016 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Robert J. Chassell
 ;; Date:   [See date below for texinfo-version]
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
 ;; Keywords: maint, tex, docs
 
 ;; This file is part of GNU Emacs.
@@ -44,6 +44,8 @@
 
 (defvar outline-heading-alist)
 
+(defvar skeleton-end-newline)
+
 (defgroup texinfo nil
   "Texinfo Mode."
   :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
@@ -84,7 +86,7 @@ command to gain use of `next-error'."
   "Make Info file from current buffer.
 
 Use the \\[next-error] command to move to the next error
-\(if there are errors\)."
+\(if there are errors)."
   t nil)
 
 (autoload 'kill-compilation
@@ -349,8 +351,6 @@ Subexpression 1 is what goes into the corresponding `@end' statement.")
   '((t (:inherit font-lock-function-name-face)))
   "Face used for section headings in `texinfo-mode'."
   :group 'texinfo)
-(define-obsolete-face-alias 'texinfo-heading-face 'texinfo-heading "22.1")
-(defvar texinfo-heading-face 'texinfo-heading)
 
 (defvar texinfo-font-lock-keywords
   `(;; All but the first had an OVERRIDE of t.
@@ -366,8 +366,10 @@ Subexpression 1 is what goes into the corresponding `@end' statement.")
     ;; their arguments frequently include a @@, and we don't want that
     ;; to overwrite the normal fontification of the argument.
     ("@\\(file\\|email\\){\\([^}]+\\)" 2 font-lock-string-face keep)
-    ("@\\(samp\\|code\\|var\\|math\\|env\\|command\\|option\\){\\([^}]+\\)"
+    ("@\\(samp\\|code\\|var\\|env\\|command\\|option\\){\\([^}]+\\)"
      2 font-lock-variable-name-face keep)
+    ;; @math allows nested braces like @math{2^{12}}
+    ("@math{\\([^{}]*{?[^{}]*}?[^{}]*\\)}" 1 font-lock-variable-name-face)
     ("@\\(cite\\|x?ref\\|pxref\\|dfn\\|inforef\\){\\([^}]+\\)"
      2 font-lock-constant-face)
     ("@\\(anchor\\){\\([^}]+\\)" 2 font-lock-type-face)
@@ -376,7 +378,8 @@ Subexpression 1 is what goes into the corresponding `@end' statement.")
     ;; (,texinfo-environment-regexp
     ;;  1 (texinfo-clone-environment (match-beginning 1) (match-end 1)) keep)
     (,(concat "^@" (regexp-opt (mapcar 'car texinfo-section-list) t)
-              ".*\n") 0 texinfo-heading-face t))
+              ".*\n")
+     0 texinfo-heading t))
   "Additional expressions to highlight in Texinfo mode.")
 
 (defun texinfo-clone-environment (start end)
@@ -389,7 +392,7 @@ Subexpression 1 is what goes into the corresponding `@end' statement.")
        (unless (get-char-property start 'text-clones)
          (if endp
              (texinfo-last-unended-begin)
-           (forward-word 1)
+           (forward-word-strictly 1)
            (texinfo-next-unmatched-end))
          (skip-syntax-forward "^w")
          (when (looking-at
@@ -626,6 +629,11 @@ value of `texinfo-mode-hook'."
   (setq-local tex-first-line-header-regexp "^\\\\input")
   (setq-local tex-trailer "@bye\n")
 
+  ;; Prevent skeleton.el from adding a newline to each inserted
+  ;; skeleton.  Those which do want a newline do that explicitly in
+  ;; their define-skeleton form.
+  (setq-local skeleton-end-newline nil)
+
   ;; Prevent filling certain lines, in addition to ones specified by
   ;; the user.
   (setq-local auto-fill-inhibit-regexp
@@ -653,7 +661,7 @@ Puts point on a blank line between them."
   (if (or (string-match "\\`def" str)
           (member str '("table" "ftable" "vtable")))
       '(nil " " -))
-  \n _ \n "@end " str \n)
+  \n _ \n "@end " str \n \n)
 
 (defun texinfo-inside-macro-p (macro &optional bound)
   "Non-nil if inside a macro matching the regexp MACRO."
@@ -682,8 +690,8 @@ Puts point on a blank line between them."
   '("example\\>" "smallexample\\>" "lisp\\>"))
 (defun texinfo-insert-quote (&optional arg)
   "Insert the appropriate quote mark for Texinfo.
-Usually inserts the value of `texinfo-open-quote' (normally ``) or
-`texinfo-close-quote' (normally ''), depending on the context.
+Usually inserts the value of `texinfo-open-quote' (normally \\=`\\=`) or
+`texinfo-close-quote' (normally \\='\\='), depending on the context.
 With prefix argument or inside @code or @example, inserts a plain \"."
   (interactive "*P")
   (let ((top (or (save-excursion (re-search-backward "@node\\>" nil t))
@@ -729,10 +737,10 @@ With prefix argument or inside @code or @example, inserts a plain \"."
   "Insert the matching `@end' for the last Texinfo command that needs one."
         (ignore-errors
           (save-excursion
-      (backward-word 1)
+             (backward-word-strictly 1)
             (texinfo-last-unended-begin)
       (or (match-string 1) '-)))
-  \n "@end " str \n)
+  \n "@end " str \n \n)
 
 (define-skeleton texinfo-insert-braces
   "Make a pair of braces and be poised to type inside of them.
@@ -771,7 +779,7 @@ The default is not to surround any existing words with the braces."
 (define-skeleton texinfo-insert-@example
   "Insert the string `@example' in a Texinfo buffer."
   nil
-  \n "@example" \n)
+  \n "@example" \n \n)
 
 (define-skeleton texinfo-insert-@file
   "Insert a `@file{...}' command in a Texinfo buffer.
@@ -816,7 +824,7 @@ Leave point after `@node'."
 
 (define-skeleton texinfo-insert-@quotation
   "Insert the string `@quotation' in a Texinfo buffer."
-  \n "@quotation" \n)
+  \n "@quotation" \n _ \n)
 
 (define-skeleton texinfo-insert-@samp
   "Insert a `@samp{...}' command in a Texinfo buffer.