unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* pcomplete makes assumptions about its interactive entry points
@ 2013-09-05 16:17 Vivek Dasmohapatra
  2013-09-13  1:44 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Vivek Dasmohapatra @ 2013-09-05 16:17 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 481 bytes --]

Forwarded at author's request

---------- Forwarded message ----------
Date: Tue, 3 Sep 2013 01:35:06 +0100 (BST)
From: Vivek Dasmohapatra <vivek@etla.org>
To: John Wiegley <johnw@gnu.org>
Subject: pcomplete

Hi - pcomplete makes an assumption (I think) about the interactive
entry point(s) which can be used to drive it which means that non-
native entry points don't get completion cycling.

Attached is a possible fix plus the alteration required
to make erc completion use it.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: TEXT/X-DIFF; NAME=pcomplete-entry-points.patch, Size: 2136 bytes --]

diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 01efd83..3917638 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -3964,7 +3964,9 @@ This places `point' just after the prompt, or at the beginning of the line."
     (kill-line)))
 
 (defun erc-complete-word-at-point ()
-  (run-hook-with-args-until-success 'erc-complete-functions))
+  (let ((pcomplete-extra-entry-points
+	 (cons 'completion-at-point pcomplete-extra-entry-points)))
+  (run-hook-with-args-until-success 'erc-complete-functions)))
 
 (define-obsolete-function-alias 'erc-complete-word 'completion-at-point "24.1")
 
diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el
index 957505f..30a743b 100644
--- a/lisp/pcomplete.el
+++ b/lisp/pcomplete.el
@@ -471,6 +471,15 @@ Same as `pcomplete' but using the standard completion UI."
                           (plist-get :predicate (nthcdr 3 data)))))
 
 ;;; Pcomplete's native UI.
+(defvar pcomplete-extra-entry-points nil
+  "When an non-native command is driving `pcomplete', that command's
+symbol must be placed in this variable while `pcomplete' is invoked
+in order to allow completion cycling to occur.\n
+For example:\n
+  When completing ab → aba abc abd able via `completion-at-point',\n
+which [may] delegate to `pcomplete' via `completion-at-point-functions',
+the functions in that list should bind this variable to include the
+symbol 'completion-at-point.")
 
 ;;;###autoload
 (defun pcomplete (&optional interactively)
@@ -481,9 +490,10 @@ completion functions list (it should occur fairly early in the list)."
   (if (and interactively
 	   pcomplete-cycle-completions
 	   pcomplete-current-completions
-	   (memq last-command '(pcomplete
-				pcomplete-expand-and-complete
-				pcomplete-reverse)))
+           (or (memq last-command '(pcomplete
+                                    pcomplete-expand-and-complete
+                                    pcomplete-reverse))
+               (memq last-command pcomplete-extra-entry-points)))
       (progn
 	(delete-char (- pcomplete-last-completion-length))
 	(if (eq this-command 'pcomplete-reverse)

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

* Re: pcomplete makes assumptions about its interactive entry points
  2013-09-05 16:17 pcomplete makes assumptions about its interactive entry points Vivek Dasmohapatra
@ 2013-09-13  1:44 ` Stefan Monnier
  2013-09-13  1:52   ` Vivek Dasmohapatra
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2013-09-13  1:44 UTC (permalink / raw)
  To: Vivek Dasmohapatra; +Cc: emacs-devel

> Hi - pcomplete makes an assumption (I think) about the interactive
> entry point(s) which can be used to drive it which means that non-
> native entry points don't get completion cycling.

> Attached is a possible fix plus the alteration required
> to make erc completion use it.

Could you explain in which circumstance this is needed?


        Stefan


PS: And could you make a bug report about it, so we can track it better,
rather than discussing it on emacs-devel?



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

* Re: pcomplete makes assumptions about its interactive entry points
  2013-09-13  1:44 ` Stefan Monnier
@ 2013-09-13  1:52   ` Vivek Dasmohapatra
  0 siblings, 0 replies; 3+ messages in thread
From: Vivek Dasmohapatra @ 2013-09-13  1:52 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On Thu, 12 Sep 2013, Stefan Monnier wrote:

>> Hi - pcomplete makes an assumption (I think) about the interactive
>> entry point(s) which can be used to drive it which means that non-
>> native entry points don't get completion cycling.
>
>> Attached is a possible fix plus the alteration required
>> to make erc completion use it.
>
> Could you explain in which circumstance this is needed?

In an erc buffer, I tried to tab-complete a nick: The initial tab completion
showed many possibilities - I typed an extra character, which should have
limited it to a small enough number for tab-completion-cycling to kick in...
but instead TAB just unconditionally completed to the first of the remaining
candidates, and never offered me the chance to pick any of the others.

It turns out that pcomplete assumes that the interactive entry point
(activating command) can only ever be one of a handful of commands,
and specifically checks for those when deciding whether to enter the
code path that starts cycling through the remaining completions.

So modes that use pcomplete but define their own commands for tab 
completion lose the ability to use pcomplete cycling unless they have
a way of adding themselves to the list of entry points that pcomplete
knows about.




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

end of thread, other threads:[~2013-09-13  1:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-05 16:17 pcomplete makes assumptions about its interactive entry points Vivek Dasmohapatra
2013-09-13  1:44 ` Stefan Monnier
2013-09-13  1:52   ` Vivek Dasmohapatra

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