emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r112425: * progmodes/octave.el (octav


From: Leo Liu
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r112425: * progmodes/octave.el (octave-variables): Remove. No builtin
Date: Tue, 30 Apr 2013 22:23:03 +0800
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 112425
committer: Leo Liu <address@hidden>
branch nick: trunk
timestamp: Tue 2013-04-30 22:23:03 +0800
message:
  * progmodes/octave.el (octave-variables): Remove.  No builtin
  variables any more.  All converted to functions.
  (octave-font-lock-keywords, octave-completion-at-point-function):
  Fix uses.
  (octave-font-lock-texinfo-comment): New user variable.
  (octave-texinfo-font-lock-keywords): New variable for texinfo
  comment block.
  (octave-function-comment-block): New face.
  (octave-font-lock-texinfo-comment): New function.
  (octave-mode): Font lock texinfo comment block.
modified:
  lisp/ChangeLog
  lisp/progmodes/octave.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-04-29 20:09:18 +0000
+++ b/lisp/ChangeLog    2013-04-30 14:23:03 +0000
@@ -1,3 +1,16 @@
+2013-04-30  Leo Liu  <address@hidden>
+
+       * progmodes/octave.el (octave-variables): Remove.  No builtin
+       variables any more.  All converted to functions.
+       (octave-font-lock-keywords, octave-completion-at-point-function):
+       Fix uses.
+       (octave-font-lock-texinfo-comment): New user variable.
+       (octave-texinfo-font-lock-keywords): New variable for texinfo
+       comment block.
+       (octave-function-comment-block): New face.
+       (octave-font-lock-texinfo-comment): New function.
+       (octave-mode): Font lock texinfo comment block.
+
 2013-04-29  Leo Liu  <address@hidden>
 
        * progmodes/octave.el (octave-font-lock-keywords): Handle 'end' in

=== modified file 'lisp/progmodes/octave.el'
--- a/lisp/progmodes/octave.el  2013-04-29 20:09:18 +0000
+++ b/lisp/progmodes/octave.el  2013-04-30 14:23:03 +0000
@@ -108,37 +108,6 @@
     "which" "who" "whos")
   "Text functions in Octave.")
 
-(defvar octave-variables
-  '("DEFAULT_EXEC_PATH" "DEFAULT_LOADPATH"
-    "EDITOR" "EXEC_PATH" "F_DUPFD" "F_GETFD" "F_GETFL" "F_SETFD"
-    "F_SETFL" "I" "IMAGE_PATH" "Inf" "J"
-    "NaN" "OCTAVE_VERSION" "O_APPEND" "O_CREAT" "O_EXCL"
-    "O_NONBLOCK" "O_RDONLY" "O_RDWR" "O_TRUNC" "O_WRONLY" "PAGER" "PS1"
-    "PS2" "PS4" "PWD" "SEEK_CUR" "SEEK_END" "SEEK_SET" "__F_DUPFD__"
-    "__F_GETFD__" "__F_GETFL__" "__F_SETFD__" "__F_SETFL__" "__I__"
-    "__Inf__" "__J__" "__NaN__" "__OCTAVE_VERSION__" "__O_APPEND__"
-    "__O_CREAT__" "__O_EXCL__" "__O_NONBLOCK__" "__O_RDONLY__"
-    "__O_RDWR__" "__O_TRUNC__" "__O_WRONLY__" "__PWD__" "__SEEK_CUR__"
-    "__SEEK_END__" "__SEEK_SET__" "__argv__" "__e__" "__eps__"
-    "__i__" "__inf__" "__j__" "__nan__" "__pi__"
-    "__program_invocation_name__" "__program_name__" "__realmax__"
-    "__realmin__" "__stderr__" "__stdin__" "__stdout__" "ans" "argv"
-    "beep_on_error" "completion_append_char"
-    "crash_dumps_octave_core" "default_save_format"
-    "e" "echo_executing_commands" "eps"
-    "error_text" "gnuplot_binary" "history_file"
-    "history_size" "ignore_function_time_stamp"
-    "inf" "nan" "nargin" "output_max_field_width" "output_precision"
-    "page_output_immediately" "page_screen_output" "pi"
-    "print_answer_id_name" "print_empty_dimensions"
-    "program_invocation_name" "program_name"
-    "realmax" "realmin" "return_last_computed_value" "save_precision"
-    "saving_history" "sighup_dumps_octave_core" "sigterm_dumps_octave_core"
-    "silent_functions" "split_long_rows" "stderr" "stdin" "stdout"
-    "string_fill_char" "struct_levels_to_print"
-    "suppress_verbose_help_message")
-  "Builtin variables in Octave.")
-
 (defvar octave-function-header-regexp
   (concat "^\\s-*\\_<\\(function\\)\\_>"
          "\\([^=;\n]*=[ \t]*\\|[ \t]*\\)\\(\\(?:\\w\\|\\s_\\)+\\)\\_>")
@@ -171,9 +140,6 @@
         (if (boundp 'font-lock-builtin-face)
             'font-lock-builtin-face
           'font-lock-preprocessor-face))
-   ;; Fontify all builtin variables.
-   (cons (concat "\\_<" (regexp-opt octave-variables) "\\_>")
-        'font-lock-variable-name-face)
    ;; Fontify all function declarations.
    (list octave-function-header-regexp
         '(1 font-lock-keyword-face)
@@ -312,6 +278,12 @@
     table)
   "Syntax table in use in `octave-mode' buffers.")
 
+(defcustom octave-font-lock-texinfo-comment t
+  "Control whether to highlight the texinfo comment block."
+  :type 'boolean
+  :group 'octave
+  :version "24.4")
+
 (defcustom octave-blink-matching-block t
   "Control the blinking of matching Octave block keywords.
 Non-nil means show matching begin of block when inserting a space,
@@ -575,6 +547,7 @@
             'octave-completion-at-point-function nil t)
   (add-hook 'before-save-hook 'octave-sync-function-file-names nil t)
   (setq-local beginning-of-defun-function 'octave-beginning-of-defun)
+  (and octave-font-lock-texinfo-comment (octave-font-lock-texinfo-comment))
 
   (easy-menu-add octave-mode-menu))
 
@@ -1049,6 +1022,50 @@
                            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)
+
+(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))
+
 
 ;;; Indentation
 
@@ -1336,8 +1353,7 @@
                            (process-live-p inferior-octave-process)
                            (inferior-octave-completion-table))
                       (append octave-reserved-words
-                              octave-text-functions
-                              octave-variables)))))
+                              octave-text-functions)))))
 
 (define-obsolete-function-alias 'octave-complete-symbol
   'completion-at-point "24.1")


reply via email to

[Prev in Thread] Current Thread [Next in Thread]