Hi,

Here's the patch files, sorry I didn't know what the usual format was. You
should just be able to pipe them into 'patch'.

-Nate

On Fri, Nov 3, 2017 at 10:41 AM Eric Ludlam <eric.lud...@mathworks.com>
wrote:

> Hi Nate,
>
>
>
> Could your provide a diff that provides context (a context diff) ?  It
> isn’t clear how to merge the patch into code where the line numbers may
> have changed.  Ideally, the diff could be intput into the ‘patch’ command.
>
>
>
> Thanks
>
> Eric
>
>
>
> *From:* nchodosh [mailto:nchod...@andrew.cmu.edu]
> *Sent:* Tuesday, October 17, 2017 11:44 AM
>
>
> *To:* Eric Ludlam <eric.lud...@mathworks.com>;
> matlab-emacs-discuss@lists.sourceforge.net
> *Subject:* Re: [Matlab-emacs-discuss] Removing extra lines from
> collect-command-output
>
>
>
> Hi,
>
>
>
> Sorry about the delay, I had a busy few weeks. Here's the diff for
> matlab.el, I also included one for company-matlab-shell.el which enables
> predictions while editing the middle of a line.
>
>
>
> Best,
>
> Nate
>
>
>
> On Tue, Oct 3, 2017 at 3:24 PM Eric Ludlam <eric.lud...@mathworks.com>
> wrote:
>
> Ah, this is a good reminder I need to poke the source forge site to point
> at the new github location that Uwe is using.
>
>
>
> Start with the mailing list.  I’m not sure what process would work best
> for Uwe.
>
>
>
> Eric
>
>
>
> *From:* Nathaniel Chodosh [mailto:nchod...@andrew.cmu.edu]
>
> *Sent:* Tuesday, October 03, 2017 1:18 PM
>
>
> *To:* Eric Ludlam <eric.lud...@mathworks.com>;
> matlab-emacs-discuss@lists.sourceforge.net
> *Subject:* Re: [Matlab-emacs-discuss] Removing extra lines from
> collect-command-output
>
>
>
> Great. I've never contributed to a sourceforge project, should I post the
> diff under patches?
>
>
>
> On Tue, Oct 3, 2017 at 12:59 PM Eric Ludlam <eric.lud...@mathworks.com>
> wrote:
>
> Sounds reasonable to me.
>
>
>
> When you are happy with your changes, post a diff and hopefully Uwe can
> install it.
>
>
>
> Thanks
>
> Eric
>
>
>
> *From:* Nathaniel Chodosh [mailto:nchod...@andrew.cmu.edu]
>
> *Sent:* Tuesday, October 03, 2017 12:26 PM
> *To:* Eric Ludlam <eric.lud...@mathworks.com>;
> matlab-emacs-discuss@lists.sourceforge.net
> *Subject:* Re: [Matlab-emacs-discuss] Removing extra lines from
> collect-command-output
>
>
>
> That's what I thought the purpose of the newline is, but the documentation
> for comint-simple-send states that it automatically appends a newline to
> the command, so it's not needed.
>
> As an aside I think that in the current version of emacs the while loop in
> the same function needs to be wrapped in a with-local-quit to avoid raising
> an error (or at least the accept-process-output call does).
>
> Best,
>
> Nate
>
>
>
> On Mon, Oct 2, 2017 at 4:14 PM Eric Ludlam <eric.lud...@mathworks.com>
> wrote:
>
> I wrote that a long time ago, but my vague recollection is that the
> newline was needed to make the subprocess execute the command.  Is it
> adding a 2nd newline to the end of ‘command’ resulting in the spare line?
>
>
>
> Eric
>
>
>
> *From:* Nathaniel Chodosh [mailto:nchod...@andrew.cmu.edu]
> *Sent:* Monday, October 02, 2017 1:27 PM
> *To:* matlab-emacs-discuss@lists.sourceforge.net
> *Subject:* [Matlab-emacs-discuss] Removing extra lines from
> collect-command-output
>
>
>
> Hello,
>
> I've noticed that calling 'matlab-shell-collect-command-output' can result
> in extra new lines being sent to the *MATLAB* buffer which aren't deleted.
> When using company-mode to complete text this behavior is pretty annoying
> since as I'm typing lines are being inserted above the prompt. I believe
> that the cause of this is the line:
> (comint-simple-send (get-buffer-process (current-buffer))
>
>               (concat command "\n"))
>
> The newline added to the end of the command causes an extra line to be
> printed since it's interpreted as execute 'command' and then send a
> newline. Removing the newline fixes the problem.
>
> This seems like a suspiciously simple fix so I'm wondering why the newline
> was being appended to the command.
>
> Thanks,
>
> Nate
>
> P.S I am new to using mailing lists so if I've committed any faux pas in
> this email please let me know
>
>
--- matlab.el	2017-11-08 12:51:31.383623975 -0500
+++ matlab-new.el	2017-10-17 11:34:44.739044723 -0400
@@ -71,7 +71,7 @@
       (defalias 'matlab-cancel-timer 'delete-itimer)
       (defun matlab-run-with-idle-timer (secs repeat function &rest args)
 	(condition-case nil
-	    (apply 'start-itimer
+:	    (apply 'start-itimer
 		   "matlab" function secs
 		   (if repeat secs nil) t
 		   t (car args))
@@ -5412,15 +5412,14 @@
       ;; We are done error checking, run the command.
       (setq pos (point))
       (comint-simple-send (get-buffer-process (current-buffer))
-			  (concat command "\n"))
+			  command)
       ;;(message "MATLAB ... Executing command.")
       (goto-char (point-max))
-      (while (or (>= (+ pos (string-width command)) (point)) (not (matlab-on-empty-prompt-p)))
-	(accept-process-output (get-buffer-process (current-buffer)))
-	(goto-char (point-max))
-	;;(message "MATLAB reading...")
-	)
-      ;;(message "MATLAB reading...done")
+      (with-local-quit
+       (while (or (>= (+ pos (string-width command)) (point))
+		  (not (matlab-on-empty-prompt-p)))
+	 (accept-process-output (get-buffer-process (current-buffer)))
+	 (goto-char (point-max))))
       (save-excursion
 	(goto-char pos)
 	(beginning-of-line)
--- company-matlab-shell.el	2017-11-08 12:51:36.875700408 -0500
+++ company-matlab-shell-new.el	2017-10-12 14:48:42.414467116 -0400
@@ -24,51 +24,56 @@
 ;; the following code is mostly taken from matlab.el, (C) Eric M. Ludlam
 (defun company-matlab-shell-tab ()
    "Send [TAB] to the currently running matlab process and retrieve completion."
-   (goto-char (point-max))
-   (let ((inhibit-field-text-motion t))
-     (beginning-of-line))
-   (re-search-forward comint-prompt-regexp)
-   (let* ((lastcmd (buffer-substring (point) (matlab-point-at-eol)))
-	  (tempcmd lastcmd)
-	  (completions nil)
-	  (limitpos nil))
-     ;; search for character which limits completion, and limit command to it
-     (setq limitpos
-	   (if (string-match ".*\\([( /[,;=']\\)" lastcmd)
-	       (1+ (match-beginning 1))
-	     0))
-     (setq lastcmd (substring lastcmd limitpos))
-     ;; Whack the old command so we can insert it back later.
-     (delete-region (+ (point) limitpos) (matlab-point-at-eol))
-     ;; double every single quote
-     (while (string-match "[^']\\('\\)\\($\\|[^']\\)" tempcmd)
-       (setq tempcmd (replace-match "''" t t tempcmd 1)))
-     ;; collect the list
-     (setq completions (matlab-shell-completion-list tempcmd))
+   (let ((orig-point (point)))
      (goto-char (point-max))
-     (insert lastcmd)
-     completions))
+     (let ((inhibit-field-text-motion t))
+       (beginning-of-line))
+     (re-search-forward comint-prompt-regexp)
+     
+     (let* ((lastcmd (buffer-substring-no-properties (point) orig-point))
+	    (eol-offset (if (> orig-point (point))
+			    (- orig-point (point-max))
+			  0))
+	    (tempcmd lastcmd)
+	    (completions nil)
+	    (limitpos nil))
+       ;; search for character which limits completion, and limit command to it
+       (setq limitpos
+	     (if (string-match ".*\\([( /[,;=']\\)" lastcmd)
+		 (1+ (match-beginning 1))
+	       0))
+       (setq lastcmd (substring lastcmd limitpos))
+       ;; double every single quote
+       (while (string-match "[^']\\('\\)\\($\\|[^']\\)" tempcmd)
+	 (setq tempcmd (replace-match "\"" t t tempcmd 1)))
+       ;; collect the list
+       (setq completions (matlab-shell-completion-list tempcmd))
+       (goto-char (+ (point-max) eol-offset))
+       completions)))
 
 (defun company-matlab-shell-grab-symbol ()
   (when (string= (buffer-name (current-buffer)) (concat "*" matlab-shell-buffer-name "*"))
     (save-excursion
-      (goto-char (point-max))
-      (let ((inhibit-field-text-motion t))
-	(beginning-of-line))
-      (re-search-forward comint-prompt-regexp)
-      (let* ((lastcmd (buffer-substring (point) (matlab-point-at-eol)))
-	     limitpos)
-	(setq limitpos
-	      (if (string-match ".*\\([( /[,;=']\\)" lastcmd)
-		  (1+ (match-beginning 1))
-		0))
-	(substring-no-properties lastcmd limitpos)))))
+      (let ((orig-point (point))) 
+	(goto-char (point-max))
+	(let ((inhibit-field-text-motion t))
+	  (beginning-of-line))
+	(re-search-forward comint-prompt-regexp)
+	(when (>= orig-point (point))
+	 (let* ((lastcmd (buffer-substring (point) orig-point))
+		limitpos)
+	   (setq limitpos
+		 (if (string-match ".*\\([( /[,;=']\\)" lastcmd)
+		     (1+ (match-beginning 1))
+		   0))
+	   (substring-no-properties lastcmd limitpos)))))))
 
 
 (defun company-matlab-shell-get-completions ()
   (when (string= (buffer-name (current-buffer)) (concat "*" matlab-shell-buffer-name "*"))
     (mapcar 'car (company-matlab-shell-tab))))
 
+
 ;;;###autoload
 (defun company-matlab-shell (command &optional arg &rest ignored)
   "A `company-mode' completion back-end for Matlab-Shell."
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Matlab-emacs-discuss mailing list
Matlab-emacs-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matlab-emacs-discuss

Reply via email to