diff options
author | Mauro Aranda <maurooaranda@gmail.com> | 2019-08-06 12:45:28 -0300 |
---|---|---|
committer | Leo Liu <sdl.web@gmail.com> | 2019-08-08 23:26:00 +0800 |
commit | cb0403d7467502a1a9ef2699ccce826aac2ace7a (patch) | |
tree | 299dc08a9801e0de1c0704ec3748bee4eccda784 | |
parent | 691790b8ea5192395a2eeac0f89a2f41d74f2ddb (diff) | |
download | emacs-cb0403d7467502a1a9ef2699ccce826aac2ace7a.tar.gz |
Fix octave-mode ElDoc support
* lisp/progmodes/octave.el (octave-eldoc-function-signatures): Fix the
regexp used, so no match happens when there is no defined function FN.
Also, tweak the regexp to support GNU Octave 4.2.x and newer. (Bug#36459)
-rw-r--r-- | lisp/progmodes/octave.el | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index 6caf8d93d3f..76181892cdb 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el @@ -1591,8 +1591,23 @@ code line." (list (format "print_usage ('%s');\n" fn))) (let (result) (dolist (line inferior-octave-output-list) + ;; The help output has changed a few times in GNU Octave. + ;; Earlier versions output "usage: " before the function signature. + ;; After deprecating the usage function, and up until GNU Octave 4.0.3, + ;; the output looks like this: + ;; -- Mapping Function: abs (Z). + ;; After GNU Octave 4.2.0, the output is less verbose and it looks like + ;; this: + ;; -- abs (Z) + ;; The following regexp matches these three formats. + ;; The "usage: " alternative matches the symbol, because a call to + ;; print_usage with a non-existent function (e.g., print_usage ('A')) + ;; would output: + ;; error: print_usage: 'A' not found + ;; and we wouldn't like to match anything in this case. + ;; See bug #36459. (when (string-match - "\\s-*\\(?:--[^:]+\\|usage\\):\\s-*\\(.*\\)$" + "\\s-*\\(?:--[^:]+:\\|\\_<usage:\\|--\\)\\s-*\\(.*\\)$" line) (push (match-string 1 line) result))) (setq octave-eldoc-cache |