aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog13
-rw-r--r--lisp/progmodes/octave.el88
2 files changed, 65 insertions, 36 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index abfd6153288..5ff660592b7 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,16 @@
12013-04-30 Leo Liu <sdl.web@gmail.com>
2
3 * progmodes/octave.el (octave-variables): Remove. No builtin
4 variables any more. All converted to functions.
5 (octave-font-lock-keywords, octave-completion-at-point-function):
6 Fix uses.
7 (octave-font-lock-texinfo-comment): New user variable.
8 (octave-texinfo-font-lock-keywords): New variable for texinfo
9 comment block.
10 (octave-function-comment-block): New face.
11 (octave-font-lock-texinfo-comment): New function.
12 (octave-mode): Font lock texinfo comment block.
13
12013-04-29 Leo Liu <sdl.web@gmail.com> 142013-04-29 Leo Liu <sdl.web@gmail.com>
2 15
3 * progmodes/octave.el (octave-font-lock-keywords): Handle 'end' in 16 * progmodes/octave.el (octave-font-lock-keywords): Handle 'end' in
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el
index 30b520b75a0..6913d70550f 100644
--- a/lisp/progmodes/octave.el
+++ b/lisp/progmodes/octave.el
@@ -108,37 +108,6 @@ All Octave abbrevs start with a grave accent (`)."
108 "which" "who" "whos") 108 "which" "who" "whos")
109 "Text functions in Octave.") 109 "Text functions in Octave.")
110 110
111(defvar octave-variables
112 '("DEFAULT_EXEC_PATH" "DEFAULT_LOADPATH"
113 "EDITOR" "EXEC_PATH" "F_DUPFD" "F_GETFD" "F_GETFL" "F_SETFD"
114 "F_SETFL" "I" "IMAGE_PATH" "Inf" "J"
115 "NaN" "OCTAVE_VERSION" "O_APPEND" "O_CREAT" "O_EXCL"
116 "O_NONBLOCK" "O_RDONLY" "O_RDWR" "O_TRUNC" "O_WRONLY" "PAGER" "PS1"
117 "PS2" "PS4" "PWD" "SEEK_CUR" "SEEK_END" "SEEK_SET" "__F_DUPFD__"
118 "__F_GETFD__" "__F_GETFL__" "__F_SETFD__" "__F_SETFL__" "__I__"
119 "__Inf__" "__J__" "__NaN__" "__OCTAVE_VERSION__" "__O_APPEND__"
120 "__O_CREAT__" "__O_EXCL__" "__O_NONBLOCK__" "__O_RDONLY__"
121 "__O_RDWR__" "__O_TRUNC__" "__O_WRONLY__" "__PWD__" "__SEEK_CUR__"
122 "__SEEK_END__" "__SEEK_SET__" "__argv__" "__e__" "__eps__"
123 "__i__" "__inf__" "__j__" "__nan__" "__pi__"
124 "__program_invocation_name__" "__program_name__" "__realmax__"
125 "__realmin__" "__stderr__" "__stdin__" "__stdout__" "ans" "argv"
126 "beep_on_error" "completion_append_char"
127 "crash_dumps_octave_core" "default_save_format"
128 "e" "echo_executing_commands" "eps"
129 "error_text" "gnuplot_binary" "history_file"
130 "history_size" "ignore_function_time_stamp"
131 "inf" "nan" "nargin" "output_max_field_width" "output_precision"
132 "page_output_immediately" "page_screen_output" "pi"
133 "print_answer_id_name" "print_empty_dimensions"
134 "program_invocation_name" "program_name"
135 "realmax" "realmin" "return_last_computed_value" "save_precision"
136 "saving_history" "sighup_dumps_octave_core" "sigterm_dumps_octave_core"
137 "silent_functions" "split_long_rows" "stderr" "stdin" "stdout"
138 "string_fill_char" "struct_levels_to_print"
139 "suppress_verbose_help_message")
140 "Builtin variables in Octave.")
141
142(defvar octave-function-header-regexp 111(defvar octave-function-header-regexp
143 (concat "^\\s-*\\_<\\(function\\)\\_>" 112 (concat "^\\s-*\\_<\\(function\\)\\_>"
144 "\\([^=;\n]*=[ \t]*\\|[ \t]*\\)\\(\\(?:\\w\\|\\s_\\)+\\)\\_>") 113 "\\([^=;\n]*=[ \t]*\\|[ \t]*\\)\\(\\(?:\\w\\|\\s_\\)+\\)\\_>")
@@ -171,9 +140,6 @@ parenthetical grouping.")
171 (if (boundp 'font-lock-builtin-face) 140 (if (boundp 'font-lock-builtin-face)
172 'font-lock-builtin-face 141 'font-lock-builtin-face
173 'font-lock-preprocessor-face)) 142 'font-lock-preprocessor-face))
174 ;; Fontify all builtin variables.
175 (cons (concat "\\_<" (regexp-opt octave-variables) "\\_>")
176 'font-lock-variable-name-face)
177 ;; Fontify all function declarations. 143 ;; Fontify all function declarations.
178 (list octave-function-header-regexp 144 (list octave-function-header-regexp
179 '(1 font-lock-keyword-face) 145 '(1 font-lock-keyword-face)
@@ -312,6 +278,12 @@ parenthetical grouping.")
312 table) 278 table)
313 "Syntax table in use in `octave-mode' buffers.") 279 "Syntax table in use in `octave-mode' buffers.")
314 280
281(defcustom octave-font-lock-texinfo-comment t
282 "Control whether to highlight the texinfo comment block."
283 :type 'boolean
284 :group 'octave
285 :version "24.4")
286
315(defcustom octave-blink-matching-block t 287(defcustom octave-blink-matching-block t
316 "Control the blinking of matching Octave block keywords. 288 "Control the blinking of matching Octave block keywords.
317Non-nil means show matching begin of block when inserting a space, 289Non-nil means show matching begin of block when inserting a space,
@@ -575,6 +547,7 @@ definitions can also be stored in files and used in batch mode."
575 'octave-completion-at-point-function nil t) 547 'octave-completion-at-point-function nil t)
576 (add-hook 'before-save-hook 'octave-sync-function-file-names nil t) 548 (add-hook 'before-save-hook 'octave-sync-function-file-names nil t)
577 (setq-local beginning-of-defun-function 'octave-beginning-of-defun) 549 (setq-local beginning-of-defun-function 'octave-beginning-of-defun)
550 (and octave-font-lock-texinfo-comment (octave-font-lock-texinfo-comment))
578 551
579 (easy-menu-add octave-mode-menu)) 552 (easy-menu-add octave-mode-menu))
580 553
@@ -1049,6 +1022,50 @@ q: Don't fix\n" func file))
1049 nil 'delimited nil nil beg end) 1022 nil 'delimited nil nil beg end)
1050 (message "Function names match"))))) 1023 (message "Function names match")))))
1051 1024
1025;; Adapted from texinfo-font-lock-keywords
1026(defvar octave-texinfo-font-lock-keywords
1027 `(("@\\([a-zA-Z]+\\|[^ \t\n]\\)" 1 font-lock-keyword-face prepend) ;commands
1028 ("^\\*\\([^\n:]*\\)" 1 font-lock-function-name-face prepend) ;menu items
1029 ("@\\(emph\\|i\\|sc\\){\\([^}]+\\)" 2 'italic prepend)
1030 ("@\\(strong\\|b\\){\\([^}]+\\)" 2 'bold prepend)
1031 ("@\\(kbd\\|key\\|url\\|uref\\){\\([^}]+\\)"
1032 2 font-lock-string-face prepend)
1033 ("@\\(file\\|email\\){\\([^}]+\\)" 2 font-lock-string-face prepend)
1034 ("@\\(samp\\|code\\|var\\|math\\|env\\|command\\|option\\){\\([^}]+\\)"
1035 2 font-lock-variable-name-face prepend)
1036 ("@\\(cite\\|x?ref\\|pxref\\|dfn\\|inforef\\){\\([^}]+\\)"
1037 2 font-lock-constant-face prepend)
1038 ("@\\(anchor\\){\\([^}]+\\)" 2 font-lock-type-face prepend)
1039 ("@\\(dmn\\|acronym\\|value\\){\\([^}]+\\)"
1040 2 font-lock-builtin-face prepend)
1041 ("@\\(end\\|itemx?\\) +\\(.+\\)" 2 font-lock-keyword-face prepend))
1042 "Additional keywords to highlight in texinfo comment block.")
1043
1044(defface octave-function-comment-block
1045 '((t (:inherit font-lock-doc-face)))
1046 "Face used to highlight function comment block."
1047 :group 'octave)
1048
1049(defun octave-font-lock-texinfo-comment ()
1050 (font-lock-add-keywords
1051 nil
1052 '(((lambda (limit)
1053 (while (and (search-forward "-*- texinfo -*-" limit t)
1054 (octave-in-comment-p))
1055 (let ((beg (nth 8 (syntax-ppss)))
1056 (end (progn
1057 (octave-skip-comment-forward (point-max))
1058 (point))))
1059 (put-text-property beg end 'font-lock-multiline t)
1060 (font-lock-prepend-text-property
1061 beg end 'face 'octave-function-comment-block)
1062 (dolist (kw octave-texinfo-font-lock-keywords)
1063 (goto-char beg)
1064 (while (re-search-forward (car kw) end 'move)
1065 (font-lock-apply-highlight (cdr kw))))))
1066 nil)))
1067 'append))
1068
1052 1069
1053;;; Indentation 1070;;; Indentation
1054 1071
@@ -1336,8 +1353,7 @@ otherwise."
1336 (process-live-p inferior-octave-process) 1353 (process-live-p inferior-octave-process)
1337 (inferior-octave-completion-table)) 1354 (inferior-octave-completion-table))
1338 (append octave-reserved-words 1355 (append octave-reserved-words
1339 octave-text-functions 1356 octave-text-functions)))))
1340 octave-variables)))))
1341 1357
1342(define-obsolete-function-alias 'octave-complete-symbol 1358(define-obsolete-function-alias 'octave-complete-symbol
1343 'completion-at-point "24.1") 1359 'completion-at-point "24.1")