From debbugs-submit-bounces@debbugs.gnu.org Sun May 02 04:52:34 2010 Received: (at submit) by debbugs.gnu.org; 2 May 2010 08:52:34 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O8Uuf-0006OM-JV for submit@debbugs.gnu.org; Sun, 02 May 2010 04:52:34 -0400 Received: from mx10.gnu.org ([199.232.76.166]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O8Uud-0006OF-Kc for submit@debbugs.gnu.org; Sun, 02 May 2010 04:52:32 -0400 Received: from lists.gnu.org ([199.232.76.165]:43778) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1O8Uua-0002vs-HJ for submit@debbugs.gnu.org; Sun, 02 May 2010 04:52:28 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O8UuZ-0001Rz-GL for bug-gnu-emacs@gnu.org; Sun, 02 May 2010 04:52:27 -0400 Received: from [140.186.70.92] (port=50397 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O8UuX-0001LB-Ki for bug-gnu-emacs@gnu.org; Sun, 02 May 2010 04:52:26 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.0 (2010-01-18) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_MED,T_RP_MATCHES_RCVD,T_TO_NO_BRKTS_FREEMAIL, T_TVD_MIME_NO_HEADERS autolearn=unavailable version=3.3.0 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O8UrT-0001UE-Gl for bug-gnu-emacs@gnu.org; Sun, 02 May 2010 04:49:18 -0400 Received: from ppsw-33.csi.cam.ac.uk ([131.111.8.133]:41708) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O8UrT-0001U0-2P for bug-gnu-emacs@gnu.org; Sun, 02 May 2010 04:49:15 -0400 X-Cam-AntiVirus: no malware found X-Cam-SpamDetails: not scanned X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from cpc1-cmbg13-0-0-cust596.cmbg.cable.ntl.com ([86.9.122.85]:62559 helo=Victoria.local) by ppsw-33.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.159]:587) with esmtpsa (PLAIN:sl392) (TLSv1:DHE-RSA-AES128-SHA:128) id 1O8UrP-0003g7-AD (Exim 4.70) for bug-gnu-emacs@gnu.org (return-path ); Sun, 02 May 2010 09:49:11 +0100 From: Leo To: bug-gnu-emacs@gnu.org Subject: 23.1.96; [PATCH] rcirc-complete for nicks and commands Date: Sun, 02 May 2010 09:49:09 +0100 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -4.9 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.0 (------) --=-=-= 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. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-New-command-rcirc-complete-that-completes-both-nicks.patch >From 25bedc278df5376f24eff69f0dd48c19bc046e6f Mon Sep 17 00:00:00 2001 From: Leo Date: Sun, 2 May 2010 07:00:56 +0100 Subject: [PATCH] New command rcirc-complete that completes both nicks and irc commands --- lisp/net/rcirc.el | 90 ++++++++++++++++++++++++++++++++++------------------- 1 files changed, 58 insertions(+), 32 deletions(-) diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index 8d70415..0a87200 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -756,42 +756,49 @@ 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) +(defvar rcirc-completions nil) +(defvar rcirc-completion-start-offset nil) -(defun rcirc-complete-nick () - "Cycle through nick completions from list of nicks in channel." +(defun rcirc-complete () + "Cycle through completions from list of nicks in channel or IRC commands. +IRC command completion is performed only if '/' is the fisrt 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 + (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)) - (setq rcirc-nick-completions - (let ((completion-ignore-case t)) + (let ((completion-ignore-case t)) + (setq rcirc-completions (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))) + (buffer-substring + (+ rcirc-prompt-end-marker + rcirc-completion-start-offset) + (point)) + (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) + (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) - ": ")))))) + (if (or (= (aref completion 0) ?/) + (not (zerop rcirc-completion-start-offset))) + " " + ": ")))))) (defun set-rcirc-decode-coding-system (coding-system) "Set the decode coding system used in this channel." @@ -809,7 +816,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) @@ -1947,17 +1954,36 @@ activity. Only run if the buffer is not visible and ;; the current buffer/channel/user, and ARGS, which is a string ;; containing the text following the /cmd. +(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'.") + (defmacro defun-rcirc-command (command argument docstring interactive-form &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.0.4 --=-=-= With best wishes, Leo --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun May 02 05:01:21 2010 Received: (at 6076) by debbugs.gnu.org; 2 May 2010 09:01:21 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O8V3B-0006Sn-4e for submit@debbugs.gnu.org; Sun, 02 May 2010 05:01:21 -0400 Received: from ppsw-33.csi.cam.ac.uk ([131.111.8.133]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O8V39-0006Si-Au for 6076@debbugs.gnu.org; Sun, 02 May 2010 05:01:20 -0400 X-Cam-AntiVirus: no malware found X-Cam-SpamDetails: not scanned X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from smaug.linux.pwf.cam.ac.uk ([193.60.95.72]:51799) by ppsw-33.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.159]:587) with esmtpsa (LOGIN:sl392) (TLSv1:DHE-RSA-AES128-SHA:128) id 1O8V36-0006mJ-9o (Exim 4.70) (return-path ); Sun, 02 May 2010 10:01:16 +0100 From: Leo To: 6076@debbugs.gnu.org Subject: Re: bug#6076: 23.1.96; [PATCH] rcirc-complete for nicks and commands References: Date: Sun, 02 May 2010 10:01:15 +0100 In-Reply-To: (Leo's message of "Sun, 02 May 2010 09:49:09 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -6.2 (------) X-Debbugs-Envelope-To: 6076 Cc: Ryan Yeske X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.2 (------) --=-=-= 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 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-New-command-rcirc-complete-that-completes-both-nicks.patch Content-Description: 0001-New-command-rcirc-complete-that-completes-both-nicks.patch >From e184aa733f1ecb4a77f0fef030f8657f2784755c Mon Sep 17 00:00:00 2001 From: Leo Date: Sun, 2 May 2010 07:00:56 +0100 Subject: [PATCH] New command rcirc-complete that completes both nicks and irc commands --- lisp/net/rcirc.el | 92 ++++++++++++++++++++++++++++++++++------------------- 1 files changed, 59 insertions(+), 33 deletions(-) diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index 8d70415..ccc9ec5 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -756,42 +756,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 fisrt 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 + (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)) - (setq rcirc-nick-completions - (let ((completion-ignore-case t)) + (let ((completion-ignore-case t)) + (setq rcirc-completions (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))) + (buffer-substring + (+ rcirc-prompt-end-marker + rcirc-completion-start-offset) + (point)) + (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) + (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) - ": ")))))) + (if (or (= (aref completion 0) ?/) + (not (zerop rcirc-completion-start-offset))) + " " + ": ")))))) (defun set-rcirc-decode-coding-system (coding-system) "Set the decode coding system used in this channel." @@ -809,7 +833,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) @@ -1950,14 +1974,16 @@ activity. Only run if the buffer is not visible and (defmacro defun-rcirc-command (command argument docstring interactive-form &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.0.4 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon May 03 12:37:21 2010 Received: (at 6076) by debbugs.gnu.org; 3 May 2010 16:37:21 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O8ye0-0004At-UO for submit@debbugs.gnu.org; Mon, 03 May 2010 12:37:21 -0400 Received: from pruche.dit.umontreal.ca ([132.204.246.22]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O8ydz-0004Al-MK for 6076@debbugs.gnu.org; Mon, 03 May 2010 12:37:19 -0400 Received: from faina.iro.umontreal.ca (faina.iro.umontreal.ca [132.204.26.177]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id o43GbD8Y027507; Mon, 3 May 2010 12:37:13 -0400 Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id 778D2B4C27; Mon, 3 May 2010 12:37:13 -0400 (EDT) From: Stefan Monnier To: Leo Subject: Re: bug#6076: 23.1.96; [PATCH] rcirc-complete for nicks and commands Message-ID: References: Date: Mon, 03 May 2010 12:37:13 -0400 In-Reply-To: (Leo's message of "Sun, 02 May 2010 09:49:09 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3525=0 X-Spam-Score: -2.0 (--) X-Debbugs-Envelope-To: 6076 Cc: 6076@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.0 (--) > 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 From debbugs-submit-bounces@debbugs.gnu.org Mon May 03 13:45:48 2010 Received: (at 6076) by debbugs.gnu.org; 3 May 2010 17:45:48 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O8ziG-0004ex-0g for submit@debbugs.gnu.org; Mon, 03 May 2010 13:45:48 -0400 Received: from ppsw-33.csi.cam.ac.uk ([131.111.8.133]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O8ziE-0004er-9S for 6076@debbugs.gnu.org; Mon, 03 May 2010 13:45:47 -0400 X-Cam-AntiVirus: no malware found X-Cam-SpamDetails: not scanned X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from smaug.linux.pwf.cam.ac.uk ([193.60.95.72]:44190) by ppsw-33.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.159]:587) with esmtpsa (LOGIN:sl392) (TLSv1:DHE-RSA-AES128-SHA:128) id 1O8zi8-0001Pa-Cd (Exim 4.70) (return-path ); Mon, 03 May 2010 18:45:40 +0100 From: Leo To: Stefan Monnier Subject: Re: bug#6076: 23.1.96; [PATCH] rcirc-complete for nicks and commands References: Date: Mon, 03 May 2010 18:45:40 +0100 In-Reply-To: (Stefan Monnier's message of "Mon, 03 May 2010 12:37:13 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -6.2 (------) X-Debbugs-Envelope-To: 6076 Cc: 6076@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.2 (------) 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 From debbugs-submit-bounces@debbugs.gnu.org Mon May 03 22:32:44 2010 Received: (at 6076) by debbugs.gnu.org; 4 May 2010 02:32:44 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O97wC-0000GB-FE for submit@debbugs.gnu.org; Mon, 03 May 2010 22:32:44 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O97wB-0000G6-Po for 6076@debbugs.gnu.org; Mon, 03 May 2010 22:32:43 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAEAk30vO+KoL/2dsb2JhbACdL3K8QIUSBIwo X-IronPort-AV: E=Sophos;i="4.52,323,1270440000"; d="scan'208";a="63265560" Received: from 206-248-170-11.dsl.teksavvy.com (HELO pastel.home) ([206.248.170.11]) by ironport2-out.pppoe.ca with ESMTP; 03 May 2010 22:32:39 -0400 Received: by pastel.home (Postfix, from userid 20848) id 9201A8007; Mon, 3 May 2010 22:32:39 -0400 (EDT) From: Stefan Monnier To: Leo Subject: Re: bug#6076: 23.1.96; [PATCH] rcirc-complete for nicks and commands Message-ID: References: Date: Mon, 03 May 2010 22:32:39 -0400 In-Reply-To: (Leo's message of "Mon, 03 May 2010 18:45:40 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 6076 Cc: 6076@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) >>> 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 From debbugs-submit-bounces@debbugs.gnu.org Tue May 04 09:41:42 2010 Received: (at submit) by debbugs.gnu.org; 4 May 2010 13:41:42 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O9INZ-00086Z-Um for submit@debbugs.gnu.org; Tue, 04 May 2010 09:41:42 -0400 Received: from mail.gnu.org ([199.232.76.166] helo=mx10.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O9INY-00086T-Br for submit@debbugs.gnu.org; Tue, 04 May 2010 09:41:41 -0400 Received: from lists.gnu.org ([199.232.76.165]:45573) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1O9INT-0007lX-Ji for submit@debbugs.gnu.org; Tue, 04 May 2010 09:41:35 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O9INS-0006Di-Oh for bug-gnu-emacs@gnu.org; Tue, 04 May 2010 09:41:34 -0400 Received: from [140.186.70.92] (port=44578 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O9INR-0006Cm-Cw for bug-gnu-emacs@gnu.org; Tue, 04 May 2010 09:41:34 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.0 (2010-01-18) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_RP_MATCHES_RCVD, T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.0 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O9INP-00020a-UD for bug-gnu-emacs@gnu.org; Tue, 04 May 2010 09:41:33 -0400 Received: from lo.gmane.org ([80.91.229.12]:57900) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O9INP-000209-Oc for bug-gnu-emacs@gnu.org; Tue, 04 May 2010 09:41:31 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1O9INI-0005GN-3S for bug-gnu-emacs@gnu.org; Tue, 04 May 2010 15:41:24 +0200 Received: from smaug.linux.pwf.cam.ac.uk ([193.60.95.72]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 04 May 2010 15:41:24 +0200 Received: from sdl.web by smaug.linux.pwf.cam.ac.uk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 04 May 2010 15:41:24 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: bug-gnu-emacs@gnu.org connect(): No such file or directory From: Leo Subject: Re: bug#6076: 23.1.96; [PATCH] rcirc-complete for nicks and commands Date: Tue, 04 May 2010 14:41:11 +0100 Organization: University of Cambridge Lines: 30 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: smaug.linux.pwf.cam.ac.uk User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:kfrLVxiEJTtRt7sisUj/s3GzcvQ= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -5.9 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) 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))))))) From debbugs-submit-bounces@debbugs.gnu.org Tue May 04 12:23:02 2010 Received: (at 6076) by debbugs.gnu.org; 4 May 2010 16:23:02 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O9Kti-0000mS-1O for submit@debbugs.gnu.org; Tue, 04 May 2010 12:23:02 -0400 Received: from smtp-out1.starman.ee ([85.253.0.3] helo=mx1.starman.ee) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O9Ktg-0000mH-Iq for 6076@debbugs.gnu.org; Tue, 04 May 2010 12:23:01 -0400 X-Virus-Scanned: by Amavisd-New at mx1.starman.ee Received: from mail.starman.ee (82.131.30.129.cable.starman.ee [82.131.30.129]) by mx1.starman.ee (Postfix) with ESMTP id 1BEDC3F4107; Tue, 4 May 2010 19:22:54 +0300 (EEST) From: Juri Linkov To: Stefan Monnier Subject: Re: bug#6076: 23.1.96; [PATCH] rcirc-complete for nicks and commands Organization: JURTA References: Date: Tue, 04 May 2010 19:18:09 +0300 In-Reply-To: (Stefan Monnier's message of "Mon, 03 May 2010 22:32:39 -0400") Message-ID: <87vdb3y7bv.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -3.5 (---) X-Debbugs-Envelope-To: 6076 Cc: 6076@debbugs.gnu.org, Leo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.5 (---) >>> 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/ From debbugs-submit-bounces@debbugs.gnu.org Tue May 04 14:29:51 2010 Received: (at 6076) by debbugs.gnu.org; 4 May 2010 18:29:51 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O9MsR-0001dv-HW for submit@debbugs.gnu.org; Tue, 04 May 2010 14:29:51 -0400 Received: from tomts40.bellnexxia.net ([209.226.175.97] helo=tomts40-srv.bellnexxia.net) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O9MsO-0001dq-II for 6076@debbugs.gnu.org; Tue, 04 May 2010 14:29:49 -0400 Received: from toip5.srvr.bell.ca ([209.226.175.88]) by tomts40-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20100504182943.CAKM1888.tomts40-srv.bellnexxia.net@toip5.srvr.bell.ca> for <6076@debbugs.gnu.org>; Tue, 4 May 2010 14:29:43 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAB4D4EtGN5LW/2dsb2JhbACdL3K+TIUTBA Received: from bas1-montreal42-1178047190.dsl.bell.ca (HELO alfajor.home) ([70.55.146.214]) by toip5.srvr.bell.ca with ESMTP; 04 May 2010 14:44:54 -0400 Received: by alfajor.home (Postfix, from userid 20848) id B1510BB4C3; Tue, 4 May 2010 14:29:40 -0400 (EDT) From: Stefan Monnier To: Juri Linkov Subject: Re: bug#6076: 23.1.96; [PATCH] rcirc-complete for nicks and commands Message-ID: References: <87vdb3y7bv.fsf@mail.jurta.org> Date: Tue, 04 May 2010 14:29:40 -0400 In-Reply-To: <87vdb3y7bv.fsf@mail.jurta.org> (Juri Linkov's message of "Tue, 04 May 2010 19:18:09 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 6076 Cc: 6076@debbugs.gnu.org, Leo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.2 (--) >> 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 From debbugs-submit-bounces@debbugs.gnu.org Tue May 04 16:14:57 2010 Received: (at 6076) by debbugs.gnu.org; 4 May 2010 20:14:58 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O9OW9-0003ma-OI for submit@debbugs.gnu.org; Tue, 04 May 2010 16:14:57 -0400 Received: from smtp-out1.starman.ee ([85.253.0.3] helo=mx1.starman.ee) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O9OW7-0003mV-Iq for 6076@debbugs.gnu.org; Tue, 04 May 2010 16:14:56 -0400 X-Virus-Scanned: by Amavisd-New at mx1.starman.ee Received: from mail.starman.ee (82.131.30.129.cable.starman.ee [82.131.30.129]) by mx1.starman.ee (Postfix) with ESMTP id 290293F410E; Tue, 4 May 2010 23:14:44 +0300 (EEST) From: Juri Linkov To: Stefan Monnier Subject: Re: bug#6076: 23.1.96; [PATCH] rcirc-complete for nicks and commands Organization: JURTA References: <87vdb3y7bv.fsf@mail.jurta.org> Date: Tue, 04 May 2010 23:01:09 +0300 In-Reply-To: (Stefan Monnier's message of "Tue, 04 May 2010 14:29:40 -0400") Message-ID: <87zl0fctpt.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -3.5 (---) X-Debbugs-Envelope-To: 6076 Cc: 6076@debbugs.gnu.org, Leo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.5 (---) > 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/ From debbugs-submit-bounces@debbugs.gnu.org Tue May 04 17:19:07 2010 Received: (at 6076) by debbugs.gnu.org; 4 May 2010 21:19:07 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O9PWE-0004DB-Fo for submit@debbugs.gnu.org; Tue, 04 May 2010 17:19:06 -0400 Received: from tomts5-srv.bellnexxia.net ([209.226.175.25]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O9PWC-0004Cn-87 for 6076@debbugs.gnu.org; Tue, 04 May 2010 17:19:05 -0400 Received: from toip4.srvr.bell.ca ([209.226.175.87]) by tomts5-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20100504211859.VKSE6410.tomts5-srv.bellnexxia.net@toip4.srvr.bell.ca> for <6076@debbugs.gnu.org>; Tue, 4 May 2010 17:18:59 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAAom4EtGN5LW/2dsb2JhbACdNXK+T4UTBA Received: from bas1-montreal42-1178047190.dsl.bell.ca (HELO alfajor.home) ([70.55.146.214]) by toip4.srvr.bell.ca with ESMTP; 04 May 2010 17:34:02 -0400 Received: by alfajor.home (Postfix, from userid 20848) id 50F5FAF46E; Tue, 4 May 2010 17:18:55 -0400 (EDT) From: Stefan Monnier To: Juri Linkov Subject: Re: bug#6076: 23.1.96; [PATCH] rcirc-complete for nicks and commands Message-ID: References: <87vdb3y7bv.fsf@mail.jurta.org> <87zl0fctpt.fsf@mail.jurta.org> Date: Tue, 04 May 2010 17:18:55 -0400 In-Reply-To: <87zl0fctpt.fsf@mail.jurta.org> (Juri Linkov's message of "Tue, 04 May 2010 23:01:09 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -2.2 (--) X-Debbugs-Envelope-To: 6076 Cc: 6076@debbugs.gnu.org, Leo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.2 (--) > 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 From debbugs-submit-bounces@debbugs.gnu.org Mon May 10 15:17:29 2010 Received: (at 6076) by debbugs.gnu.org; 10 May 2010 19:17:29 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OBYTo-0001eW-HQ for submit@debbugs.gnu.org; Mon, 10 May 2010 15:17:28 -0400 Received: from smtp-out1.starman.ee ([85.253.0.3] helo=mx1.starman.ee) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OBYTl-0001eR-OT for 6076@debbugs.gnu.org; Mon, 10 May 2010 15:17:26 -0400 X-Virus-Scanned: by Amavisd-New at mx1.starman.ee Received: from mail.starman.ee (82.131.69.38.cable.starman.ee [82.131.69.38]) by mx1.starman.ee (Postfix) with ESMTP id CA2973F413E; Mon, 10 May 2010 22:17:17 +0300 (EEST) From: Juri Linkov To: Stefan Monnier Subject: Re: bug#6076: 23.1.96; [PATCH] rcirc-complete for nicks and commands Organization: JURTA References: <87vdb3y7bv.fsf@mail.jurta.org> <87zl0fctpt.fsf@mail.jurta.org> Date: Mon, 10 May 2010 22:14:28 +0300 In-Reply-To: (Stefan Monnier's message of "Tue, 04 May 2010 17:18:55 -0400") Message-ID: <87ljbu36ed.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -2.2 (--) X-Debbugs-Envelope-To: 6076 Cc: 6076@debbugs.gnu.org, Leo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.5 (---) >> 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/ From debbugs-submit-bounces@debbugs.gnu.org Mon May 10 21:14:17 2010 Received: (at 6076) by debbugs.gnu.org; 11 May 2010 01:14:17 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OBe36-000486-SO for submit@debbugs.gnu.org; Mon, 10 May 2010 21:14:17 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.183] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OBe35-000481-3J for 6076@debbugs.gnu.org; Mon, 10 May 2010 21:14:15 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEADdM6EtLd+Zs/2dsb2JhbACeI3K6doUUBIwy X-IronPort-AV: E=Sophos;i="4.53,204,1272859200"; d="scan'208";a="63867875" Received: from 75-119-230-108.dsl.teksavvy.com (HELO pastel.home) ([75.119.230.108]) by ironport2-out.pppoe.ca with ESMTP; 10 May 2010 21:14:11 -0400 Received: by pastel.home (Postfix, from userid 20848) id CCE7F80B1; Mon, 10 May 2010 21:14:10 -0400 (EDT) From: Stefan Monnier To: Juri Linkov Subject: Re: bug#6076: 23.1.96; [PATCH] rcirc-complete for nicks and commands Message-ID: References: <87vdb3y7bv.fsf@mail.jurta.org> <87zl0fctpt.fsf@mail.jurta.org> <87ljbu36ed.fsf@mail.jurta.org> Date: Mon, 10 May 2010 21:14:10 -0400 In-Reply-To: <87ljbu36ed.fsf@mail.jurta.org> (Juri Linkov's message of "Mon, 10 May 2010 22:14:28 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -2.0 (--) X-Debbugs-Envelope-To: 6076 Cc: 6076@debbugs.gnu.org, Leo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.0 (--) > 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 From debbugs-submit-bounces@debbugs.gnu.org Tue May 11 12:54:29 2010 Received: (at 6076) by debbugs.gnu.org; 11 May 2010 16:54:29 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OBsiz-0002xU-8B for submit@debbugs.gnu.org; Tue, 11 May 2010 12:54:29 -0400 Received: from smtp-out2.starman.ee ([85.253.0.4] helo=mx2.starman.ee) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OBsiw-0002xP-Mi for 6076@debbugs.gnu.org; Tue, 11 May 2010 12:54:27 -0400 X-Virus-Scanned: by Amavisd-New at mx2.starman.ee Received: from mail.starman.ee (82.131.68.105.cable.starman.ee [82.131.68.105]) by mx2.starman.ee (Postfix) with ESMTP id A96C53F40EF; Tue, 11 May 2010 19:54:17 +0300 (EEST) From: Juri Linkov To: Stefan Monnier Subject: Re: bug#6076: 23.1.96; [PATCH] rcirc-complete for nicks and commands Organization: JURTA References: <87vdb3y7bv.fsf@mail.jurta.org> <87zl0fctpt.fsf@mail.jurta.org> <87ljbu36ed.fsf@mail.jurta.org> Date: Tue, 11 May 2010 19:54:14 +0300 In-Reply-To: (Stefan Monnier's message of "Mon, 10 May 2010 21:14:10 -0400") Message-ID: <874oiequd2.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -3.5 (---) X-Debbugs-Envelope-To: 6076 Cc: 6076@debbugs.gnu.org, Leo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.5 (---) > 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/ From debbugs-submit-bounces@debbugs.gnu.org Tue May 11 15:52:39 2010 Received: (at 6076) by debbugs.gnu.org; 11 May 2010 19:52:39 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OBvVO-0005Np-Qz for submit@debbugs.gnu.org; Tue, 11 May 2010 15:52:39 -0400 Received: from tomts20-srv.bellnexxia.net ([209.226.175.74]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OBvVL-0005Ng-Q1 for 6076@debbugs.gnu.org; Tue, 11 May 2010 15:52:36 -0400 Received: from toip3.srvr.bell.ca ([209.226.175.86]) by tomts20-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20100511195230.LLVX3465.tomts20-srv.bellnexxia.net@toip3.srvr.bell.ca> for <6076@debbugs.gnu.org>; Tue, 11 May 2010 15:52:30 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAI5N6UtKDMwD/2dsb2JhbACeKXK8XYURBA Received: from bas1-montreal42-1242352643.dsl.bell.ca (HELO ceviche.home) ([74.12.204.3]) by toip3.srvr.bell.ca with ESMTP; 11 May 2010 15:44:18 -0400 Received: by ceviche.home (Postfix, from userid 20848) id 8D8CA660DC; Tue, 11 May 2010 15:52:29 -0400 (EDT) From: Stefan Monnier To: Juri Linkov Subject: Re: bug#6076: 23.1.96; [PATCH] rcirc-complete for nicks and commands Message-ID: References: <87vdb3y7bv.fsf@mail.jurta.org> <87zl0fctpt.fsf@mail.jurta.org> <87ljbu36ed.fsf@mail.jurta.org> <874oiequd2.fsf@mail.jurta.org> Date: Tue, 11 May 2010 15:52:29 -0400 In-Reply-To: <874oiequd2.fsf@mail.jurta.org> (Juri Linkov's message of "Tue, 11 May 2010 19:54:14 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: 6076 Cc: 6076@debbugs.gnu.org, Leo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.5 (-) >> 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 From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 23 06:35:15 2010 Received: (at 6076) by debbugs.gnu.org; 23 Aug 2010 10:35:15 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OnUN0-0006HC-KG for submit@debbugs.gnu.org; Mon, 23 Aug 2010 06:35:14 -0400 Received: from ppsw-33.csi.cam.ac.uk ([131.111.8.133]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OnUMw-0006H4-T7 for 6076@debbugs.gnu.org; Mon, 23 Aug 2010 06:35:11 -0400 X-Cam-AntiVirus: no malware found X-Cam-SpamDetails: not scanned X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from cpc1-cmbg13-0-0-cust596.5-4.cable.virginmedia.com ([86.9.122.85]:63914 helo=Victoria.local) by ppsw-33.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.159]:587) with esmtpsa (PLAIN:sl392) (TLSv1:DHE-RSA-AES128-SHA:128) id 1OnUOB-0001Jh-gH (Exim 4.72) (return-path ); Mon, 23 Aug 2010 11:36:27 +0100 From: Leo To: 6076@debbugs.gnu.org Subject: Re: 23.1.96; [PATCH] rcirc-complete for nicks and commands Date: Mon, 23 Aug 2010 11:36:25 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (Mac OS X 10.6.4) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: 6076 Cc: Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.3 (-----) --=-=-= 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-New-command-rcirc-complete-6076.patch Content-Description: 0001-New-command-rcirc-complete-6076.patch >From af9423a2d099f615a3ff45c0bfa67ae58856681d Mon Sep 17 00:00:00 2001 From: Leo 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 --=-=-= Leo --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 03 18:11:41 2010 Received: (at 6076) by debbugs.gnu.org; 3 Sep 2010 22:11:41 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OreU1-00022q-9x for submit@debbugs.gnu.org; Fri, 03 Sep 2010 18:11:41 -0400 Received: from mail-px0-f172.google.com ([209.85.212.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OreTz-00022j-CL for 6076@debbugs.gnu.org; Fri, 03 Sep 2010 18:11:40 -0400 Received: by pxi6 with SMTP id 6so299617pxi.3 for <6076@debbugs.gnu.org>; Fri, 03 Sep 2010 15:13:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:date:message-id:to :cc:cc:subject:from; bh=hltOQ/1IAFHuyW5GKtRVfWjMuoCBZ6FQaN2o7lV8zqQ=; b=KI1F9gYFaGeOhKARdkxri0UtnTA7a/0xEjzKaP56dfso0Y9QuoblYz8DMw5I4qXFHI ROo6Tcwllpcacy8babyGdPfEjlzMs2EnGYCDaDCCg2uOhQGwtzQww6+c36S6t1BKCO52 /IMYHUffAZlpBFjyuOhSqSBTgWeuDB/grV+W0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:message-id:to:cc:subject:from; b=D+1rbUJswBETLGB2j4hnMKuE38cfpqqFsikbzDhwV1kJPCqKXLYk/Yyv4t5uTDaFjt wKg1IBHb3PJkgGx8v2nIRtebr3NKHUyY6Yy6mReo/jXj3CdIBuVsTMdVBy00y3Ua3crw LpfHdR/8NljET/x9ALCGiMuR3G7i024ynj2rI= Received: by 10.114.135.12 with SMTP id i12mr55958wad.50.1283551998644; Fri, 03 Sep 2010 15:13:18 -0700 (PDT) Received: from eggplant (d75-157-70-95.bchsia.telus.net [75.157.70.95]) by mx.google.com with ESMTPS id s5sm4605574wak.12.2010.09.03.15.13.16 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 03 Sep 2010 15:13:17 -0700 (PDT) Received: from rcy by eggplant with local (Exim 4.71) (envelope-from ) id 1OreVV-0002gb-67; Fri, 03 Sep 2010 15:13:13 -0700 Date: Fri, 03 Sep 2010 15:13:13 -0700 Message-Id: To: 6076@debbugs.gnu.org Subject: Re: bug#6076: 23.1.96; [PATCH] rcirc-complete for nicks and commands From: Ryan Yeske X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 6076 Cc: Leo , Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) 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 From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 04 04:23:14 2010 Received: (at 6076) by debbugs.gnu.org; 4 Sep 2010 08:23:14 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oro1q-0005uH-Kb for submit@debbugs.gnu.org; Sat, 04 Sep 2010 04:23:14 -0400 Received: from impaqm3.telefonica.net ([213.4.138.3]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oro1o-0005uB-FG for 6076@debbugs.gnu.org; Sat, 04 Sep 2010 04:23:13 -0400 Received: from IMPmailhost4.adm.correo ([10.20.102.125]) by IMPaqm3.telefonica.net with bizsmtp id 2YF31f00A2iL0W23PYQdSb; Sat, 04 Sep 2010 10:24:37 +0200 Received: from ceviche.home ([83.61.33.16]) by IMPmailhost4.adm.correo with BIZ IMP id 2YQb1f0040LsqWj1kYQcSe; Sat, 04 Sep 2010 10:24:37 +0200 X-Brightmail-Tracker: AAAAAA== X-TE-authinfo: authemail="monnier$movistar.es" |auth_email="monnier@movistar.es" X-TE-AcuTerraCos: auth_cuTerraCos="cosuitnetc01" Received: by ceviche.home (Postfix, from userid 20848) id D4814661B8; Sat, 4 Sep 2010 10:24:35 +0200 (CEST) From: Stefan Monnier To: Ryan Yeske Subject: Re: bug#6076: 23.1.96; [PATCH] rcirc-complete for nicks and commands Message-ID: References: Date: Sat, 04 Sep 2010 10:24:35 +0200 In-Reply-To: (Ryan Yeske's message of "Fri, 03 Sep 2010 15:13:13 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 6076 Cc: 6076@debbugs.gnu.org, Leo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) > 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 From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 04 06:19:44 2010 Received: (at 6076) by debbugs.gnu.org; 4 Sep 2010 10:19:44 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OrpqZ-0006eP-UY for submit@debbugs.gnu.org; Sat, 04 Sep 2010 06:19:44 -0400 Received: from ppsw-32.csi.cam.ac.uk ([131.111.8.132]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OrpqX-0006eJ-IA for 6076@debbugs.gnu.org; Sat, 04 Sep 2010 06:19:42 -0400 X-Cam-AntiVirus: no malware found X-Cam-SpamDetails: not scanned X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from cpc1-cmbg13-0-0-cust596.5-4.cable.virginmedia.com ([86.9.122.85]:50607 helo=Victoria.local) by ppsw-32.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.158]:587) with esmtpsa (PLAIN:sl392) (TLSv1:DHE-RSA-AES128-SHA:128) id 1OrpsG-0000sQ-1O (Exim 4.72) (return-path ); Sat, 04 Sep 2010 11:21:28 +0100 From: Leo To: Stefan Monnier Subject: Re: bug#6076: 23.1.96; [PATCH] rcirc-complete for nicks and commands References: Date: Sat, 04 Sep 2010 11:21:27 +0100 In-Reply-To: (Stefan Monnier's message of "Sat, 04 Sep 2010 10:24:35 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (Mac OS X 10.6.4) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -6.3 (------) X-Debbugs-Envelope-To: 6076 Cc: 6076@debbugs.gnu.org, Ryan Yeske X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.3 (------) --=-=-= 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 * 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=rcirc-complete.diff Content-Description: rcirc-complete.diff 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." --=-=-= Regards, Leo --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 04 17:42:38 2010 Received: (at 6076) by debbugs.gnu.org; 4 Sep 2010 21:42:38 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Os0VR-00051R-Ph for submit@debbugs.gnu.org; Sat, 04 Sep 2010 17:42:37 -0400 Received: from impaqm3.telefonica.net ([213.4.138.3]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Os0VP-00051L-Er for 6076@debbugs.gnu.org; Sat, 04 Sep 2010 17:42:36 -0400 Received: from IMPmailhost2.adm.correo ([10.20.102.39]) by IMPaqm3.telefonica.net with bizsmtp id 2b1c1f00B0r0BT63PlkPd4; Sat, 04 Sep 2010 23:44:23 +0200 Received: from ceviche.home ([83.61.51.178]) by IMPmailhost2.adm.correo with BIZ IMP id 2lkN1f0023qhCuj1ilkNMA; Sat, 04 Sep 2010 23:44:23 +0200 X-Brightmail-Tracker: AAAAAA== X-TE-authinfo: authemail="monnier$movistar.es" |auth_email="monnier@movistar.es" X-TE-AcuTerraCos: auth_cuTerraCos="cosuitnetc01" Received: by ceviche.home (Postfix, from userid 20848) id F2F2766115; Sat, 4 Sep 2010 23:44:21 +0200 (CEST) From: Stefan Monnier To: Leo Subject: Re: bug#6076: 23.1.96; [PATCH] rcirc-complete for nicks and commands Message-ID: References: Date: Sat, 04 Sep 2010 23:44:21 +0200 In-Reply-To: (Leo's message of "Sat, 04 Sep 2010 11:21:27 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 6076 Cc: 6076@debbugs.gnu.org, Ryan Yeske X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) > 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 From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 06 13:50:35 2010 Received: (at 6076) by debbugs.gnu.org; 6 Sep 2010 17:50:35 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Osfpy-00088G-UY for submit@debbugs.gnu.org; Mon, 06 Sep 2010 13:50:35 -0400 Received: from ppsw-31.csi.cam.ac.uk ([131.111.8.131]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Osfpx-00088A-LT for 6076@debbugs.gnu.org; Mon, 06 Sep 2010 13:50:34 -0400 X-Cam-AntiVirus: no malware found X-Cam-SpamDetails: not scanned X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from cpc1-cmbg13-0-0-cust596.5-4.cable.virginmedia.com ([86.9.122.85]:57562 helo=Victoria.local) by ppsw-31.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.157]:587) with esmtpsa (PLAIN:sl392) (TLSv1:DHE-RSA-AES128-SHA:128) id 1Osfrn-0001Cv-Jm (Exim 4.72) (return-path ); Mon, 06 Sep 2010 18:52:27 +0100 From: Leo To: Stefan Monnier Subject: Re: bug#6076: 23.1.96; [PATCH] rcirc-complete for nicks and commands References: Date: Mon, 06 Sep 2010 18:52:25 +0100 In-Reply-To: (Stefan Monnier's message of "Sat, 04 Sep 2010 23:44:21 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (Mac OS X 10.6.4) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -6.3 (------) X-Debbugs-Envelope-To: 6076 Cc: 6076@debbugs.gnu.org, Ryan Yeske X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.3 (------) 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 From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 11 08:53:41 2010 Received: (at 6076) by debbugs.gnu.org; 11 Sep 2010 12:53:41 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OuPaO-0000vK-Rh for submit@debbugs.gnu.org; Sat, 11 Sep 2010 08:53:41 -0400 Received: from impaqm4.telefonica.net ([213.4.138.4]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OuPaN-0000u9-CJ for 6076@debbugs.gnu.org; Sat, 11 Sep 2010 08:53:39 -0400 Received: from IMPmailhost4.adm.correo ([10.20.102.125]) by IMPaqm4.telefonica.net with bizsmtp id 5LVE1f00v2iL0W23QQvq61; Sat, 11 Sep 2010 14:55:50 +0200 Received: from ceviche.home ([83.61.39.212]) by IMPmailhost4.adm.correo with BIZ IMP id 5Qvq1f0014aeRwb1kQvqV0; Sat, 11 Sep 2010 14:55:50 +0200 X-Brightmail-Tracker: AAAAAA== X-TE-authinfo: authemail="monnier$movistar.es" |auth_email="monnier@movistar.es" X-TE-AcuTerraCos: auth_cuTerraCos="cosuitnetc01" Received: by ceviche.home (Postfix, from userid 20848) id 07B87660D2; Sat, 11 Sep 2010 14:55:50 +0200 (CEST) From: Stefan Monnier To: Leo Subject: Re: bug#6076: 23.1.96; [PATCH] rcirc-complete for nicks and commands Message-ID: References: Date: Sat, 11 Sep 2010 14:55:50 +0200 In-Reply-To: (Leo's message of "Mon, 06 Sep 2010 18:52:25 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.0 (--) X-Debbugs-Envelope-To: 6076 Cc: 6076@debbugs.gnu.org, Ryan Yeske X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.0 (--) >>> 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 From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 11 09:01:54 2010 Received: (at 6076) by debbugs.gnu.org; 11 Sep 2010 13:01:54 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OuPiL-00019e-K3 for submit@debbugs.gnu.org; Sat, 11 Sep 2010 09:01:54 -0400 Received: from ppsw-31.csi.cam.ac.uk ([131.111.8.131]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OuPiJ-00019N-CL for 6076@debbugs.gnu.org; Sat, 11 Sep 2010 09:01:52 -0400 X-Cam-AntiVirus: no malware found X-Cam-SpamDetails: not scanned X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from cpc1-cmbg13-0-0-cust596.5-4.cable.virginmedia.com ([86.9.122.85]:64253 helo=Victoria.local) by ppsw-31.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.157]:587) with esmtpsa (PLAIN:sl392) (TLSv1:DHE-RSA-AES128-SHA:128) id 1OuPkK-0003lk-Lt (Exim 4.72) (return-path ); Sat, 11 Sep 2010 14:03:57 +0100 From: Leo To: Stefan Monnier Subject: Re: bug#6076: 23.1.96; [PATCH] rcirc-complete for nicks and commands References: Date: Sat, 11 Sep 2010 14:03:55 +0100 In-Reply-To: (Stefan Monnier's message of "Sat, 11 Sep 2010 14:55:50 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (Mac OS X 10.6.4) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -6.3 (------) X-Debbugs-Envelope-To: 6076 Cc: 6076@debbugs.gnu.org, Ryan Yeske X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.3 (------) --=-=-= 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=rcirc-complete.diff Content-Description: rcirc-complete.diff 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." --=-=-= Leo --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 12 11:37:15 2010 Received: (at 6076-done) by debbugs.gnu.org; 12 Sep 2010 15:37:15 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OuocD-0000sQ-VI for submit@debbugs.gnu.org; Sun, 12 Sep 2010 11:37:15 -0400 Received: from impaqm1.telefonica.net ([213.4.138.1]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OukRJ-0006tE-LD for 6076-done@debbugs.gnu.org; Sun, 12 Sep 2010 07:09:42 -0400 Received: from IMPmailhost5.adm.correo ([10.20.102.126]) by IMPaqm1.telefonica.net with bizsmtp id 5gue1f00r2jdgqJ01nBp3L; Sun, 12 Sep 2010 13:11:49 +0200 Received: from ceviche.home ([83.61.39.212]) by IMPmailhost5.adm.correo with BIZ IMP id 5nBn1f00D4aeRwb1lnBofC; Sun, 12 Sep 2010 13:11:49 +0200 X-Brightmail-Tracker: AAAAAA== X-TE-authinfo: authemail="monnier$movistar.es" |auth_email="monnier@movistar.es" X-TE-AcuTerraCos: auth_cuTerraCos="cosuitnetc01" Received: by ceviche.home (Postfix, from userid 20848) id D9E3B660D2; Sun, 12 Sep 2010 13:11:47 +0200 (CEST) From: Stefan Monnier To: Leo Subject: Re: bug#6076: 23.1.96; [PATCH] rcirc-complete for nicks and commands Message-ID: References: Date: Sun, 12 Sep 2010 13:11:47 +0200 In-Reply-To: (Leo's message of "Sat, 11 Sep 2010 14:03:55 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.0 (--) X-Debbugs-Envelope-To: 6076-done X-Mailman-Approved-At: Sun, 12 Sep 2010 11:37:11 -0400 Cc: Ryan Yeske X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.0 (--) > 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 From unknown Sun Aug 10 07:24:16 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 11 Oct 2010 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator