Hi Jonathan,

I happened to have MATLAB 18a installed and was able to test using matlab.el, and matlab-shell.el from git, but could not replicate a completion problem.  Sorry. Is it special to the "EEG" data structure, or does this occur everywhere?

You had some other questions too.

Matlab mode does support CEDET, but you do not need to use CEDET in order to use matlab mode.  MATLAB mode without support packages supports a  bunch of different completion features, but most are pretty simple.  If you enable CEDET with the data base and have matlab-shell running, it will try to use the shell to find files on your path, but it doesn't use the shell for completions.  That code is pretty old and I don't think those bits were every plugged together.

I did a little hacking and put together the attached patch that enables completion via MATLAB shell in MATLAB buffers.  It is rather primitive as it only does global symbols and knows nothing about the local context, but perhaps it can serve as inspiration for putting something more complete together.

Lastly, in a MATLAB buffer, you can type:

M-x matlab-shell-describe-command RET

on a symbol and it should do vaguely what you were asking for below.

Eric

On 11/25/20 11:41 AM, Jonathan Sahar wrote:
Hi Eric, thanks for your reply!

I'm running version  '9.4.0.949201 (R2018a) Update 6'.
I've installed matlab-mode through Doom emacs' (package! ...) directive, but I've looked at the changelog locally and on sourceforge, and the latest commit is the same one...

Best,
Jonathan




On Wed, 25 Nov 2020 at 18:03, Eric Ludlam <ericlud...@gmail.com <mailto:ericlud...@gmail.com>> wrote:

    Hi Jonathan,

    As new version of MATLAB come out, the text that comes out for
    errors,
    completions, and all sorts of things change which can break the shell.

    What version of MATLAB are you using, and which version of the matlab
    mode code are you using?

    We made a bunch of updates last winter to ML shell which you can get
    from the git repository:

    https://sourceforge.net/p/matlab-emacs/src/ci/master/tree/

    There are also a few extra fixes on the 'usage1' branch which haven't
    been merged into the main branch yet.

    That all said, I don't recall big changes needed for completion
    lately. :(

    Eric


    On 11/18/20 10:03 AM, Jonathan Sahar wrote:
    >
    > I've been working with matlab-mode and matlab-shell for the last
    few
    > days, and I'm really digging it so far. The only two things I can't
    > get to work properly are completion - neither in shell, nor in .m
    > files - and jumping to function definitions, and I would really
    > appreciate some help with these. when I hit TAB in shell, my text
    > turns into
    >
    > |>> emacsdocomplete('EEG.(cond') |
    >
    > and when I hit RETURN I get (the appropriate):
    >
    > |emacs_completions_output = java.lang.String[]: 'cond' 'condeig' |
    >
    > but it's not integrated into the shell properly, i.e. I can't
    choose
    > which of the above I want, I have to re-type the command along with
    > the chosen completion. In .m files I just get nothing except for
    the
    > word completion for words already in the buffer - which I've
    > configured myself.
    >
    > I've read somewhere that the completion is meant to be related to
    > CEDET somehow but I couldn't make out much more (I'm working on
    Doom
    > Emacs, and I seen to have CEDET installed, and can run
    > matlab-cedet-setup, which does nothing as far as I can tell).
    >
    > As to function definitions - I don't even know where to start..
    I've
    > read that ctags now supports matlab, but I don't know where (if)
    the
    > actual .m files for the built-in functions reside in the install
    dir.
    >
    > Ideally I'd love to be able to stand on a function name and be
    able to
    > get the "help funcName" output in another buffer or something (this
    > works from the shell).
    >
    > Thanks a lot!
    >


diff --git a/matlab-complete.el b/matlab-complete.el
index b3a6290..8ad5345 100644
--- a/matlab-complete.el
+++ b/matlab-complete.el
@@ -1,6 +1,6 @@
 ;;; matlab-complete.el --- Simple completion tool for matlab-mode
 ;;
-;; Copyright (C) 2019 Eric Ludlam
+;; Copyright (C) 2019, 2020 Eric Ludlam
 ;;
 ;; Author: Eric Ludlam <za...@gnu.org>
 ;;
@@ -397,6 +397,29 @@ The last type of semantic used while completing things.")
 
 ;;;###autoload
 (defun matlab-complete-symbol (&optional arg)
+  "Complete a partially typed symbol in a MATLAB mode buffer."
+  (interactive "P")
+  (if (and (matlab-shell-active-p) matlab-shell-ask-MATLAB-for-completions)
+      ;; Try to do completion with the shell
+      (matlab-navigation-syntax
+	(let* ((common-substr-start-pt nil)
+	       (common-substr-end-pt nil)
+	       (prefix (if (and (not (eq last-command 'matlab-complete-symbol))
+				(member (preceding-char) '(?  ?\t ?\n ?, ?\( ?\[ ?\')))
+			   ""
+			 (buffer-substring-no-properties
+			  (save-excursion (forward-word -1) (setq common-substr-start-pt (point)))
+			  (setq common-substr-end-pt (point)))))
+	       (completion-info (matlab-shell-completion-list prefix))
+               (completions (cdr (assoc 'completions completion-info)))
+	       )
+	  (completion-in-region common-substr-start-pt common-substr-end-pt completions)
+	  ))
+    ;; Else, do the antique version.
+    (matlab-complete-symbol-local arg)
+    ))
+
+(defun matlab-complete-symbol-local (&optional arg)
   "Complete a partially typed symbol in a MATLAB mode buffer.
 If the previously entered command was also `matlab-complete-symbol'
 then undo the last completion, and find a new one.
_______________________________________________
Matlab-emacs-discuss mailing list
Matlab-emacs-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matlab-emacs-discuss

Reply via email to