From 1e2c18dfbdb60f603393287a487c36c511864463 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sun, 5 May 2013 22:29:42 -0400 Subject: [PATCH] * lisp/progmodes/octave.el (octave-texinfo-font-lock-keywords): Remove. (octave-font-lock-texinfo-comment): Use texinfo-font-lock-keywords with some tweaks, instead. --- lisp/ChangeLog | 6 ++++ lisp/progmodes/octave.el | 65 +++++++++++++++++----------------------- 2 files changed, 34 insertions(+), 37 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5395bf46e2..1836465453 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2013-05-06 Stefan Monnier + + * 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 * progmodes/octave.el (octave-font-lock-keywords) diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index ddc1916c3b..a2d494f049 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el @@ -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))) ;;; Indentation -- 2.20.1