28 |
;;; Todo: |
;;; Todo: |
29 |
|
|
30 |
;; - facemenu support. |
;; - facemenu support. |
31 |
|
;; - command completion. |
32 |
|
|
33 |
;;; Commentary: |
;;; Commentary: |
34 |
|
|
266 |
|
|
267 |
(defvar texinfo-section-list |
(defvar texinfo-section-list |
268 |
'(("top" 1) |
'(("top" 1) |
|
("majorheading" 2) |
|
269 |
("chapter" 2) |
("chapter" 2) |
|
("unnumbered" 2) |
|
|
("appendix" 2) |
|
|
("chapheading" 2) |
|
270 |
("section" 3) |
("section" 3) |
|
("unnumberedsec" 3) |
|
|
("appendixsec" 3) |
|
|
("heading" 3) |
|
271 |
("subsection" 4) |
("subsection" 4) |
|
("unnumberedsubsec" 4) |
|
|
("appendixsubsec" 4) |
|
|
("subheading" 4) |
|
272 |
("subsubsection" 5) |
("subsubsection" 5) |
273 |
|
("unnumbered" 2) |
274 |
|
("unnumberedsec" 3) |
275 |
|
("unnumberedsubsec" 4) |
276 |
("unnumberedsubsubsec" 5) |
("unnumberedsubsubsec" 5) |
277 |
|
("appendix" 2) |
278 |
|
("appendixsec" 3) |
279 |
|
("appendixsubsec" 4) |
280 |
("appendixsubsubsec" 5) |
("appendixsubsubsec" 5) |
281 |
|
("majorheading" 2) |
282 |
|
("chapheading" 2) |
283 |
|
("heading" 3) |
284 |
|
("subheading" 4) |
285 |
("subsubheading" 5)) |
("subsubheading" 5)) |
286 |
"Alist of sectioning commands and their relative level.") |
"Alist of sectioning commands and their relative level.") |
287 |
|
|
318 |
"Syntactic keywords to catch comment delimiters in `texinfo-mode'.") |
"Syntactic keywords to catch comment delimiters in `texinfo-mode'.") |
319 |
|
|
320 |
(defconst texinfo-environments |
(defconst texinfo-environments |
321 |
'("cartouche" "defcv" "deffn" "defivar" "defmac" "defmethod" "defop" |
'("cartouche" "copying" "defcv" "deffn" "defivar" "defmac" |
322 |
"defopt" "defspec" "deftp" "deftypefn" "deftypefun" "deftypevar" |
"defmethod" "defop" "defopt" "defspec" "deftp" "deftypefn" |
323 |
"deftypevr" "defun" "defvar" "defvr" "description" "detailmenu" |
"deftypefun" "deftypevar" "deftypevr" "defun" "defvar" |
324 |
"direntry" "display" "enumerate" "example" "flushleft" "flushright" |
"defvr" "description" "detailmenu" "direntry" "display" |
325 |
"format" "ftable" "group" "ifclear" "ifset" "ifhtml" "ifinfo" |
"documentdescription" "enumerate" "example" "flushleft" |
326 |
"ifnothtml" "ifnotinfo" "ifnottex" "iftex" "ignore" "itemize" "lisp" |
"flushright" "format" "ftable" "group" "ifclear" "ifset" |
327 |
"macro" "menu" "multitable" "quotation" "smalldisplay" "smallexample" |
"ifhtml" "ifinfo" "ifnothtml" "ifnotinfo" "ifnotplaintext" |
328 |
"smallformat" "smalllisp" "table" "tex" "titlepage" "vtable") |
"ifnottex" "ifplaintext" "iftex" "ignore" "itemize" "lisp" |
329 |
|
"macro" "menu" "multitable" "quotation" "smalldisplay" |
330 |
|
"smallexample" "smallformat" "smalllisp" "table" "tex" |
331 |
|
"titlepage" "verbatim" "vtable") |
332 |
"List of TeXinfo environments.") |
"List of TeXinfo environments.") |
333 |
|
|
334 |
(defconst texinfo-environment-regexp |
(defconst texinfo-environment-regexp |
362 |
("@\\(anchor\\){\\([^}]+\\)" 2 font-lock-type-face) |
("@\\(anchor\\){\\([^}]+\\)" 2 font-lock-type-face) |
363 |
("@\\(dmn\\|acronym\\|value\\){\\([^}]+\\)" 2 font-lock-builtin-face) |
("@\\(dmn\\|acronym\\|value\\){\\([^}]+\\)" 2 font-lock-builtin-face) |
364 |
("@\\(end\\|itemx?\\) +\\(.+\\)" 2 font-lock-keyword-face keep) |
("@\\(end\\|itemx?\\) +\\(.+\\)" 2 font-lock-keyword-face keep) |
365 |
(,texinfo-environment-regexp |
;; (,texinfo-environment-regexp |
366 |
1 (texinfo-clone-environment (match-beginning 1) (match-end 1)) keep) |
;; 1 (texinfo-clone-environment (match-beginning 1) (match-end 1)) keep) |
367 |
(,(concat "^@" (regexp-opt (mapcar 'car texinfo-section-list) t) |
(,(concat "^@" (regexp-opt (mapcar 'car texinfo-section-list) t) |
368 |
".*\n") 0 texinfo-heading-face t)) |
".*\n") 0 texinfo-heading-face t)) |
369 |
"Additional expressions to highlight in TeXinfo mode.") |
"Additional expressions to highlight in TeXinfo mode.") |
381 |
(forward-word 1) |
(forward-word 1) |
382 |
(texinfo-next-unmatched-end)) |
(texinfo-next-unmatched-end)) |
383 |
(skip-syntax-forward "^w") |
(skip-syntax-forward "^w") |
384 |
(when (looking-at (regexp-quote (buffer-substring start end))) |
(when (looking-at |
385 |
|
(concat (regexp-quote (buffer-substring start end)) "\\>")) |
386 |
(text-clone-create start end 'spread "\\w*"))))))) |
(text-clone-create start end 'spread "\\w*"))))))) |
387 |
|
|
|
(defun texinfo-outline-level () |
|
|
;; Calculate level of current texinfo outline heading. |
|
|
(save-excursion |
|
|
(if (bobp) |
|
|
0 |
|
|
(forward-char 1) |
|
|
(let* ((word (buffer-substring-no-properties |
|
|
(point) (progn (forward-word 1) (point)))) |
|
|
(entry (assoc word texinfo-section-list))) |
|
|
(if entry |
|
|
(nth 1 entry) |
|
|
5))))) |
|
|
|
|
388 |
|
|
389 |
;;; Keybindings |
;;; Keybindings |
390 |
(defvar texinfo-mode-map nil) |
(defvar texinfo-mode-map nil) |
601 |
(font-lock-syntactic-keywords |
(font-lock-syntactic-keywords |
602 |
. texinfo-font-lock-syntactic-keywords))) |
. texinfo-font-lock-syntactic-keywords))) |
603 |
(set (make-local-variable 'parse-sexp-lookup-properties) t) |
(set (make-local-variable 'parse-sexp-lookup-properties) t) |
604 |
(make-local-variable 'outline-regexp) |
|
605 |
(setq outline-regexp |
;; Outline settings. |
606 |
(concat "@" (regexp-opt (mapcar 'car texinfo-section-list) t) "\\>")) |
(set (make-local-variable 'outline-heading-alist) |
607 |
(make-local-variable 'outline-level) |
;; We should merge outline-heading-alist and texinfo-section-list |
608 |
(setq outline-level 'texinfo-outline-level) |
;; 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 |
|
|
615 |
(make-local-variable 'tex-start-of-header) |
(make-local-variable 'tex-start-of-header) |
616 |
(setq tex-start-of-header "%\\*\\*start") |
(setq tex-start-of-header "%\\*\\*start") |
617 |
(make-local-variable 'tex-end-of-header) |
(make-local-variable 'tex-end-of-header) |
628 |
(if (null auto-fill-inhibit-regexp) |
(if (null auto-fill-inhibit-regexp) |
629 |
prevent-filling |
prevent-filling |
630 |
(concat auto-fill-inhibit-regexp "\\|" prevent-filling))))) |
(concat auto-fill-inhibit-regexp "\\|" prevent-filling))))) |
631 |
|
|
632 |
|
|
633 |
|
|
634 |
;;; Insert string commands |
;;; Insert string commands |
640 |
Puts point on a blank line between them." |
Puts point on a blank line between them." |
641 |
(setq texinfo-block-default |
(setq texinfo-block-default |
642 |
(completing-read (format "Block name [%s]: " texinfo-block-default) |
(completing-read (format "Block name [%s]: " texinfo-block-default) |
643 |
(mapcar 'list texinfo-environments) |
texinfo-environments |
644 |
nil nil nil nil texinfo-block-default)) |
nil nil nil nil texinfo-block-default)) |
645 |
\n "@" str \n _ \n "@end " str \n) |
\n "@" str \n _ \n "@end " str \n) |
646 |
|
|
666 |
(and (re-search-backward (concat "@\\(end\\s +\\)?" env) bound t) |
(and (re-search-backward (concat "@\\(end\\s +\\)?" env) bound t) |
667 |
(not (match-end 1))))) |
(not (match-end 1))))) |
668 |
|
|
669 |
|
(defvar texinfo-enable-quote-macros '("@\\(code\\|samp\\|kbd\\)\\>")) |
670 |
|
(defvar texinfo-enable-quote-envs '("example\\>" "lisp\\>")) |
671 |
(defun texinfo-insert-quote (&optional arg) |
(defun texinfo-insert-quote (&optional arg) |
672 |
"Insert the appropriate quote mark for TeXinfo. |
"Insert the appropriate quote mark for TeXinfo. |
673 |
Usually inserts the value of `texinfo-open-quote' (normally ``) or |
Usually inserts the value of `texinfo-open-quote' (normally ``) or |
684 |
(looking-at texinfo-close-quote)) |
(looking-at texinfo-close-quote)) |
685 |
(delete-char (length texinfo-open-quote)) |
(delete-char (length texinfo-open-quote)) |
686 |
t)) |
t)) |
687 |
(texinfo-inside-macro-p "@\\(code\\|samp\\|kbd\\)\\>" top) |
(texinfo-inside-macro-p texinfo-enable-quote-macros top) |
688 |
(texinfo-inside-env-p "example\\>" top) |
(let ((in-env nil)) |
689 |
(texinfo-inside-env-p "lisp\\>" top)) |
(dolist (env texinfo-enable-quote-envs in-env) |
690 |
|
(if (texinfo-inside-env-p env top) |
691 |
|
(setq in-env t))))) |
692 |
(self-insert-command (prefix-numeric-value arg)) |
(self-insert-command (prefix-numeric-value arg)) |
693 |
(insert |
(insert |
694 |
(if (memq (char-syntax (preceding-char)) '(?\( ?> ?\ )) |
(if (memq (char-syntax (preceding-char)) '(?\( ?> ?\ )) |
695 |
texinfo-open-quote |
texinfo-open-quote |
696 |
texinfo-close-quote))))) |
texinfo-close-quote))))) |
697 |
|
|
698 |
;; The following texinfo-insert-@end command not only inserts a SPC |
;; The following texinfo-insert-@end command not only inserts a SPC |
699 |
;; after the @end, but tries to find out what belongs there. It is |
;; after the @end, but tries to find out what belongs there. It is |
700 |
;; not very smart: it does not understand nested lists. |
;; not very smart: it does not understand nested lists. |
875 |
|
|
876 |
Lines with structuring commands beginning in them are displayed in |
Lines with structuring commands beginning in them are displayed in |
877 |
another buffer named `*Occur*'. In that buffer, you can move point to |
another buffer named `*Occur*'. In that buffer, you can move point to |
878 |
one of those lines and then use |
one of those lines and then use |
879 |
\\<occur-mode-map>\\[occur-mode-goto-occurrence], |
\\<occur-mode-map>\\[occur-mode-goto-occurrence], |
880 |
to jump to the corresponding spot in the Texinfo source file." |
to jump to the corresponding spot in the Texinfo source file." |
881 |
|
|
885 |
current-location) |
current-location) |
886 |
(save-excursion |
(save-excursion |
887 |
(end-of-line) ; so as to find section on current line |
(end-of-line) ; so as to find section on current line |
888 |
(if (re-search-backward |
(if (re-search-backward |
889 |
;; do not require `texinfo-section-types-regexp' in texnfo-upd.el |
;; do not require `texinfo-section-types-regexp' in texnfo-upd.el |
890 |
"^@\\(chapter \\|sect\\|subs\\|subh\\|unnum\\|major\\|chapheading \\|heading \\|appendix\\)" |
"^@\\(chapter \\|sect\\|subs\\|subh\\|unnum\\|major\\|chapheading \\|heading \\|appendix\\)" |
891 |
nil t) |
nil t) |
916 |
(indent-to-column (+ (current-column) (* 4 (- level 2)))) |
(indent-to-column (+ (current-column) (* 4 (- level 2)))) |
917 |
(beginning-of-line)))) |
(beginning-of-line)))) |
918 |
;; Third, go to line corresponding to location in source file |
;; Third, go to line corresponding to location in source file |
919 |
;; potential bug: two exactly similar `current-location' lines ... |
;; potential bug: two exactly similar `current-location' lines ... |
920 |
(goto-char (point-min)) |
(goto-char (point-min)) |
921 |
(re-search-forward current-location nil t) |
(re-search-forward current-location nil t) |
922 |
(beginning-of-line) |
(beginning-of-line) |