From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: C-r and C-s in minibuffer should search completion Date: Sun, 20 Apr 2008 01:46:55 +0300 Organization: JURTA Message-ID: <873aph5v28.fsf@jurta.org> References: <87lk440z31.fsf@jurta.org> <87od8xccz6.fsf@jurta.org> <87hceouksk.fsf@jurta.org> <87y77zlqji.fsf@jurta.org> <873aq2czp4.fsf@jurta.org> <871w5j2ca1.fsf@jurta.org> <87r6d6vjg2.fsf@jurta.org> <87od89sb4y.fsf@jurta.org> <87mynsrg9m.fsf@jurta.org> <87zlrp8zn1.fsf@jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1208647939 16414 80.91.229.12 (19 Apr 2008 23:32:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Apr 2008 23:32:19 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 20 01:32:53 2008 connect(): Connection refused Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JnMY8-00021V-Dq for ged-emacs-devel@m.gmane.org; Sun, 20 Apr 2008 01:32:53 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JnMXS-0005xl-Ph for ged-emacs-devel@m.gmane.org; Sat, 19 Apr 2008 19:32:10 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JnMXO-0005wh-Nu for emacs-devel@gnu.org; Sat, 19 Apr 2008 19:32:06 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JnMXN-0005wC-QB for emacs-devel@gnu.org; Sat, 19 Apr 2008 19:32:06 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JnMXN-0005w9-Is for emacs-devel@gnu.org; Sat, 19 Apr 2008 19:32:05 -0400 Original-Received: from mx20.gnu.org ([199.232.41.8]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JnMXN-0000S6-50 for emacs-devel@gnu.org; Sat, 19 Apr 2008 19:32:05 -0400 Original-Received: from relay03.kiev.sovam.com ([62.64.120.201]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JnMEh-0000J1-7M for emacs-devel@gnu.org; Sat, 19 Apr 2008 19:12:47 -0400 Original-Received: from [83.170.232.243] (helo=smtp.svitonline.com) by relay03.kiev.sovam.com with esmtp (Exim 4.67) (envelope-from ) id 1JnMEc-0001AW-4n; Sun, 20 Apr 2008 02:12:42 +0300 In-Reply-To: (Stefan Monnier's message of "Sat, 19 Apr 2008 17:10:16 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu) X-Scanner-Signature: e3b942a55251a77f49093e43cd2f7d51 X-DrWeb-checked: yes X-SpamTest-Envelope-From: juri@jurta.org X-SpamTest-Group-ID: 00000000 X-SpamTest-Header: Not Detected X-SpamTest-Info: Profiles 2676 [Apr 18 2008] X-SpamTest-Info: helo_type=3 X-SpamTest-Info: {HEADERS: header Content-Type found without required header Content-Transfer-Encoding} X-SpamTest-Method: none X-SpamTest-Rate: 10 X-SpamTest-Status: Not detected X-SpamTest-Status-Extended: not_detected X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0278], KAS30/Release X-detected-kernel: by mx20.gnu.org: FreeBSD 6.x (1) X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:95497 Archived-At: >> by having both in Lisp with removing possible problems of using >> Vbuffer_alist that you mentioned. > > Yes, except that your proposal doesn't remove possible problems with using > Vbuffer_alist (that problem is if someone gets hold of this list > and does things like "rplcd" (i.e. setcdr) on it). That is why I propose creating a function `buffer-alist' that returns a copy of Vbuffer_alist, not using this variable directly. So modifications on this alist would be impossible. >>> Or you could define it on top of the internal-complete-buffer code, >>> using the `predicate' argument. > >> Do you mean something like > >> (defun internal-complete-buffer-sans-current (string predicate flag) >> "Perform completion on buffer names excluding the current buffer. >> Like `internal-complete-buffer', but removes the current buffer from >> the completion list." >> (let ((current-buffer (buffer-name (other-buffer (current-buffer) t)))) >> (internal-complete-buffer >> string (lambda (buffer) (not (equal current-buffer buffer))) flag))) > > Yes, except it should not ignore `predicate'. > You could define it in terms of completion-table-with-predicate (100% > untested code, of course): > > (defun internal-complete-buffer-except (&optional buf) > (lexical-let ((except (if (stringp buf) buf (buffer-name buf)))) > (apply-partially 'completion-table-with-predicate > 'internal-complete-buffer > (lambda (name) (not (equal name except))) > nil))) This works correctly in the following patch: Index: lisp/minibuffer.el =================================================================== RCS file: /sources/emacs/emacs/lisp/minibuffer.el,v retrieving revision 1.18 diff -c -r1.18 minibuffer.el *** lisp/minibuffer.el 19 Apr 2008 03:34:02 -0000 1.18 --- lisp/minibuffer.el 19 Apr 2008 22:46:29 -0000 *************** *** 758,763 **** --- 758,772 ---- 'completion--file-name-table) "Internal subroutine for `read-file-name'. Do not call this.") + (defun internal-complete-buffer-except (&optional buffer) + "Perform completion on all buffers excluding BUFFER. + Like `internal-complete-buffer', but removes BUFFER from the completion list." + (lexical-let ((except (if (stringp buffer) buffer (buffer-name buffer)))) + (apply-partially 'completion-table-with-predicate + 'internal-complete-buffer + (lambda (name) (not (equal name except))) + nil))) + (provide 'minibuffer) ;; arch-tag: ef8a0a15-1080-4790-a754-04017c02f08f Index: lisp/files.el =================================================================== RCS file: /sources/emacs/emacs/lisp/files.el,v retrieving revision 1.971 diff -c -r1.971 files.el *** lisp/files.el 19 Apr 2008 03:33:12 -0000 1.971 --- lisp/files.el 19 Apr 2008 22:46:42 -0000 *************** *** 1039,1044 **** --- 1039,1054 ---- (rename-file encoded new-encoded ok-if-already-exists) newname)) + (defun read-buffer-to-switch (prompt) + "Read the name of a buffer to switch to and return as a string. + It is intended for `switch-to-buffer' family of commands since they + need to omit the name of current buffer from the list of defaults." + (minibuffer-with-setup-hook + (lambda () + (set (make-local-variable 'minibuffer-completion-table) + (internal-complete-buffer-except (other-buffer (current-buffer) t)))) + (read-buffer prompt (other-buffer (current-buffer))))) + (defun switch-to-buffer-other-window (buffer &optional norecord) "Select buffer BUFFER in another window. If BUFFER does not identify an existing buffer, then this function *************** *** 1053,1059 **** This uses the function `display-buffer' as a subroutine; see its documentation for additional customization information." ! (interactive "BSwitch to buffer in other window: ") (let ((pop-up-windows t) ;; Don't let these interfere. same-window-buffer-names same-window-regexps) --- 1063,1070 ---- This uses the function `display-buffer' as a subroutine; see its documentation for additional customization information." ! (interactive ! (list (read-buffer-to-switch "Switch to buffer in other window: "))) (let ((pop-up-windows t) ;; Don't let these interfere. same-window-buffer-names same-window-regexps) *************** *** 1067,1073 **** This uses the function `display-buffer' as a subroutine; see its documentation for additional customization information." ! (interactive "BSwitch to buffer in other frame: ") (let ((pop-up-frames t) same-window-buffer-names same-window-regexps) (prog1 --- 1078,1085 ---- This uses the function `display-buffer' as a subroutine; see its documentation for additional customization information." ! (interactive ! (list (read-buffer-to-switch "Switch to buffer in other frame: "))) (let ((pop-up-frames t) same-window-buffer-names same-window-regexps) (prog1 *************** *** 1978,1984 **** (if (fboundp 'ucs-set-table-for-input) ; don't lose when building (ucs-set-table-for-input))) ! (defcustom auto-mode-case-fold nil "Non-nil means to try second pass through `auto-mode-alist'. This means that if the first case-sensitive search through the alist fails to find a matching major mode, a second case-insensitive search is made. --- 1990,1996 ---- (if (fboundp 'ucs-set-table-for-input) ; don't lose when building (ucs-set-table-for-input))) ! (defcustom auto-mode-case-fold t "Non-nil means to try second pass through `auto-mode-alist'. This means that if the first case-sensitive search through the alist fails to find a matching major mode, a second case-insensitive search is made. -- Juri Linkov http://www.jurta.org/emacs/