diff options
| -rw-r--r-- | lisp/ChangeLog | 13 | ||||
| -rw-r--r-- | lisp/font-lock.el | 72 | ||||
| -rw-r--r-- | lisp/progmodes/asm-mode.el | 28 | ||||
| -rw-r--r-- | lisp/progmodes/ld-script.el | 19 |
4 files changed, 110 insertions, 22 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d4876ee3d94..0e4d34248f3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2006-01-06 Masatake YAMATO <jet@gyve.org> | ||
| 2 | |||
| 3 | * font-lock.el (cpp-font-lock-keywords): Font lock keywords for | ||
| 4 | C preprocessor forward ported from GNU Emacs 21.2. | ||
| 5 | |||
| 6 | * progmodes/asm-mode.el (asm-font-lock-keywords): Use | ||
| 7 | `cpp-font-lock-keywords'. | ||
| 8 | |||
| 9 | * progmodes/ld-script.el (ld-script-font-lock-keywords): Ditto. | ||
| 10 | |||
| 11 | * progmodes/ld-script.el (auto-mode-alist): Use \\> instead | ||
| 12 | of $ for "\\.ld[s]?". | ||
| 13 | |||
| 1 | 2006-01-10 Stefan Monnier <monnier@iro.umontreal.ca> | 14 | 2006-01-10 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 15 | ||
| 3 | * progmodes/tcl.el (tcl-indent-command): Use indent-for-tab-command. | 16 | * progmodes/tcl.el (tcl-indent-command): Use indent-for-tab-command. |
diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 032b8fb04f8..00394e86762 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el | |||
| @@ -1963,6 +1963,78 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item." | |||
| 1963 | (goto-char (or (scan-sexps (point) 1) (point-max)))) | 1963 | (goto-char (or (scan-sexps (point) 1) (point-max)))) |
| 1964 | (goto-char (match-end 2))) | 1964 | (goto-char (match-end 2))) |
| 1965 | (error t))))) | 1965 | (error t))))) |
| 1966 | |||
| 1967 | ;; C preprocessor(cpp) is used outside of C, C++ and Objective-C source file. | ||
| 1968 | ;; e.g. assembler code and GNU linker script in Linux kernel. | ||
| 1969 | ;; `cpp-font-lock-keywords' is handy for modes for the files. | ||
| 1970 | ;; | ||
| 1971 | ;; Here we cannot use `regexp-opt' because because regex-opt is not preloaded | ||
| 1972 | ;; while font-lock.el is preloaded to emacs. So values pre-calculated with | ||
| 1973 | ;; regexp-opt are used here. | ||
| 1974 | |||
| 1975 | ;; `cpp-font-lock-keywords-source-directives' is calculated from: | ||
| 1976 | ;; | ||
| 1977 | ;; (regexp-opt | ||
| 1978 | ;; '("define" "elif" "else" "endif" "error" "file" "if" "ifdef" | ||
| 1979 | ;; "ifndef" "include" "line" "pragma" "undef")) | ||
| 1980 | ;; | ||
| 1981 | (defconst cpp-font-lock-keywords-source-directives | ||
| 1982 | "define\\|e\\(?:l\\(?:if\\|se\\)\\|ndif\\|rror\\)\\|file\\|i\\(?:f\\(?:n?def\\)?\\|nclude\\)\\|line\\|pragma\\|undef" | ||
| 1983 | "Regular expressoin used in `cpp-font-lock-keywords'.") | ||
| 1984 | |||
| 1985 | ;; `cpp-font-lock-keywords-source-depth' is calculated from: | ||
| 1986 | ;; | ||
| 1987 | ;; (regexp-opt-depth (regexp-opt | ||
| 1988 | ;; '("define" "elif" "else" "endif" "error" "file" "if" "ifdef" | ||
| 1989 | ;; "ifndef" "include" "line" "pragma" "undef"))) | ||
| 1990 | ;; | ||
| 1991 | (defconst cpp-font-lock-keywords-source-depth 0 | ||
| 1992 | "An integer representing regular expression depth of `cpp-font-lock-keywords-source-directives'. | ||
| 1993 | Used in `cpp-font-lock-keywords'.") | ||
| 1994 | |||
| 1995 | (defconst cpp-font-lock-keywords | ||
| 1996 | (let* ((directives cpp-font-lock-keywords-source-directives) | ||
| 1997 | (directives-depth cpp-font-lock-keywords-source-depth)) | ||
| 1998 | (list | ||
| 1999 | ;; | ||
| 2000 | ;; Fontify error directives. | ||
| 2001 | '("^#[ \t]*error[ \t]+\\(.+\\)" 1 font-lock-warning-face prepend) | ||
| 2002 | ;; | ||
| 2003 | ;; Fontify filenames in #include <...> preprocessor directives as strings. | ||
| 2004 | '("^#[ \t]*\\(?:import\\|include\\)[ \t]*\\(<[^>\"\n]*>?\\)" | ||
| 2005 | 1 font-lock-string-face prepend) | ||
| 2006 | ;; | ||
| 2007 | ;; Fontify function macro names. | ||
| 2008 | '("^#[ \t]*define[ \t]+\\([[:alpha:]_][[:alnum:]_$]*\\)(" | ||
| 2009 | (1 font-lock-function-name-face prepend) | ||
| 2010 | ;; | ||
| 2011 | ;; Macro arguments. | ||
| 2012 | ((lambda (limit) | ||
| 2013 | (re-search-forward | ||
| 2014 | "\\(?:\\([[:alpha:]_][[:alnum:]_]*\\)[,]?\\)" | ||
| 2015 | (or (save-excursion (re-search-forward ")" limit t)) | ||
| 2016 | limit) | ||
| 2017 | t)) | ||
| 2018 | nil nil (1 font-lock-variable-name-face prepend))) | ||
| 2019 | ;; | ||
| 2020 | ;; Fontify symbol names in #elif or #if ... defined preprocessor directives. | ||
| 2021 | '("^#[ \t]*\\(?:elif\\|if\\)\\>" | ||
| 2022 | ("\\<\\(defined\\)\\>[ \t]*(?\\([[:alpha:]_][[:alnum:]_]*\\)?" nil nil | ||
| 2023 | (1 font-lock-builtin-face prepend) (2 font-lock-variable-name-face prepend t))) | ||
| 2024 | ;; | ||
| 2025 | ;; Fontify otherwise as symbol names, and the preprocessor directive names. | ||
| 2026 | (list | ||
| 2027 | (concat "^\\(#[ \t]*\\(?:" directives | ||
| 2028 | "\\)\\)\\>[ \t!]*\\([[:alpha:]_][[:alnum:]_]*\\)?") | ||
| 2029 | '(1 font-lock-preprocessor-face prepend) | ||
| 2030 | (list (+ 2 directives-depth) | ||
| 2031 | 'font-lock-variable-name-face nil t)))) | ||
| 2032 | "Font lock keyords for C preprocessor directives. | ||
| 2033 | `c-mode', `c++-mode' and `objc-mode' have their own | ||
| 2034 | font lock keyords for C preprocessor directives. This definition is for the | ||
| 2035 | other modes in which C preprocessor directives are used. e.g. `asm-mode' and | ||
| 2036 | `ld-script-mode'.") | ||
| 2037 | |||
| 1966 | 2038 | ||
| 1967 | ;; Lisp. | 2039 | ;; Lisp. |
| 1968 | 2040 | ||
diff --git a/lisp/progmodes/asm-mode.el b/lisp/progmodes/asm-mode.el index 51d58d7c7a9..44605b1fa9a 100644 --- a/lisp/progmodes/asm-mode.el +++ b/lisp/progmodes/asm-mode.el | |||
| @@ -83,19 +83,21 @@ | |||
| 83 | "Keymap for Asm mode.") | 83 | "Keymap for Asm mode.") |
| 84 | 84 | ||
| 85 | (defconst asm-font-lock-keywords | 85 | (defconst asm-font-lock-keywords |
| 86 | '(("^\\(\\(\\sw\\|\\s_\\)+\\)\\>:?[ \t]*\\(\\sw+\\(\\.\\sw+\\)*\\)?" | 86 | (append |
| 87 | (1 font-lock-function-name-face) (3 font-lock-keyword-face nil t)) | 87 | '(("^\\(\\(\\sw\\|\\s_\\)+\\)\\>:?[ \t]*\\(\\sw+\\(\\.\\sw+\\)*\\)?" |
| 88 | ;; label started from ".". | 88 | (1 font-lock-function-name-face) (3 font-lock-keyword-face nil t)) |
| 89 | ("^\\(\\.\\(\\sw\\|\\s_\\)+\\)\\>:" | 89 | ;; label started from ".". |
| 90 | 1 font-lock-function-name-face) | 90 | ("^\\(\\.\\(\\sw\\|\\s_\\)+\\)\\>:" |
| 91 | ("^\\((\\sw+)\\)?\\s +\\(\\(\\.?\\sw\\|\\s_\\)+\\(\\.\\sw+\\)*\\)" | 91 | 1 font-lock-function-name-face) |
| 92 | 2 font-lock-keyword-face) | 92 | ("^\\((\\sw+)\\)?\\s +\\(\\(\\.?\\sw\\|\\s_\\)+\\(\\.\\sw+\\)*\\)" |
| 93 | ;; directive started from ".". | 93 | 2 font-lock-keyword-face) |
| 94 | ("^\\(\\.\\(\\sw\\|\\s_\\)+\\)\\>[^:]?" | 94 | ;; directive started from ".". |
| 95 | 1 font-lock-keyword-face) | 95 | ("^\\(\\.\\(\\sw\\|\\s_\\)+\\)\\>[^:]?" |
| 96 | ;; %register | 96 | 1 font-lock-keyword-face) |
| 97 | ("%\\sw+" . font-lock-variable-name-face)) | 97 | ;; %register |
| 98 | "Additional expressions to highlight in Assembler mode.") | 98 | ("%\\sw+" . font-lock-variable-name-face)) |
| 99 | cpp-font-lock-keywords) | ||
| 100 | "Additional expressions to highlight in Assembler mode.") | ||
| 99 | 101 | ||
| 100 | ;;;###autoload | 102 | ;;;###autoload |
| 101 | (defun asm-mode () | 103 | (defun asm-mode () |
diff --git a/lisp/progmodes/ld-script.el b/lisp/progmodes/ld-script.el index 99477b73c63..4dbbe0faa18 100644 --- a/lisp/progmodes/ld-script.el +++ b/lisp/progmodes/ld-script.el | |||
| @@ -114,18 +114,19 @@ | |||
| 114 | "Builtin functions of GNU ld script.") | 114 | "Builtin functions of GNU ld script.") |
| 115 | 115 | ||
| 116 | (defvar ld-script-font-lock-keywords | 116 | (defvar ld-script-font-lock-keywords |
| 117 | `((,(regexp-opt ld-script-keywords 'words) | 117 | (append |
| 118 | 1 font-lock-keyword-face) | 118 | `((,(regexp-opt ld-script-keywords 'words) |
| 119 | (,(regexp-opt ld-script-builtins 'words) | 119 | 1 font-lock-keyword-face) |
| 120 | 1 font-lock-builtin-face) | 120 | (,(regexp-opt ld-script-builtins 'words) |
| 121 | ("/DISCARD/" . font-lock-warning-face) | 121 | 1 font-lock-builtin-face) |
| 122 | ("##\\|#[^#\n]+$" . font-lock-preprocessor-face) | 122 | ("/DISCARD/" . font-lock-warning-face) |
| 123 | ("\\W\\(\\.\\)\\W" 1 ld-script-location-counter-face) | 123 | ("\\W\\(\\.\\)\\W" 1 ld-script-location-counter-face) |
| 124 | ) | 124 | ) |
| 125 | cpp-font-lock-keywords) | ||
| 125 | "Default font-lock-keywords for `ld-script-mode'.") | 126 | "Default font-lock-keywords for `ld-script-mode'.") |
| 126 | 127 | ||
| 127 | ;;;###autoload | 128 | ;;;###autoload |
| 128 | (add-to-list 'auto-mode-alist '("\\.ld[s]?\\(\\.in\\)?$" . ld-script-mode)) | 129 | (add-to-list 'auto-mode-alist '("\\.ld[s]?\\>" . ld-script-mode)) |
| 129 | ;;;###autoload | 130 | ;;;###autoload |
| 130 | (add-to-list 'auto-mode-alist '("\\.x[bdsru]?[cn]?$" . ld-script-mode)) | 131 | (add-to-list 'auto-mode-alist '("\\.x[bdsru]?[cn]?$" . ld-script-mode)) |
| 131 | 132 | ||