diff options
| author | Stefan Monnier | 2000-12-08 16:31:50 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2000-12-08 16:31:50 +0000 |
| commit | a11609d8c3c1df07c3e77726cfd2db82a7dbc560 (patch) | |
| tree | fc29998e298b8a15ebb594acfec59c510dad2095 | |
| parent | 30cd075d946b02da3ed5118c527eaeed8b1d6088 (diff) | |
| download | emacs-a11609d8c3c1df07c3e77726cfd2db82a7dbc560.tar.gz emacs-a11609d8c3c1df07c3e77726cfd2db82a7dbc560.zip | |
Move the (require 'cl) to the front of the
file where it's more visible.
(texinfo-filter, texinfo-chapter-level-regexp): New variables
moved from texnfo-upd.el (for AUCTeX's compatibility, originally).
(texinfo-mode): Use texinfo-chapter-level-regexp for page-delimiter.
(texinfo-inside-macro-p): Only catch `scan-error's.
(texinfo-inside-env-p): Make better use of the match info.
(texinfo-insert-quote): Collapse calls to `texinfo-inside-macro-p'.
(texinfo-insert-@end): Slight re-organization.
Also remove useless `looking-at' call.
| -rw-r--r-- | lisp/textmodes/texinfo.el | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/lisp/textmodes/texinfo.el b/lisp/textmodes/texinfo.el index c416d1f1c9f..eb3b0b246b5 100644 --- a/lisp/textmodes/texinfo.el +++ b/lisp/textmodes/texinfo.el | |||
| @@ -34,7 +34,7 @@ | |||
| 34 | (defmacro defcustom (var value doc &rest ignore) | 34 | (defmacro defcustom (var value doc &rest ignore) |
| 35 | `(defvar ,var ,value ,doc))) | 35 | `(defvar ,var ,value ,doc))) |
| 36 | 36 | ||
| 37 | (eval-when-compile (require 'tex-mode)) | 37 | (eval-when-compile (require 'tex-mode) (require 'cl)) |
| 38 | 38 | ||
| 39 | (defgroup texinfo nil | 39 | (defgroup texinfo nil |
| 40 | "Texinfo Mode" | 40 | "Texinfo Mode" |
| @@ -256,7 +256,6 @@ chapter." | |||
| 256 | ;;; Code: | 256 | ;;; Code: |
| 257 | 257 | ||
| 258 | ;;; Don't you dare insert any `require' calls at top level in this file--rms. | 258 | ;;; Don't you dare insert any `require' calls at top level in this file--rms. |
| 259 | (eval-when-compile (require 'cl)) ;; for ignore-errors | ||
| 260 | 259 | ||
| 261 | (defvar texinfo-section-list | 260 | (defvar texinfo-section-list |
| 262 | '(("top" 1) | 261 | '(("top" 1) |
| @@ -451,6 +450,15 @@ chapter." | |||
| 451 | ["Makeinfo buffer" makeinfo-buffer t])) | 450 | ["Makeinfo buffer" makeinfo-buffer t])) |
| 452 | 451 | ||
| 453 | 452 | ||
| 453 | (defun texinfo-filter (section list) | ||
| 454 | (let (res) | ||
| 455 | (dolist (x list) (if (eq section (cadr x)) (push (car x) res))) | ||
| 456 | res)) | ||
| 457 | |||
| 458 | (defvar texinfo-chapter-level-regexp | ||
| 459 | (regexp-opt (texinfo-filter 2 texinfo-section-list)) | ||
| 460 | "Regular expression matching just the Texinfo chapter level headings.") | ||
| 461 | |||
| 454 | ;;; Texinfo mode | 462 | ;;; Texinfo mode |
| 455 | 463 | ||
| 456 | ;;;###autoload | 464 | ;;;###autoload |
| @@ -518,14 +526,14 @@ Top node, is accompanied by some kind of section line, such as an | |||
| 518 | If the file has a `top' node, it must be called `top' or `Top' and | 526 | If the file has a `top' node, it must be called `top' or `Top' and |
| 519 | be the first node in the file. | 527 | be the first node in the file. |
| 520 | 528 | ||
| 529 | |||
| 521 | Entering Texinfo mode calls the value of `text-mode-hook', and then the | 530 | Entering Texinfo mode calls the value of `text-mode-hook', and then the |
| 522 | value of `texinfo-mode-hook'." | 531 | value of `texinfo-mode-hook'." |
| 523 | (make-local-variable 'page-delimiter) | 532 | (set (make-local-variable 'page-delimiter) |
| 524 | (setq page-delimiter | 533 | (concat |
| 525 | (concat | 534 | "^@node [ \t]*[Tt]op\\|^@\\(" |
| 526 | "^@node [ \t]*[Tt]op\\|^@\\(" | 535 | texinfo-chapter-level-regexp |
| 527 | "chapter\\|unnumbered \\|appendix \\|majorheading\\|chapheading" | 536 | "\\)\\>")) |
| 528 | "\\)")) | ||
| 529 | (make-local-variable 'require-final-newline) | 537 | (make-local-variable 'require-final-newline) |
| 530 | (setq require-final-newline t) | 538 | (setq require-final-newline t) |
| 531 | (make-local-variable 'indent-tabs-mode) | 539 | (make-local-variable 'indent-tabs-mode) |
| @@ -571,13 +579,11 @@ value of `texinfo-mode-hook'." | |||
| 571 | ;; Prevent filling certain lines, in addition to ones specified | 579 | ;; Prevent filling certain lines, in addition to ones specified |
| 572 | ;; by the user. | 580 | ;; by the user. |
| 573 | (let ((prevent-filling "^@\\(def\\|multitable\\)")) | 581 | (let ((prevent-filling "^@\\(def\\|multitable\\)")) |
| 574 | (make-local-variable 'auto-fill-inhibit-regexp) | 582 | (set (make-local-variable 'auto-fill-inhibit-regexp) |
| 575 | (if (null auto-fill-inhibit-regexp) | 583 | (if (null auto-fill-inhibit-regexp) |
| 576 | (setq auto-fill-inhibit-regexp prevent-filling) | 584 | prevent-filling |
| 577 | (setq auto-fill-inhibit-regexp | 585 | (concat "\\(" auto-fill-inhibit-regexp "\\)\\|\\(" |
| 578 | (concat "\\(" auto-fill-inhibit-regexp "\\)\\|\\(" | 586 | prevent-filling "\\)"))))) |
| 579 | prevent-filling "\\)"))))) | ||
| 580 | |||
| 581 | 587 | ||
| 582 | 588 | ||
| 583 | ;;; Insert string commands | 589 | ;;; Insert string commands |
| @@ -663,15 +669,15 @@ Puts point on a blank line between them." | |||
| 663 | (save-excursion | 669 | (save-excursion |
| 664 | (backward-sexp 1) | 670 | (backward-sexp 1) |
| 665 | (looking-at macro)) | 671 | (looking-at macro)) |
| 666 | (error nil))))) | 672 | (scan-error nil))))) |
| 667 | t)) | 673 | t)) |
| 668 | (error nil))) | 674 | (scan-error nil))) |
| 669 | 675 | ||
| 670 | (defun texinfo-inside-env-p (env &optional bound) | 676 | (defun texinfo-inside-env-p (env &optional bound) |
| 671 | "Non-nil if inside an environment matching the regexp @ENV." | 677 | "Non-nil if inside an environment matching the regexp @ENV." |
| 672 | (save-excursion | 678 | (save-excursion |
| 673 | (and (re-search-backward (concat "@\\(end\\s +\\)?" env) bound t) | 679 | (and (re-search-backward (concat "@\\(end\\s +\\)?" env) bound t) |
| 674 | (looking-at (concat "@" env))))) | 680 | (not (match-end 1))))) |
| 675 | 681 | ||
| 676 | (defun texinfo-insert-quote (&optional arg) | 682 | (defun texinfo-insert-quote (&optional arg) |
| 677 | "Insert the appropriate quote mark for TeXinfo. | 683 | "Insert the appropriate quote mark for TeXinfo. |
| @@ -684,10 +690,7 @@ With prefix argument or inside @code or @example, inserts a plain \"." | |||
| 684 | (if (or arg | 690 | (if (or arg |
| 685 | (texinfo-inside-env-p "example\\>" top) | 691 | (texinfo-inside-env-p "example\\>" top) |
| 686 | (texinfo-inside-env-p "lisp\\>" top) | 692 | (texinfo-inside-env-p "lisp\\>" top) |
| 687 | (texinfo-inside-macro-p "@code\\>" top) | 693 | (texinfo-inside-macro-p "@\\(code\\|samp\\|kbd\\)\\>" top)) |
| 688 | (texinfo-inside-macro-p "@samp\\>" top) | ||
| 689 | (texinfo-inside-macro-p "@kbd\\>" top) | ||
| 690 | (texinfo-inside-macro-p "@kbd\\>" top)) | ||
| 691 | (self-insert-command (prefix-numeric-value arg)) | 694 | (self-insert-command (prefix-numeric-value arg)) |
| 692 | (insert | 695 | (insert |
| 693 | (cond ((= (preceding-char) ?\\) ?\") | 696 | (cond ((= (preceding-char) ?\\) ?\") |
| @@ -706,14 +709,13 @@ With prefix argument or inside @code or @example, inserts a plain \"." | |||
| 706 | (save-excursion | 709 | (save-excursion |
| 707 | (while (and (> depth 0) | 710 | (while (and (> depth 0) |
| 708 | (re-search-backward texinfo-environment-regexp nil t)) | 711 | (re-search-backward texinfo-environment-regexp nil t)) |
| 709 | (if (looking-at "@end") | 712 | (setq depth (if (looking-at "@end") (1+ depth) (1- depth)))) |
| 710 | (setq depth (1+ depth)) | 713 | (when (zerop depth) |
| 711 | (setq depth (1- depth)))) | 714 | ;; This looking-at is unnecessary since if depth==0, |
| 712 | (looking-at texinfo-environment-regexp) | 715 | ;; (looking-at "@end") has just failed, so the match data is still |
| 713 | (if (zerop depth) | 716 | ;; the one from re-search-backward -sm |
| 714 | (setq string | 717 | ;; (looking-at texinfo-environment-regexp) |
| 715 | (buffer-substring (match-beginning 1) | 718 | (setq string (match-string 1)))) |
| 716 | (match-end 1))))) | ||
| 717 | (insert "@end ") | 719 | (insert "@end ") |
| 718 | (if string (insert string "\n")))) | 720 | (if string (insert string "\n")))) |
| 719 | 721 | ||