diff options
| author | Stefan Monnier | 2003-03-14 22:29:13 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2003-03-14 22:29:13 +0000 |
| commit | f412245b470c1d52dda54f285a0eacb29d5b7a2a (patch) | |
| tree | bbeabbb30d5468e213f68c1b58bc716cbb89d91b | |
| parent | 8973cfc9158f00f291c61f7c7ac2a966afd26cc7 (diff) | |
| download | emacs-f412245b470c1d52dda54f285a0eacb29d5b7a2a.tar.gz emacs-f412245b470c1d52dda54f285a0eacb29d5b7a2a.zip | |
(texinfo-outline-level): Remove.
(texinfo-mode): Set outline-heading-alist instead.
(texinfo-section-list): Reorder for the needs of outline-heading-alist.
(texinfo-insert-block): Don't cons needlessly.
(texinfo-enable-quote-macros, texinfo-enable-quote-envs): New vars.
(texinfo-insert-quote): Use them.
| -rw-r--r-- | lisp/textmodes/texinfo.el | 62 |
1 files changed, 30 insertions, 32 deletions
diff --git a/lisp/textmodes/texinfo.el b/lisp/textmodes/texinfo.el index 5b8de9fa3e5..3b9b9c7b1e3 100644 --- a/lisp/textmodes/texinfo.el +++ b/lisp/textmodes/texinfo.el | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | ;;; Todo: | 28 | ;;; Todo: |
| 29 | 29 | ||
| 30 | ;; - facemenu support. | 30 | ;; - facemenu support. |
| 31 | ;; - command completion. | ||
| 31 | 32 | ||
| 32 | ;;; Commentary: | 33 | ;;; Commentary: |
| 33 | 34 | ||
| @@ -265,22 +266,22 @@ chapter." | |||
| 265 | 266 | ||
| 266 | (defvar texinfo-section-list | 267 | (defvar texinfo-section-list |
| 267 | '(("top" 1) | 268 | '(("top" 1) |
| 268 | ("majorheading" 2) | ||
| 269 | ("chapter" 2) | 269 | ("chapter" 2) |
| 270 | ("unnumbered" 2) | ||
| 271 | ("appendix" 2) | ||
| 272 | ("chapheading" 2) | ||
| 273 | ("section" 3) | 270 | ("section" 3) |
| 274 | ("unnumberedsec" 3) | ||
| 275 | ("appendixsec" 3) | ||
| 276 | ("heading" 3) | ||
| 277 | ("subsection" 4) | 271 | ("subsection" 4) |
| 278 | ("unnumberedsubsec" 4) | ||
| 279 | ("appendixsubsec" 4) | ||
| 280 | ("subheading" 4) | ||
| 281 | ("subsubsection" 5) | 272 | ("subsubsection" 5) |
| 273 | ("unnumbered" 2) | ||
| 274 | ("unnumberedsec" 3) | ||
| 275 | ("unnumberedsubsec" 4) | ||
| 282 | ("unnumberedsubsubsec" 5) | 276 | ("unnumberedsubsubsec" 5) |
| 277 | ("appendix" 2) | ||
| 278 | ("appendixsec" 3) | ||
| 279 | ("appendixsubsec" 4) | ||
| 283 | ("appendixsubsubsec" 5) | 280 | ("appendixsubsubsec" 5) |
| 281 | ("majorheading" 2) | ||
| 282 | ("chapheading" 2) | ||
| 283 | ("heading" 3) | ||
| 284 | ("subheading" 4) | ||
| 284 | ("subsubheading" 5)) | 285 | ("subsubheading" 5)) |
| 285 | "Alist of sectioning commands and their relative level.") | 286 | "Alist of sectioning commands and their relative level.") |
| 286 | 287 | ||
| @@ -384,19 +385,6 @@ Subexpression 1 is what goes into the corresponding `@end' statement.") | |||
| 384 | (concat (regexp-quote (buffer-substring start end)) "\\>")) | 385 | (concat (regexp-quote (buffer-substring start end)) "\\>")) |
| 385 | (text-clone-create start end 'spread "\\w*"))))))) | 386 | (text-clone-create start end 'spread "\\w*"))))))) |
| 386 | 387 | ||
| 387 | (defun texinfo-outline-level () | ||
| 388 | ;; Calculate level of current texinfo outline heading. | ||
| 389 | (save-excursion | ||
| 390 | (if (bobp) | ||
| 391 | 0 | ||
| 392 | (forward-char 1) | ||
| 393 | (let* ((word (buffer-substring-no-properties | ||
| 394 | (point) (progn (forward-word 1) (point)))) | ||
| 395 | (entry (assoc word texinfo-section-list))) | ||
| 396 | (if entry | ||
| 397 | (nth 1 entry) | ||
| 398 | 5))))) | ||
| 399 | |||
| 400 | 388 | ||
| 401 | ;;; Keybindings | 389 | ;;; Keybindings |
| 402 | (defvar texinfo-mode-map nil) | 390 | (defvar texinfo-mode-map nil) |
| @@ -613,11 +601,17 @@ value of `texinfo-mode-hook'." | |||
| 613 | (font-lock-syntactic-keywords | 601 | (font-lock-syntactic-keywords |
| 614 | . texinfo-font-lock-syntactic-keywords))) | 602 | . texinfo-font-lock-syntactic-keywords))) |
| 615 | (set (make-local-variable 'parse-sexp-lookup-properties) t) | 603 | (set (make-local-variable 'parse-sexp-lookup-properties) t) |
| 616 | (make-local-variable 'outline-regexp) | 604 | |
| 617 | (setq outline-regexp | 605 | ;; Outline settings. |
| 618 | (concat "@" (regexp-opt (mapcar 'car texinfo-section-list) t) "\\>")) | 606 | (set (make-local-variable 'outline-heading-alist) |
| 619 | (make-local-variable 'outline-level) | 607 | ;; We should merge outline-heading-alist and texinfo-section-list |
| 620 | (setq outline-level 'texinfo-outline-level) | 608 | ;; but in the mean time, let's just generate one from the other. |
| 609 | (mapcar (lambda (x) (cons (concat "@" (car x)) (cadr x))) | ||
| 610 | texinfo-section-list)) | ||
| 611 | (set (make-local-variable 'outline-regexp) | ||
| 612 | (concat (regexp-opt (mapcar 'car outline-heading-alist) t) | ||
| 613 | "\\>")) | ||
| 614 | |||
| 621 | (make-local-variable 'tex-start-of-header) | 615 | (make-local-variable 'tex-start-of-header) |
| 622 | (setq tex-start-of-header "%\\*\\*start") | 616 | (setq tex-start-of-header "%\\*\\*start") |
| 623 | (make-local-variable 'tex-end-of-header) | 617 | (make-local-variable 'tex-end-of-header) |
| @@ -646,7 +640,7 @@ value of `texinfo-mode-hook'." | |||
| 646 | Puts point on a blank line between them." | 640 | Puts point on a blank line between them." |
| 647 | (setq texinfo-block-default | 641 | (setq texinfo-block-default |
| 648 | (completing-read (format "Block name [%s]: " texinfo-block-default) | 642 | (completing-read (format "Block name [%s]: " texinfo-block-default) |
| 649 | (mapcar 'list texinfo-environments) | 643 | texinfo-environments |
| 650 | nil nil nil nil texinfo-block-default)) | 644 | nil nil nil nil texinfo-block-default)) |
| 651 | \n "@" str \n _ \n "@end " str \n) | 645 | \n "@" str \n _ \n "@end " str \n) |
| 652 | 646 | ||
| @@ -672,6 +666,8 @@ Puts point on a blank line between them." | |||
| 672 | (and (re-search-backward (concat "@\\(end\\s +\\)?" env) bound t) | 666 | (and (re-search-backward (concat "@\\(end\\s +\\)?" env) bound t) |
| 673 | (not (match-end 1))))) | 667 | (not (match-end 1))))) |
| 674 | 668 | ||
| 669 | (defvar texinfo-enable-quote-macros '("@\\(code\\|samp\\|kbd\\)\\>")) | ||
| 670 | (defvar texinfo-enable-quote-envs '("example\\>" "lisp\\>")) | ||
| 675 | (defun texinfo-insert-quote (&optional arg) | 671 | (defun texinfo-insert-quote (&optional arg) |
| 676 | "Insert the appropriate quote mark for TeXinfo. | 672 | "Insert the appropriate quote mark for TeXinfo. |
| 677 | Usually inserts the value of `texinfo-open-quote' (normally ``) or | 673 | Usually inserts the value of `texinfo-open-quote' (normally ``) or |
| @@ -688,9 +684,11 @@ With prefix argument or inside @code or @example, inserts a plain \"." | |||
| 688 | (looking-at texinfo-close-quote)) | 684 | (looking-at texinfo-close-quote)) |
| 689 | (delete-char (length texinfo-open-quote)) | 685 | (delete-char (length texinfo-open-quote)) |
| 690 | t)) | 686 | t)) |
| 691 | (texinfo-inside-macro-p "@\\(code\\|samp\\|kbd\\)\\>" top) | 687 | (texinfo-inside-macro-p texinfo-enable-quote-macros top) |
| 692 | (texinfo-inside-env-p "example\\>" top) | 688 | (let ((in-env nil)) |
| 693 | (texinfo-inside-env-p "lisp\\>" top)) | 689 | (dolist (env texinfo-enable-quote-envs in-env) |
| 690 | (if (texinfo-inside-env-p env top) | ||
| 691 | (setq in-env t))))) | ||
| 694 | (self-insert-command (prefix-numeric-value arg)) | 692 | (self-insert-command (prefix-numeric-value arg)) |
| 695 | (insert | 693 | (insert |
| 696 | (if (memq (char-syntax (preceding-char)) '(?\( ?> ?\ )) | 694 | (if (memq (char-syntax (preceding-char)) '(?\( ?> ?\ )) |