branch: externals/matlab-mode commit 06b94e8cd578adcb53c68e15766dec88e95afb8f Author: John Ciolfi <john.ciolfi...@gmail.com> Commit: John Ciolfi <john.ciolfi...@gmail.com>
imenu: removed ellipsis handling for funtion return args The prior matlab-imenu-generic-expression looks correct, but causes Emacs 30.1 to hang, likely due to nested shy capture groups. Thus, removing '...' handling on return function args. This is an edge case for most and likely not noticed. See: https://github.com/mathworks/Emacs-MATLAB-Mode/issues/42 --- matlab.el | 44 ++++++++++++++++++--------- tests/metest-imenu-files/f0.m | 5 +++ tests/metest-imenu-files/f0_expected.txt | 3 +- tests/metest-imenu-files/foobar1.m | 17 +++++++++++ tests/metest-imenu-files/foobar1_expected.txt | 6 ++++ tests/metest-imenu-files/g0_expected.txt | 2 -- 6 files changed, 59 insertions(+), 18 deletions(-) diff --git a/matlab.el b/matlab.el index 3b73f54775..4a8f391714 100644 --- a/matlab.el +++ b/matlab.el @@ -408,10 +408,11 @@ This is used to generate and identify continuation lines." (defvar matlab--ellipsis-to-eol-re (concat "\\.\\.\\.[[:blank:]]*\\(?:%[^\r\n]*\\)?\r?\n") - "Regexp used to match either of the following including the newline + "Regexp used to match either of the following including the newline. +For example, the end-of-lines: ... ... % comment -") +are matched.") (defcustom matlab-fill-code nil "*If true, `auto-fill-mode' causes code lines to be automatically continued." @@ -1245,22 +1246,37 @@ This matcher will handle a range of variable features." "function\\>" ;; Optional return args, function ARGS = NAME. Capture the 'ARGS =' - (concat "\\(?:" - - ;; ARGS can span multiple lines - (concat "\\(?:" - ;; valid ARGS chars: "[" "]" variables "," space, tab - "[]\\[a-zA-Z0-9_,[:blank:]]*" - ;; Optional continue to next line "..." or "... % comment" - "\\(?:" matlab--ellipsis-to-eol-re "\\)?" - "\\)+") + ;; The following regexp is better for capturing 'ARGS ='. The regexp allows for any + ;; characters in the "% comments", however with Emacs 30.1, running: + ;; M-: (re-search-forward (cadar matlab-imenu-generic-expression) nil t) + ;; on this file with point at 0 + ;; function foo123567890123567890123567890123567890123567890(fh) + ;; end + ;; gives us a hang. If you shorten the function name, Emacs won't hang. + ;; + ;; (concat "\\(?:" + ;; ;; ARGS can span multiple lines + ;; (concat "\\(?:" + ;; ;; valid ARGS chars: "[" "]" variables "," space, tab + ;; "[]\\[a-zA-Z0-9_,[:blank:]]*" + ;; ;; Optional continue to next line "..." or "... % comment" + ;; "\\(?:" matlab--ellipsis-to-eol-re "\\)?" + ;; "\\)+") + ;; ;; ARGS must be preceeded by the assignment operator, "=" + ;; "[[:blank:]]*=" + ;; "\\)?") + + ;; Capture 'ARGS = ' using a less accurate regexp that doesn't handle ellipsis + ;; due to performance problems with the above. + (concat "\\(?:" + ;; valid ARGS chars: "[" "]" variables "," space, tab + "[]\\[a-zA-Z0-9_,[:blank:]]+" ;; ARGS must be preceeded by the assignment operator, "=" - "[[:blank:]]*=" - + "=" "\\)?") - ;; Optional space/tabs or '...' continuation + ;; Optional space/tabs, "...", or "... % comment" continuation (concat "\\(?:" "[[:blank:]]*" "\\(?:" matlab--ellipsis-to-eol-re "\\)?" diff --git a/tests/metest-imenu-files/f0.m b/tests/metest-imenu-files/f0.m index 4ec463e827..2bfff71f9c 100644 --- a/tests/metest-imenu-files/f0.m +++ b/tests/metest-imenu-files/f0.m @@ -5,6 +5,7 @@ function f0 [a, b] = f4(2); a = F6; f7; + foo123567890123567890123567890123567890123567890; end function... @@ -47,3 +48,7 @@ function... f7 disp('in f7') end + +function foo123567890123567890123567890123567890123567890 + disp('in foo123567890123567890123567890123567890123567890') +end diff --git a/tests/metest-imenu-files/f0_expected.txt b/tests/metest-imenu-files/f0_expected.txt index 00e0d2b5d5..f35cfaccdc 100644 --- a/tests/metest-imenu-files/f0_expected.txt +++ b/tests/metest-imenu-files/f0_expected.txt @@ -1,8 +1,7 @@ f0 -f1 f2 f3 -f4 f5 F6 f7 +foo123567890123567890123567890123567890123567890 diff --git a/tests/metest-imenu-files/foobar1.m b/tests/metest-imenu-files/foobar1.m new file mode 100644 index 0000000000..659a9ad6b0 --- /dev/null +++ b/tests/metest-imenu-files/foobar1.m @@ -0,0 +1,17 @@ +function foobar1(a, b, c) +end + +function foobar2(a, b, c) +end + +function gen_pulse_avg_lin_data(a, b, c) +end + +function gen_pulse_avg_log_data(a, b, c) +end + +function gen_beamsharpened_data(a, b, c) +end + +function foobar3(a, b, c) +end diff --git a/tests/metest-imenu-files/foobar1_expected.txt b/tests/metest-imenu-files/foobar1_expected.txt new file mode 100644 index 0000000000..abe7c30ebb --- /dev/null +++ b/tests/metest-imenu-files/foobar1_expected.txt @@ -0,0 +1,6 @@ +foobar1 +foobar2 +gen_pulse_avg_lin_data +gen_pulse_avg_log_data +gen_beamsharpened_data +foobar3 diff --git a/tests/metest-imenu-files/g0_expected.txt b/tests/metest-imenu-files/g0_expected.txt index 2b9d3637b6..df8fd65723 100644 --- a/tests/metest-imenu-files/g0_expected.txt +++ b/tests/metest-imenu-files/g0_expected.txt @@ -1,6 +1,4 @@ g0 -g1 g2 g3 -g4 g5