[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo.el
From: |
Stefan Monnier |
Subject: |
texinfo.el |
Date: |
Thu, 05 Oct 2000 15:53:16 -0400 |
I recently committed changes to texinfo.el in Emacs' CVS repository
without realizing that this file was not maintained by the FSF.
I attach the corresponding patch below.
Could you tell me which part could stay, which part should be
reshaped and which part is "out of the question" ?
Stefan
(texinfo-font-lock-syntactic-keywords):
Add regexp for @ignore ... @end ignore.
(texinfo-heading-face): New face.
(texinfo-font-lock-keywords): Use it.
(texinfo-mode-menu): New menu.
(texinfo-inside-macro-p, texinfo-inside-env-p, texinfo-insert-quote):
New functions.
(texinfo-mode-map): Bind " to insert-quote and M-RET to address@hidden
(texinfo-section-types-regexp, texinfo-section-level-regexp)
(texinfo-subsection-level-regexp, texinfo-subsubsection-level-regexp):
Remove declaration.
(texinfo-show-structure): Use outline-regexp and texinfo-section-list.
Index: texinfo.el
===================================================================
RCS file: /cvs/emacs/lisp/textmodes/texinfo.el,v
retrieving revision 1.67
retrieving revision 1.70
diff -u -u -b -r1.67 -r1.70
--- texinfo.el 2000/09/25 11:16:43 1.67
+++ texinfo.el 2000/10/03 18:33:10 1.70
@@ -243,6 +243,27 @@
;;; Don't you dare insert any `require' calls at top level in this file--rms.
+(defvar texinfo-section-list
+ '(("top" 1)
+ ("majorheading" 1)
+ ("chapter" 2)
+ ("unnumbered" 2)
+ ("appendix" 2)
+ ("chapheading" 2)
+ ("section" 3)
+ ("unnumberedsec" 3)
+ ("appendixsec" 3)
+ ("heading" 3)
+ ("subsection" 4)
+ ("unnumberedsubsec" 4)
+ ("appendixsubsec" 4)
+ ("subheading" 4)
+ ("subsubsection" 5)
+ ("unnumberedsubsubsec" 5)
+ ("appendixsubsubsec" 5)
+ ("subsubheading" 5))
+ "Alist of sectioning commands and their relative level.")
+
;;; Syntax table
(defvar texinfo-mode-syntax-table nil)
@@ -267,15 +288,21 @@
(defvar texinfo-imenu-generic-expression
'((nil "address@hidden \t]+\\([^,\n]*\\)" 1)
("Chapters" "address@hidden \t]+\\(.*\\)$" 1))
-
"Imenu generic expression for TexInfo mode. See
`imenu-generic-expression'.")
(defvar texinfo-font-lock-syntactic-keywords
- '(("\\(@\\)c\\(omment\\)?\\>" (1 '(11))))
+ '(("\\(@\\)c\\(omment\\)?\\>" (1 '(11)))
+ ("^\\(@\\)ignore\\>" (1 '(2097163)))
+ ("address@hidden ignore\\(\n\\)" (1 '(2097164))))
"Syntactic keywords to catch comment delimiters in `texinfo-mode'.")
+(defface texinfo-heading-face
+ '((t (:inherit font-lock-function-name-face)))
+ "Face used for section headings in `texinfo-mode'.")
+(defvar texinfo-heading-face 'texinfo-heading-face)
+
(defvar texinfo-font-lock-keywords
- '(;; All but the first had an OVERRIDE of t.
+ `(;; All but the first had an OVERRIDE of t.
;; It didn't seem to be any better, and it's slower--simon.
;; Robert J. Chassell <address@hidden> says remove this line.
;;("\\$\\([^$]*\\)\\$" 1 font-lock-string-face t)
@@ -287,30 +314,10 @@
2 font-lock-variable-name-face)
("@\\(cite\\|[ux]?ref\\|pxref\\){\\([^}]+\\)" 2 font-lock-constant-face)
("@\\(end\\|itemx?\\) +\\(.+\\)" 2 font-lock-function-name-face keep)
- )
+ (,(concat "^@" (regexp-opt (mapcar 'car texinfo-section-list) t)
+ ".*\n") 0 texinfo-heading-face t))
"Additional expressions to highlight in TeXinfo mode.")
-(defvar texinfo-section-list
- '(("top" 1)
- ("majorheading" 1)
- ("chapter" 2)
- ("unnumbered" 2)
- ("appendix" 2)
- ("chapheading" 2)
- ("section" 3)
- ("unnumberedsec" 3)
- ("appendixsec" 3)
- ("heading" 3)
- ("subsection" 4)
- ("unnumberedsubsec" 4)
- ("appendixsubsec" 4)
- ("subheading" 4)
- ("subsubsection" 5)
- ("unnumberedsubsubsec" 5)
- ("appendixsubsubsec" 5)
- ("subsubheading" 5))
- "Alist of sectioning commands and their relative level.")
-
(defun texinfo-outline-level ()
;; Calculate level of current texinfo outline heading.
(save-excursion
@@ -354,9 +361,7 @@
;; bindings for `texnfo-tex.el'
(texinfo-define-common-keys texinfo-mode-map)
- ;; Bindings from `tex-mode.el'
- ;; This should still use " when inside @example and @code
- ;;(define-key texinfo-mode-map "\"" 'tex-insert-quote)
+ (define-key texinfo-mode-map "\"" 'texinfo-insert-quote)
;; bindings for `makeinfo.el'
(define-key texinfo-mode-map "\C-c\C-m\C-k" 'kill-compilation)
@@ -369,6 +374,9 @@
(define-key texinfo-mode-map "\C-c\C-e\C-r" 'texinfo-format-region)
(define-key texinfo-mode-map "\C-c\C-e\C-b" 'texinfo-format-buffer)
+ ;; AUCTeX-like bindings
+ (define-key texinfo-mode-map "\e\r" 'address@hidden)
+
;; bindings for updating nodes and menus
(define-key texinfo-mode-map "\C-c\C-um" 'texinfo-master-menu)
@@ -407,6 +415,27 @@
(define-key texinfo-mode-map "\C-c\C-cd" 'address@hidden)
(define-key texinfo-mode-map "\C-c\C-cc" 'address@hidden))
+(easy-menu-define texinfo-mode-menu
+ texinfo-mode-map
+ "Menu used for `texinfo-mode'."
+ '("Texinfo"
+ ["Insert block" texinfo-insert-block t]
+ ;; ["Insert node" address@hidden t]
+ "----"
+ ["Update All" (lambda () (interactive) (texinfo-master-menu t))
+ :keys "\\[universal-argument] \\[texinfo-master-menu]"]
+ ["Update every node" texinfo-every-node-update t]
+ ["Update node" texinfo-update-node t]
+ ["Make Master menu" texinfo-master-menu t]
+ ["Make menu" texinfo-make-menu t]
+ ["Update all menus" texinfo-all-menus-update t]
+ "----"
+ ["Show structure" texinfo-show-structure t]
+ ["Format region" texinfo-format-region t]
+ ["Format buffer" texinfo-format-buffer t]
+ ["Makeinfo region" makeinfo-region t]
+ ["Makeinfo buffer" makeinfo-buffer t]))
+
;;; Texinfo mode
@@ -609,6 +638,39 @@
(completing-read "Block name: " (mapcar 'list texinfo-environments))
"@" str \n _ \n "@end " str \n)
+(defun texinfo-inside-macro-p (macro &optional bound)
+ "Non-nil if inside a macro matching the regexp MACRO."
+ (ignore-errors
+ (save-excursion
+ (save-restriction
+ (narrow-to-region bound (point))
+ (while (progn
+ (up-list -1)
+ (not (ignore-errors
+ (save-excursion
+ (backward-sexp 1)
+ (looking-at macro))))))
+ t))))
+
+(defun texinfo-inside-env-p (env &optional bound)
+ "Non-nil if inside an environment matching the regexp @ENV."
+ (save-excursion
+ (and (re-search-backward (concat "@\\(end\\s +\\)?" env) bound t)
+ (looking-at (concat "@" env)))))
+
+(autoload 'tex-insert-quote "tex-mode" nil t)
+(defun texinfo-insert-quote (&optional arg)
+ "Insert the appropriate quote mark for TeXinfo.
+Inserts a plain \" if inside @code or @example, else inserts `` or ''
+by calling `tex-insert-quote'."
+ (interactive "*P")
+ (let ((top (or (save-excursion (re-search-backward "@node\\>" nil t))
+ (point-min))))
+ (if (or (texinfo-inside-env-p "example\\>" top)
+ (texinfo-inside-macro-p "@code\\>" top))
+ (self-insert-command (prefix-numeric-value arg))
+ (tex-insert-quote arg))))
+
;; The following address@hidden command not only inserts a SPC
;; after the @end, but tries to find out what belongs there. It is
;; not very smart: it does not understand nested lists.
@@ -771,12 +833,6 @@
;;; Texinfo file structure
-;; These are defined in texnfo-upd.el. defvars here avoid warnings.
-(defvar texinfo-section-types-regexp)
-(defvar texinfo-section-level-regexp)
-(defvar texinfo-subsection-level-regexp)
-(defvar texinfo-subsubsection-level-regexp)
-
(defun texinfo-show-structure (&optional nodes-too)
"Show the structure of a Texinfo file.
List the lines in the file that begin with the @-sign commands for
@@ -792,12 +848,11 @@
to jump to the corresponding spot in the Texinfo source file."
(interactive "P")
- (require 'texnfo-upd)
(save-excursion
(goto-char (point-min))
(if nodes-too
- (occur (concat "\\(address@hidden)\\|" texinfo-section-types-regexp))
- (occur texinfo-section-types-regexp)))
+ (occur (concat "address@hidden>\\|" outline-regexp))
+ (occur outline-regexp)))
(pop-to-buffer "*Occur*")
(goto-char (point-min))
(let ((inhibit-read-only t))
@@ -805,41 +860,11 @@
;; Now format the "*Occur*" buffer to show the structure.
;; Thanks to address@hidden (Per Cederqvist)
(goto-char (point-max))
- (let ((margin 5))
- (while (re-search-backward "^ *[0-9]*:" nil 0)
- (re-search-forward ":")
- (setq margin
- (cond
- ((looking-at
- (concat "@\\(" texinfo-chapter-level-regexp "\\)")) 5)
- ;; ((looking-at "@chapter ") 5)
- ;; ((looking-at "@unnumbered ") 5)
- ;; ((looking-at "@appendix ") 5)
- ;; ((looking-at "@majorheading ") 5)
- ;; ((looking-at "@chapheading ") 5)
-
- ((looking-at
- (concat "@\\(" texinfo-section-level-regexp "\\)")) 9)
- ;; ((looking-at "@section ") 9)
- ;; ((looking-at "@unnumberedsec ") 9)
- ;; ((looking-at "@appendixsec ") 9)
- ;; ((looking-at "@heading ") 9)
-
- ((looking-at
- (concat "@\\(" texinfo-subsection-level-regexp "\\)")) 13)
- ;; ((looking-at "@subsection ") 13)
- ;; ((looking-at "@unnumberedsubsec ") 13)
- ;; ((looking-at "@appendixsubsec ") 13)
- ;; ((looking-at "@subheading ") 13)
-
- ((looking-at
- (concat "@\\(" texinfo-subsubsection-level-regexp "\\)")) 17)
- ;; ((looking-at "@subsubsection ") 17)
- ;; ((looking-at "@unnumberedsubsubsec ") 17)
- ;; ((looking-at "@appendixsubsubsec ") 17)
- ;; ((looking-at "@subsubheading ") 17)
- (t margin)))
- (indent-to-column margin)
+ (let (level)
+ (while (re-search-backward "^ *[0-9]*:@\\(\\sw+\\)" nil 0)
+ (goto-char (1- (match-beginning 1)))
+ (setq level (or (cadr (assoc (match-string 1) texinfo-section-list)) 2))
+ (indent-to-column (+ (current-column) (* 4 (- level 2))))
(beginning-of-line)))))
;;; The tex and print function definitions:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo.el,
Stefan Monnier <=