diff options
| author | Richard M. Stallman | 1995-07-18 21:43:16 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-07-18 21:43:16 +0000 |
| commit | 878c1d73d048d949dbace5688929d2d7701706cd (patch) | |
| tree | 78084a77df9e2ee62c434d434de16c9ac71ac021 | |
| parent | 419e4198521e2898635520303cb693bb55c66002 (diff) | |
| download | emacs-878c1d73d048d949dbace5688929d2d7701706cd.tar.gz emacs-878c1d73d048d949dbace5688929d2d7701706cd.zip | |
(font-lock-defaults): New variable.
(nroff-mode-syntax-table): New variable to provide comment syntax
for font-lock; I'm not sure if this is (or should be) necessary in
19.29 with font-lock-defaults.
(nroff-font-lock-keywords): New variable.
(nroff-mode): Install nroff syntax table and font lock keywords.
Comment about comments in filling and line-counting.
| -rw-r--r-- | lisp/textmodes/nroff-mode.el | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/lisp/textmodes/nroff-mode.el b/lisp/textmodes/nroff-mode.el index b3258f38e11..15d5fd32c24 100644 --- a/lisp/textmodes/nroff-mode.el +++ b/lisp/textmodes/nroff-mode.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; nroff-mode.el --- GNU Emacs major mode for editing nroff source | 1 | ;;; nroff-mode.el --- GNU Emacs major mode for editing nroff source |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1985, 1986, 1994 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1985, 1986, 1994, 1995 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Maintainer: FSF | 5 | ;; Maintainer: FSF |
| 6 | ;; Keywords: wp | 6 | ;; Keywords: wp |
| @@ -29,6 +29,9 @@ | |||
| 29 | ;; a command to count text lines (excluding nroff constructs), a command | 29 | ;; a command to count text lines (excluding nroff constructs), a command |
| 30 | ;; to center a line, and movement commands that know how to skip macros. | 30 | ;; to center a line, and movement commands that know how to skip macros. |
| 31 | 31 | ||
| 32 | ;; Paragraph filling and line-counting currently don't respect comments, | ||
| 33 | ;; as they should. | ||
| 34 | |||
| 32 | ;;; Code: | 35 | ;;; Code: |
| 33 | 36 | ||
| 34 | (defvar nroff-mode-abbrev-table nil | 37 | (defvar nroff-mode-abbrev-table nil |
| @@ -47,6 +50,32 @@ | |||
| 47 | (define-key nroff-mode-map "\en" 'forward-text-line) | 50 | (define-key nroff-mode-map "\en" 'forward-text-line) |
| 48 | (define-key nroff-mode-map "\ep" 'backward-text-line))) | 51 | (define-key nroff-mode-map "\ep" 'backward-text-line))) |
| 49 | 52 | ||
| 53 | (defvar nroff-mode-syntax-table nil | ||
| 54 | "Syntax table used while in nroff mode.") | ||
| 55 | |||
| 56 | (defvar nroff-font-lock-keywords | ||
| 57 | (list | ||
| 58 | ;; Directives are . or ' at start of line, followed by | ||
| 59 | ;; optional whitespace, then command (which my be longer than | ||
| 60 | ;; 2 characters in groff). Perhaps the arguments should be | ||
| 61 | ;; fontified as well. | ||
| 62 | "^[.']\\s-*\\sw+" | ||
| 63 | ;; There are numerous groff escapes; the following get things | ||
| 64 | ;; like \-, \(em (standard troff) and \f[bar] (groff | ||
| 65 | ;; variants). This won't currently do groff's \A'foo' and | ||
| 66 | ;; the like properly. One might expect it to highlight an escape's | ||
| 67 | ;; arguments in common cases, like \f. | ||
| 68 | (concat "\\\\" ; backslash | ||
| 69 | "\\(" ; followed by various possibilities | ||
| 70 | (mapconcat 'identity | ||
| 71 | '("[f*n]*\\[.+]" ; some groff extensions | ||
| 72 | "(.." ; two chars after ( | ||
| 73 | "[^(\"]" ; single char escape | ||
| 74 | ) "\\|") | ||
| 75 | "\\)") | ||
| 76 | ) | ||
| 77 | "Font-lock highlighting control in nroff-mode.") | ||
| 78 | |||
| 50 | ;;;###autoload | 79 | ;;;###autoload |
| 51 | (defun nroff-mode () | 80 | (defun nroff-mode () |
| 52 | "Major mode for editing text intended for nroff to format. | 81 | "Major mode for editing text intended for nroff to format. |
| @@ -59,7 +88,19 @@ closing requests for requests that are used in matched pairs." | |||
| 59 | (use-local-map nroff-mode-map) | 88 | (use-local-map nroff-mode-map) |
| 60 | (setq mode-name "Nroff") | 89 | (setq mode-name "Nroff") |
| 61 | (setq major-mode 'nroff-mode) | 90 | (setq major-mode 'nroff-mode) |
| 62 | (set-syntax-table text-mode-syntax-table) | 91 | (if nroff-mode-syntax-table |
| 92 | () | ||
| 93 | (setq nroff-mode-syntax-table (copy-syntax-table text-mode-syntax-table)) | ||
| 94 | ;; " isn't given string quote syntax in text-mode but it | ||
| 95 | ;; (arguably) should be for use round nroff arguments (with ` and | ||
| 96 | ;; ' used otherwise). | ||
| 97 | (modify-syntax-entry ?\" "\" 2" nroff-mode-syntax-table) | ||
| 98 | ;; Comments are delimited by \" and newline. | ||
| 99 | (modify-syntax-entry ?\\ "\\ 1" nroff-mode-syntax-table) | ||
| 100 | (modify-syntax-entry ?\n "> 1" nroff-mode-syntax-table)) | ||
| 101 | (set-syntax-table nroff-mode-syntax-table) | ||
| 102 | (make-local-variable 'font-lock-defaults) | ||
| 103 | (setq font-lock-defaults '(nroff-font-lock-keywords nil t)) | ||
| 63 | (setq local-abbrev-table nroff-mode-abbrev-table) | 104 | (setq local-abbrev-table nroff-mode-abbrev-table) |
| 64 | (make-local-variable 'nroff-electric-mode) | 105 | (make-local-variable 'nroff-electric-mode) |
| 65 | (setq nroff-electric-mode nil) | 106 | (setq nroff-electric-mode nil) |