GNU bug report logs - #14300
24.3; comint-dynamic-complete-functions breaks

Previous Next

Package: emacs;

Reported by: Leo Liu <sdl.web <at> gmail.com>

Date: Mon, 29 Apr 2013 06:46:01 UTC

Severity: normal

Found in version 24.3

Done: Leo Liu <sdl.web <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14300 in the body.
You can then email your comments to 14300 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#14300; Package emacs. (Mon, 29 Apr 2013 06:46:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Leo Liu <sdl.web <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 29 Apr 2013 06:46:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3; comint-dynamic-complete-functions breaks
Date: Mon, 29 Apr 2013 14:39:10 +0800
This looks like a regression to me.

The semantics of comint-dynamic-complete-functions has changed between
emacs-24 and previous releases.

Previously entries are tried one after another to perform completion
i.e. actually perform the completion.

With the new semantics it only does the first one because it will always
(99% cases) succeed (getting the completion-table nearly always
succeeds).

This is unfortunate because a lot of modes rely on the previous
behaviour to provide rich completions for comint based modes.

I noticed this bug because file completion no longer works in
octave-mode.

Leo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14300; Package emacs. (Sat, 04 May 2013 20:10:02 GMT) Full text and rfc822 format available.

Message #8 received at 14300 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: 14300 <at> debbugs.gnu.org
Subject: Re: bug#14300: 24.3; comint-dynamic-complete-functions breaks
Date: Sat, 04 May 2013 16:08:40 -0400
> The semantics of comint-dynamic-complete-functions has changed between
> emacs-24 and previous releases.

Indeed.

> With the new semantics it only does the first one because it will always
> (99% cases) succeed (getting the completion-table nearly always
> succeeds).

Then the code needs to be fixed not to succeed when point is somewhere
where that completion doesn't apply.

> This is unfortunate because a lot of modes rely on the previous
> behaviour to provide rich completions for comint based modes.

But that ad-hoc way to combine completions had many downsides (e.g. you
can't tell when to hide the *Completions* buffer, you can't provide
completion-help-at-point, and it interacts poorly with sophisticated
completion-styles).

> I noticed this bug because file completion no longer works in
> octave-mode.

Let's try to focus on this, then.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14300; Package emacs. (Sun, 05 May 2013 01:57:02 GMT) Full text and rfc822 format available.

Message #11 received at 14300 <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 14300 <at> debbugs.gnu.org
Subject: Re: bug#14300: 24.3; comint-dynamic-complete-functions breaks
Date: Sun, 05 May 2013 09:55:41 +0800
On 2013-05-05 04:08 +0800, Stefan Monnier wrote:
>> I noticed this bug because file completion no longer works in
>> octave-mode.
>
> Let's try to focus on this, then.

Let's see if we can fix this just for octave.

How can I differentiate between an octave function completion from a
file completion if they don't have different delimiters?

Leo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14300; Package emacs. (Sun, 05 May 2013 06:40:02 GMT) Full text and rfc822 format available.

Message #14 received at 14300 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: 14300 <at> debbugs.gnu.org
Subject: Re: bug#14300: 24.3; comint-dynamic-complete-functions breaks
Date: Sun, 05 May 2013 02:39:02 -0400
> How can I differentiate between an octave function completion from a
> file completion if they don't have different delimiters?

Good question.  Can file names really occur at the same places as
function names in Octave?


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14300; Package emacs. (Sun, 05 May 2013 07:04:02 GMT) Full text and rfc822 format available.

Message #17 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#14300: 24.3; comint-dynamic-complete-functions breaks
Date: Sun, 05 May 2013 15:02:49 +0800
On 2013-05-05 14:39 +0800, Stefan Monnier wrote:
> Good question.  Can file names really occur at the same places as
> function names in Octave?

F("arg1", "arg2", ...) can be written as F arg1 arg2 ... in octave. For
example 'help sin' and 'cd /usr'.

So there is no clear way to detect whether a position is file-completion
or function-completion given the fact that user can define a function
that does do both in the same position.

Leo





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14300; Package emacs. (Mon, 06 May 2013 02:40:02 GMT) Full text and rfc822 format available.

Message #20 received at 14300 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: 14300 <at> debbugs.gnu.org
Subject: Re: bug#14300: 24.3; comint-dynamic-complete-functions breaks
Date: Sun, 05 May 2013 22:38:34 -0400
>> Good question.  Can file names really occur at the same places as
>> function names in Octave?
> F("arg1", "arg2", ...) can be written as F arg1 arg2 ... in octave. For
> example 'help sin' and 'cd /usr'.

> So there is no clear way to detect whether a position is file-completion
> or function-completion given the fact that user can define a function
> that does do both in the same position.

While there are cases where there is ambiguity, there are many where the
ambiguity can be lifted:

You could prevent function completion within a string, so file name
completion still won't work after 'cd /u' but it will after 'cd "/u'.
Similarly you might disable function completion if the "current function
name" includes a / (assuming real functions don't include a slash in
their name).

In the worst case, you might want to use ":exclusive t", tho it means that
function completion won't be able to benefit from fancier completion styles.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14300; Package emacs. (Mon, 06 May 2013 03:42:02 GMT) Full text and rfc822 format available.

Message #23 received at 14300 <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 14300 <at> debbugs.gnu.org
Subject: Re: bug#14300: 24.3; comint-dynamic-complete-functions breaks
Date: Mon, 06 May 2013 11:40:35 +0800
On 2013-05-06 10:38 +0800, Stefan Monnier wrote:
> While there are cases where there is ambiguity, there are many where the
> ambiguity can be lifted:
>
> You could prevent function completion within a string, so file name
> completion still won't work after 'cd /u' but it will after 'cd "/u'.
> Similarly you might disable function completion if the "current function
> name" includes a / (assuming real functions don't include a slash in
> their name).
>
> In the worst case, you might want to use ":exclusive t", tho it means that
> function completion won't be able to benefit from fancier completion styles.

It would be nice if there is a way I can provide completion-at-point
with two tables and it will just try them one after another if the
preceding table has no match.

In most cases path starts with no leading / and function completion
needs to work well in strings too due to its inline functions:

   f = inline("sin(x)^2 + 2");

Octave's syntax is eccentric.

A 80% solution might be to special-case 'cd', 'rmdir', 'source',
'unlink' etc.

Leo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14300; Package emacs. (Mon, 06 May 2013 13:35:10 GMT) Full text and rfc822 format available.

Message #26 received at 14300 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: 14300 <at> debbugs.gnu.org
Subject: Re: bug#14300: 24.3; comint-dynamic-complete-functions breaks
Date: Mon, 06 May 2013 09:32:59 -0400
> It would be nice if there is a way I can provide completion-at-point
> with two tables and it will just try them one after another if the
> preceding table has no match.

That's what ":exclusive t" does.  Of course "no match" is tricky to
define: if you use a fancy completion style that tries really hard to
find a match (ido-flex style, maybe even with "typo-correction"), then
only trying the second table when "there's no match" for the first one
might end up meaning that it never tries the second one.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14300; Package emacs. (Tue, 07 May 2013 08:20:01 GMT) Full text and rfc822 format available.

Message #29 received at 14300 <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 14300 <at> debbugs.gnu.org
Subject: Re: bug#14300: 24.3; comint-dynamic-complete-functions breaks
Date: Tue, 07 May 2013 16:18:15 +0800
On 2013-05-06 21:32 +0800, Stefan Monnier wrote:
> That's what ":exclusive t" does.  Of course "no match" is tricky to
> define: if you use a fancy completion style that tries really hard to
> find a match (ido-flex style, maybe even with "typo-correction"), then
> only trying the second table when "there's no match" for the first one
> might end up meaning that it never tries the second one.

I got a solution that seems good enough. Do you see any room for
improvement? Thanks.


diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el
index 138c1948..3118f49e 100644
--- a/lisp/progmodes/octave.el
+++ b/lisp/progmodes/octave.el
@@ -741,13 +741,19 @@ (defun inferior-octave-completion-table ()
 
 (defun inferior-octave-completion-at-point ()
   "Return the data to complete the Octave symbol at point."
-  (let* ((end (point))
+  ;; http://debbugs.gnu.org/14300
+  (let* ((filecomp (string-match-p
+                    "/" (or (comint--match-partial-filename) "")))
+         (end (point))
 	 (start
-	  (save-excursion
-	    (skip-syntax-backward "w_" (comint-line-beginning-position))
-            (point))))
-    (when (> end start)
-      (list start end (inferior-octave-completion-table)))))
+	  (unless filecomp
+            (save-excursion
+              (skip-syntax-backward "w_" (comint-line-beginning-position))
+              (point)))))
+    (when (and start (> end start))
+      (list start end (completion-table-in-turn
+                       (inferior-octave-completion-table)
+                       'comint-completion-file-name-table)))))
 
 (define-obsolete-function-alias 'inferior-octave-complete
   'completion-at-point "24.1")




Reply sent to Leo Liu <sdl.web <at> gmail.com>:
You have taken responsibility. (Fri, 10 May 2013 01:22:02 GMT) Full text and rfc822 format available.

Notification sent to Leo Liu <sdl.web <at> gmail.com>:
bug acknowledged by developer. (Fri, 10 May 2013 01:22:02 GMT) Full text and rfc822 format available.

Message #34 received at 14300-done <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: 14300-done <at> debbugs.gnu.org
Subject: Re: bug#14300: 24.3; comint-dynamic-complete-functions breaks
Date: Fri, 10 May 2013 09:21:21 +0800
Fix in trunk for octave mode instead.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 07 Jun 2013 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 202 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.