;;; texinfo.el --- major mode for editing Texinfo files -*- coding: utf-8 -*-
-;; Copyright (C) 1985, 1988-1993, 1996-1997, 2000-2012
-;; Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1988-1993, 1996-1997, 2000-2015 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.
(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)
(regexp-opt (texinfo-filter 2 texinfo-section-list))
"Regular expression matching just the Texinfo chapter level headings.")
+(defun texinfo-current-defun-name ()
+ "Return the name of the Texinfo node at point, or nil."
+ (save-excursion
+ (if (re-search-backward "^@node[ \t]+\\([^,\n]+\\)" nil t)
+ (match-string-no-properties 1))))
+
;;; Texinfo mode
;;;###autoload
(setq-local require-final-newline mode-require-final-newline)
(setq-local indent-tabs-mode nil)
(setq-local paragraph-separate
- (concat "\b\\|@[a-zA-Z]*[ \n]\\|" paragraph-separate))
- (setq-local paragraph-start (concat "\b\\|@[a-zA-Z]*[ \n]\\|" paragraph-start))
+ (concat "\b\\|@[a-zA-Z]*[ \n]\\|"
+ paragraph-separate))
+ (setq-local paragraph-start (concat "\b\\|@[a-zA-Z]*[ \n]\\|"
+ paragraph-start))
(setq-local sentence-end-base "\\(@\\(end\\)?dots{}\\|[.?!]\\)[]\"'”)}]*")
(setq-local fill-column 70)
(setq-local comment-start "@c ")
'(texinfo-font-lock-keywords nil nil nil backward-paragraph))
(setq-local syntax-propertize-function texinfo-syntax-propertize-function)
(setq-local parse-sexp-lookup-properties t)
+ (setq-local add-log-current-defun-function #'texinfo-current-defun-name)
;; Outline settings.
(setq-local outline-heading-alist
(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
(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."
(not (match-end 1)))))
(defvar texinfo-enable-quote-macros "@\\(code\\|samp\\|kbd\\)\\>")
-(defvar texinfo-enable-quote-envs '("example\\>" "lisp\\>"))
+(defvar texinfo-enable-quote-envs
+ '("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
+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")
(backward-word 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.
(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.
(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.