From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stephen Eglen Newsgroups: gmane.emacs.bugs Subject: bug#4050: 23.1.50; iswitchb virtual buffers don't play well with symlinks Date: Tue, 15 Sep 2009 12:00:22 +0100 Message-ID: <25602.1253012422@maps> Reply-To: Stephen Eglen , 4050@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1253012892 6378 80.91.229.12 (15 Sep 2009 11:08:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 15 Sep 2009 11:08:12 +0000 (UTC) Cc: Tassilo Horn , Stephen Eglen , 4050@emacsbugs.donarmstrong.com To: Chong Yidong Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Sep 15 13:08:03 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MnVtB-0000Nk-HP for geb-bug-gnu-emacs@m.gmane.org; Tue, 15 Sep 2009 13:08:01 +0200 Original-Received: from localhost ([127.0.0.1]:42985 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MnVt9-0008KI-PW for geb-bug-gnu-emacs@m.gmane.org; Tue, 15 Sep 2009 07:07:59 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MnVsK-00083Q-AF for bug-gnu-emacs@gnu.org; Tue, 15 Sep 2009 07:07:08 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MnVsF-00082M-Kf for bug-gnu-emacs@gnu.org; Tue, 15 Sep 2009 07:07:08 -0400 Original-Received: from [199.232.76.173] (port=48815 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MnVsF-00082J-HV for bug-gnu-emacs@gnu.org; Tue, 15 Sep 2009 07:07:03 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:45562) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MnVsE-0002SX-Q8 for bug-gnu-emacs@gnu.org; Tue, 15 Sep 2009 07:07:03 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n8FB70XZ021612; Tue, 15 Sep 2009 04:07:00 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id n8FB5ANZ020691; Tue, 15 Sep 2009 04:05:10 -0700 Resent-Date: Tue, 15 Sep 2009 04:05:10 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Stephen Eglen Original-Sender: sje30@damtp.cam.ac.uk Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Tue, 15 Sep 2009 11:05:09 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 4050 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 4050-submit@emacsbugs.donarmstrong.com id=B4050.125301242718605 (code B ref 4050); Tue, 15 Sep 2009 11:05:09 +0000 Original-Received: (at 4050) by emacsbugs.donarmstrong.com; 15 Sep 2009 11:00:27 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from ppsw-5.csi.cam.ac.uk (ppsw-5.csi.cam.ac.uk [131.111.8.135]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n8FB0Peg018597 for <4050@emacsbugs.donarmstrong.com>; Tue, 15 Sep 2009 04:00:26 -0700 X-Cam-AntiVirus: no malware found X-Cam-SpamDetails: not scanned X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Original-Received: from lapc-br1-003.maths.private.cam.ac.uk ([172.16.218.3]:49663 helo=maps) by ppsw-5.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.135]:25) with esmtp id 1MnVln-0004kp-HP (Exim 4.70) (return-path ); Tue, 15 Sep 2009 12:00:23 +0100 Original-Received: from stephen (helo=maps) by maps with local-esmtp (Exim 4.69) (envelope-from ) id 1MnVlm-0006ex-KR; Tue, 15 Sep 2009 12:00:22 +0100 X-Mailer: MH-E 8.2; nmh 1.2; GNU Emacs 23.1.1 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Tue, 15 Sep 2009 07:07:07 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:31105 Archived-At: --=-=-= I've looked athe bug that Tassilo submitted, and can see the problem. It occurs when the name of the symlink differs from the name of the file pointed to. e.g. if I do ln -s teach txt/org/teaching.org Then if I have previously visited the file as 'teach', Emacs opens it as 'teach', rather than 'teaching.org' When iswitchb opens teach, it uses find-file-noselect, which opens the file 'teaching.org' with that name as the buffer, rather than using the name 'teach'. The fix then is to tell iswitchb to use the name returned by find-file-noselect. I've attached a new version of the function iswitchb-read-buffer - please can you test it to see that it solves the problem for you Tassilo, and then I'll commit a patch. I guess the only issue is whether the buffer should be called the name of the symlink 'teach' or the name of the real file 'teaching.org' - is there a way to tell Emacs to prefer the symlink name? Thanks for the report -- I didn't even follow the recentf code in iswitchb, it was contributed by someone else. Stephen --=-=-= Content-Type: text/x-lisp Content-Disposition: attachment; filename=i.el (defun iswitchb-read-buffer (prompt &optional default require-match start matches-set) "Replacement for the built-in `read-buffer'. Return the name of a buffer selected. PROMPT is the prompt to give to the user. DEFAULT if given is the default buffer to be selected, which will go to the front of the list. If REQUIRE-MATCH is non-nil, an existing buffer must be selected. If START is a string, the selection process is started with that string. If MATCHES-SET is non-nil, the buflist is not updated before the selection process begins. Used by isearchb.el." (let ( buf-sel iswitchb-final-text (icomplete-mode nil) ;; prevent icomplete starting up ) (iswitchb-define-mode-map) (setq iswitchb-exit nil) (setq iswitchb-default (if (bufferp default) (buffer-name default) default)) (setq iswitchb-text (or start "")) (unless matches-set (setq iswitchb-rescan t) (iswitchb-make-buflist iswitchb-default) (iswitchb-set-matches)) (let ((minibuffer-local-completion-map iswitchb-mode-map) ;; Record the minibuffer depth that we expect to find once ;; the minibuffer is set up and iswitchb-entryfn-p is called. (iswitchb-minibuf-depth (1+ (minibuffer-depth))) (iswitchb-require-match require-match)) ;; prompt the user for the buffer name (setq iswitchb-final-text (completing-read prompt ;the prompt '(("dummy" . 1)) ;table nil ;predicate nil ;require-match [handled elsewhere] start ;initial-contents 'iswitchb-history))) (if (and (not (eq iswitchb-exit 'usefirst)) (get-buffer iswitchb-final-text)) ;; This happens for example if the buffer was chosen with the mouse. (setq iswitchb-matches (list iswitchb-final-text) iswitchb-virtual-buffers nil)) ;; If no buffer matched, but a virtual buffer was selected, visit ;; that file now and act as though that buffer had been selected. (if (and iswitchb-virtual-buffers (not (iswitchb-existing-buffer-p))) (let ((virt (car iswitchb-virtual-buffers)) (new-buf)) ;; Keep the name of the buffer returned by find-file-noselect, as ;; the buffer 'virt' could be a symlink to a file of a different name. (setq new-buf (buffer-name (find-file-noselect (cdr virt)))) (setq iswitchb-matches (list new-buf) iswitchb-virtual-buffers nil))) ;; Handling the require-match must be done in a better way. (if (and require-match (not (iswitchb-existing-buffer-p))) (error "Must specify valid buffer")) (if (or (eq iswitchb-exit 'takeprompt) (null iswitchb-matches)) (setq buf-sel iswitchb-final-text) ;; else take head of list (setq buf-sel (car iswitchb-matches))) ;; Or possibly choose the default buffer (if (equal iswitchb-final-text "") (setq buf-sel (car iswitchb-matches))) buf-sel)) --=-=-=--