]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/progmodes/octave.el (octave-texinfo-font-lock-keywords): Remove.
authorStefan Monnier <monnier@iro.umontreal.ca>
Mon, 6 May 2013 02:29:42 +0000 (22:29 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Mon, 6 May 2013 02:29:42 +0000 (22:29 -0400)
(octave-font-lock-texinfo-comment): Use texinfo-font-lock-keywords with
some tweaks, instead.

lisp/ChangeLog
lisp/progmodes/octave.el

index 5395bf46e2acda7e04c2cf043efb8f96b0777a70..1836465453921e0b9e0984de81799a758a6e1526 100644 (file)
@@ -1,3 +1,9 @@
+2013-05-06  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * progmodes/octave.el (octave-texinfo-font-lock-keywords): Remove.
+       (octave-font-lock-texinfo-comment): Use texinfo-font-lock-keywords with
+       some tweaks, instead.
+
 2013-05-05  Leo Liu  <sdl.web@gmail.com>
 
        * progmodes/octave.el (octave-font-lock-keywords)
index ddc1916c3b52ba26e58dd64b5a761a9253852c8f..a2d494f0497c3dabcdd744242c96a64faffc5df9 100644 (file)
@@ -998,49 +998,40 @@ q: Don't fix\n" func file))
                            nil 'delimited nil nil beg end)
         (message "Function names match")))))
 
-;; Adapted from texinfo-font-lock-keywords
-(defvar octave-texinfo-font-lock-keywords
-  `(("@\\([a-zA-Z]+\\|[^ \t\n]\\)" 1 font-lock-keyword-face prepend) ;commands
-    ("^\\*\\([^\n:]*\\)" 1 font-lock-function-name-face prepend) ;menu items
-    ("@\\(emph\\|i\\|sc\\){\\([^}]+\\)" 2 'italic prepend)
-    ("@\\(strong\\|b\\){\\([^}]+\\)" 2 'bold prepend)
-    ("@\\(kbd\\|key\\|url\\|uref\\){\\([^}]+\\)"
-     2 font-lock-string-face prepend)
-    ("@\\(file\\|email\\){\\([^}]+\\)" 2 font-lock-string-face prepend)
-    ("@\\(samp\\|code\\|var\\|math\\|env\\|command\\|option\\){\\([^}]+\\)"
-     2 font-lock-variable-name-face prepend)
-    ("@\\(cite\\|x?ref\\|pxref\\|dfn\\|inforef\\){\\([^}]+\\)"
-     2 font-lock-constant-face prepend)
-    ("@\\(anchor\\){\\([^}]+\\)" 2 font-lock-type-face prepend)
-    ("@\\(dmn\\|acronym\\|value\\){\\([^}]+\\)"
-     2 font-lock-builtin-face prepend)
-    ("@\\(end\\|itemx?\\) +\\(.+\\)" 2 font-lock-keyword-face prepend))
-  "Additional keywords to highlight in texinfo comment block.")
-
 (defface octave-function-comment-block
   '((t (:inherit font-lock-doc-face)))
   "Face used to highlight function comment block."
   :group 'octave)
 
+(eval-when-compile (require 'texinfo))
+
 (defun octave-font-lock-texinfo-comment ()
-  (font-lock-add-keywords
-   nil
-   `((,(lambda (limit)
-         (while (and (search-forward "-*- texinfo -*-" limit t)
-                     (octave-in-comment-p))
-           (let ((beg (nth 8 (syntax-ppss)))
-                 (end (progn
-                        (octave-skip-comment-forward (point-max))
-                        (point))))
-             (put-text-property beg end 'font-lock-multiline t)
-             (font-lock-prepend-text-property
-              beg end 'face 'octave-function-comment-block)
-             (dolist (kw octave-texinfo-font-lock-keywords)
-               (goto-char beg)
-               (while (re-search-forward (car kw) end 'move)
-                 (font-lock-apply-highlight (cdr kw))))))
-         nil)))
-   'append))
+  (let ((kws
+         (eval-when-compile
+           (delq nil (mapcar
+                      (lambda (kw)
+                        (if (numberp (nth 1 kw))
+                            `(,(nth 0 kw) ,(nth 1 kw) ,(nth 2 kw) prepend)
+                          (message "Ignoring Texinfo highlight: %S" kw)))
+                      texinfo-font-lock-keywords)))))
+    (font-lock-add-keywords
+     nil
+     `((,(lambda (limit)
+           (while (and (search-forward "-*- texinfo -*-" limit t)
+                       (octave-in-comment-p))
+             (let ((beg (nth 8 (syntax-ppss)))
+                   (end (progn
+                          (octave-skip-comment-forward (point-max))
+                          (point))))
+               (put-text-property beg end 'font-lock-multiline t)
+               (font-lock-prepend-text-property
+                beg end 'face 'octave-function-comment-block)
+               (dolist (kw kws)
+                 (goto-char beg)
+                 (while (re-search-forward (car kw) end 'move)
+                   (font-lock-apply-highlight (cdr kw))))))
+           nil)))
+     'append)))
 
 \f
 ;;; Indentation