1997-04-20 07:33:52 +00:00
|
|
|
|
;;; octave-mod.el --- editing Octave source files under Emacs
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
2010-11-10 00:21:06 -08:00
|
|
|
|
;; Copyright (C) 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
|
|
|
|
|
;; 2009, 2010 Free Software Foundation, Inc.
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
2005-08-26 13:41:26 +00:00
|
|
|
|
;; Author: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at>
|
2010-08-12 13:22:16 +02:00
|
|
|
|
;; Author: John Eaton <jwe@octave.org>
|
2005-08-26 13:41:26 +00:00
|
|
|
|
;; Maintainer: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at>
|
1997-01-21 00:29:57 +00:00
|
|
|
|
;; Keywords: languages
|
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 07:25:26 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1997-01-21 00:29:57 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 07:25:26 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2008-05-06 07:25:26 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
1997-01-21 00:40:19 +00:00
|
|
|
|
;; This package provides Emacs support for Octave.
|
|
|
|
|
;; It defines Octave mode, a major mode for editing
|
|
|
|
|
;; Octave code.
|
|
|
|
|
|
|
|
|
|
;; The file octave-inf.el contains code for interacting with an inferior
|
|
|
|
|
;; Octave process using comint.
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
2008-04-30 08:48:02 +00:00
|
|
|
|
;; See the documentation of `octave-mode' and
|
1997-01-21 00:40:19 +00:00
|
|
|
|
;; `run-octave' for further information on usage and customization.
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
1997-01-21 00:40:19 +00:00
|
|
|
|
;;; Code:
|
1999-10-24 18:17:01 +00:00
|
|
|
|
(require 'custom)
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
1998-01-26 11:29:46 +00:00
|
|
|
|
(defgroup octave nil
|
|
|
|
|
"Major mode for editing Octave source files."
|
2005-11-17 07:40:11 +00:00
|
|
|
|
:link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
|
1998-01-26 11:29:46 +00:00
|
|
|
|
:group 'languages)
|
|
|
|
|
|
1997-04-22 04:45:17 +00:00
|
|
|
|
(defvar inferior-octave-output-list nil)
|
|
|
|
|
(defvar inferior-octave-output-string nil)
|
|
|
|
|
(defvar inferior-octave-receive-in-progress nil)
|
|
|
|
|
|
2007-11-19 08:50:04 +00:00
|
|
|
|
(declare-function inferior-octave-send-list-and-digest "octave-inf" (list))
|
|
|
|
|
|
1997-01-21 04:43:45 +00:00
|
|
|
|
(defconst octave-maintainer-address
|
2005-08-26 13:41:26 +00:00
|
|
|
|
"Kurt Hornik <Kurt.Hornik@wu-wien.ac.at>, bug-gnu-emacs@gnu.org"
|
1997-01-21 04:43:45 +00:00
|
|
|
|
"Current maintainer of the Emacs Octave package.")
|
|
|
|
|
|
2008-05-02 18:32:18 +00:00
|
|
|
|
(define-abbrev-table 'octave-abbrev-table
|
|
|
|
|
(mapcar (lambda (e) (append e '(nil 0 t)))
|
|
|
|
|
'(("`a" "all_va_args")
|
|
|
|
|
("`b" "break")
|
|
|
|
|
("`cs" "case")
|
|
|
|
|
("`ca" "catch")
|
|
|
|
|
("`c" "continue")
|
|
|
|
|
("`el" "else")
|
|
|
|
|
("`eli" "elseif")
|
|
|
|
|
("`et" "end_try_catch")
|
|
|
|
|
("`eu" "end_unwind_protect")
|
|
|
|
|
("`ef" "endfor")
|
|
|
|
|
("`efu" "endfunction")
|
|
|
|
|
("`ei" "endif")
|
|
|
|
|
("`es" "endswitch")
|
|
|
|
|
("`ew" "endwhile")
|
|
|
|
|
("`f" "for")
|
|
|
|
|
("`fu" "function")
|
|
|
|
|
("`gl" "global")
|
|
|
|
|
("`gp" "gplot")
|
|
|
|
|
("`gs" "gsplot")
|
|
|
|
|
("`if" "if ()")
|
|
|
|
|
("`o" "otherwise")
|
|
|
|
|
("`rp" "replot")
|
|
|
|
|
("`r" "return")
|
|
|
|
|
("`s" "switch")
|
|
|
|
|
("`t" "try")
|
|
|
|
|
("`u" "until ()")
|
|
|
|
|
("`up" "unwind_protect")
|
|
|
|
|
("`upc" "unwind_protect_cleanup")
|
|
|
|
|
("`w" "while ()")))
|
1997-01-21 04:43:45 +00:00
|
|
|
|
"Abbrev table for Octave's reserved words.
|
2001-12-30 22:23:27 +00:00
|
|
|
|
Used in `octave-mode' and inferior-octave-mode buffers.
|
2008-05-02 18:32:18 +00:00
|
|
|
|
All Octave abbrevs start with a grave accent (`)."
|
|
|
|
|
:regexp "\\(?:[^`]\\|^\\)\\(\\(?:\\<\\|`\\)\\w+\\)\\W*")
|
1997-01-21 04:43:45 +00:00
|
|
|
|
|
|
|
|
|
(defvar octave-comment-char ?#
|
|
|
|
|
"Character to start an Octave comment.")
|
|
|
|
|
(defvar octave-comment-start
|
2010-08-12 13:22:16 +02:00
|
|
|
|
(string octave-comment-char ?\s)
|
1997-01-21 04:43:45 +00:00
|
|
|
|
"String to insert to start a new Octave in-line comment.")
|
|
|
|
|
(defvar octave-comment-start-skip "\\s<+\\s-*"
|
|
|
|
|
"Regexp to match the start of an Octave comment up to its body.")
|
|
|
|
|
|
|
|
|
|
(defvar octave-begin-keywords
|
John W. Eaton <jwe at octave.org>
(octave-abbrev-table): Add "until".
(octave-begin-keywords): Add "do".
(octave-end-keywords): Remove "end".
(octave-reserved-words): Add "end". Remove "all_va_args",
"gplot", and 'gsplot".
(octave-text-functions): Remove "gset", "gshow", "set", and "show".
(octave-variables): Remove "IMAGEPATH", "INFO_FILE",
"INFO_PROGRAM", "LOADPATH", "__error_text__", "automatic_replot",
"default_return_value", "define_all_return_values",
"do_fortran_indexing", "empty_list_elements_ok",
"gnuplot_has_multiplot", "implicit_str_to_num_ok",
"ok_to_lose_imaginary_part", "prefer_column_vectors",
"prefer_zero_one_indexing", "propagate_empty_matrices",
"resize_on_range_error", "treat_neg_dim_as_zero",
"warn_assign_as_truth_value", "warn_comma_in_global_decl",
"warn_divide_by_zero", "warn_function_name_clash",
"warn_missing_semicolon", "whitespace_in_literal_matrix".
Add "DEFAULT_EXEC_PATH", "DEFAULT_LOADPATH", "IMAGE_PATH",
"crash_dumps_octave_core", "sighup_dumps_octave_core",
"sigterm_dumps_octave_core".
(octave-block-match-alist): Remove "end" from block-end keywords.
(octave-mode): Update ftp site address.
2007-10-06 01:49:23 +00:00
|
|
|
|
'("do" "for" "function" "if" "switch" "try" "unwind_protect" "while"))
|
1997-01-21 04:43:45 +00:00
|
|
|
|
(defvar octave-else-keywords
|
1997-03-12 00:35:32 +00:00
|
|
|
|
'("case" "catch" "else" "elseif" "otherwise" "unwind_protect_cleanup"))
|
1997-01-21 04:43:45 +00:00
|
|
|
|
(defvar octave-end-keywords
|
John W. Eaton <jwe at octave.org>
(octave-abbrev-table): Add "until".
(octave-begin-keywords): Add "do".
(octave-end-keywords): Remove "end".
(octave-reserved-words): Add "end". Remove "all_va_args",
"gplot", and 'gsplot".
(octave-text-functions): Remove "gset", "gshow", "set", and "show".
(octave-variables): Remove "IMAGEPATH", "INFO_FILE",
"INFO_PROGRAM", "LOADPATH", "__error_text__", "automatic_replot",
"default_return_value", "define_all_return_values",
"do_fortran_indexing", "empty_list_elements_ok",
"gnuplot_has_multiplot", "implicit_str_to_num_ok",
"ok_to_lose_imaginary_part", "prefer_column_vectors",
"prefer_zero_one_indexing", "propagate_empty_matrices",
"resize_on_range_error", "treat_neg_dim_as_zero",
"warn_assign_as_truth_value", "warn_comma_in_global_decl",
"warn_divide_by_zero", "warn_function_name_clash",
"warn_missing_semicolon", "whitespace_in_literal_matrix".
Add "DEFAULT_EXEC_PATH", "DEFAULT_LOADPATH", "IMAGE_PATH",
"crash_dumps_octave_core", "sighup_dumps_octave_core",
"sigterm_dumps_octave_core".
(octave-block-match-alist): Remove "end" from block-end keywords.
(octave-mode): Update ftp site address.
2007-10-06 01:49:23 +00:00
|
|
|
|
'("endfor" "endfunction" "endif" "endswitch" "end_try_catch"
|
2010-01-02 14:40:59 -05:00
|
|
|
|
"end_unwind_protect" "endwhile" "until" "end"))
|
1997-01-21 04:43:45 +00:00
|
|
|
|
|
|
|
|
|
(defvar octave-reserved-words
|
1997-03-12 00:35:32 +00:00
|
|
|
|
(append octave-begin-keywords
|
|
|
|
|
octave-else-keywords
|
|
|
|
|
octave-end-keywords
|
John W. Eaton <jwe at octave.org>
(octave-abbrev-table): Add "until".
(octave-begin-keywords): Add "do".
(octave-end-keywords): Remove "end".
(octave-reserved-words): Add "end". Remove "all_va_args",
"gplot", and 'gsplot".
(octave-text-functions): Remove "gset", "gshow", "set", and "show".
(octave-variables): Remove "IMAGEPATH", "INFO_FILE",
"INFO_PROGRAM", "LOADPATH", "__error_text__", "automatic_replot",
"default_return_value", "define_all_return_values",
"do_fortran_indexing", "empty_list_elements_ok",
"gnuplot_has_multiplot", "implicit_str_to_num_ok",
"ok_to_lose_imaginary_part", "prefer_column_vectors",
"prefer_zero_one_indexing", "propagate_empty_matrices",
"resize_on_range_error", "treat_neg_dim_as_zero",
"warn_assign_as_truth_value", "warn_comma_in_global_decl",
"warn_divide_by_zero", "warn_function_name_clash",
"warn_missing_semicolon", "whitespace_in_literal_matrix".
Add "DEFAULT_EXEC_PATH", "DEFAULT_LOADPATH", "IMAGE_PATH",
"crash_dumps_octave_core", "sighup_dumps_octave_core",
"sigterm_dumps_octave_core".
(octave-block-match-alist): Remove "end" from block-end keywords.
(octave-mode): Update ftp site address.
2007-10-06 01:49:23 +00:00
|
|
|
|
'("break" "continue" "end" "global" "persistent" "return"))
|
1997-01-21 04:43:45 +00:00
|
|
|
|
"Reserved words in Octave.")
|
|
|
|
|
|
|
|
|
|
(defvar octave-text-functions
|
|
|
|
|
'("casesen" "cd" "chdir" "clear" "diary" "dir" "document" "echo"
|
John W. Eaton <jwe at octave.org>
(octave-abbrev-table): Add "until".
(octave-begin-keywords): Add "do".
(octave-end-keywords): Remove "end".
(octave-reserved-words): Add "end". Remove "all_va_args",
"gplot", and 'gsplot".
(octave-text-functions): Remove "gset", "gshow", "set", and "show".
(octave-variables): Remove "IMAGEPATH", "INFO_FILE",
"INFO_PROGRAM", "LOADPATH", "__error_text__", "automatic_replot",
"default_return_value", "define_all_return_values",
"do_fortran_indexing", "empty_list_elements_ok",
"gnuplot_has_multiplot", "implicit_str_to_num_ok",
"ok_to_lose_imaginary_part", "prefer_column_vectors",
"prefer_zero_one_indexing", "propagate_empty_matrices",
"resize_on_range_error", "treat_neg_dim_as_zero",
"warn_assign_as_truth_value", "warn_comma_in_global_decl",
"warn_divide_by_zero", "warn_function_name_clash",
"warn_missing_semicolon", "whitespace_in_literal_matrix".
Add "DEFAULT_EXEC_PATH", "DEFAULT_LOADPATH", "IMAGE_PATH",
"crash_dumps_octave_core", "sighup_dumps_octave_core",
"sigterm_dumps_octave_core".
(octave-block-match-alist): Remove "end" from block-end keywords.
(octave-mode): Update ftp site address.
2007-10-06 01:49:23 +00:00
|
|
|
|
"edit_history" "format" "help" "history" "hold"
|
|
|
|
|
"load" "ls" "more" "run_history" "save" "type"
|
1997-01-21 04:43:45 +00:00
|
|
|
|
"which" "who" "whos")
|
John W. Eaton <jwe at octave.org>
(octave-abbrev-table): Add "until".
(octave-begin-keywords): Add "do".
(octave-end-keywords): Remove "end".
(octave-reserved-words): Add "end". Remove "all_va_args",
"gplot", and 'gsplot".
(octave-text-functions): Remove "gset", "gshow", "set", and "show".
(octave-variables): Remove "IMAGEPATH", "INFO_FILE",
"INFO_PROGRAM", "LOADPATH", "__error_text__", "automatic_replot",
"default_return_value", "define_all_return_values",
"do_fortran_indexing", "empty_list_elements_ok",
"gnuplot_has_multiplot", "implicit_str_to_num_ok",
"ok_to_lose_imaginary_part", "prefer_column_vectors",
"prefer_zero_one_indexing", "propagate_empty_matrices",
"resize_on_range_error", "treat_neg_dim_as_zero",
"warn_assign_as_truth_value", "warn_comma_in_global_decl",
"warn_divide_by_zero", "warn_function_name_clash",
"warn_missing_semicolon", "whitespace_in_literal_matrix".
Add "DEFAULT_EXEC_PATH", "DEFAULT_LOADPATH", "IMAGE_PATH",
"crash_dumps_octave_core", "sighup_dumps_octave_core",
"sigterm_dumps_octave_core".
(octave-block-match-alist): Remove "end" from block-end keywords.
(octave-mode): Update ftp site address.
2007-10-06 01:49:23 +00:00
|
|
|
|
"Text functions in Octave.")
|
1997-01-21 04:43:45 +00:00
|
|
|
|
|
|
|
|
|
(defvar octave-variables
|
John W. Eaton <jwe at octave.org>
(octave-abbrev-table): Add "until".
(octave-begin-keywords): Add "do".
(octave-end-keywords): Remove "end".
(octave-reserved-words): Add "end". Remove "all_va_args",
"gplot", and 'gsplot".
(octave-text-functions): Remove "gset", "gshow", "set", and "show".
(octave-variables): Remove "IMAGEPATH", "INFO_FILE",
"INFO_PROGRAM", "LOADPATH", "__error_text__", "automatic_replot",
"default_return_value", "define_all_return_values",
"do_fortran_indexing", "empty_list_elements_ok",
"gnuplot_has_multiplot", "implicit_str_to_num_ok",
"ok_to_lose_imaginary_part", "prefer_column_vectors",
"prefer_zero_one_indexing", "propagate_empty_matrices",
"resize_on_range_error", "treat_neg_dim_as_zero",
"warn_assign_as_truth_value", "warn_comma_in_global_decl",
"warn_divide_by_zero", "warn_function_name_clash",
"warn_missing_semicolon", "whitespace_in_literal_matrix".
Add "DEFAULT_EXEC_PATH", "DEFAULT_LOADPATH", "IMAGE_PATH",
"crash_dumps_octave_core", "sighup_dumps_octave_core",
"sigterm_dumps_octave_core".
(octave-block-match-alist): Remove "end" from block-end keywords.
(octave-mode): Update ftp site address.
2007-10-06 01:49:23 +00:00
|
|
|
|
'("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"
|
1997-01-21 04:43:45 +00:00
|
|
|
|
"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__"
|
John W. Eaton <jwe at octave.org>
(octave-abbrev-table): Add "until".
(octave-begin-keywords): Add "do".
(octave-end-keywords): Remove "end".
(octave-reserved-words): Add "end". Remove "all_va_args",
"gplot", and 'gsplot".
(octave-text-functions): Remove "gset", "gshow", "set", and "show".
(octave-variables): Remove "IMAGEPATH", "INFO_FILE",
"INFO_PROGRAM", "LOADPATH", "__error_text__", "automatic_replot",
"default_return_value", "define_all_return_values",
"do_fortran_indexing", "empty_list_elements_ok",
"gnuplot_has_multiplot", "implicit_str_to_num_ok",
"ok_to_lose_imaginary_part", "prefer_column_vectors",
"prefer_zero_one_indexing", "propagate_empty_matrices",
"resize_on_range_error", "treat_neg_dim_as_zero",
"warn_assign_as_truth_value", "warn_comma_in_global_decl",
"warn_divide_by_zero", "warn_function_name_clash",
"warn_missing_semicolon", "whitespace_in_literal_matrix".
Add "DEFAULT_EXEC_PATH", "DEFAULT_LOADPATH", "IMAGE_PATH",
"crash_dumps_octave_core", "sighup_dumps_octave_core",
"sigterm_dumps_octave_core".
(octave-block-match-alist): Remove "end" from block-end keywords.
(octave-mode): Update ftp site address.
2007-10-06 01:49:23 +00:00
|
|
|
|
"__i__" "__inf__" "__j__" "__nan__" "__pi__"
|
1997-01-21 04:43:45 +00:00
|
|
|
|
"__program_invocation_name__" "__program_name__" "__realmax__"
|
|
|
|
|
"__realmin__" "__stderr__" "__stdin__" "__stdout__" "ans" "argv"
|
John W. Eaton <jwe at octave.org>
(octave-abbrev-table): Add "until".
(octave-begin-keywords): Add "do".
(octave-end-keywords): Remove "end".
(octave-reserved-words): Add "end". Remove "all_va_args",
"gplot", and 'gsplot".
(octave-text-functions): Remove "gset", "gshow", "set", and "show".
(octave-variables): Remove "IMAGEPATH", "INFO_FILE",
"INFO_PROGRAM", "LOADPATH", "__error_text__", "automatic_replot",
"default_return_value", "define_all_return_values",
"do_fortran_indexing", "empty_list_elements_ok",
"gnuplot_has_multiplot", "implicit_str_to_num_ok",
"ok_to_lose_imaginary_part", "prefer_column_vectors",
"prefer_zero_one_indexing", "propagate_empty_matrices",
"resize_on_range_error", "treat_neg_dim_as_zero",
"warn_assign_as_truth_value", "warn_comma_in_global_decl",
"warn_divide_by_zero", "warn_function_name_clash",
"warn_missing_semicolon", "whitespace_in_literal_matrix".
Add "DEFAULT_EXEC_PATH", "DEFAULT_LOADPATH", "IMAGE_PATH",
"crash_dumps_octave_core", "sighup_dumps_octave_core",
"sigterm_dumps_octave_core".
(octave-block-match-alist): Remove "end" from block-end keywords.
(octave-mode): Update ftp site address.
2007-10-06 01:49:23 +00:00
|
|
|
|
"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"
|
1997-01-21 04:43:45 +00:00
|
|
|
|
"page_output_immediately" "page_screen_output" "pi"
|
|
|
|
|
"print_answer_id_name" "print_empty_dimensions"
|
John W. Eaton <jwe at octave.org>
(octave-abbrev-table): Add "until".
(octave-begin-keywords): Add "do".
(octave-end-keywords): Remove "end".
(octave-reserved-words): Add "end". Remove "all_va_args",
"gplot", and 'gsplot".
(octave-text-functions): Remove "gset", "gshow", "set", and "show".
(octave-variables): Remove "IMAGEPATH", "INFO_FILE",
"INFO_PROGRAM", "LOADPATH", "__error_text__", "automatic_replot",
"default_return_value", "define_all_return_values",
"do_fortran_indexing", "empty_list_elements_ok",
"gnuplot_has_multiplot", "implicit_str_to_num_ok",
"ok_to_lose_imaginary_part", "prefer_column_vectors",
"prefer_zero_one_indexing", "propagate_empty_matrices",
"resize_on_range_error", "treat_neg_dim_as_zero",
"warn_assign_as_truth_value", "warn_comma_in_global_decl",
"warn_divide_by_zero", "warn_function_name_clash",
"warn_missing_semicolon", "whitespace_in_literal_matrix".
Add "DEFAULT_EXEC_PATH", "DEFAULT_LOADPATH", "IMAGE_PATH",
"crash_dumps_octave_core", "sighup_dumps_octave_core",
"sigterm_dumps_octave_core".
(octave-block-match-alist): Remove "end" from block-end keywords.
(octave-mode): Update ftp site address.
2007-10-06 01:49:23 +00:00
|
|
|
|
"program_invocation_name" "program_name"
|
|
|
|
|
"realmax" "realmin" "return_last_computed_value" "save_precision"
|
|
|
|
|
"saving_history" "sighup_dumps_octave_core" "sigterm_dumps_octave_core"
|
1997-01-21 04:43:45 +00:00
|
|
|
|
"silent_functions" "split_long_rows" "stderr" "stdin" "stdout"
|
|
|
|
|
"string_fill_char" "struct_levels_to_print"
|
John W. Eaton <jwe at octave.org>
(octave-abbrev-table): Add "until".
(octave-begin-keywords): Add "do".
(octave-end-keywords): Remove "end".
(octave-reserved-words): Add "end". Remove "all_va_args",
"gplot", and 'gsplot".
(octave-text-functions): Remove "gset", "gshow", "set", and "show".
(octave-variables): Remove "IMAGEPATH", "INFO_FILE",
"INFO_PROGRAM", "LOADPATH", "__error_text__", "automatic_replot",
"default_return_value", "define_all_return_values",
"do_fortran_indexing", "empty_list_elements_ok",
"gnuplot_has_multiplot", "implicit_str_to_num_ok",
"ok_to_lose_imaginary_part", "prefer_column_vectors",
"prefer_zero_one_indexing", "propagate_empty_matrices",
"resize_on_range_error", "treat_neg_dim_as_zero",
"warn_assign_as_truth_value", "warn_comma_in_global_decl",
"warn_divide_by_zero", "warn_function_name_clash",
"warn_missing_semicolon", "whitespace_in_literal_matrix".
Add "DEFAULT_EXEC_PATH", "DEFAULT_LOADPATH", "IMAGE_PATH",
"crash_dumps_octave_core", "sighup_dumps_octave_core",
"sigterm_dumps_octave_core".
(octave-block-match-alist): Remove "end" from block-end keywords.
(octave-mode): Update ftp site address.
2007-10-06 01:49:23 +00:00
|
|
|
|
"suppress_verbose_help_message")
|
1997-01-21 04:43:45 +00:00
|
|
|
|
"Builtin variables in Octave.")
|
|
|
|
|
|
|
|
|
|
(defvar octave-function-header-regexp
|
|
|
|
|
(concat "^\\s-*\\<\\(function\\)\\>"
|
|
|
|
|
"\\([^=;\n]*=[ \t]*\\|[ \t]*\\)\\(\\w+\\)\\>")
|
|
|
|
|
"Regexp to match an Octave function header.
|
|
|
|
|
The string `function' and its name are given by the first and third
|
|
|
|
|
parenthetical grouping.")
|
|
|
|
|
|
|
|
|
|
(defvar octave-font-lock-keywords
|
|
|
|
|
(list
|
|
|
|
|
;; Fontify all builtin keywords.
|
|
|
|
|
(cons (concat "\\<\\("
|
2010-08-30 22:34:52 +02:00
|
|
|
|
(regexp-opt (append octave-reserved-words
|
|
|
|
|
octave-text-functions))
|
1997-01-21 04:43:45 +00:00
|
|
|
|
"\\)\\>")
|
|
|
|
|
'font-lock-keyword-face)
|
|
|
|
|
;; Fontify all builtin operators.
|
|
|
|
|
(cons "\\(&\\||\\|<=\\|>=\\|==\\|<\\|>\\|!=\\|!\\)"
|
2000-03-09 13:29:44 +00:00
|
|
|
|
(if (boundp 'font-lock-builtin-face)
|
|
|
|
|
'font-lock-builtin-face
|
|
|
|
|
'font-lock-preprocessor-face))
|
1997-01-21 04:43:45 +00:00
|
|
|
|
;; Fontify all builtin variables.
|
2010-08-17 17:49:30 +02:00
|
|
|
|
(cons (concat "\\<" (regexp-opt octave-variables) "\\>")
|
1997-01-21 04:43:45 +00:00
|
|
|
|
'font-lock-variable-name-face)
|
|
|
|
|
;; Fontify all function declarations.
|
|
|
|
|
(list octave-function-header-regexp
|
|
|
|
|
'(1 font-lock-keyword-face)
|
|
|
|
|
'(3 font-lock-function-name-face nil t)))
|
|
|
|
|
"Additional Octave expressions to highlight.")
|
|
|
|
|
|
New syntax-propertize functionality.
* lisp/font-lock.el (font-lock-syntactic-keywords): Make obsolete.
(font-lock-fontify-syntactic-keywords-region): Move handling of
font-lock-syntactically-fontified to...
(font-lock-default-fontify-region): ...here.
Let syntax-propertize-function take precedence.
(font-lock-fontify-syntactically-region): Cal syntax-propertize.
* lisp/emacs-lisp/regexp-opt.el (regexp-opt-depth): Skip named groups.
* lisp/emacs-lisp/syntax.el (syntax-propertize-function)
(syntax-propertize-chunk-size, syntax-propertize--done)
(syntax-propertize-extend-region-functions): New vars.
(syntax-propertize-wholelines, syntax-propertize-multiline)
(syntax-propertize--shift-groups, syntax-propertize-via-font-lock)
(syntax-propertize): New functions.
(syntax-propertize-rules): New macro.
(syntax-ppss-flush-cache): Set syntax-propertize--done.
(syntax-ppss): Call syntax-propertize.
* lisp/progmodes/ada-mode.el (ada-set-syntax-table-properties)
(ada-after-change-function, ada-initialize-syntax-table-properties)
(ada-handle-syntax-table-properties): Only define when
syntax-propertize is not available.
(ada-mode): Use syntax-propertize-function.
* lisp/progmodes/autoconf.el (autoconf-mode):
Use syntax-propertize-function.
(autoconf-font-lock-syntactic-keywords): Remove.
* lisp/progmodes/cfengine.el (cfengine-mode):
Use syntax-propertize-function.
(cfengine-font-lock-syntactic-keywords): Remove.
* lisp/progmodes/cperl-mode.el (cperl-mode): Use syntax-propertize-function.
* lisp/progmodes/fortran.el (fortran-mode): Use syntax-propertize-function.
(fortran--font-lock-syntactic-keywords): New var.
(fortran-line-length): Update syntax-propertize-function and
fortran--font-lock-syntactic-keywords.
* lisp/progmodes/gud.el (gdb-script-syntax-propertize-function): New var;
replaces gdb-script-font-lock-syntactic-keywords.
(gdb-script-mode): Use it.
* lisp/progmodes/js.el (js--regexp-literal): Define while compiling.
(js-syntax-propertize-function): New var; replaces
js-font-lock-syntactic-keywords.
(js-mode): Use it.
* lisp/progmodes/make-mode.el (makefile-syntax-propertize-function):
New var; replaces makefile-font-lock-syntactic-keywords.
(makefile-mode): Use it.
(makefile-imake-mode): Adjust.
* lisp/progmodes/mixal-mode.el (mixal-syntax-propertize-function): New var;
replaces mixal-font-lock-syntactic-keywords.
(mixal-mode): Use it.
* lisp/progmodes/octave-mod.el (octave-syntax-propertize-sqs): New function
to replace octave-font-lock-close-quotes.
(octave-syntax-propertize-function): New function to replace
octave-font-lock-syntactic-keywords.
(octave-mode): Use it.
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function): New fun to
replace perl-font-lock-syntactic-keywords.
(perl-syntax-propertize-special-constructs): New fun to replace
perl-font-lock-special-syntactic-constructs.
(perl-font-lock-syntactic-face-function): New fun.
(perl-mode): Use it.
* lisp/progmodes/python.el (python-syntax-propertize-function): New var to
replace python-font-lock-syntactic-keywords.
(python-mode): Use it.
(python-quote-syntax): Simplify and adjust to new use.
* lisp/progmodes/ruby-mode.el (ruby-here-doc-beg-re):
Define while compiling.
(ruby-here-doc-end-re, ruby-here-doc-beg-match)
(ruby-font-lock-syntactic-keywords, ruby-comment-beg-syntax)
(syntax-ppss, ruby-in-ppss-context-p, ruby-in-here-doc-p)
(ruby-here-doc-find-end, ruby-here-doc-beg-syntax)
(ruby-here-doc-end-syntax): Only define when
syntax-propertize is not available.
(ruby-syntax-propertize-function, ruby-syntax-propertize-heredoc):
New functions.
(ruby-in-ppss-context-p): Update to new syntax of heredocs.
(electric-indent-chars): Silence bytecompiler.
(ruby-mode): Use prog-mode, syntax-propertize-function, and
electric-indent-chars.
* lisp/progmodes/sh-script.el (sh-st-symbol): Remove.
(sh-font-lock-close-heredoc, sh-font-lock-open-heredoc): Add eol arg.
(sh-font-lock-flush-syntax-ppss-cache, sh-font-lock-here-doc): Remove.
(sh-font-lock-quoted-subshell): Assume we've already matched $(.
(sh-font-lock-paren): Set syntax-multiline.
(sh-font-lock-syntactic-keywords): Remove.
(sh-syntax-propertize-function): New function to replace it.
(sh-mode): Use it.
* lisp/progmodes/simula.el (simula-syntax-propertize-function): New var to
replace simula-font-lock-syntactic-keywords.
(simula-mode): Use it.
* lisp/progmodes/tcl.el (tcl-syntax-propertize-function): New var to
replace tcl-font-lock-syntactic-keywords.
(tcl-mode): Use it.
* lisp/progmodes/vhdl-mode.el (vhdl-mode): Use syntax-propertize-function
if available.
(vhdl-fontify-buffer): Adjust.
* lisp/textmodes/bibtex.el (bibtex-mode): Use syntax-propertize-function.
* lisp/textmodes/reftex.el (font-lock-syntactic-keywords): Don't declare
since we don't use it.
* lisp/textmodes/sgml-mode.el (sgml-syntax-propertize-function): New var to
replace sgml-font-lock-syntactic-keywords.
(sgml-mode): Use it.
* lisp/textmodes/tex-mode.el (tex-common-initialization, doctex-mode):
Use syntax-propertize-function.
* lisp/textmodes/texinfo.el (texinfo-syntax-propertize-function): New fun
to replace texinfo-font-lock-syntactic-keywords.
(texinfo-mode): Use it.
* test/indent/octave.m: Remove some `fixindent' not needed any more.
2010-09-11 01:13:42 +02:00
|
|
|
|
(defun octave-syntax-propertize-function (start end)
|
|
|
|
|
(goto-char start)
|
|
|
|
|
(octave-syntax-propertize-sqs end)
|
|
|
|
|
(funcall (syntax-propertize-rules
|
2010-08-17 17:49:30 +02:00
|
|
|
|
;; Try to distinguish the string-quotes from the transpose-quotes.
|
New syntax-propertize functionality.
* lisp/font-lock.el (font-lock-syntactic-keywords): Make obsolete.
(font-lock-fontify-syntactic-keywords-region): Move handling of
font-lock-syntactically-fontified to...
(font-lock-default-fontify-region): ...here.
Let syntax-propertize-function take precedence.
(font-lock-fontify-syntactically-region): Cal syntax-propertize.
* lisp/emacs-lisp/regexp-opt.el (regexp-opt-depth): Skip named groups.
* lisp/emacs-lisp/syntax.el (syntax-propertize-function)
(syntax-propertize-chunk-size, syntax-propertize--done)
(syntax-propertize-extend-region-functions): New vars.
(syntax-propertize-wholelines, syntax-propertize-multiline)
(syntax-propertize--shift-groups, syntax-propertize-via-font-lock)
(syntax-propertize): New functions.
(syntax-propertize-rules): New macro.
(syntax-ppss-flush-cache): Set syntax-propertize--done.
(syntax-ppss): Call syntax-propertize.
* lisp/progmodes/ada-mode.el (ada-set-syntax-table-properties)
(ada-after-change-function, ada-initialize-syntax-table-properties)
(ada-handle-syntax-table-properties): Only define when
syntax-propertize is not available.
(ada-mode): Use syntax-propertize-function.
* lisp/progmodes/autoconf.el (autoconf-mode):
Use syntax-propertize-function.
(autoconf-font-lock-syntactic-keywords): Remove.
* lisp/progmodes/cfengine.el (cfengine-mode):
Use syntax-propertize-function.
(cfengine-font-lock-syntactic-keywords): Remove.
* lisp/progmodes/cperl-mode.el (cperl-mode): Use syntax-propertize-function.
* lisp/progmodes/fortran.el (fortran-mode): Use syntax-propertize-function.
(fortran--font-lock-syntactic-keywords): New var.
(fortran-line-length): Update syntax-propertize-function and
fortran--font-lock-syntactic-keywords.
* lisp/progmodes/gud.el (gdb-script-syntax-propertize-function): New var;
replaces gdb-script-font-lock-syntactic-keywords.
(gdb-script-mode): Use it.
* lisp/progmodes/js.el (js--regexp-literal): Define while compiling.
(js-syntax-propertize-function): New var; replaces
js-font-lock-syntactic-keywords.
(js-mode): Use it.
* lisp/progmodes/make-mode.el (makefile-syntax-propertize-function):
New var; replaces makefile-font-lock-syntactic-keywords.
(makefile-mode): Use it.
(makefile-imake-mode): Adjust.
* lisp/progmodes/mixal-mode.el (mixal-syntax-propertize-function): New var;
replaces mixal-font-lock-syntactic-keywords.
(mixal-mode): Use it.
* lisp/progmodes/octave-mod.el (octave-syntax-propertize-sqs): New function
to replace octave-font-lock-close-quotes.
(octave-syntax-propertize-function): New function to replace
octave-font-lock-syntactic-keywords.
(octave-mode): Use it.
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function): New fun to
replace perl-font-lock-syntactic-keywords.
(perl-syntax-propertize-special-constructs): New fun to replace
perl-font-lock-special-syntactic-constructs.
(perl-font-lock-syntactic-face-function): New fun.
(perl-mode): Use it.
* lisp/progmodes/python.el (python-syntax-propertize-function): New var to
replace python-font-lock-syntactic-keywords.
(python-mode): Use it.
(python-quote-syntax): Simplify and adjust to new use.
* lisp/progmodes/ruby-mode.el (ruby-here-doc-beg-re):
Define while compiling.
(ruby-here-doc-end-re, ruby-here-doc-beg-match)
(ruby-font-lock-syntactic-keywords, ruby-comment-beg-syntax)
(syntax-ppss, ruby-in-ppss-context-p, ruby-in-here-doc-p)
(ruby-here-doc-find-end, ruby-here-doc-beg-syntax)
(ruby-here-doc-end-syntax): Only define when
syntax-propertize is not available.
(ruby-syntax-propertize-function, ruby-syntax-propertize-heredoc):
New functions.
(ruby-in-ppss-context-p): Update to new syntax of heredocs.
(electric-indent-chars): Silence bytecompiler.
(ruby-mode): Use prog-mode, syntax-propertize-function, and
electric-indent-chars.
* lisp/progmodes/sh-script.el (sh-st-symbol): Remove.
(sh-font-lock-close-heredoc, sh-font-lock-open-heredoc): Add eol arg.
(sh-font-lock-flush-syntax-ppss-cache, sh-font-lock-here-doc): Remove.
(sh-font-lock-quoted-subshell): Assume we've already matched $(.
(sh-font-lock-paren): Set syntax-multiline.
(sh-font-lock-syntactic-keywords): Remove.
(sh-syntax-propertize-function): New function to replace it.
(sh-mode): Use it.
* lisp/progmodes/simula.el (simula-syntax-propertize-function): New var to
replace simula-font-lock-syntactic-keywords.
(simula-mode): Use it.
* lisp/progmodes/tcl.el (tcl-syntax-propertize-function): New var to
replace tcl-font-lock-syntactic-keywords.
(tcl-mode): Use it.
* lisp/progmodes/vhdl-mode.el (vhdl-mode): Use syntax-propertize-function
if available.
(vhdl-fontify-buffer): Adjust.
* lisp/textmodes/bibtex.el (bibtex-mode): Use syntax-propertize-function.
* lisp/textmodes/reftex.el (font-lock-syntactic-keywords): Don't declare
since we don't use it.
* lisp/textmodes/sgml-mode.el (sgml-syntax-propertize-function): New var to
replace sgml-font-lock-syntactic-keywords.
(sgml-mode): Use it.
* lisp/textmodes/tex-mode.el (tex-common-initialization, doctex-mode):
Use syntax-propertize-function.
* lisp/textmodes/texinfo.el (texinfo-syntax-propertize-function): New fun
to replace texinfo-font-lock-syntactic-keywords.
(texinfo-mode): Use it.
* test/indent/octave.m: Remove some `fixindent' not needed any more.
2010-09-11 01:13:42 +02:00
|
|
|
|
("[[({,; ]\\('\\)"
|
|
|
|
|
(1 (prog1 "\"'" (octave-syntax-propertize-sqs end)))))
|
|
|
|
|
(point) end))
|
|
|
|
|
|
|
|
|
|
(defun octave-syntax-propertize-sqs (end)
|
|
|
|
|
"Propertize the content/end of single-quote strings."
|
|
|
|
|
(when (eq (nth 3 (syntax-ppss)) ?\')
|
2010-08-17 17:49:30 +02:00
|
|
|
|
;; A '..' string.
|
New syntax-propertize functionality.
* lisp/font-lock.el (font-lock-syntactic-keywords): Make obsolete.
(font-lock-fontify-syntactic-keywords-region): Move handling of
font-lock-syntactically-fontified to...
(font-lock-default-fontify-region): ...here.
Let syntax-propertize-function take precedence.
(font-lock-fontify-syntactically-region): Cal syntax-propertize.
* lisp/emacs-lisp/regexp-opt.el (regexp-opt-depth): Skip named groups.
* lisp/emacs-lisp/syntax.el (syntax-propertize-function)
(syntax-propertize-chunk-size, syntax-propertize--done)
(syntax-propertize-extend-region-functions): New vars.
(syntax-propertize-wholelines, syntax-propertize-multiline)
(syntax-propertize--shift-groups, syntax-propertize-via-font-lock)
(syntax-propertize): New functions.
(syntax-propertize-rules): New macro.
(syntax-ppss-flush-cache): Set syntax-propertize--done.
(syntax-ppss): Call syntax-propertize.
* lisp/progmodes/ada-mode.el (ada-set-syntax-table-properties)
(ada-after-change-function, ada-initialize-syntax-table-properties)
(ada-handle-syntax-table-properties): Only define when
syntax-propertize is not available.
(ada-mode): Use syntax-propertize-function.
* lisp/progmodes/autoconf.el (autoconf-mode):
Use syntax-propertize-function.
(autoconf-font-lock-syntactic-keywords): Remove.
* lisp/progmodes/cfengine.el (cfengine-mode):
Use syntax-propertize-function.
(cfengine-font-lock-syntactic-keywords): Remove.
* lisp/progmodes/cperl-mode.el (cperl-mode): Use syntax-propertize-function.
* lisp/progmodes/fortran.el (fortran-mode): Use syntax-propertize-function.
(fortran--font-lock-syntactic-keywords): New var.
(fortran-line-length): Update syntax-propertize-function and
fortran--font-lock-syntactic-keywords.
* lisp/progmodes/gud.el (gdb-script-syntax-propertize-function): New var;
replaces gdb-script-font-lock-syntactic-keywords.
(gdb-script-mode): Use it.
* lisp/progmodes/js.el (js--regexp-literal): Define while compiling.
(js-syntax-propertize-function): New var; replaces
js-font-lock-syntactic-keywords.
(js-mode): Use it.
* lisp/progmodes/make-mode.el (makefile-syntax-propertize-function):
New var; replaces makefile-font-lock-syntactic-keywords.
(makefile-mode): Use it.
(makefile-imake-mode): Adjust.
* lisp/progmodes/mixal-mode.el (mixal-syntax-propertize-function): New var;
replaces mixal-font-lock-syntactic-keywords.
(mixal-mode): Use it.
* lisp/progmodes/octave-mod.el (octave-syntax-propertize-sqs): New function
to replace octave-font-lock-close-quotes.
(octave-syntax-propertize-function): New function to replace
octave-font-lock-syntactic-keywords.
(octave-mode): Use it.
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function): New fun to
replace perl-font-lock-syntactic-keywords.
(perl-syntax-propertize-special-constructs): New fun to replace
perl-font-lock-special-syntactic-constructs.
(perl-font-lock-syntactic-face-function): New fun.
(perl-mode): Use it.
* lisp/progmodes/python.el (python-syntax-propertize-function): New var to
replace python-font-lock-syntactic-keywords.
(python-mode): Use it.
(python-quote-syntax): Simplify and adjust to new use.
* lisp/progmodes/ruby-mode.el (ruby-here-doc-beg-re):
Define while compiling.
(ruby-here-doc-end-re, ruby-here-doc-beg-match)
(ruby-font-lock-syntactic-keywords, ruby-comment-beg-syntax)
(syntax-ppss, ruby-in-ppss-context-p, ruby-in-here-doc-p)
(ruby-here-doc-find-end, ruby-here-doc-beg-syntax)
(ruby-here-doc-end-syntax): Only define when
syntax-propertize is not available.
(ruby-syntax-propertize-function, ruby-syntax-propertize-heredoc):
New functions.
(ruby-in-ppss-context-p): Update to new syntax of heredocs.
(electric-indent-chars): Silence bytecompiler.
(ruby-mode): Use prog-mode, syntax-propertize-function, and
electric-indent-chars.
* lisp/progmodes/sh-script.el (sh-st-symbol): Remove.
(sh-font-lock-close-heredoc, sh-font-lock-open-heredoc): Add eol arg.
(sh-font-lock-flush-syntax-ppss-cache, sh-font-lock-here-doc): Remove.
(sh-font-lock-quoted-subshell): Assume we've already matched $(.
(sh-font-lock-paren): Set syntax-multiline.
(sh-font-lock-syntactic-keywords): Remove.
(sh-syntax-propertize-function): New function to replace it.
(sh-mode): Use it.
* lisp/progmodes/simula.el (simula-syntax-propertize-function): New var to
replace simula-font-lock-syntactic-keywords.
(simula-mode): Use it.
* lisp/progmodes/tcl.el (tcl-syntax-propertize-function): New var to
replace tcl-font-lock-syntactic-keywords.
(tcl-mode): Use it.
* lisp/progmodes/vhdl-mode.el (vhdl-mode): Use syntax-propertize-function
if available.
(vhdl-fontify-buffer): Adjust.
* lisp/textmodes/bibtex.el (bibtex-mode): Use syntax-propertize-function.
* lisp/textmodes/reftex.el (font-lock-syntactic-keywords): Don't declare
since we don't use it.
* lisp/textmodes/sgml-mode.el (sgml-syntax-propertize-function): New var to
replace sgml-font-lock-syntactic-keywords.
(sgml-mode): Use it.
* lisp/textmodes/tex-mode.el (tex-common-initialization, doctex-mode):
Use syntax-propertize-function.
* lisp/textmodes/texinfo.el (texinfo-syntax-propertize-function): New fun
to replace texinfo-font-lock-syntactic-keywords.
(texinfo-mode): Use it.
* test/indent/octave.m: Remove some `fixindent' not needed any more.
2010-09-11 01:13:42 +02:00
|
|
|
|
(when (re-search-forward
|
|
|
|
|
"\\(?:\\=\\|[^']\\)\\(?:''\\)*\\('\\)\\($\\|[^']\\)" end 'move)
|
|
|
|
|
(goto-char (match-beginning 2))
|
2010-09-03 15:28:09 +02:00
|
|
|
|
(when (eq (char-before (match-beginning 1)) ?\\)
|
|
|
|
|
;; Backslash cannot escape a single quote.
|
|
|
|
|
(put-text-property (1- (match-beginning 1)) (match-beginning 1)
|
|
|
|
|
'syntax-table (string-to-syntax ".")))
|
2010-08-17 17:49:30 +02:00
|
|
|
|
(put-text-property (match-beginning 1) (match-end 1)
|
New syntax-propertize functionality.
* lisp/font-lock.el (font-lock-syntactic-keywords): Make obsolete.
(font-lock-fontify-syntactic-keywords-region): Move handling of
font-lock-syntactically-fontified to...
(font-lock-default-fontify-region): ...here.
Let syntax-propertize-function take precedence.
(font-lock-fontify-syntactically-region): Cal syntax-propertize.
* lisp/emacs-lisp/regexp-opt.el (regexp-opt-depth): Skip named groups.
* lisp/emacs-lisp/syntax.el (syntax-propertize-function)
(syntax-propertize-chunk-size, syntax-propertize--done)
(syntax-propertize-extend-region-functions): New vars.
(syntax-propertize-wholelines, syntax-propertize-multiline)
(syntax-propertize--shift-groups, syntax-propertize-via-font-lock)
(syntax-propertize): New functions.
(syntax-propertize-rules): New macro.
(syntax-ppss-flush-cache): Set syntax-propertize--done.
(syntax-ppss): Call syntax-propertize.
* lisp/progmodes/ada-mode.el (ada-set-syntax-table-properties)
(ada-after-change-function, ada-initialize-syntax-table-properties)
(ada-handle-syntax-table-properties): Only define when
syntax-propertize is not available.
(ada-mode): Use syntax-propertize-function.
* lisp/progmodes/autoconf.el (autoconf-mode):
Use syntax-propertize-function.
(autoconf-font-lock-syntactic-keywords): Remove.
* lisp/progmodes/cfengine.el (cfengine-mode):
Use syntax-propertize-function.
(cfengine-font-lock-syntactic-keywords): Remove.
* lisp/progmodes/cperl-mode.el (cperl-mode): Use syntax-propertize-function.
* lisp/progmodes/fortran.el (fortran-mode): Use syntax-propertize-function.
(fortran--font-lock-syntactic-keywords): New var.
(fortran-line-length): Update syntax-propertize-function and
fortran--font-lock-syntactic-keywords.
* lisp/progmodes/gud.el (gdb-script-syntax-propertize-function): New var;
replaces gdb-script-font-lock-syntactic-keywords.
(gdb-script-mode): Use it.
* lisp/progmodes/js.el (js--regexp-literal): Define while compiling.
(js-syntax-propertize-function): New var; replaces
js-font-lock-syntactic-keywords.
(js-mode): Use it.
* lisp/progmodes/make-mode.el (makefile-syntax-propertize-function):
New var; replaces makefile-font-lock-syntactic-keywords.
(makefile-mode): Use it.
(makefile-imake-mode): Adjust.
* lisp/progmodes/mixal-mode.el (mixal-syntax-propertize-function): New var;
replaces mixal-font-lock-syntactic-keywords.
(mixal-mode): Use it.
* lisp/progmodes/octave-mod.el (octave-syntax-propertize-sqs): New function
to replace octave-font-lock-close-quotes.
(octave-syntax-propertize-function): New function to replace
octave-font-lock-syntactic-keywords.
(octave-mode): Use it.
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function): New fun to
replace perl-font-lock-syntactic-keywords.
(perl-syntax-propertize-special-constructs): New fun to replace
perl-font-lock-special-syntactic-constructs.
(perl-font-lock-syntactic-face-function): New fun.
(perl-mode): Use it.
* lisp/progmodes/python.el (python-syntax-propertize-function): New var to
replace python-font-lock-syntactic-keywords.
(python-mode): Use it.
(python-quote-syntax): Simplify and adjust to new use.
* lisp/progmodes/ruby-mode.el (ruby-here-doc-beg-re):
Define while compiling.
(ruby-here-doc-end-re, ruby-here-doc-beg-match)
(ruby-font-lock-syntactic-keywords, ruby-comment-beg-syntax)
(syntax-ppss, ruby-in-ppss-context-p, ruby-in-here-doc-p)
(ruby-here-doc-find-end, ruby-here-doc-beg-syntax)
(ruby-here-doc-end-syntax): Only define when
syntax-propertize is not available.
(ruby-syntax-propertize-function, ruby-syntax-propertize-heredoc):
New functions.
(ruby-in-ppss-context-p): Update to new syntax of heredocs.
(electric-indent-chars): Silence bytecompiler.
(ruby-mode): Use prog-mode, syntax-propertize-function, and
electric-indent-chars.
* lisp/progmodes/sh-script.el (sh-st-symbol): Remove.
(sh-font-lock-close-heredoc, sh-font-lock-open-heredoc): Add eol arg.
(sh-font-lock-flush-syntax-ppss-cache, sh-font-lock-here-doc): Remove.
(sh-font-lock-quoted-subshell): Assume we've already matched $(.
(sh-font-lock-paren): Set syntax-multiline.
(sh-font-lock-syntactic-keywords): Remove.
(sh-syntax-propertize-function): New function to replace it.
(sh-mode): Use it.
* lisp/progmodes/simula.el (simula-syntax-propertize-function): New var to
replace simula-font-lock-syntactic-keywords.
(simula-mode): Use it.
* lisp/progmodes/tcl.el (tcl-syntax-propertize-function): New var to
replace tcl-font-lock-syntactic-keywords.
(tcl-mode): Use it.
* lisp/progmodes/vhdl-mode.el (vhdl-mode): Use syntax-propertize-function
if available.
(vhdl-fontify-buffer): Adjust.
* lisp/textmodes/bibtex.el (bibtex-mode): Use syntax-propertize-function.
* lisp/textmodes/reftex.el (font-lock-syntactic-keywords): Don't declare
since we don't use it.
* lisp/textmodes/sgml-mode.el (sgml-syntax-propertize-function): New var to
replace sgml-font-lock-syntactic-keywords.
(sgml-mode): Use it.
* lisp/textmodes/tex-mode.el (tex-common-initialization, doctex-mode):
Use syntax-propertize-function.
* lisp/textmodes/texinfo.el (texinfo-syntax-propertize-function): New fun
to replace texinfo-font-lock-syntactic-keywords.
(texinfo-mode): Use it.
* test/indent/octave.m: Remove some `fixindent' not needed any more.
2010-09-11 01:13:42 +02:00
|
|
|
|
'syntax-table (string-to-syntax "\"'")))))
|
2010-08-17 17:49:30 +02:00
|
|
|
|
|
1998-01-26 11:29:46 +00:00
|
|
|
|
(defcustom inferior-octave-buffer "*Inferior Octave*"
|
2007-09-19 14:47:51 +00:00
|
|
|
|
"Name of buffer for running an inferior Octave process."
|
1998-01-26 11:29:46 +00:00
|
|
|
|
:type 'string
|
|
|
|
|
:group 'octave-inferior)
|
1997-01-21 04:43:45 +00:00
|
|
|
|
|
|
|
|
|
(defvar inferior-octave-process nil)
|
|
|
|
|
|
2007-09-19 14:47:51 +00:00
|
|
|
|
(defvar octave-mode-map
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
|
(define-key map "`" 'octave-abbrev-start)
|
2003-02-04 13:24:35 +00:00
|
|
|
|
(define-key map "\e\n" 'octave-indent-new-comment-line)
|
|
|
|
|
(define-key map "\M-\C-q" 'octave-indent-defun)
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(define-key map "\C-c\C-b" 'octave-submit-bug-report)
|
|
|
|
|
(define-key map "\C-c\C-p" 'octave-previous-code-line)
|
|
|
|
|
(define-key map "\C-c\C-n" 'octave-next-code-line)
|
|
|
|
|
(define-key map "\C-c\C-a" 'octave-beginning-of-line)
|
2003-02-04 13:24:35 +00:00
|
|
|
|
(define-key map "\C-c\C-e" 'octave-end-of-line)
|
Remove old indentation and navigation code on octave-mode.
* lisp/progmodes/octave-mod.el (octave-mode-map): Remap down-list to
smie-down-list rather than add a binding for octave-down-block.
(octave-mark-block, octave-blink-matching-block-open):
Rely on forward-sexp-function.
(octave-fill-paragraph): Don't narrow, so you can use
indent-according-to-mode.
(octave-block-begin-regexp, octave-block-begin-or-end-regexp): Remove.
(octave-in-block-p, octave-re-search-forward-kw)
(octave-re-search-backward-kw, octave-indent-calculate)
(octave-end-as-array-index-p, octave-block-end-offset)
(octave-scan-blocks, octave-forward-block, octave-backward-block)
(octave-down-block, octave-backward-up-block, octave-up-block)
(octave-before-magic-comment-p, octave-indent-line): Remove.
2010-08-31 14:13:51 +02:00
|
|
|
|
(define-key map [remap down-list] 'smie-down-list)
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(define-key map "\C-c\M-\C-h" 'octave-mark-block)
|
2010-08-30 22:34:52 +02:00
|
|
|
|
(define-key map "\C-c]" 'smie-close-block)
|
|
|
|
|
(define-key map "\C-c/" 'smie-close-block)
|
2003-01-20 08:59:40 +00:00
|
|
|
|
(define-key map "\C-c\C-f" 'octave-insert-defun)
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(define-key map "\C-c\C-h" 'octave-help)
|
2003-01-20 08:59:40 +00:00
|
|
|
|
(define-key map "\C-c\C-il" 'octave-send-line)
|
|
|
|
|
(define-key map "\C-c\C-ib" 'octave-send-block)
|
|
|
|
|
(define-key map "\C-c\C-if" 'octave-send-defun)
|
2003-02-04 13:24:35 +00:00
|
|
|
|
(define-key map "\C-c\C-ir" 'octave-send-region)
|
2003-01-20 08:59:40 +00:00
|
|
|
|
(define-key map "\C-c\C-is" 'octave-show-process-buffer)
|
|
|
|
|
(define-key map "\C-c\C-ih" 'octave-hide-process-buffer)
|
|
|
|
|
(define-key map "\C-c\C-ik" 'octave-kill-process)
|
|
|
|
|
(define-key map "\C-c\C-i\C-l" 'octave-send-line)
|
|
|
|
|
(define-key map "\C-c\C-i\C-b" 'octave-send-block)
|
|
|
|
|
(define-key map "\C-c\C-i\C-f" 'octave-send-defun)
|
2003-02-04 13:24:35 +00:00
|
|
|
|
(define-key map "\C-c\C-i\C-r" 'octave-send-region)
|
2003-01-20 08:59:40 +00:00
|
|
|
|
(define-key map "\C-c\C-i\C-s" 'octave-show-process-buffer)
|
|
|
|
|
(define-key map "\C-c\C-i\C-h" 'octave-hide-process-buffer)
|
|
|
|
|
(define-key map "\C-c\C-i\C-k" 'octave-kill-process)
|
2007-09-19 14:47:51 +00:00
|
|
|
|
map)
|
|
|
|
|
"Keymap used in Octave mode.")
|
|
|
|
|
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
2010-08-17 17:49:30 +02:00
|
|
|
|
|
|
|
|
|
(easy-menu-define octave-mode-menu octave-mode-map
|
|
|
|
|
"Menu for Octave mode."
|
2007-09-19 14:47:51 +00:00
|
|
|
|
'("Octave"
|
2008-09-25 22:10:31 +00:00
|
|
|
|
("Lines"
|
2007-09-19 14:47:51 +00:00
|
|
|
|
["Previous Code Line" octave-previous-code-line t]
|
|
|
|
|
["Next Code Line" octave-next-code-line t]
|
|
|
|
|
["Begin of Continuation" octave-beginning-of-line t]
|
|
|
|
|
["End of Continuation" octave-end-of-line t]
|
|
|
|
|
["Split Line at Point" octave-indent-new-comment-line t])
|
2008-09-25 22:10:31 +00:00
|
|
|
|
("Blocks"
|
2007-09-19 14:47:51 +00:00
|
|
|
|
["Mark Block" octave-mark-block t]
|
2010-08-30 22:34:52 +02:00
|
|
|
|
["Close Block" smie-close-block t])
|
2008-09-25 22:10:31 +00:00
|
|
|
|
("Functions"
|
2007-09-19 14:47:51 +00:00
|
|
|
|
["Indent Function" octave-indent-defun t]
|
|
|
|
|
["Insert Function" octave-insert-defun t])
|
|
|
|
|
"-"
|
2008-09-25 22:10:31 +00:00
|
|
|
|
("Debug"
|
2007-09-19 14:47:51 +00:00
|
|
|
|
["Send Current Line" octave-send-line t]
|
|
|
|
|
["Send Current Block" octave-send-block t]
|
|
|
|
|
["Send Current Function" octave-send-defun t]
|
|
|
|
|
["Send Region" octave-send-region t]
|
|
|
|
|
["Show Process Buffer" octave-show-process-buffer t]
|
|
|
|
|
["Hide Process Buffer" octave-hide-process-buffer t]
|
|
|
|
|
["Kill Process" octave-kill-process t])
|
|
|
|
|
"-"
|
|
|
|
|
["Indent Line" indent-according-to-mode t]
|
2010-08-12 13:22:16 +02:00
|
|
|
|
["Complete Symbol" completion-at-point t]
|
2007-09-19 14:47:51 +00:00
|
|
|
|
"-"
|
2010-08-18 15:12:34 +02:00
|
|
|
|
["Toggle Abbrev Mode" abbrev-mode
|
|
|
|
|
:style toggle :selected abbrev-mode]
|
|
|
|
|
["Toggle Auto-Fill Mode" auto-fill-mode
|
|
|
|
|
:style toggle :selected auto-fill-function]
|
2007-09-19 14:47:51 +00:00
|
|
|
|
"-"
|
|
|
|
|
["Submit Bug Report" octave-submit-bug-report t]
|
|
|
|
|
"-"
|
2010-08-12 13:22:16 +02:00
|
|
|
|
["Describe Octave Mode" describe-mode t]
|
2010-08-17 17:49:30 +02:00
|
|
|
|
["Lookup Octave Index" info-lookup-symbol t]))
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
2003-10-24 18:58:28 +00:00
|
|
|
|
(defvar octave-mode-syntax-table
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(let ((table (make-syntax-table)))
|
|
|
|
|
(modify-syntax-entry ?\r " " table)
|
|
|
|
|
(modify-syntax-entry ?+ "." table)
|
|
|
|
|
(modify-syntax-entry ?- "." table)
|
|
|
|
|
(modify-syntax-entry ?= "." table)
|
|
|
|
|
(modify-syntax-entry ?* "." table)
|
|
|
|
|
(modify-syntax-entry ?/ "." table)
|
|
|
|
|
(modify-syntax-entry ?> "." table)
|
|
|
|
|
(modify-syntax-entry ?< "." table)
|
|
|
|
|
(modify-syntax-entry ?& "." table)
|
|
|
|
|
(modify-syntax-entry ?| "." table)
|
|
|
|
|
(modify-syntax-entry ?! "." table)
|
|
|
|
|
(modify-syntax-entry ?\\ "\\" table)
|
|
|
|
|
(modify-syntax-entry ?\' "." table)
|
2008-05-02 18:32:18 +00:00
|
|
|
|
;; Was "w" for abbrevs, but now that it's not necessary any more,
|
|
|
|
|
(modify-syntax-entry ?\` "." table)
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(modify-syntax-entry ?\" "\"" table)
|
|
|
|
|
(modify-syntax-entry ?. "w" table)
|
|
|
|
|
(modify-syntax-entry ?_ "w" table)
|
2010-08-12 16:44:16 +02:00
|
|
|
|
;; The "b" flag only applies to the second letter of the comstart
|
2010-08-12 14:46:24 +02:00
|
|
|
|
;; and the first letter of the comend, i.e. the "4b" below is ineffective.
|
|
|
|
|
;; If we try to put `b' on the single-line comments, we get a similar
|
|
|
|
|
;; problem where the % and # chars appear as first chars of the 2-char
|
|
|
|
|
;; comend, so the multi-line ender is also turned into style-b.
|
2010-08-12 16:44:16 +02:00
|
|
|
|
;; So we need the new "c" comment style.
|
2010-08-12 13:22:16 +02:00
|
|
|
|
(modify-syntax-entry ?\% "< 13" table)
|
|
|
|
|
(modify-syntax-entry ?\# "< 13" table)
|
2010-08-12 16:44:16 +02:00
|
|
|
|
(modify-syntax-entry ?\{ "(} 2c" table)
|
|
|
|
|
(modify-syntax-entry ?\} "){ 4c" table)
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(modify-syntax-entry ?\n ">" table)
|
2003-10-24 18:58:28 +00:00
|
|
|
|
table)
|
|
|
|
|
"Syntax table in use in `octave-mode' buffers.")
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
1998-01-26 11:29:46 +00:00
|
|
|
|
(defcustom octave-blink-matching-block t
|
2007-09-19 14:47:51 +00:00
|
|
|
|
"Control the blinking of matching Octave block keywords.
|
1997-01-21 00:29:57 +00:00
|
|
|
|
Non-nil means show matching begin of block when inserting a space,
|
1998-01-26 11:29:46 +00:00
|
|
|
|
newline or semicolon after an else or end keyword."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'octave)
|
2010-08-17 17:49:30 +02:00
|
|
|
|
|
1998-01-26 11:29:46 +00:00
|
|
|
|
(defcustom octave-block-offset 2
|
2007-09-19 14:47:51 +00:00
|
|
|
|
"Extra indentation applied to statements in Octave block structures."
|
1998-01-26 11:29:46 +00:00
|
|
|
|
:type 'integer
|
|
|
|
|
:group 'octave)
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
|
|
|
|
(defvar octave-block-comment-start
|
|
|
|
|
(concat (make-string 2 octave-comment-char) " ")
|
|
|
|
|
"String to insert to start a new Octave comment on an empty line.")
|
|
|
|
|
|
1998-01-26 11:29:46 +00:00
|
|
|
|
(defcustom octave-continuation-offset 4
|
2007-09-19 14:47:51 +00:00
|
|
|
|
"Extra indentation applied to Octave continuation lines."
|
1998-01-26 11:29:46 +00:00
|
|
|
|
:type 'integer
|
|
|
|
|
:group 'octave)
|
2010-08-30 22:34:52 +02:00
|
|
|
|
(eval-and-compile
|
|
|
|
|
(defconst octave-continuation-marker-regexp "\\\\\\|\\.\\.\\."))
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(defvar octave-continuation-regexp
|
2010-08-30 22:34:52 +02:00
|
|
|
|
(concat "[^#%\n]*\\(" octave-continuation-marker-regexp
|
|
|
|
|
"\\)\\s-*\\(\\s<.*\\)?$"))
|
1998-01-26 11:29:46 +00:00
|
|
|
|
(defcustom octave-continuation-string "\\"
|
2007-09-19 14:47:51 +00:00
|
|
|
|
"Character string used for Octave continuation lines. Normally \\."
|
1998-01-26 11:29:46 +00:00
|
|
|
|
:type 'string
|
|
|
|
|
:group 'octave)
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
|
|
|
|
(defvar octave-completion-alist nil
|
|
|
|
|
"Alist of Octave symbols for completion in Octave mode.
|
|
|
|
|
Each element looks like (VAR . VAR), where the car and cdr are the same
|
|
|
|
|
symbol (an Octave command or variable name).
|
2003-02-04 13:24:35 +00:00
|
|
|
|
Currently, only builtin variables can be completed.")
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
|
|
|
|
(defvar octave-mode-imenu-generic-expression
|
|
|
|
|
(list
|
|
|
|
|
;; Functions
|
|
|
|
|
(list nil octave-function-header-regexp 3))
|
|
|
|
|
"Imenu expression for Octave mode. See `imenu-generic-expression'.")
|
|
|
|
|
|
1998-01-26 11:29:46 +00:00
|
|
|
|
(defcustom octave-mode-hook nil
|
2007-09-19 14:47:51 +00:00
|
|
|
|
"Hook to be run when Octave mode is started."
|
1998-01-26 11:29:46 +00:00
|
|
|
|
:type 'hook
|
|
|
|
|
:group 'octave)
|
|
|
|
|
|
|
|
|
|
(defcustom octave-send-show-buffer t
|
2007-09-19 14:47:51 +00:00
|
|
|
|
"Non-nil means display `inferior-octave-buffer' after sending to it."
|
1998-01-26 11:29:46 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'octave)
|
|
|
|
|
(defcustom octave-send-line-auto-forward t
|
2007-09-19 14:47:51 +00:00
|
|
|
|
"Control auto-forward after sending to the inferior Octave process.
|
1998-01-26 11:29:46 +00:00
|
|
|
|
Non-nil means always go to the next Octave code line after sending."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'octave)
|
|
|
|
|
(defcustom octave-send-echo-input t
|
2007-09-19 14:47:51 +00:00
|
|
|
|
"Non-nil means echo input sent to the inferior Octave process."
|
1998-01-26 11:29:46 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'octave)
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
|
|
|
|
|
2010-08-30 22:34:52 +02:00
|
|
|
|
;;; SMIE indentation
|
|
|
|
|
|
|
|
|
|
(require 'smie)
|
|
|
|
|
|
|
|
|
|
(defconst octave-operator-table
|
|
|
|
|
'((assoc ";" "\n") (assoc ",") ; The doc claims they have equal precedence!?
|
|
|
|
|
(right "=" "+=" "-=" "*=" "/=")
|
|
|
|
|
(assoc "&&") (assoc "||") ; The doc claims they have equal precedence!?
|
|
|
|
|
(assoc "&") (assoc "|") ; The doc claims they have equal precedence!?
|
|
|
|
|
(nonassoc "<" "<=" "==" ">=" ">" "!=" "~=")
|
|
|
|
|
(nonassoc ":") ;No idea what this is.
|
|
|
|
|
(assoc "+" "-")
|
|
|
|
|
(assoc "*" "/" "\\" ".\\" ".*" "./")
|
|
|
|
|
(nonassoc "'" ".'")
|
|
|
|
|
(nonassoc "++" "--" "!" "~") ;And unary "+" and "-".
|
|
|
|
|
(right "^" "**" ".^" ".**")
|
|
|
|
|
;; It's not really an operator, but for indentation purposes it
|
|
|
|
|
;; could be convenient to treat it as one.
|
|
|
|
|
(assoc "...")))
|
|
|
|
|
|
2010-09-03 15:28:09 +02:00
|
|
|
|
(defconst octave-smie-bnf-table
|
|
|
|
|
'((atom)
|
|
|
|
|
;; We can't distinguish the first element in a sequence with
|
|
|
|
|
;; precedence grammars, so we can't distinguish the condition
|
|
|
|
|
;; if the `if' from the subsequent body, for example.
|
|
|
|
|
;; This has to be done later in the indentation rules.
|
|
|
|
|
(exp (exp "\n" exp)
|
|
|
|
|
;; We need to mention at least one of the operators in this part
|
|
|
|
|
;; of the grammar: if the BNF and the operator table have
|
|
|
|
|
;; no overlap, SMIE can't know how they relate.
|
|
|
|
|
(exp ";" exp)
|
|
|
|
|
("try" exp "catch" exp "end_try_catch")
|
|
|
|
|
("try" exp "catch" exp "end")
|
|
|
|
|
("unwind_protect" exp
|
|
|
|
|
"unwind_protect_cleanup" exp "end_unwind_protect")
|
|
|
|
|
("unwind_protect" exp "unwind_protect_cleanup" exp "end")
|
|
|
|
|
("for" exp "endfor")
|
|
|
|
|
("for" exp "end")
|
|
|
|
|
("do" exp "until" atom)
|
|
|
|
|
("while" exp "endwhile")
|
|
|
|
|
("while" exp "end")
|
|
|
|
|
("if" exp "endif")
|
|
|
|
|
("if" exp "else" exp "endif")
|
|
|
|
|
("if" exp "elseif" exp "else" exp "endif")
|
|
|
|
|
("if" exp "elseif" exp "elseif" exp "else" exp "endif")
|
|
|
|
|
("if" exp "elseif" exp "elseif" exp "else" exp "end")
|
|
|
|
|
("switch" exp "case" exp "endswitch")
|
|
|
|
|
("switch" exp "case" exp "otherwise" exp "endswitch")
|
|
|
|
|
("switch" exp "case" exp "case" exp "otherwise" exp "endswitch")
|
|
|
|
|
("switch" exp "case" exp "case" exp "otherwise" exp "end")
|
|
|
|
|
("function" exp "endfunction")
|
|
|
|
|
("function" exp "end"))
|
|
|
|
|
;; (fundesc (atom "=" atom))
|
|
|
|
|
))
|
|
|
|
|
|
2010-11-07 10:45:45 -05:00
|
|
|
|
(defconst octave-smie-grammar
|
|
|
|
|
(smie-prec2->grammar
|
2010-08-30 22:34:52 +02:00
|
|
|
|
(smie-merge-prec2s
|
2010-11-07 10:45:45 -05:00
|
|
|
|
(smie-bnf->prec2 octave-smie-bnf-table
|
|
|
|
|
'((assoc "\n" ";")))
|
2010-08-30 22:34:52 +02:00
|
|
|
|
|
2010-11-07 10:45:45 -05:00
|
|
|
|
(smie-precs->prec2 octave-operator-table))))
|
2010-08-30 22:34:52 +02:00
|
|
|
|
|
|
|
|
|
;; Tokenizing needs to be refined so that ";;" is treated as two
|
|
|
|
|
;; tokens and also so as to recognize the \n separator (and
|
|
|
|
|
;; corresponding continuation lines).
|
|
|
|
|
|
|
|
|
|
(defconst octave-operator-regexp
|
|
|
|
|
(regexp-opt (apply 'append (mapcar 'cdr octave-operator-table))))
|
|
|
|
|
|
|
|
|
|
(defun octave-smie-backward-token ()
|
|
|
|
|
(let ((pos (point)))
|
|
|
|
|
(forward-comment (- (point)))
|
|
|
|
|
(cond
|
|
|
|
|
((and (not (eq (char-before) ?\;)) ;Coalesce ";" and "\n".
|
|
|
|
|
(> pos (line-end-position))
|
|
|
|
|
(if (looking-back octave-continuation-marker-regexp (- (point) 3))
|
|
|
|
|
(progn
|
|
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
|
(forward-comment (- (point)))
|
|
|
|
|
nil)
|
|
|
|
|
t)
|
|
|
|
|
;; Ignore it if it's within parentheses.
|
|
|
|
|
(let ((ppss (syntax-ppss)))
|
|
|
|
|
(not (and (nth 1 ppss)
|
|
|
|
|
(eq ?\( (char-after (nth 1 ppss)))))))
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
;; Why bother distinguishing \n and ;?
|
|
|
|
|
";") ;;"\n"
|
|
|
|
|
((and (looking-back octave-operator-regexp (- (point) 3) 'greedy)
|
|
|
|
|
;; Don't mistake a string quote for a transpose.
|
|
|
|
|
(not (looking-back "\\s\"" (1- (point)))))
|
|
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
|
(match-string-no-properties 0))
|
|
|
|
|
(t
|
|
|
|
|
(smie-default-backward-token)))))
|
|
|
|
|
|
|
|
|
|
(defun octave-smie-forward-token ()
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(when (looking-at (eval-when-compile
|
|
|
|
|
(concat "\\(" octave-continuation-marker-regexp
|
|
|
|
|
"\\)[ \t]*\\($\\|[%#]\\)")))
|
|
|
|
|
(goto-char (match-end 1))
|
|
|
|
|
(forward-comment 1))
|
|
|
|
|
(cond
|
|
|
|
|
((and (looking-at "$\\|[%#]")
|
|
|
|
|
;; Ignore it if it's within parentheses.
|
|
|
|
|
(prog1 (let ((ppss (syntax-ppss)))
|
|
|
|
|
(not (and (nth 1 ppss)
|
|
|
|
|
(eq ?\( (char-after (nth 1 ppss))))))
|
|
|
|
|
(forward-comment (point-max))))
|
|
|
|
|
;; Why bother distinguishing \n and ;?
|
|
|
|
|
";") ;;"\n"
|
|
|
|
|
((looking-at ";[ \t]*\\($\\|[%#]\\)")
|
|
|
|
|
;; Combine the ; with the subsequent \n.
|
|
|
|
|
(goto-char (match-beginning 1))
|
|
|
|
|
(forward-comment 1)
|
|
|
|
|
";")
|
|
|
|
|
((and (looking-at octave-operator-regexp)
|
|
|
|
|
;; Don't mistake a string quote for a transpose.
|
|
|
|
|
(not (looking-at "\\s\"")))
|
|
|
|
|
(goto-char (match-end 0))
|
|
|
|
|
(match-string-no-properties 0))
|
|
|
|
|
(t
|
|
|
|
|
(smie-default-forward-token))))
|
|
|
|
|
|
2010-10-29 15:20:28 -04:00
|
|
|
|
(defun octave-smie-rules (kind token)
|
|
|
|
|
(pcase (cons kind token)
|
2010-11-07 10:45:45 -05:00
|
|
|
|
;; We could set smie-indent-basic instead, but that would have two
|
|
|
|
|
;; disadvantages:
|
|
|
|
|
;; - changes to octave-block-offset wouldn't take effect immediately.
|
|
|
|
|
;; - edebug wouldn't show the use of this variable.
|
2010-10-29 15:20:28 -04:00
|
|
|
|
(`(:elem . basic) octave-block-offset)
|
2010-11-07 10:45:45 -05:00
|
|
|
|
;; Since "case" is in the same BNF rules as switch..end, SMIE by default
|
|
|
|
|
;; aligns it with "switch".
|
|
|
|
|
(`(:before . "case") (if (not (smie-rule-sibling-p)) octave-block-offset))
|
2010-10-29 15:20:28 -04:00
|
|
|
|
(`(:after . ";")
|
2010-11-07 10:45:45 -05:00
|
|
|
|
(if (smie-rule-parent-p "function" "if" "while" "else" "elseif" "for"
|
|
|
|
|
"otherwise" "case" "try" "catch" "unwind_protect"
|
|
|
|
|
"unwind_protect_cleanup")
|
|
|
|
|
(smie-rule-parent octave-block-offset)
|
2010-10-29 15:20:28 -04:00
|
|
|
|
;; For (invalid) code between switch and case.
|
|
|
|
|
;; (if (smie-parent-p "switch") 4)
|
|
|
|
|
0))))
|
2010-08-30 22:34:52 +02:00
|
|
|
|
|
2010-11-16 16:19:34 -05:00
|
|
|
|
(defvar electric-layout-rules)
|
2010-09-08 18:21:23 +02:00
|
|
|
|
|
1997-01-21 00:29:57 +00:00
|
|
|
|
;;;###autoload
|
2010-08-12 13:22:16 +02:00
|
|
|
|
(define-derived-mode octave-mode prog-mode "Octave"
|
1997-01-21 00:29:57 +00:00
|
|
|
|
"Major mode for editing Octave code.
|
|
|
|
|
|
|
|
|
|
This mode makes it easier to write Octave code by helping with
|
|
|
|
|
indentation, doing some of the typing for you (with Abbrev mode) and by
|
2010-01-02 02:05:44 +01:00
|
|
|
|
showing keywords, comments, strings, etc. in different faces (with
|
1997-01-21 00:29:57 +00:00
|
|
|
|
Font Lock mode on terminals that support it).
|
|
|
|
|
|
|
|
|
|
Octave itself is a high-level language, primarily intended for numerical
|
|
|
|
|
computations. It provides a convenient command line interface for
|
|
|
|
|
solving linear and nonlinear problems numerically. Function definitions
|
|
|
|
|
can also be stored in files, and it can be used in a batch mode (which
|
|
|
|
|
is why you need this mode!).
|
|
|
|
|
|
|
|
|
|
The latest released version of Octave is always available via anonymous
|
John W. Eaton <jwe at octave.org>
(octave-abbrev-table): Add "until".
(octave-begin-keywords): Add "do".
(octave-end-keywords): Remove "end".
(octave-reserved-words): Add "end". Remove "all_va_args",
"gplot", and 'gsplot".
(octave-text-functions): Remove "gset", "gshow", "set", and "show".
(octave-variables): Remove "IMAGEPATH", "INFO_FILE",
"INFO_PROGRAM", "LOADPATH", "__error_text__", "automatic_replot",
"default_return_value", "define_all_return_values",
"do_fortran_indexing", "empty_list_elements_ok",
"gnuplot_has_multiplot", "implicit_str_to_num_ok",
"ok_to_lose_imaginary_part", "prefer_column_vectors",
"prefer_zero_one_indexing", "propagate_empty_matrices",
"resize_on_range_error", "treat_neg_dim_as_zero",
"warn_assign_as_truth_value", "warn_comma_in_global_decl",
"warn_divide_by_zero", "warn_function_name_clash",
"warn_missing_semicolon", "whitespace_in_literal_matrix".
Add "DEFAULT_EXEC_PATH", "DEFAULT_LOADPATH", "IMAGE_PATH",
"crash_dumps_octave_core", "sighup_dumps_octave_core",
"sigterm_dumps_octave_core".
(octave-block-match-alist): Remove "end" from block-end keywords.
(octave-mode): Update ftp site address.
2007-10-06 01:49:23 +00:00
|
|
|
|
ftp from ftp.octave.org in the directory `/pub/octave'. Complete
|
1997-01-21 00:29:57 +00:00
|
|
|
|
source and binaries for several popular systems are available.
|
|
|
|
|
|
|
|
|
|
Type \\[list-abbrevs] to display the built-in abbrevs for Octave keywords.
|
|
|
|
|
|
|
|
|
|
Keybindings
|
|
|
|
|
===========
|
|
|
|
|
|
|
|
|
|
\\{octave-mode-map}
|
|
|
|
|
|
|
|
|
|
Variables you can use to customize Octave mode
|
|
|
|
|
==============================================
|
|
|
|
|
|
2007-09-19 14:47:51 +00:00
|
|
|
|
`octave-blink-matching-block'
|
1997-01-21 00:29:57 +00:00
|
|
|
|
Non-nil means show matching begin of block when inserting a space,
|
|
|
|
|
newline or semicolon after an else or end keyword. Default is t.
|
|
|
|
|
|
2007-09-19 14:47:51 +00:00
|
|
|
|
`octave-block-offset'
|
1997-01-21 00:29:57 +00:00
|
|
|
|
Extra indentation applied to statements in block structures.
|
|
|
|
|
Default is 2.
|
|
|
|
|
|
2007-09-19 14:47:51 +00:00
|
|
|
|
`octave-continuation-offset'
|
1997-01-21 00:29:57 +00:00
|
|
|
|
Extra indentation applied to Octave continuation lines.
|
|
|
|
|
Default is 4.
|
|
|
|
|
|
2007-09-19 14:47:51 +00:00
|
|
|
|
`octave-continuation-string'
|
1997-01-21 00:29:57 +00:00
|
|
|
|
String used for Octave continuation lines.
|
|
|
|
|
Default is a backslash.
|
|
|
|
|
|
2007-09-19 14:47:51 +00:00
|
|
|
|
`octave-send-echo-input'
|
1997-01-21 00:29:57 +00:00
|
|
|
|
Non-nil means always display `inferior-octave-buffer' after sending a
|
|
|
|
|
command to the inferior Octave process.
|
|
|
|
|
|
2007-09-19 14:47:51 +00:00
|
|
|
|
`octave-send-line-auto-forward'
|
1997-01-21 00:29:57 +00:00
|
|
|
|
Non-nil means always go to the next unsent line of Octave code after
|
|
|
|
|
sending a line to the inferior Octave process.
|
|
|
|
|
|
2007-09-19 14:47:51 +00:00
|
|
|
|
`octave-send-echo-input'
|
1997-01-21 00:29:57 +00:00
|
|
|
|
Non-nil means echo input sent to the inferior Octave process.
|
|
|
|
|
|
|
|
|
|
Turning on Octave mode runs the hook `octave-mode-hook'.
|
|
|
|
|
|
|
|
|
|
To begin using this mode for all `.m' files that you edit, add the
|
|
|
|
|
following lines to your `.emacs' file:
|
|
|
|
|
|
2007-09-19 14:47:51 +00:00
|
|
|
|
(add-to-list 'auto-mode-alist '(\"\\\\.m\\\\'\" . octave-mode))
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
John W. Eaton <jwe at octave.org>
(octave-abbrev-table): Add "until".
(octave-begin-keywords): Add "do".
(octave-end-keywords): Remove "end".
(octave-reserved-words): Add "end". Remove "all_va_args",
"gplot", and 'gsplot".
(octave-text-functions): Remove "gset", "gshow", "set", and "show".
(octave-variables): Remove "IMAGEPATH", "INFO_FILE",
"INFO_PROGRAM", "LOADPATH", "__error_text__", "automatic_replot",
"default_return_value", "define_all_return_values",
"do_fortran_indexing", "empty_list_elements_ok",
"gnuplot_has_multiplot", "implicit_str_to_num_ok",
"ok_to_lose_imaginary_part", "prefer_column_vectors",
"prefer_zero_one_indexing", "propagate_empty_matrices",
"resize_on_range_error", "treat_neg_dim_as_zero",
"warn_assign_as_truth_value", "warn_comma_in_global_decl",
"warn_divide_by_zero", "warn_function_name_clash",
"warn_missing_semicolon", "whitespace_in_literal_matrix".
Add "DEFAULT_EXEC_PATH", "DEFAULT_LOADPATH", "IMAGE_PATH",
"crash_dumps_octave_core", "sighup_dumps_octave_core",
"sigterm_dumps_octave_core".
(octave-block-match-alist): Remove "end" from block-end keywords.
(octave-mode): Update ftp site address.
2007-10-06 01:49:23 +00:00
|
|
|
|
To automatically turn on the abbrev and auto-fill features,
|
1997-01-21 00:29:57 +00:00
|
|
|
|
add the following lines to your `.emacs' file as well:
|
|
|
|
|
|
|
|
|
|
(add-hook 'octave-mode-hook
|
|
|
|
|
(lambda ()
|
|
|
|
|
(abbrev-mode 1)
|
2007-09-19 14:47:51 +00:00
|
|
|
|
(auto-fill-mode 1)))
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
|
|
|
|
To submit a problem report, enter \\[octave-submit-bug-report] from \
|
|
|
|
|
an Octave mode buffer.
|
|
|
|
|
This automatically sets up a mail buffer with version information
|
|
|
|
|
already added. You just need to add a description of the problem,
|
|
|
|
|
including a reproducible test case and send the message."
|
|
|
|
|
(setq local-abbrev-table octave-abbrev-table)
|
2010-08-12 13:22:16 +02:00
|
|
|
|
|
2010-11-07 10:45:45 -05:00
|
|
|
|
(smie-setup octave-smie-grammar #'octave-smie-rules
|
2010-10-29 15:20:28 -04:00
|
|
|
|
:forward-token #'octave-smie-forward-token
|
|
|
|
|
:backward-token #'octave-smie-backward-token)
|
2010-08-30 22:34:52 +02:00
|
|
|
|
(set (make-local-variable 'smie-indent-basic) 'octave-block-offset)
|
2010-10-29 15:20:28 -04:00
|
|
|
|
|
2010-09-03 15:28:09 +02:00
|
|
|
|
(set (make-local-variable 'smie-blink-matching-triggers)
|
2010-10-29 15:20:28 -04:00
|
|
|
|
(cons ?\; smie-blink-matching-triggers))
|
|
|
|
|
(unless octave-blink-matching-block
|
|
|
|
|
(remove-hook 'post-self-insert-hook #'smie-blink-matching-open 'local))
|
2010-09-03 15:28:09 +02:00
|
|
|
|
|
2010-10-27 10:26:01 -04:00
|
|
|
|
(set (make-local-variable 'electric-indent-chars)
|
|
|
|
|
(cons ?\; electric-indent-chars))
|
2010-11-16 16:19:34 -05:00
|
|
|
|
;; IIUC matlab-mode takes the opposite approach: it makes RET insert
|
|
|
|
|
;; a ";" at those places where it's correct (i.e. outside of parens).
|
|
|
|
|
(set (make-local-variable 'electric-layout-rules) '((?\; . after)))
|
2010-08-12 13:22:16 +02:00
|
|
|
|
|
|
|
|
|
(set (make-local-variable 'comment-start) octave-comment-start)
|
|
|
|
|
(set (make-local-variable 'comment-end) "")
|
|
|
|
|
;; Don't set it here: it's not really a property of the language,
|
|
|
|
|
;; just a personal preference of the author.
|
|
|
|
|
;; (set (make-local-variable 'comment-column) 32)
|
|
|
|
|
(set (make-local-variable 'comment-start-skip) "\\s<+\\s-*")
|
2010-08-12 12:46:44 +02:00
|
|
|
|
(set (make-local-variable 'comment-add) 1)
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
2010-08-12 13:22:16 +02:00
|
|
|
|
(set (make-local-variable 'parse-sexp-ignore-comments) t)
|
|
|
|
|
(set (make-local-variable 'paragraph-start)
|
|
|
|
|
(concat "\\s-*$\\|" page-delimiter))
|
|
|
|
|
(set (make-local-variable 'paragraph-separate) paragraph-start)
|
|
|
|
|
(set (make-local-variable 'paragraph-ignore-fill-prefix) t)
|
|
|
|
|
(set (make-local-variable 'fill-paragraph-function) 'octave-fill-paragraph)
|
|
|
|
|
;; FIXME: Why disable it?
|
|
|
|
|
;; (set (make-local-variable 'adaptive-fill-regexp) nil)
|
|
|
|
|
;; Again, this is not a property of the language, don't set it here.
|
|
|
|
|
;; (set (make-local-variable 'fill-column) 72)
|
|
|
|
|
(set (make-local-variable 'normal-auto-fill-function) 'octave-auto-fill)
|
|
|
|
|
|
|
|
|
|
(set (make-local-variable 'font-lock-defaults)
|
New syntax-propertize functionality.
* lisp/font-lock.el (font-lock-syntactic-keywords): Make obsolete.
(font-lock-fontify-syntactic-keywords-region): Move handling of
font-lock-syntactically-fontified to...
(font-lock-default-fontify-region): ...here.
Let syntax-propertize-function take precedence.
(font-lock-fontify-syntactically-region): Cal syntax-propertize.
* lisp/emacs-lisp/regexp-opt.el (regexp-opt-depth): Skip named groups.
* lisp/emacs-lisp/syntax.el (syntax-propertize-function)
(syntax-propertize-chunk-size, syntax-propertize--done)
(syntax-propertize-extend-region-functions): New vars.
(syntax-propertize-wholelines, syntax-propertize-multiline)
(syntax-propertize--shift-groups, syntax-propertize-via-font-lock)
(syntax-propertize): New functions.
(syntax-propertize-rules): New macro.
(syntax-ppss-flush-cache): Set syntax-propertize--done.
(syntax-ppss): Call syntax-propertize.
* lisp/progmodes/ada-mode.el (ada-set-syntax-table-properties)
(ada-after-change-function, ada-initialize-syntax-table-properties)
(ada-handle-syntax-table-properties): Only define when
syntax-propertize is not available.
(ada-mode): Use syntax-propertize-function.
* lisp/progmodes/autoconf.el (autoconf-mode):
Use syntax-propertize-function.
(autoconf-font-lock-syntactic-keywords): Remove.
* lisp/progmodes/cfengine.el (cfengine-mode):
Use syntax-propertize-function.
(cfengine-font-lock-syntactic-keywords): Remove.
* lisp/progmodes/cperl-mode.el (cperl-mode): Use syntax-propertize-function.
* lisp/progmodes/fortran.el (fortran-mode): Use syntax-propertize-function.
(fortran--font-lock-syntactic-keywords): New var.
(fortran-line-length): Update syntax-propertize-function and
fortran--font-lock-syntactic-keywords.
* lisp/progmodes/gud.el (gdb-script-syntax-propertize-function): New var;
replaces gdb-script-font-lock-syntactic-keywords.
(gdb-script-mode): Use it.
* lisp/progmodes/js.el (js--regexp-literal): Define while compiling.
(js-syntax-propertize-function): New var; replaces
js-font-lock-syntactic-keywords.
(js-mode): Use it.
* lisp/progmodes/make-mode.el (makefile-syntax-propertize-function):
New var; replaces makefile-font-lock-syntactic-keywords.
(makefile-mode): Use it.
(makefile-imake-mode): Adjust.
* lisp/progmodes/mixal-mode.el (mixal-syntax-propertize-function): New var;
replaces mixal-font-lock-syntactic-keywords.
(mixal-mode): Use it.
* lisp/progmodes/octave-mod.el (octave-syntax-propertize-sqs): New function
to replace octave-font-lock-close-quotes.
(octave-syntax-propertize-function): New function to replace
octave-font-lock-syntactic-keywords.
(octave-mode): Use it.
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function): New fun to
replace perl-font-lock-syntactic-keywords.
(perl-syntax-propertize-special-constructs): New fun to replace
perl-font-lock-special-syntactic-constructs.
(perl-font-lock-syntactic-face-function): New fun.
(perl-mode): Use it.
* lisp/progmodes/python.el (python-syntax-propertize-function): New var to
replace python-font-lock-syntactic-keywords.
(python-mode): Use it.
(python-quote-syntax): Simplify and adjust to new use.
* lisp/progmodes/ruby-mode.el (ruby-here-doc-beg-re):
Define while compiling.
(ruby-here-doc-end-re, ruby-here-doc-beg-match)
(ruby-font-lock-syntactic-keywords, ruby-comment-beg-syntax)
(syntax-ppss, ruby-in-ppss-context-p, ruby-in-here-doc-p)
(ruby-here-doc-find-end, ruby-here-doc-beg-syntax)
(ruby-here-doc-end-syntax): Only define when
syntax-propertize is not available.
(ruby-syntax-propertize-function, ruby-syntax-propertize-heredoc):
New functions.
(ruby-in-ppss-context-p): Update to new syntax of heredocs.
(electric-indent-chars): Silence bytecompiler.
(ruby-mode): Use prog-mode, syntax-propertize-function, and
electric-indent-chars.
* lisp/progmodes/sh-script.el (sh-st-symbol): Remove.
(sh-font-lock-close-heredoc, sh-font-lock-open-heredoc): Add eol arg.
(sh-font-lock-flush-syntax-ppss-cache, sh-font-lock-here-doc): Remove.
(sh-font-lock-quoted-subshell): Assume we've already matched $(.
(sh-font-lock-paren): Set syntax-multiline.
(sh-font-lock-syntactic-keywords): Remove.
(sh-syntax-propertize-function): New function to replace it.
(sh-mode): Use it.
* lisp/progmodes/simula.el (simula-syntax-propertize-function): New var to
replace simula-font-lock-syntactic-keywords.
(simula-mode): Use it.
* lisp/progmodes/tcl.el (tcl-syntax-propertize-function): New var to
replace tcl-font-lock-syntactic-keywords.
(tcl-mode): Use it.
* lisp/progmodes/vhdl-mode.el (vhdl-mode): Use syntax-propertize-function
if available.
(vhdl-fontify-buffer): Adjust.
* lisp/textmodes/bibtex.el (bibtex-mode): Use syntax-propertize-function.
* lisp/textmodes/reftex.el (font-lock-syntactic-keywords): Don't declare
since we don't use it.
* lisp/textmodes/sgml-mode.el (sgml-syntax-propertize-function): New var to
replace sgml-font-lock-syntactic-keywords.
(sgml-mode): Use it.
* lisp/textmodes/tex-mode.el (tex-common-initialization, doctex-mode):
Use syntax-propertize-function.
* lisp/textmodes/texinfo.el (texinfo-syntax-propertize-function): New fun
to replace texinfo-font-lock-syntactic-keywords.
(texinfo-mode): Use it.
* test/indent/octave.m: Remove some `fixindent' not needed any more.
2010-09-11 01:13:42 +02:00
|
|
|
|
'(octave-font-lock-keywords))
|
|
|
|
|
|
|
|
|
|
(set (make-local-variable 'syntax-propertize-function)
|
|
|
|
|
#'octave-syntax-propertize-function)
|
2010-08-12 13:22:16 +02:00
|
|
|
|
|
|
|
|
|
(set (make-local-variable 'imenu-generic-expression)
|
|
|
|
|
octave-mode-imenu-generic-expression)
|
|
|
|
|
(set (make-local-variable 'imenu-case-fold-search) nil)
|
|
|
|
|
|
|
|
|
|
(add-hook 'completion-at-point-functions
|
|
|
|
|
'octave-completion-at-point-function nil t)
|
2010-08-17 17:49:30 +02:00
|
|
|
|
(set (make-local-variable 'beginning-of-defun-function)
|
|
|
|
|
'octave-beginning-of-defun)
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
2010-08-17 17:49:30 +02:00
|
|
|
|
(easy-menu-add octave-mode-menu)
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(octave-initialize-completions)
|
2005-05-26 16:43:37 +00:00
|
|
|
|
(run-mode-hooks 'octave-mode-hook))
|
2008-04-30 08:48:02 +00:00
|
|
|
|
|
2010-08-17 17:49:30 +02:00
|
|
|
|
(defvar info-lookup-mode)
|
|
|
|
|
|
2008-04-30 08:48:02 +00:00
|
|
|
|
(defun octave-help ()
|
|
|
|
|
"Get help on Octave symbols from the Octave info files.
|
|
|
|
|
Look up symbol in the function, operator and variable indices of the info files."
|
|
|
|
|
(let ((info-lookup-mode 'octave-mode))
|
|
|
|
|
(call-interactively 'info-lookup-symbol)))
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
|
|
|
|
;;; Miscellaneous useful functions
|
|
|
|
|
|
|
|
|
|
(defsubst octave-in-comment-p ()
|
2007-08-08 07:34:30 +00:00
|
|
|
|
"Return t if point is inside an Octave comment."
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(save-excursion
|
2010-08-12 13:22:16 +02:00
|
|
|
|
;; FIXME: use syntax-ppss?
|
2003-10-24 18:58:28 +00:00
|
|
|
|
(nth 4 (parse-partial-sexp (line-beginning-position) (point)))))
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
|
|
|
|
(defsubst octave-in-string-p ()
|
2007-08-08 07:34:30 +00:00
|
|
|
|
"Return t if point is inside an Octave string."
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(save-excursion
|
2010-08-12 13:22:16 +02:00
|
|
|
|
;; FIXME: use syntax-ppss?
|
2003-10-24 18:58:28 +00:00
|
|
|
|
(nth 3 (parse-partial-sexp (line-beginning-position) (point)))))
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
|
|
|
|
(defsubst octave-not-in-string-or-comment-p ()
|
2007-08-08 07:34:30 +00:00
|
|
|
|
"Return t if point is not inside an Octave string or comment."
|
2010-08-12 13:22:16 +02:00
|
|
|
|
;; FIXME: Use syntax-ppss?
|
2003-10-24 18:58:28 +00:00
|
|
|
|
(let ((pps (parse-partial-sexp (line-beginning-position) (point))))
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(not (or (nth 3 pps) (nth 4 pps)))))
|
|
|
|
|
|
|
|
|
|
|
2007-10-13 20:01:54 +00:00
|
|
|
|
(defun octave-looking-at-kw (regexp)
|
2007-10-13 20:09:14 +00:00
|
|
|
|
"Like `looking-at', but sets `case-fold-search' nil."
|
2007-10-13 20:01:54 +00:00
|
|
|
|
(let ((case-fold-search nil))
|
|
|
|
|
(looking-at regexp)))
|
|
|
|
|
|
1997-10-24 20:11:44 +00:00
|
|
|
|
(defun octave-maybe-insert-continuation-string ()
|
|
|
|
|
(if (or (octave-in-comment-p)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(looking-at octave-continuation-regexp)))
|
|
|
|
|
nil
|
|
|
|
|
(delete-horizontal-space)
|
|
|
|
|
(insert (concat " " octave-continuation-string))))
|
|
|
|
|
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
|
|
|
|
;;; Indentation
|
|
|
|
|
|
|
|
|
|
(defun octave-indent-new-comment-line ()
|
|
|
|
|
"Break Octave line at point, continuing comment if within one.
|
|
|
|
|
If within code, insert `octave-continuation-string' before breaking the
|
2003-02-04 13:24:35 +00:00
|
|
|
|
line. If within a string, signal an error.
|
|
|
|
|
The new line is properly indented."
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(delete-horizontal-space)
|
|
|
|
|
(cond
|
|
|
|
|
((octave-in-comment-p)
|
|
|
|
|
(indent-new-comment-line))
|
|
|
|
|
((octave-in-string-p)
|
|
|
|
|
(error "Cannot split a code line inside a string"))
|
|
|
|
|
(t
|
|
|
|
|
(insert (concat " " octave-continuation-string))
|
2010-11-16 16:19:34 -05:00
|
|
|
|
(reindent-then-newline-and-indent))))
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
|
|
|
|
(defun octave-indent-defun ()
|
2007-09-19 14:47:51 +00:00
|
|
|
|
"Properly indent the Octave function which contains point."
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(save-excursion
|
2010-08-17 17:49:30 +02:00
|
|
|
|
(mark-defun)
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(message "Indenting function...")
|
|
|
|
|
(indent-region (point) (mark) nil))
|
|
|
|
|
(message "Indenting function...done."))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Motion
|
|
|
|
|
(defun octave-next-code-line (&optional arg)
|
|
|
|
|
"Move ARG lines of Octave code forward (backward if ARG is negative).
|
|
|
|
|
Skips past all empty and comment lines. Default for ARG is 1.
|
|
|
|
|
|
|
|
|
|
On success, return 0. Otherwise, go as far as possible and return -1."
|
|
|
|
|
(interactive "p")
|
|
|
|
|
(or arg (setq arg 1))
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(let ((n 0)
|
|
|
|
|
(inc (if (> arg 0) 1 -1)))
|
|
|
|
|
(while (and (/= arg 0) (= n 0))
|
|
|
|
|
(setq n (forward-line inc))
|
|
|
|
|
(while (and (= n 0)
|
|
|
|
|
(looking-at "\\s-*\\($\\|\\s<\\)"))
|
|
|
|
|
(setq n (forward-line inc)))
|
|
|
|
|
(setq arg (- arg inc)))
|
|
|
|
|
n))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(defun octave-previous-code-line (&optional arg)
|
|
|
|
|
"Move ARG lines of Octave code backward (forward if ARG is negative).
|
|
|
|
|
Skips past all empty and comment lines. Default for ARG is 1.
|
|
|
|
|
|
|
|
|
|
On success, return 0. Otherwise, go as far as possible and return -1."
|
|
|
|
|
(interactive "p")
|
|
|
|
|
(or arg (setq arg 1))
|
|
|
|
|
(octave-next-code-line (- arg)))
|
|
|
|
|
|
|
|
|
|
(defun octave-beginning-of-line ()
|
|
|
|
|
"Move point to beginning of current Octave line.
|
|
|
|
|
If on an empty or comment line, go to the beginning of that line.
|
|
|
|
|
Otherwise, move backward to the beginning of the first Octave code line
|
|
|
|
|
which is not inside a continuation statement, i.e., which does not
|
|
|
|
|
follow a code line ending in `...' or `\\', or is inside an open
|
|
|
|
|
parenthesis list."
|
|
|
|
|
(interactive)
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(if (not (looking-at "\\s-*\\($\\|\\s<\\)"))
|
|
|
|
|
(while (or (condition-case nil
|
|
|
|
|
(progn
|
|
|
|
|
(up-list -1)
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
t)
|
|
|
|
|
(error nil))
|
|
|
|
|
(and (or (looking-at "\\s-*\\($\\|\\s<\\)")
|
|
|
|
|
(save-excursion
|
|
|
|
|
(if (zerop (octave-previous-code-line))
|
|
|
|
|
(looking-at octave-continuation-regexp))))
|
|
|
|
|
(zerop (forward-line -1)))))))
|
|
|
|
|
|
|
|
|
|
(defun octave-end-of-line ()
|
|
|
|
|
"Move point to end of current Octave line.
|
|
|
|
|
If on an empty or comment line, go to the end of that line.
|
|
|
|
|
Otherwise, move forward to the end of the first Octave code line which
|
|
|
|
|
does not end in `...' or `\\' or is inside an open parenthesis list."
|
|
|
|
|
(interactive)
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(if (save-excursion
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(looking-at "\\s-*\\($\\|\\s<\\)"))
|
|
|
|
|
()
|
|
|
|
|
(while (or (condition-case nil
|
|
|
|
|
(progn
|
|
|
|
|
(up-list 1)
|
|
|
|
|
(end-of-line)
|
|
|
|
|
t)
|
|
|
|
|
(error nil))
|
|
|
|
|
(and (save-excursion
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(or (looking-at "\\s-*\\($\\|\\s<\\)")
|
|
|
|
|
(looking-at octave-continuation-regexp)))
|
|
|
|
|
(zerop (forward-line 1)))))
|
|
|
|
|
(end-of-line)))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(defun octave-mark-block ()
|
|
|
|
|
"Put point at the beginning of this Octave block, mark at the end.
|
|
|
|
|
The block marked is the one that contains point or follows point."
|
|
|
|
|
(interactive)
|
Remove old indentation and navigation code on octave-mode.
* lisp/progmodes/octave-mod.el (octave-mode-map): Remap down-list to
smie-down-list rather than add a binding for octave-down-block.
(octave-mark-block, octave-blink-matching-block-open):
Rely on forward-sexp-function.
(octave-fill-paragraph): Don't narrow, so you can use
indent-according-to-mode.
(octave-block-begin-regexp, octave-block-begin-or-end-regexp): Remove.
(octave-in-block-p, octave-re-search-forward-kw)
(octave-re-search-backward-kw, octave-indent-calculate)
(octave-end-as-array-index-p, octave-block-end-offset)
(octave-scan-blocks, octave-forward-block, octave-backward-block)
(octave-down-block, octave-backward-up-block, octave-up-block)
(octave-before-magic-comment-p, octave-indent-line): Remove.
2010-08-31 14:13:51 +02:00
|
|
|
|
(unless (or (looking-at "\\s(")
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let* ((token (funcall smie-forward-token-function))
|
2010-11-10 00:21:06 -08:00
|
|
|
|
(level (assoc token smie-grammar)))
|
Remove old indentation and navigation code on octave-mode.
* lisp/progmodes/octave-mod.el (octave-mode-map): Remap down-list to
smie-down-list rather than add a binding for octave-down-block.
(octave-mark-block, octave-blink-matching-block-open):
Rely on forward-sexp-function.
(octave-fill-paragraph): Don't narrow, so you can use
indent-according-to-mode.
(octave-block-begin-regexp, octave-block-begin-or-end-regexp): Remove.
(octave-in-block-p, octave-re-search-forward-kw)
(octave-re-search-backward-kw, octave-indent-calculate)
(octave-end-as-array-index-p, octave-block-end-offset)
(octave-scan-blocks, octave-forward-block, octave-backward-block)
(octave-down-block, octave-backward-up-block, octave-up-block)
(octave-before-magic-comment-p, octave-indent-line): Remove.
2010-08-31 14:13:51 +02:00
|
|
|
|
(and level (null (cadr level))))))
|
|
|
|
|
(backward-up-list 1))
|
|
|
|
|
(mark-sexp))
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
|
|
|
|
(defun octave-beginning-of-defun (&optional arg)
|
|
|
|
|
"Move backward to the beginning of an Octave function.
|
|
|
|
|
With positive ARG, do it that many times. Negative argument -N means
|
|
|
|
|
move forward to Nth following beginning of a function.
|
|
|
|
|
Returns t unless search stops at the beginning or end of the buffer."
|
|
|
|
|
(let* ((arg (or arg 1))
|
|
|
|
|
(inc (if (> arg 0) 1 -1))
|
2010-08-17 17:49:30 +02:00
|
|
|
|
(found nil)
|
|
|
|
|
(case-fold-search nil))
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(and (not (eobp))
|
2010-08-17 17:49:30 +02:00
|
|
|
|
(not (and (> arg 0) (looking-at "\\<function\\>")))
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(skip-syntax-forward "w"))
|
|
|
|
|
(while (and (/= arg 0)
|
|
|
|
|
(setq found
|
2010-08-17 17:49:30 +02:00
|
|
|
|
(re-search-backward "\\<function\\>" inc)))
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(if (octave-not-in-string-or-comment-p)
|
|
|
|
|
(setq arg (- arg inc))))
|
|
|
|
|
(if found
|
|
|
|
|
(progn
|
|
|
|
|
(and (< inc 0) (goto-char (match-beginning 0)))
|
|
|
|
|
t))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Filling
|
|
|
|
|
(defun octave-auto-fill ()
|
1997-10-24 20:11:44 +00:00
|
|
|
|
"Perform auto-fill in Octave mode.
|
|
|
|
|
Returns nil if no feasible place to break the line could be found, and t
|
|
|
|
|
otherwise."
|
|
|
|
|
(let (fc give-up)
|
|
|
|
|
(if (or (null (setq fc (current-fill-column)))
|
|
|
|
|
(save-excursion
|
2003-02-04 13:24:35 +00:00
|
|
|
|
(beginning-of-line)
|
1997-10-24 20:11:44 +00:00
|
|
|
|
(and auto-fill-inhibit-regexp
|
2007-10-13 20:01:54 +00:00
|
|
|
|
(octave-looking-at-kw auto-fill-inhibit-regexp))))
|
1997-10-24 20:11:44 +00:00
|
|
|
|
nil ; Can't do anything
|
|
|
|
|
(if (and (not (octave-in-comment-p))
|
|
|
|
|
(> (current-column) fc))
|
|
|
|
|
(setq fc (- fc (+ (length octave-continuation-string) 1))))
|
|
|
|
|
(while (and (not give-up) (> (current-column) fc))
|
|
|
|
|
(let* ((opoint (point))
|
|
|
|
|
(fpoint
|
|
|
|
|
(save-excursion
|
|
|
|
|
(move-to-column (+ fc 1))
|
|
|
|
|
(skip-chars-backward "^ \t\n")
|
|
|
|
|
;; If we're at the beginning of the line, break after
|
|
|
|
|
;; the first word
|
|
|
|
|
(if (bolp)
|
|
|
|
|
(re-search-forward "[ \t]" opoint t))
|
|
|
|
|
;; If we're in a comment line, don't break after the
|
|
|
|
|
;; comment chars
|
|
|
|
|
(if (save-excursion
|
|
|
|
|
(skip-syntax-backward " <")
|
|
|
|
|
(bolp))
|
2003-10-24 18:58:28 +00:00
|
|
|
|
(re-search-forward "[ \t]" (line-end-position)
|
1997-10-24 20:11:44 +00:00
|
|
|
|
'move))
|
|
|
|
|
;; If we're not in a comment line and just ahead the
|
|
|
|
|
;; continuation string, don't break here.
|
|
|
|
|
(if (and (not (octave-in-comment-p))
|
|
|
|
|
(looking-at
|
|
|
|
|
(concat "\\s-*"
|
|
|
|
|
(regexp-quote
|
|
|
|
|
octave-continuation-string)
|
|
|
|
|
"\\s-*$")))
|
|
|
|
|
(end-of-line))
|
|
|
|
|
(skip-chars-backward " \t")
|
|
|
|
|
(point))))
|
|
|
|
|
(if (save-excursion
|
|
|
|
|
(goto-char fpoint)
|
|
|
|
|
(not (or (bolp) (eolp))))
|
|
|
|
|
(let ((prev-column (current-column)))
|
|
|
|
|
(if (save-excursion
|
|
|
|
|
(skip-chars-backward " \t")
|
|
|
|
|
(= (point) fpoint))
|
|
|
|
|
(progn
|
|
|
|
|
(octave-maybe-insert-continuation-string)
|
|
|
|
|
(indent-new-comment-line t))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char fpoint)
|
|
|
|
|
(octave-maybe-insert-continuation-string)
|
|
|
|
|
(indent-new-comment-line t)))
|
|
|
|
|
(if (>= (current-column) prev-column)
|
|
|
|
|
(setq give-up t)))
|
|
|
|
|
(setq give-up t))))
|
|
|
|
|
(not give-up))))
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
|
|
|
|
(defun octave-fill-paragraph (&optional arg)
|
Remove old indentation and navigation code on octave-mode.
* lisp/progmodes/octave-mod.el (octave-mode-map): Remap down-list to
smie-down-list rather than add a binding for octave-down-block.
(octave-mark-block, octave-blink-matching-block-open):
Rely on forward-sexp-function.
(octave-fill-paragraph): Don't narrow, so you can use
indent-according-to-mode.
(octave-block-begin-regexp, octave-block-begin-or-end-regexp): Remove.
(octave-in-block-p, octave-re-search-forward-kw)
(octave-re-search-backward-kw, octave-indent-calculate)
(octave-end-as-array-index-p, octave-block-end-offset)
(octave-scan-blocks, octave-forward-block, octave-backward-block)
(octave-down-block, octave-backward-up-block, octave-up-block)
(octave-before-magic-comment-p, octave-indent-line): Remove.
2010-08-31 14:13:51 +02:00
|
|
|
|
"Fill paragraph of Octave code, handling Octave comments."
|
|
|
|
|
;; FIXME: difference with generic fill-paragraph:
|
|
|
|
|
;; - code lines are only split, never joined.
|
|
|
|
|
;; - \n that end comments are never removed.
|
|
|
|
|
;; - insert continuation marker when splitting code lines.
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((end (progn (forward-paragraph) (copy-marker (point) t)))
|
|
|
|
|
(beg (progn
|
|
|
|
|
(forward-paragraph -1)
|
|
|
|
|
(skip-chars-forward " \t\n")
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(point)))
|
|
|
|
|
(cfc (current-fill-column))
|
|
|
|
|
comment-prefix)
|
|
|
|
|
(goto-char beg)
|
|
|
|
|
(while (< (point) end)
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(indent-according-to-mode)
|
|
|
|
|
(error nil))
|
|
|
|
|
(move-to-column cfc)
|
|
|
|
|
;; First check whether we need to combine non-empty comment lines
|
|
|
|
|
(if (and (< (current-column) cfc)
|
|
|
|
|
(octave-in-comment-p)
|
|
|
|
|
(not (save-excursion
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(looking-at "^\\s-*\\s<+\\s-*$"))))
|
|
|
|
|
;; This is a nonempty comment line which does not extend
|
|
|
|
|
;; past the fill column. If it is followed by a nonempty
|
|
|
|
|
;; comment line with the same comment prefix, try to
|
|
|
|
|
;; combine them, and repeat this until either we reach the
|
|
|
|
|
;; fill-column or there is nothing more to combine.
|
|
|
|
|
(progn
|
|
|
|
|
;; Get the comment prefix
|
|
|
|
|
(save-excursion
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(while (and (re-search-forward "\\s<+")
|
|
|
|
|
(not (octave-in-comment-p))))
|
|
|
|
|
(setq comment-prefix (match-string 0)))
|
|
|
|
|
;; And keep combining ...
|
|
|
|
|
(while (and (< (current-column) cfc)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(forward-line 1)
|
|
|
|
|
(and (looking-at
|
|
|
|
|
(concat "^\\s-*"
|
|
|
|
|
comment-prefix
|
|
|
|
|
"\\S<"))
|
|
|
|
|
(not (looking-at
|
|
|
|
|
(concat "^\\s-*"
|
|
|
|
|
comment-prefix
|
|
|
|
|
"\\s-*$"))))))
|
|
|
|
|
(delete-char 1)
|
|
|
|
|
(re-search-forward comment-prefix)
|
|
|
|
|
(delete-region (match-beginning 0) (match-end 0))
|
|
|
|
|
(fixup-whitespace)
|
|
|
|
|
(move-to-column cfc))))
|
|
|
|
|
;; We might also try to combine continued code lines> Perhaps
|
|
|
|
|
;; some other time ...
|
|
|
|
|
(skip-chars-forward "^ \t\n")
|
|
|
|
|
(delete-horizontal-space)
|
|
|
|
|
(if (or (< (current-column) cfc)
|
|
|
|
|
(and (= (current-column) cfc) (eolp)))
|
|
|
|
|
(forward-line 1)
|
|
|
|
|
(if (not (eolp)) (insert " "))
|
|
|
|
|
(or (octave-auto-fill)
|
|
|
|
|
(forward-line 1))))
|
|
|
|
|
t)))
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Completions
|
|
|
|
|
(defun octave-initialize-completions ()
|
|
|
|
|
"Create an alist for Octave completions."
|
|
|
|
|
(if octave-completion-alist
|
|
|
|
|
()
|
|
|
|
|
(setq octave-completion-alist
|
2010-08-12 13:22:16 +02:00
|
|
|
|
(append octave-reserved-words
|
|
|
|
|
octave-text-functions
|
|
|
|
|
octave-variables))))
|
|
|
|
|
|
|
|
|
|
(defun octave-completion-at-point-function ()
|
|
|
|
|
"Find the text to complete and the corresponding table."
|
2010-08-12 14:46:24 +02:00
|
|
|
|
(let* ((beg (save-excursion (backward-sexp 1) (point)))
|
2010-08-17 17:49:30 +02:00
|
|
|
|
(end (point)))
|
|
|
|
|
(if (< beg (point))
|
|
|
|
|
;; Extend region past point, if applicable.
|
|
|
|
|
(save-excursion (goto-char beg) (forward-sexp 1)
|
|
|
|
|
(setq end (max end (point)))))
|
2010-08-12 13:22:16 +02:00
|
|
|
|
(list beg end octave-completion-alist)))
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
|
|
|
|
(defun octave-complete-symbol ()
|
|
|
|
|
"Perform completion on Octave symbol preceding point.
|
|
|
|
|
Compare that symbol against Octave's reserved words and builtin
|
|
|
|
|
variables."
|
|
|
|
|
(interactive)
|
2010-08-12 13:22:16 +02:00
|
|
|
|
(apply 'completion-in-region (octave-completion-at-point-function)))
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
|
|
|
|
;;; Electric characters && friends
|
|
|
|
|
|
|
|
|
|
(defun octave-abbrev-start ()
|
|
|
|
|
"Start entering an Octave abbreviation.
|
|
|
|
|
If Abbrev mode is turned on, typing ` (grave accent) followed by ? or
|
|
|
|
|
\\[help-command] lists all Octave abbrevs. Any other key combination is
|
|
|
|
|
executed normally.
|
|
|
|
|
Note that all Octave mode abbrevs start with a grave accent."
|
|
|
|
|
(interactive)
|
|
|
|
|
(if (not abbrev-mode)
|
|
|
|
|
(self-insert-command 1)
|
|
|
|
|
(let (c)
|
2009-01-09 04:23:38 +00:00
|
|
|
|
(insert last-command-event)
|
* emulation/edt-mapper.el (function-key-map):
(edt-map-key): Make it a function instead of using fset. Inline
edt-gnu-map-key and edt-lucid-map-key. Use featurep 'xemacs.
(edt-gnu-map-key, edt-lucid-map-key): Remove.
(edt-x-emacs-p): Remove.
(edt-emacs-variant, edt-window-system, edt-xserver):
Use featurep 'xemacs.
* net/eudc.el: Use (featurep 'xemacs) instead of the string test.
Replace eudc-xemacs-p with its definition.
(eudc-xemacs-p, eudc-emacs-p, eudc-xemacs-mule-p)
(eudc-emacs-mule-p): Remove.
(eudc-install-menu, eudc-mode): Replace eudc-emacs-p and
eudc-xemacs-p with feature tests.
* net/eudc-bob.el (eudc-bob-generic-menu, eudc-bob-mail-keymap)
(eudc-bob-url-keymap, eudc-bob-sound-keymap)
(eudc-bob-generic-keymap, eudc-bob-popup-menu)
(eudc-bob-toggle-inline-display):
* net/eudc-hotlist.el (eudc-hotlist-emacs-menu): Replace
eudc-emacs-p and eudc-xemacs-p with feature tests.
* net/eudcb-ph.el (eudc-ph-open-session): Replace
eudc-xemacs-mule-p with its former definition.
* progmodes/octave-mod.el (octave-xemacs-p): Remove.
(octave-abbrev-start): Replace octave-xemacs-p with
(featurep 'xemacs).
* progmodes/vera-mode.el (vera-xemacs): Remove.
(vera-mode-syntax-table): Replace vera-xemacs with
(featurep 'xemacs).
* progmodes/vhdl-mode.el (vhdl-xemacs): Remove.
(vhdl-doc-mode, vhdl-doc-variable, vhdl-compile-init)
(vhdl-speedbar-initialize, vhdl-ps-print-init)
(vhdl-forward-comment, vhdl-mode-map-init, vhdl-show-messages)
(vhdl-emacs-22, vhdl-emacs-21): Replace vhdl-xemacs
with (featurep 'xemacs).
* progmodes/antlr-mode.el (cond-emacs-xemacs-macfn, defunx)
(save-buffer-state-x):
* obsolete/fast-lock.el (fast-lock-verbose):
* emulation/viper-init.el (viper-xemacs-p)
(viper-cond-compile-for-xemacs-or-emacs):
* emacs-lisp/checkdoc.el (checkdoc-minor-mode-map):
* ps-print.el (case-fold-search):
* ediff-hook.el (ediff-cond-compile-for-xemacs-or-emacs):
* calculator.el (calculator-help): Use featurep 'xemacs.
2007-10-21 17:22:04 +00:00
|
|
|
|
(if (if (featurep 'xemacs)
|
1998-12-10 03:15:25 +00:00
|
|
|
|
(or (eq (event-to-character (setq c (next-event))) ??)
|
|
|
|
|
(eq (event-to-character c) help-char))
|
|
|
|
|
(or (eq (setq c (read-event)) ??)
|
|
|
|
|
(eq c help-char)))
|
|
|
|
|
(let ((abbrev-table-name-list '(octave-abbrev-table)))
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(list-abbrevs))
|
|
|
|
|
(setq unread-command-events (list c))))))
|
|
|
|
|
|
2010-08-12 13:22:16 +02:00
|
|
|
|
(define-skeleton octave-insert-defun
|
1997-01-21 00:29:57 +00:00
|
|
|
|
"Insert an Octave function skeleton.
|
|
|
|
|
Prompt for the function's name, arguments and return values (to be
|
|
|
|
|
entered without parens)."
|
2010-08-12 13:22:16 +02:00
|
|
|
|
(let* ((defname (substring (buffer-name) 0 -2))
|
|
|
|
|
(name (read-string (format "Function name (default %s): " defname)
|
|
|
|
|
nil nil defname))
|
|
|
|
|
(args (read-string "Arguments: "))
|
|
|
|
|
(vals (read-string "Return values: ")))
|
|
|
|
|
(format "%s%s (%s)"
|
|
|
|
|
(cond
|
|
|
|
|
((string-equal vals "") vals)
|
|
|
|
|
((string-match "[ ,]" vals) (concat "[" vals "] = "))
|
|
|
|
|
(t (concat vals " = ")))
|
|
|
|
|
name
|
|
|
|
|
args))
|
|
|
|
|
\n "function " > str \n \n
|
|
|
|
|
octave-block-comment-start "usage: " str \n
|
|
|
|
|
octave-block-comment-start \n octave-block-comment-start
|
|
|
|
|
\n _ \n
|
|
|
|
|
"endfunction" > \n)
|
1997-01-21 00:29:57 +00:00
|
|
|
|
|
|
|
|
|
;;; Communication with the inferior Octave process
|
|
|
|
|
(defun octave-kill-process ()
|
|
|
|
|
"Kill inferior Octave process and its buffer."
|
|
|
|
|
(interactive)
|
|
|
|
|
(if inferior-octave-process
|
|
|
|
|
(progn
|
|
|
|
|
(process-send-string inferior-octave-process "quit;\n")
|
|
|
|
|
(accept-process-output inferior-octave-process)))
|
|
|
|
|
(if inferior-octave-buffer
|
|
|
|
|
(kill-buffer inferior-octave-buffer)))
|
|
|
|
|
|
|
|
|
|
(defun octave-show-process-buffer ()
|
|
|
|
|
"Make sure that `inferior-octave-buffer' is displayed."
|
|
|
|
|
(interactive)
|
|
|
|
|
(if (get-buffer inferior-octave-buffer)
|
|
|
|
|
(display-buffer inferior-octave-buffer)
|
|
|
|
|
(message "No buffer named %s" inferior-octave-buffer)))
|
|
|
|
|
|
|
|
|
|
(defun octave-hide-process-buffer ()
|
|
|
|
|
"Delete all windows that display `inferior-octave-buffer'."
|
|
|
|
|
(interactive)
|
|
|
|
|
(if (get-buffer inferior-octave-buffer)
|
|
|
|
|
(delete-windows-on inferior-octave-buffer)
|
|
|
|
|
(message "No buffer named %s" inferior-octave-buffer)))
|
|
|
|
|
|
|
|
|
|
(defun octave-send-region (beg end)
|
|
|
|
|
"Send current region to the inferior Octave process."
|
|
|
|
|
(interactive "r")
|
2003-02-04 13:24:35 +00:00
|
|
|
|
(inferior-octave t)
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(let ((proc inferior-octave-process)
|
|
|
|
|
(string (buffer-substring-no-properties beg end))
|
|
|
|
|
line)
|
2008-04-30 08:48:02 +00:00
|
|
|
|
(with-current-buffer inferior-octave-buffer
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(setq inferior-octave-output-list nil)
|
|
|
|
|
(while (not (string-equal string ""))
|
|
|
|
|
(if (string-match "\n" string)
|
|
|
|
|
(setq line (substring string 0 (match-beginning 0))
|
|
|
|
|
string (substring string (match-end 0)))
|
|
|
|
|
(setq line string string ""))
|
|
|
|
|
(setq inferior-octave-receive-in-progress t)
|
|
|
|
|
(inferior-octave-send-list-and-digest (list (concat line "\n")))
|
|
|
|
|
(while inferior-octave-receive-in-progress
|
|
|
|
|
(accept-process-output proc))
|
|
|
|
|
(insert-before-markers
|
|
|
|
|
(mapconcat 'identity
|
|
|
|
|
(append
|
|
|
|
|
(if octave-send-echo-input (list line) (list ""))
|
|
|
|
|
(mapcar 'inferior-octave-strip-ctrl-g
|
|
|
|
|
inferior-octave-output-list)
|
|
|
|
|
(list inferior-octave-output-string))
|
|
|
|
|
"\n")))))
|
|
|
|
|
(if octave-send-show-buffer
|
|
|
|
|
(display-buffer inferior-octave-buffer)))
|
|
|
|
|
|
|
|
|
|
(defun octave-send-block ()
|
2003-02-04 13:24:35 +00:00
|
|
|
|
"Send current Octave block to the inferior Octave process."
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(octave-mark-block)
|
|
|
|
|
(octave-send-region (point) (mark))))
|
|
|
|
|
|
|
|
|
|
(defun octave-send-defun ()
|
|
|
|
|
"Send current Octave function to the inferior Octave process."
|
|
|
|
|
(interactive)
|
|
|
|
|
(save-excursion
|
2010-08-17 17:49:30 +02:00
|
|
|
|
(mark-defun)
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(octave-send-region (point) (mark))))
|
|
|
|
|
|
|
|
|
|
(defun octave-send-line (&optional arg)
|
|
|
|
|
"Send current Octave code line to the inferior Octave process.
|
|
|
|
|
With positive prefix ARG, send that many lines.
|
|
|
|
|
If `octave-send-line-auto-forward' is non-nil, go to the next unsent
|
|
|
|
|
code line."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(or arg (setq arg 1))
|
|
|
|
|
(if (> arg 0)
|
|
|
|
|
(let (beg end)
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(setq beg (point))
|
|
|
|
|
(octave-next-code-line (- arg 1))
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(setq end (point))
|
|
|
|
|
(if octave-send-line-auto-forward
|
|
|
|
|
(octave-next-code-line 1))
|
|
|
|
|
(octave-send-region beg end))))
|
|
|
|
|
|
|
|
|
|
(defun octave-eval-print-last-sexp ()
|
|
|
|
|
"Evaluate Octave sexp before point and print value into current buffer."
|
|
|
|
|
(interactive)
|
|
|
|
|
(inferior-octave t)
|
|
|
|
|
(let ((standard-output (current-buffer))
|
|
|
|
|
(print-escape-newlines nil)
|
|
|
|
|
(opoint (point)))
|
|
|
|
|
(terpri)
|
2003-02-04 13:24:35 +00:00
|
|
|
|
(prin1
|
1997-01-21 00:29:57 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(forward-sexp -1)
|
|
|
|
|
(inferior-octave-send-list-and-digest
|
|
|
|
|
(list (concat (buffer-substring-no-properties (point) opoint)
|
|
|
|
|
"\n")))
|
|
|
|
|
(mapconcat 'identity inferior-octave-output-list "\n")))
|
|
|
|
|
(terpri)))
|
1997-01-21 00:40:19 +00:00
|
|
|
|
|
|
|
|
|
;;; Bug reporting
|
|
|
|
|
(defun octave-submit-bug-report ()
|
|
|
|
|
"Submit a bug report on the Emacs Octave package via mail."
|
|
|
|
|
(interactive)
|
|
|
|
|
(require 'reporter)
|
|
|
|
|
(and
|
|
|
|
|
(y-or-n-p "Do you want to submit a bug report? ")
|
|
|
|
|
(reporter-submit-bug-report
|
|
|
|
|
octave-maintainer-address
|
|
|
|
|
(concat "Emacs version " emacs-version)
|
|
|
|
|
(list
|
|
|
|
|
'octave-blink-matching-block
|
|
|
|
|
'octave-block-offset
|
|
|
|
|
'octave-comment-char
|
|
|
|
|
'octave-continuation-offset
|
|
|
|
|
'octave-continuation-string
|
|
|
|
|
'octave-send-echo-input
|
|
|
|
|
'octave-send-line-auto-forward
|
|
|
|
|
'octave-send-show-buffer))))
|
|
|
|
|
|
2008-04-30 08:48:02 +00:00
|
|
|
|
;; provide ourself
|
1997-01-21 00:40:19 +00:00
|
|
|
|
|
1997-01-21 04:43:45 +00:00
|
|
|
|
(provide 'octave-mod)
|
1997-01-21 00:40:19 +00:00
|
|
|
|
|
|
|
|
|
;;; octave-mod.el ends here
|