GNU bug report logs -
#6076
23.1.96; [PATCH] rcirc-complete for nicks and commands
Previous Next
Reported by: Leo <sdl.web <at> gmail.com>
Date: Sun, 2 May 2010 08:53:01 UTC
Severity: normal
Tags: patch
Found in version 23.1.96
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
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 6076 in the body.
You can then email your comments to 6076 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6076
; Package
emacs
.
(Sun, 02 May 2010 08:53:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Leo <sdl.web <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sun, 02 May 2010 08:53:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
The attached patch replaces rcirc-complete-nick with rcirc-complete that
completes both nicks and user commands. User command completion is only
done after '/'.
I have yet to find a reliable way to obtaining a list of commands
supported by an irc server. So in the end only the standard commands are
copied from RFCs. Let me know if there is a better solution.
[0001-New-command-rcirc-complete-that-completes-both-nicks.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
With best wishes,
Leo
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6076
; Package
emacs
.
(Sun, 02 May 2010 09:02:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 6076 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hello Ryan,
On 2010-05-02 09:49 +0100, Leo wrote:
> The attached patch replaces rcirc-complete-nick with rcirc-complete that
> completes both nicks and user commands. User command completion is only
> done after '/'.
>
> I have yet to find a reliable way to obtaining a list of commands
> supported by an irc server. So in the end only the standard commands are
> copied from RFCs. Let me know if there is a better solution.
>
> With best wishes,
> Leo
Please review the attached patch instead which fixed compiler warnings
in the previous patch.
Thanks.
Leo
[0001-New-command-rcirc-complete-that-completes-both-nicks.patch (text/x-patch, attachment)]
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6076
; Package
emacs
.
(Mon, 03 May 2010 16:38:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 6076 <at> debbugs.gnu.org (full text, mbox):
> The attached patch replaces rcirc-complete-nick with rcirc-complete that
> completes both nicks and user commands. User command completion is only
> done after '/'.
Please try and make it use completion-at-point-functions.
Stefan
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6076
; Package
emacs
.
(Mon, 03 May 2010 17:46:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 6076 <at> debbugs.gnu.org (full text, mbox):
On 2010-05-03 17:37 +0100, Stefan Monnier wrote:
>> The attached patch replaces rcirc-complete-nick with rcirc-complete that
>> completes both nicks and user commands. User command completion is only
>> done after '/'.
>
> Please try and make it use completion-at-point-functions.
>
I thought of this before making the patch.
rcirc has a very simple completion interface that doesn't get in the
way. It cycles through completions if any. No popup windows no
minibuffer messages etc. I have found that excellent for ircing. Do you
think we should force it into the completion at point framework?
>
> Stefan
Leo
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6076
; Package
emacs
.
(Tue, 04 May 2010 02:33:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 6076 <at> debbugs.gnu.org (full text, mbox):
>>> The attached patch replaces rcirc-complete-nick with rcirc-complete that
>>> completes both nicks and user commands. User command completion is only
>>> done after '/'.
>> Please try and make it use completion-at-point-functions.
> I thought of this before making the patch.
> rcirc has a very simple completion interface that doesn't get in the
> way. It cycles through completions if any. No popup windows no
> minibuffer messages etc. I have found that excellent for ircing.
> Do you think we should force it into the completion at
> point framework?
I guess the right solution is to improve completion-at-point so that it
can be told to use cycling (the functionality is already provided by the
minibuffer-force-complete command).
This relates to a larger question: how to provide "in-buffer" the
variety of completion commands seen in minibuffer completion.
I.e. minibuffer-completion-help, minibuffer-force-complete,
minibuffer-complete-word, icomplete-mode, ...
Stefan
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6076
; Package
emacs
.
(Tue, 04 May 2010 13:42:01 GMT)
Full text and
rfc822 format available.
Message #20 received at submit <at> debbugs.gnu.org (full text, mbox):
On 2010-05-02 10:01 +0100, Leo wrote:
> Please review the attached patch instead which fixed compiler warnings
> in the previous patch.
>
> Thanks.
> Leo
This patch make sures commands defined by rcirc are seen first before
server commands.
Leo
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index 2e5e7ac..9b58112 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -800,9 +800,9 @@ IRC command completion is performed only if '/' is the first input char."
(if (and (zerop rcirc-completion-start-offset)
(char-after rcirc-prompt-end-marker)
(= (char-after rcirc-prompt-end-marker) ?/))
- (sort (delete-dups (append rcirc-client-commands
- (copy-sequence rcirc-server-commands)))
- 'string-lessp)
+ (delete-dups
+ (append (sort (copy-sequence rcirc-client-commands) 'string-lessp)
+ (sort (copy-sequence rcirc-server-commands) 'string-lessp)))
(mapcar (lambda (x) (cons x nil))
(rcirc-channel-nicks (rcirc-buffer-process)
rcirc-target)))))))
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6076
; Package
emacs
.
(Tue, 04 May 2010 16:24:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 6076 <at> debbugs.gnu.org (full text, mbox):
>>> Please try and make it use completion-at-point-functions.
>> I thought of this before making the patch.
>
>> rcirc has a very simple completion interface that doesn't get in the
>> way. It cycles through completions if any. No popup windows no
>> minibuffer messages etc. I have found that excellent for ircing.
>> Do you think we should force it into the completion at
>> point framework?
>
> I guess the right solution is to improve completion-at-point so that it
> can be told to use cycling (the functionality is already provided by the
> minibuffer-force-complete command).
`flyspell-auto-correct-word' (bound to M-TAB) that cycles through
completions could use this as well.
> This relates to a larger question: how to provide "in-buffer" the
> variety of completion commands seen in minibuffer completion.
> I.e. minibuffer-completion-help, minibuffer-force-complete,
> minibuffer-complete-word, icomplete-mode, ...
Is the problem in the implementation of these commands or in choosing
key bindings for them available for "in-buffer" completion?
--
Juri Linkov
http://www.jurta.org/emacs/
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6076
; Package
emacs
.
(Tue, 04 May 2010 18:30:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 6076 <at> debbugs.gnu.org (full text, mbox):
>> I guess the right solution is to improve completion-at-point so that it
>> can be told to use cycling (the functionality is already provided by the
>> minibuffer-force-complete command).
> `flyspell-auto-correct-word' (bound to M-TAB) that cycles through
> completions could use this as well.
Even more so, yes, because the choice between completion and cycling
is not just a preference for this one.
>> This relates to a larger question: how to provide "in-buffer" the
>> variety of completion commands seen in minibuffer completion.
>> I.e. minibuffer-completion-help, minibuffer-force-complete,
>> minibuffer-complete-word, icomplete-mode, ...
> Is the problem in the implementation of these commands or in choosing
> key bindings for them available for "in-buffer" completion?
I'm not sure. We could try and provide key bindings for all those
commands, but that would seem close to impossible: we're talking about
keybindings that would mostly need to be very short (single-key) to be
worthwhile, and we really don't have that many single-key available.
So, I see it as an implementation problem where we want to make
in-buffer completion modal to some extent: when in-buffer completion is
started you'd be put into a new "mode" (kind of like isearch, I guess),
where new completion commands become available. The main problem is
how/when to leave this mode (it should be as seamless as possible).
Some other reason for such a change: we want to be able to run code when
completion is finished, e.g. to hide the *Completion* buffer.
Stefan
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6076
; Package
emacs
.
(Tue, 04 May 2010 20:15:02 GMT)
Full text and
rfc822 format available.
Message #29 received at 6076 <at> debbugs.gnu.org (full text, mbox):
> So, I see it as an implementation problem where we want to make
> in-buffer completion modal to some extent: when in-buffer completion is
> started you'd be put into a new "mode" (kind of like isearch, I guess),
> where new completion commands become available. The main problem is
> how/when to leave this mode (it should be as seamless as possible).
> Some other reason for such a change: we want to be able to run code when
> completion is finished, e.g. to hide the *Completion* buffer.
Isearch-like mode would be a good thing. Typing a key not bound
in its mode map will leave this mode and hide the *Completions* buffer.
Also like in isearch, typing M-e could activate the minibuffer with
the current completion string and provide normal UI for completion.
Leaving this minibuffer should copy the completion string from the
minibuffer to the original buffer.
--
Juri Linkov
http://www.jurta.org/emacs/
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6076
; Package
emacs
.
(Tue, 04 May 2010 21:20:03 GMT)
Full text and
rfc822 format available.
Message #32 received at 6076 <at> debbugs.gnu.org (full text, mbox):
> Isearch-like mode would be a good thing. Typing a key not bound
> in its mode map will leave this mode and hide the *Completions* buffer.
Right. But choosing which keys/events make it leave because we want it
to be very lightweight (i.e. we want to leave as soon as possible), but
we'd rather not leave when the user is still editing the completion.
So self-insert-command should not leave, but then SPC (and several
others likewise) probably should (even tho it's also
self-insert-command) and maybe DEL shouldn't either, but what about
C-f/C-b? I was thinking maybe we should decide it based on the position
of point (whether it's still inside the completion text or not).
Stefan
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6076
; Package
emacs
.
(Mon, 10 May 2010 19:18:02 GMT)
Full text and
rfc822 format available.
Message #35 received at 6076 <at> debbugs.gnu.org (full text, mbox):
>> Isearch-like mode would be a good thing. Typing a key not bound
>> in its mode map will leave this mode and hide the *Completions* buffer.
>
> Right. But choosing which keys/events make it leave because we want it
> to be very lightweight (i.e. we want to leave as soon as possible), but
> we'd rather not leave when the user is still editing the completion.
>
> So self-insert-command should not leave, but then SPC (and several
> others likewise) probably should (even tho it's also
> self-insert-command) and maybe DEL shouldn't either, but what about
> C-f/C-b? I was thinking maybe we should decide it based on the position
> of point (whether it's still inside the completion text or not).
This is something that in other programs is called "in-place editing".
Usually a field for editing is highlighted with a different background.
In terms of Emacs this could be called "in-place completion". For its
implementation the most suitable feature is the `field' property.
When completion is activated, a field could be created in the buffer
and removed when completion is finished. I suggest using the same
key to finish completion as in the minibuffer, i.e. RET.
--
Juri Linkov
http://www.jurta.org/emacs/
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6076
; Package
emacs
.
(Tue, 11 May 2010 01:15:02 GMT)
Full text and
rfc822 format available.
Message #38 received at 6076 <at> debbugs.gnu.org (full text, mbox):
> This is something that in other programs is called "in-place editing".
> Usually a field for editing is highlighted with a different background.
> In terms of Emacs this could be called "in-place completion". For its
> implementation the most suitable feature is the `field' property.
> When completion is activated, a field could be created in the buffer
> and removed when completion is finished. I suggest using the same
> key to finish completion as in the minibuffer, i.e. RET.
Yes, completion-in-region already places a field, so that's indeed part
of the plan, but I'd like it to be slightly more lightweight than what
you suggest: RET should not be required to leave completion.
Stefan
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6076
; Package
emacs
.
(Tue, 11 May 2010 16:55:02 GMT)
Full text and
rfc822 format available.
Message #41 received at 6076 <at> debbugs.gnu.org (full text, mbox):
> Yes, completion-in-region already places a field, so that's indeed part
> of the plan, but I'd like it to be slightly more lightweight than what
> you suggest: RET should not be required to leave completion.
Then maybe leave completion when the property `point-left' calls its hook
when leaving the field?
--
Juri Linkov
http://www.jurta.org/emacs/
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6076
; Package
emacs
.
(Tue, 11 May 2010 19:53:01 GMT)
Full text and
rfc822 format available.
Message #44 received at 6076 <at> debbugs.gnu.org (full text, mbox):
>> Yes, completion-in-region already places a field, so that's indeed part
>> of the plan, but I'd like it to be slightly more lightweight than what
>> you suggest: RET should not be required to leave completion.
> Then maybe leave completion when the property `point-left' calls its hook
> when leaving the field?
Yup, something like that (tho, with extra care since point-motion hooks
are evil).
Stefan
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6076
; Package
emacs
.
(Mon, 23 Aug 2010 10:36:02 GMT)
Full text and
rfc822 format available.
Message #47 received at 6076 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
I have regenerated the patch against emacs-23 branch with a small tweak
that is nick completion no longer inserts a space (same as in the
original completion) if it is in the middle of an input.
I wonder if it is possible to apply this patch first and then think
about using the new completion-in-region-functions. I think this is a
safer step. completion-in-region-functions can be problematic when more
than one mode customise it though I haven't looked into this in full.
But I currently have TeX and a minor mode uses
completion-in-region-functions and I have been surprised a few times.
[0001-New-command-rcirc-complete-6076.patch (text/x-diff, inline)]
From af9423a2d099f615a3ff45c0bfa67ae58856681d Mon Sep 17 00:00:00 2001
From: Leo <sdl.web <at> gmail.com>
Date: Mon, 23 Aug 2010 11:14:05 +0100
Subject: [PATCH] New command rcirc-complete (#6076)
which completes both nicks and irc commands.
---
lisp/net/rcirc.el | 100 +++++++++++++++++++++++++++++++++-------------------
1 files changed, 63 insertions(+), 37 deletions(-)
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index ec67c3e..373e1b3 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -771,42 +771,66 @@ If SILENT is non-nil, do not print the message in any irc buffer."
(setq rcirc-input-ring-index (1- rcirc-input-ring-index))
(insert (rcirc-prev-input-string -1))))
-(defvar rcirc-nick-completions nil)
-(defvar rcirc-nick-completion-start-offset nil)
-
-(defun rcirc-complete-nick ()
- "Cycle through nick completions from list of nicks in channel."
+(defvar rcirc-server-commands
+ '("/admin" "/away" "/connect" "/die" "/error" "/info"
+ "/invite" "/ison" "/join" "/kick" "/kill" "/links"
+ "/list" "/lusers" "/mode" "/motd" "/names" "/nick"
+ "/notice" "/oper" "/part" "/pass" "/ping" "/pong"
+ "/privmsg" "/quit" "/rehash" "/restart" "/service" "/servlist"
+ "/server" "/squery" "/squit" "/stats" "/summon" "/time"
+ "/topic" "/trace" "/user" "/userhost" "/users" "/version"
+ "/wallops" "/who" "/whois" "/whowas")
+ "A list of user commands by IRC server.
+The value defaults to RFCs 1459 and 2812.")
+
+;; /me and /ctcp are not defined by `defun-rcirc-command'.
+(defvar rcirc-client-commands '("/me" "/ctcp")
+ "A list of user commands defined by IRC client rcirc.
+The list is updated automatically by `defun-rcirc-command'.")
+
+(defvar rcirc-completions nil)
+(defvar rcirc-completion-start-offset nil)
+
+(defun rcirc-complete ()
+ "Cycle through completions from list of nicks in channel or IRC commands.
+IRC command completion is performed only if '/' is the first input char."
(interactive)
(if (eq last-command this-command)
- (setq rcirc-nick-completions
- (append (cdr rcirc-nick-completions)
- (list (car rcirc-nick-completions))))
- (setq rcirc-nick-completion-start-offset
- (- (save-excursion
- (if (re-search-backward " " rcirc-prompt-end-marker t)
- (1+ (point))
- rcirc-prompt-end-marker))
- rcirc-prompt-end-marker))
- (setq rcirc-nick-completions
- (let ((completion-ignore-case t))
- (all-completions
+ (setq rcirc-completions
+ (append (cdr rcirc-completions)
+ (list (car rcirc-completions))))
+ (setq rcirc-completion-start-offset
+ (- (save-excursion
+ (if (re-search-backward " " rcirc-prompt-end-marker t)
+ (1+ (point))
+ rcirc-prompt-end-marker))
+ rcirc-prompt-end-marker))
+ (let ((completion-ignore-case t))
+ (setq rcirc-completions
+ (all-completions
(buffer-substring
(+ rcirc-prompt-end-marker
- rcirc-nick-completion-start-offset)
+ rcirc-completion-start-offset)
(point))
- (mapcar (lambda (x) (cons x nil))
- (rcirc-channel-nicks (rcirc-buffer-process)
- rcirc-target))))))
- (let ((completion (car rcirc-nick-completions)))
+ (if (and (zerop rcirc-completion-start-offset)
+ (char-after rcirc-prompt-end-marker)
+ (= (char-after rcirc-prompt-end-marker) ?/))
+ (delete-dups
+ (append (sort (copy-sequence rcirc-client-commands) 'string-lessp)
+ (sort (copy-sequence rcirc-server-commands) 'string-lessp)))
+ (mapcar (lambda (x) (cons x nil))
+ (rcirc-channel-nicks (rcirc-buffer-process)
+ rcirc-target)))))))
+ (let ((completion (car rcirc-completions)))
(when completion
(delete-region (+ rcirc-prompt-end-marker
- rcirc-nick-completion-start-offset)
+ rcirc-completion-start-offset)
(point))
(insert (concat completion
- (if (= (+ rcirc-prompt-end-marker
- rcirc-nick-completion-start-offset)
- rcirc-prompt-end-marker)
- ": "))))))
+ (cond
+ ((= (aref completion 0) ?/) " ")
+ ((zerop rcirc-completion-start-offset) ": ")
+ (t "")))))))
(defun set-rcirc-decode-coding-system (coding-system)
"Set the decode coding system used in this channel."
@@ -824,7 +848,7 @@ If SILENT is non-nil, do not print the message in any irc buffer."
(define-key rcirc-mode-map (kbd "RET") 'rcirc-send-input)
(define-key rcirc-mode-map (kbd "M-p") 'rcirc-insert-prev-input)
(define-key rcirc-mode-map (kbd "M-n") 'rcirc-insert-next-input)
-(define-key rcirc-mode-map (kbd "TAB") 'rcirc-complete-nick)
+(define-key rcirc-mode-map (kbd "TAB") 'rcirc-complete)
(define-key rcirc-mode-map (kbd "C-c C-b") 'rcirc-browse-url)
(define-key rcirc-mode-map (kbd "C-c C-c") 'rcirc-edit-multiline)
(define-key rcirc-mode-map (kbd "C-c C-j") 'rcirc-cmd-join)
@@ -1962,16 +1986,18 @@ activity. Only run if the buffer is not visible and
;; containing the text following the /cmd.
(defmacro defun-rcirc-command (command argument docstring interactive-form
- &rest body)
+ &rest body)
"Define a command."
- `(defun ,(intern (concat "rcirc-cmd-" (symbol-name command)))
- (,@argument &optional process target)
- ,(concat docstring "\n\nNote: If PROCESS or TARGET are nil, the values given"
- "\nby `rcirc-buffer-process' and `rcirc-target' will be used.")
- ,interactive-form
- (let ((process (or process (rcirc-buffer-process)))
- (target (or target rcirc-target)))
- ,@body)))
+ `(progn
+ (add-to-list 'rcirc-client-commands ,(concat "/" (symbol-name command)))
+ (defun ,(intern (concat "rcirc-cmd-" (symbol-name command)))
+ (,@argument &optional process target)
+ ,(concat docstring "\n\nNote: If PROCESS or TARGET are nil, the values given"
+ "\nby `rcirc-buffer-process' and `rcirc-target' will be used.")
+ ,interactive-form
+ (let ((process (or process (rcirc-buffer-process)))
+ (target (or target rcirc-target)))
+ ,@body))))
(defun-rcirc-command msg (message)
"Send private MESSAGE to TARGET."
--
1.7.2
[Message part 3 (text/plain, inline)]
Leo
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6076
; Package
emacs
.
(Fri, 03 Sep 2010 22:12:02 GMT)
Full text and
rfc822 format available.
Message #50 received at 6076 <at> debbugs.gnu.org (full text, mbox):
I reviewed Leo's updated patch at http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6076#47
I agree with Leo, we should install this patch and then look into
improvements using completion in region.
Ryan
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6076
; Package
emacs
.
(Sat, 04 Sep 2010 08:24:02 GMT)
Full text and
rfc822 format available.
Message #53 received at 6076 <at> debbugs.gnu.org (full text, mbox):
> I reviewed Leo's updated patch at http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6076#47
> I agree with Leo, we should install this patch and then look into
> improvements using completion in region.
I mostly agree, but I think the patch should first be restructured into
one or 2 functions suitable for completion-at-point-functions
(i.e. either one that provides the completion data for nicks and
commands, or one for nicks and one for commands), and then an
rcirc-complete command that uses these functions to do the completion
with the desired UI.
I.e. basically a refactoring of rcirc-complete such that it uses the
same interface between the completion data and the completion UI as the
one used by completion-at-point.
Then users can choose to use rcirc-complete or completion-at-point, and
when/if completion-at-point (i.e. completion-in-region) gets to the
point of being able to provide the same behavior as rcirc-complete, then
we can get rid of rcirc-complete.
Stefan
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6076
; Package
emacs
.
(Sat, 04 Sep 2010 10:20:03 GMT)
Full text and
rfc822 format available.
Message #56 received at 6076 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 2010-09-04 09:24 +0100, Stefan Monnier wrote:
>> I reviewed Leo's updated patch at http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6076#47
>> I agree with Leo, we should install this patch and then look into
>> improvements using completion in region.
>
> I mostly agree, but I think the patch should first be restructured into
> one or 2 functions suitable for completion-at-point-functions
> (i.e. either one that provides the completion data for nicks and
> commands, or one for nicks and one for commands), and then an
> rcirc-complete command that uses these functions to do the completion
> with the desired UI.
>
> I.e. basically a refactoring of rcirc-complete such that it uses the
> same interface between the completion data and the completion UI as the
> one used by completion-at-point.
>
> Then users can choose to use rcirc-complete or completion-at-point, and
> when/if completion-at-point (i.e. completion-in-region) gets to the
> point of being able to provide the same behavior as rcirc-complete, then
> we can get rid of rcirc-complete.
>
>
> Stefan
Thanks, Stefan, for the comments.
I have recreated the patch against emacs-23 as suggested. I have also
briefly tested it. Seems to work as expected. M-TAB in rcirc-mode now
uses the new completion at point interface.
BTW, I just realise the macro defun-rcirc-command is better named
define-rcirc-command.
2010-09-04 Leo <sdl.web <at> gmail.com>
* net/rcirc.el (rcirc-server-commands, rcirc-client-commands)
(rcirc-completion-start): new variables.
(rcirc-nick-completions): rename to rcirc-completions.
(rcirc-nick-completion-start-offset): delete.
(rcirc-completion-at-point): new function for constructing
completion data for both nicks and irc commands. Add to
completion-at-point-functions in rcirc mode.
(rcirc-complete): use rcirc-completion-at-point.
(defun-rcirc-command): update rcirc-client-commands.
[rcirc-complete.diff (text/x-diff, inline)]
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index ec67c3e..cade679 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -771,42 +771,63 @@ If SILENT is non-nil, do not print the message in any irc buffer."
(setq rcirc-input-ring-index (1- rcirc-input-ring-index))
(insert (rcirc-prev-input-string -1))))
-(defvar rcirc-nick-completions nil)
-(defvar rcirc-nick-completion-start-offset nil)
-
-(defun rcirc-complete-nick ()
- "Cycle through nick completions from list of nicks in channel."
+(defvar rcirc-server-commands
+ '("/admin" "/away" "/connect" "/die" "/error" "/info"
+ "/invite" "/ison" "/join" "/kick" "/kill" "/links"
+ "/list" "/lusers" "/mode" "/motd" "/names" "/nick"
+ "/notice" "/oper" "/part" "/pass" "/ping" "/pong"
+ "/privmsg" "/quit" "/rehash" "/restart" "/service" "/servlist"
+ "/server" "/squery" "/squit" "/stats" "/summon" "/time"
+ "/topic" "/trace" "/user" "/userhost" "/users" "/version"
+ "/wallops" "/who" "/whois" "/whowas")
+ "A list of user commands by IRC server.
+The value defaults to RFCs 1459 and 2812.")
+
+;; /me and /ctcp are not defined by `defun-rcirc-command'.
+(defvar rcirc-client-commands '("/me" "/ctcp")
+ "A list of user commands defined by IRC client rcirc.
+The list is updated automatically by `defun-rcirc-command'.")
+
+(defun rcirc-completion-at-point ()
+ "Function used for `completion-at-point-functions' in `rcirc-mode'."
+ (let* ((beg (save-excursion
+ (if (re-search-backward " " rcirc-prompt-end-marker t)
+ (1+ (point))
+ rcirc-prompt-end-marker)))
+ (table (if (and (eq beg rcirc-prompt-end-marker)
+ (eq (char-after beg) ?/))
+ (delete-dups
+ (append (sort (copy-sequence rcirc-client-commands) 'string-lessp)
+ (sort (copy-sequence rcirc-server-commands) 'string-lessp)))
+ (rcirc-channel-nicks (rcirc-buffer-process) rcirc-target))))
+ (list beg (point) table)))
+
+(defvar rcirc-completions nil)
+(defvar rcirc-completion-start nil)
+
+(defun rcirc-complete ()
+ "Cycle through completions from list of nicks in channel or IRC commands.
+IRC command completion is performed only if '/' is the first input char."
(interactive)
(if (eq last-command this-command)
- (setq rcirc-nick-completions
- (append (cdr rcirc-nick-completions)
- (list (car rcirc-nick-completions))))
- (setq rcirc-nick-completion-start-offset
- (- (save-excursion
- (if (re-search-backward " " rcirc-prompt-end-marker t)
- (1+ (point))
- rcirc-prompt-end-marker))
- rcirc-prompt-end-marker))
- (setq rcirc-nick-completions
- (let ((completion-ignore-case t))
- (all-completions
- (buffer-substring
- (+ rcirc-prompt-end-marker
- rcirc-nick-completion-start-offset)
- (point))
- (mapcar (lambda (x) (cons x nil))
- (rcirc-channel-nicks (rcirc-buffer-process)
- rcirc-target))))))
- (let ((completion (car rcirc-nick-completions)))
+ (setq rcirc-completions
+ (append (cdr rcirc-completions) (list (car rcirc-completions))))
+ (let ((completion-ignore-case t)
+ (table (rcirc-completion-at-point)))
+ (setq rcirc-completion-start (car table))
+ (setq rcirc-completions
+ (all-completions (buffer-substring rcirc-completion-start
+ (cadr table))
+ (nth 2 table)))))
+ (let ((completion (car rcirc-completions)))
(when completion
- (delete-region (+ rcirc-prompt-end-marker
- rcirc-nick-completion-start-offset)
- (point))
- (insert (concat completion
- (if (= (+ rcirc-prompt-end-marker
- rcirc-nick-completion-start-offset)
- rcirc-prompt-end-marker)
- ": "))))))
+ (delete-region rcirc-completion-start (point))
+ (insert
+ (concat completion
+ (cond
+ ((= (aref completion 0) ?/) " ")
+ ((= rcirc-completion-start rcirc-prompt-end-marker) ": ")
+ (t "")))))))
(defun set-rcirc-decode-coding-system (coding-system)
"Set the decode coding system used in this channel."
@@ -824,7 +845,7 @@ If SILENT is non-nil, do not print the message in any irc buffer."
(define-key rcirc-mode-map (kbd "RET") 'rcirc-send-input)
(define-key rcirc-mode-map (kbd "M-p") 'rcirc-insert-prev-input)
(define-key rcirc-mode-map (kbd "M-n") 'rcirc-insert-next-input)
-(define-key rcirc-mode-map (kbd "TAB") 'rcirc-complete-nick)
+(define-key rcirc-mode-map (kbd "TAB") 'rcirc-complete)
(define-key rcirc-mode-map (kbd "C-c C-b") 'rcirc-browse-url)
(define-key rcirc-mode-map (kbd "C-c C-c") 'rcirc-edit-multiline)
(define-key rcirc-mode-map (kbd "C-c C-j") 'rcirc-cmd-join)
@@ -944,6 +965,9 @@ This number is independent of the number of lines in the buffer.")
rcirc-buffer-alist))))
(rcirc-update-short-buffer-names))
+ (add-hook 'completion-at-point-functions
+ 'rcirc-completion-at-point nil 'local)
+
(run-hooks 'rcirc-mode-hook))
(defun rcirc-update-prompt (&optional all)
@@ -1962,16 +1986,18 @@ activity. Only run if the buffer is not visible and
;; containing the text following the /cmd.
(defmacro defun-rcirc-command (command argument docstring interactive-form
- &rest body)
+ &rest body)
"Define a command."
- `(defun ,(intern (concat "rcirc-cmd-" (symbol-name command)))
- (,@argument &optional process target)
- ,(concat docstring "\n\nNote: If PROCESS or TARGET are nil, the values given"
- "\nby `rcirc-buffer-process' and `rcirc-target' will be used.")
- ,interactive-form
- (let ((process (or process (rcirc-buffer-process)))
- (target (or target rcirc-target)))
- ,@body)))
+ `(progn
+ (add-to-list 'rcirc-client-commands ,(concat "/" (symbol-name command)))
+ (defun ,(intern (concat "rcirc-cmd-" (symbol-name command)))
+ (,@argument &optional process target)
+ ,(concat docstring "\n\nNote: If PROCESS or TARGET are nil, the values given"
+ "\nby `rcirc-buffer-process' and `rcirc-target' will be used.")
+ ,interactive-form
+ (let ((process (or process (rcirc-buffer-process)))
+ (target (or target rcirc-target)))
+ ,@body))))
(defun-rcirc-command msg (message)
"Send private MESSAGE to TARGET."
[Message part 3 (text/plain, inline)]
Regards,
Leo
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6076
; Package
emacs
.
(Sat, 04 Sep 2010 21:43:02 GMT)
Full text and
rfc822 format available.
Message #59 received at 6076 <at> debbugs.gnu.org (full text, mbox):
> I have recreated the patch against emacs-23 as suggested. I have also
> briefly tested it. Seems to work as expected. M-TAB in rcirc-mode now
> uses the new completion at point interface.
Looks goot to me,
Stefan
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6076
; Package
emacs
.
(Mon, 06 Sep 2010 17:51:02 GMT)
Full text and
rfc822 format available.
Message #62 received at 6076 <at> debbugs.gnu.org (full text, mbox):
On 2010-09-04 22:44 +0100, Stefan Monnier wrote:
>> I have recreated the patch against emacs-23 as suggested. I have also
>> briefly tested it. Seems to work as expected. M-TAB in rcirc-mode now
>> uses the new completion at point interface.
>
> Looks goot to me,
>
>
> Stefan
I have been using it over the weekend and nothing abnormal found. But
maybe apply the following minor tweaks on top of the previous patch.
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index cade679..7a43678 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -794,11 +794,12 @@ The list is updated automatically by `defun-rcirc-command'.")
(if (re-search-backward " " rcirc-prompt-end-marker t)
(1+ (point))
rcirc-prompt-end-marker)))
- (table (if (and (eq beg rcirc-prompt-end-marker)
+ (table (if (and (= beg rcirc-prompt-end-marker)
(eq (char-after beg) ?/))
(delete-dups
- (append (sort (copy-sequence rcirc-client-commands) 'string-lessp)
- (sort (copy-sequence rcirc-server-commands) 'string-lessp)))
+ (nconc
+ (sort (copy-sequence rcirc-client-commands) 'string-lessp)
+ (sort (copy-sequence rcirc-server-commands) 'string-lessp)))
(rcirc-channel-nicks (rcirc-buffer-process) rcirc-target))))
(list beg (point) table)))
Leo
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6076
; Package
emacs
.
(Sat, 11 Sep 2010 12:54:01 GMT)
Full text and
rfc822 format available.
Message #65 received at 6076 <at> debbugs.gnu.org (full text, mbox):
>>> I have recreated the patch against emacs-23 as suggested. I have also
>>> briefly tested it. Seems to work as expected. M-TAB in rcirc-mode now
>>> uses the new completion at point interface.
>> Looks good to me,
> I have been using it over the weekend and nothing abnormal found. But
> maybe apply the following minor tweaks on top of the previous patch.
Can you post a final patch to install?
Stefan
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#6076
; Package
emacs
.
(Sat, 11 Sep 2010 13:02:02 GMT)
Full text and
rfc822 format available.
Message #68 received at 6076 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 2010-09-11 13:55 +0100, Stefan Monnier wrote:
>>>> I have recreated the patch against emacs-23 as suggested. I have also
>>>> briefly tested it. Seems to work as expected. M-TAB in rcirc-mode now
>>>> uses the new completion at point interface.
>>> Looks good to me,
>> I have been using it over the weekend and nothing abnormal found. But
>> maybe apply the following minor tweaks on top of the previous patch.
>
> Can you post a final patch to install?
>
>
> Stefan
Attached.
The ChangeLog entry could looks something like this:
* net/rcirc.el (rcirc-server-commands, rcirc-client-commands)
(rcirc-completion-start): new variables.
(rcirc-nick-completions): rename to rcirc-completions.
(rcirc-nick-completion-start-offset): delete.
(rcirc-completion-at-point): new function for constructing
completion data for both nicks and irc commands. Add to
completion-at-point-functions in rcirc mode.
(rcirc-complete): rename from rcirc-nick-complete; use
rcirc-completion-at-point.
(defun-rcirc-command): update rcirc-client-commands.
[rcirc-complete.diff (text/x-diff, inline)]
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index ec67c3e..7a43678 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -771,42 +771,64 @@ If SILENT is non-nil, do not print the message in any irc buffer."
(setq rcirc-input-ring-index (1- rcirc-input-ring-index))
(insert (rcirc-prev-input-string -1))))
-(defvar rcirc-nick-completions nil)
-(defvar rcirc-nick-completion-start-offset nil)
-
-(defun rcirc-complete-nick ()
- "Cycle through nick completions from list of nicks in channel."
+(defvar rcirc-server-commands
+ '("/admin" "/away" "/connect" "/die" "/error" "/info"
+ "/invite" "/ison" "/join" "/kick" "/kill" "/links"
+ "/list" "/lusers" "/mode" "/motd" "/names" "/nick"
+ "/notice" "/oper" "/part" "/pass" "/ping" "/pong"
+ "/privmsg" "/quit" "/rehash" "/restart" "/service" "/servlist"
+ "/server" "/squery" "/squit" "/stats" "/summon" "/time"
+ "/topic" "/trace" "/user" "/userhost" "/users" "/version"
+ "/wallops" "/who" "/whois" "/whowas")
+ "A list of user commands by IRC server.
+The value defaults to RFCs 1459 and 2812.")
+
+;; /me and /ctcp are not defined by `defun-rcirc-command'.
+(defvar rcirc-client-commands '("/me" "/ctcp")
+ "A list of user commands defined by IRC client rcirc.
+The list is updated automatically by `defun-rcirc-command'.")
+
+(defun rcirc-completion-at-point ()
+ "Function used for `completion-at-point-functions' in `rcirc-mode'."
+ (let* ((beg (save-excursion
+ (if (re-search-backward " " rcirc-prompt-end-marker t)
+ (1+ (point))
+ rcirc-prompt-end-marker)))
+ (table (if (and (= beg rcirc-prompt-end-marker)
+ (eq (char-after beg) ?/))
+ (delete-dups
+ (nconc
+ (sort (copy-sequence rcirc-client-commands) 'string-lessp)
+ (sort (copy-sequence rcirc-server-commands) 'string-lessp)))
+ (rcirc-channel-nicks (rcirc-buffer-process) rcirc-target))))
+ (list beg (point) table)))
+
+(defvar rcirc-completions nil)
+(defvar rcirc-completion-start nil)
+
+(defun rcirc-complete ()
+ "Cycle through completions from list of nicks in channel or IRC commands.
+IRC command completion is performed only if '/' is the first input char."
(interactive)
(if (eq last-command this-command)
- (setq rcirc-nick-completions
- (append (cdr rcirc-nick-completions)
- (list (car rcirc-nick-completions))))
- (setq rcirc-nick-completion-start-offset
- (- (save-excursion
- (if (re-search-backward " " rcirc-prompt-end-marker t)
- (1+ (point))
- rcirc-prompt-end-marker))
- rcirc-prompt-end-marker))
- (setq rcirc-nick-completions
- (let ((completion-ignore-case t))
- (all-completions
- (buffer-substring
- (+ rcirc-prompt-end-marker
- rcirc-nick-completion-start-offset)
- (point))
- (mapcar (lambda (x) (cons x nil))
- (rcirc-channel-nicks (rcirc-buffer-process)
- rcirc-target))))))
- (let ((completion (car rcirc-nick-completions)))
+ (setq rcirc-completions
+ (append (cdr rcirc-completions) (list (car rcirc-completions))))
+ (let ((completion-ignore-case t)
+ (table (rcirc-completion-at-point)))
+ (setq rcirc-completion-start (car table))
+ (setq rcirc-completions
+ (all-completions (buffer-substring rcirc-completion-start
+ (cadr table))
+ (nth 2 table)))))
+ (let ((completion (car rcirc-completions)))
(when completion
- (delete-region (+ rcirc-prompt-end-marker
- rcirc-nick-completion-start-offset)
- (point))
- (insert (concat completion
- (if (= (+ rcirc-prompt-end-marker
- rcirc-nick-completion-start-offset)
- rcirc-prompt-end-marker)
- ": "))))))
+ (delete-region rcirc-completion-start (point))
+ (insert
+ (concat completion
+ (cond
+ ((= (aref completion 0) ?/) " ")
+ ((= rcirc-completion-start rcirc-prompt-end-marker) ": ")
+ (t "")))))))
(defun set-rcirc-decode-coding-system (coding-system)
"Set the decode coding system used in this channel."
@@ -824,7 +846,7 @@ If SILENT is non-nil, do not print the message in any irc buffer."
(define-key rcirc-mode-map (kbd "RET") 'rcirc-send-input)
(define-key rcirc-mode-map (kbd "M-p") 'rcirc-insert-prev-input)
(define-key rcirc-mode-map (kbd "M-n") 'rcirc-insert-next-input)
-(define-key rcirc-mode-map (kbd "TAB") 'rcirc-complete-nick)
+(define-key rcirc-mode-map (kbd "TAB") 'rcirc-complete)
(define-key rcirc-mode-map (kbd "C-c C-b") 'rcirc-browse-url)
(define-key rcirc-mode-map (kbd "C-c C-c") 'rcirc-edit-multiline)
(define-key rcirc-mode-map (kbd "C-c C-j") 'rcirc-cmd-join)
@@ -944,6 +966,9 @@ This number is independent of the number of lines in the buffer.")
rcirc-buffer-alist))))
(rcirc-update-short-buffer-names))
+ (add-hook 'completion-at-point-functions
+ 'rcirc-completion-at-point nil 'local)
+
(run-hooks 'rcirc-mode-hook))
(defun rcirc-update-prompt (&optional all)
@@ -1962,16 +1987,18 @@ activity. Only run if the buffer is not visible and
;; containing the text following the /cmd.
(defmacro defun-rcirc-command (command argument docstring interactive-form
- &rest body)
+ &rest body)
"Define a command."
- `(defun ,(intern (concat "rcirc-cmd-" (symbol-name command)))
- (,@argument &optional process target)
- ,(concat docstring "\n\nNote: If PROCESS or TARGET are nil, the values given"
- "\nby `rcirc-buffer-process' and `rcirc-target' will be used.")
- ,interactive-form
- (let ((process (or process (rcirc-buffer-process)))
- (target (or target rcirc-target)))
- ,@body)))
+ `(progn
+ (add-to-list 'rcirc-client-commands ,(concat "/" (symbol-name command)))
+ (defun ,(intern (concat "rcirc-cmd-" (symbol-name command)))
+ (,@argument &optional process target)
+ ,(concat docstring "\n\nNote: If PROCESS or TARGET are nil, the values given"
+ "\nby `rcirc-buffer-process' and `rcirc-target' will be used.")
+ ,interactive-form
+ (let ((process (or process (rcirc-buffer-process)))
+ (target (or target rcirc-target)))
+ ,@body))))
(defun-rcirc-command msg (message)
"Send private MESSAGE to TARGET."
[Message part 3 (text/plain, inline)]
Leo
Reply sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
You have taken responsibility.
(Sun, 12 Sep 2010 15:38:04 GMT)
Full text and
rfc822 format available.
Notification sent
to
Leo <sdl.web <at> gmail.com>
:
bug acknowledged by developer.
(Sun, 12 Sep 2010 15:38:04 GMT)
Full text and
rfc822 format available.
Message #73 received at 6076-done <at> debbugs.gnu.org (full text, mbox):
> The ChangeLog entry could looks something like this:
> * net/rcirc.el (rcirc-server-commands, rcirc-client-commands)
> (rcirc-completion-start): new variables.
> (rcirc-nick-completions): rename to rcirc-completions.
> (rcirc-nick-completion-start-offset): delete.
> (rcirc-completion-at-point): new function for constructing
> completion data for both nicks and irc commands. Add to
> completion-at-point-functions in rcirc mode.
> (rcirc-complete): rename from rcirc-nick-complete; use
> rcirc-completion-at-point.
> (defun-rcirc-command): update rcirc-client-commands.
Looks fine, except that we capitalize after the ":".
Installed, thank you,
Stefan
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 11 Oct 2010 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 14 years and 306 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.