unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#14300: 24.3; comint-dynamic-complete-functions breaks
@ 2013-04-29  6:39 Leo Liu
  2013-05-04 20:08 ` Stefan Monnier
  0 siblings, 1 reply; 10+ messages in thread
From: Leo Liu @ 2013-04-29  6:39 UTC (permalink / raw)
  To: 14300

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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#14300: 24.3; comint-dynamic-complete-functions breaks
  2013-04-29  6:39 bug#14300: 24.3; comint-dynamic-complete-functions breaks Leo Liu
@ 2013-05-04 20:08 ` Stefan Monnier
  2013-05-05  1:55   ` Leo Liu
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2013-05-04 20:08 UTC (permalink / raw)
  To: Leo Liu; +Cc: 14300

> 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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#14300: 24.3; comint-dynamic-complete-functions breaks
  2013-05-04 20:08 ` Stefan Monnier
@ 2013-05-05  1:55   ` Leo Liu
  2013-05-05  6:39     ` Stefan Monnier
  0 siblings, 1 reply; 10+ messages in thread
From: Leo Liu @ 2013-05-05  1:55 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 14300

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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#14300: 24.3; comint-dynamic-complete-functions breaks
  2013-05-05  1:55   ` Leo Liu
@ 2013-05-05  6:39     ` Stefan Monnier
  2013-05-05  7:02       ` Leo Liu
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2013-05-05  6:39 UTC (permalink / raw)
  To: Leo Liu; +Cc: 14300

> 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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#14300: 24.3; comint-dynamic-complete-functions breaks
  2013-05-05  6:39     ` Stefan Monnier
@ 2013-05-05  7:02       ` Leo Liu
  2013-05-06  2:38         ` Stefan Monnier
  0 siblings, 1 reply; 10+ messages in thread
From: Leo Liu @ 2013-05-05  7:02 UTC (permalink / raw)
  To: 14300

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






^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#14300: 24.3; comint-dynamic-complete-functions breaks
  2013-05-05  7:02       ` Leo Liu
@ 2013-05-06  2:38         ` Stefan Monnier
  2013-05-06  3:40           ` Leo Liu
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2013-05-06  2:38 UTC (permalink / raw)
  To: Leo Liu; +Cc: 14300

>> 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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#14300: 24.3; comint-dynamic-complete-functions breaks
  2013-05-06  2:38         ` Stefan Monnier
@ 2013-05-06  3:40           ` Leo Liu
  2013-05-06 13:32             ` Stefan Monnier
  0 siblings, 1 reply; 10+ messages in thread
From: Leo Liu @ 2013-05-06  3:40 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 14300

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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#14300: 24.3; comint-dynamic-complete-functions breaks
  2013-05-06  3:40           ` Leo Liu
@ 2013-05-06 13:32             ` Stefan Monnier
  2013-05-07  8:18               ` Leo Liu
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2013-05-06 13:32 UTC (permalink / raw)
  To: Leo Liu; +Cc: 14300

> 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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#14300: 24.3; comint-dynamic-complete-functions breaks
  2013-05-06 13:32             ` Stefan Monnier
@ 2013-05-07  8:18               ` Leo Liu
  2013-05-10  1:21                 ` Leo Liu
  0 siblings, 1 reply; 10+ messages in thread
From: Leo Liu @ 2013-05-07  8:18 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 14300

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")





^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#14300: 24.3; comint-dynamic-complete-functions breaks
  2013-05-07  8:18               ` Leo Liu
@ 2013-05-10  1:21                 ` Leo Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Leo Liu @ 2013-05-10  1:21 UTC (permalink / raw)
  To: 14300-done

Fix in trunk for octave mode instead.





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-05-10  1:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-29  6:39 bug#14300: 24.3; comint-dynamic-complete-functions breaks Leo Liu
2013-05-04 20:08 ` Stefan Monnier
2013-05-05  1:55   ` Leo Liu
2013-05-05  6:39     ` Stefan Monnier
2013-05-05  7:02       ` Leo Liu
2013-05-06  2:38         ` Stefan Monnier
2013-05-06  3:40           ` Leo Liu
2013-05-06 13:32             ` Stefan Monnier
2013-05-07  8:18               ` Leo Liu
2013-05-10  1:21                 ` Leo Liu

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).