From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Leo Newsgroups: gmane.emacs.bugs Subject: bug#7090: 23.2; [PATCH] Fix return value of dnd-get-local-file-name Date: Thu, 23 Sep 2010 14:02:42 +0100 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1285247477 24895 80.91.229.12 (23 Sep 2010 13:11:17 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 23 Sep 2010 13:11:17 +0000 (UTC) To: 7090@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Sep 23 15:11:15 2010 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.69) (envelope-from ) id 1OylZx-0005hG-D6 for geb-bug-gnu-emacs@m.gmane.org; Thu, 23 Sep 2010 15:11:14 +0200 Original-Received: from localhost ([127.0.0.1]:60357 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OylZw-0004cq-C1 for geb-bug-gnu-emacs@m.gmane.org; Thu, 23 Sep 2010 09:11:12 -0400 Original-Received: from [140.186.70.92] (port=48512 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OylZo-0004cl-T6 for bug-gnu-emacs@gnu.org; Thu, 23 Sep 2010 09:11:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OylZn-0001Ui-KQ for bug-gnu-emacs@gnu.org; Thu, 23 Sep 2010 09:11:04 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:46104) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OylZn-0001Ue-Ip for bug-gnu-emacs@gnu.org; Thu, 23 Sep 2010 09:11:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1OylQ8-0003WH-EI; Thu, 23 Sep 2010 09:01:04 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Leo Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 23 Sep 2010 13:01:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 7090 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.128524681413512 (code B ref -1); Thu, 23 Sep 2010 13:01:04 +0000 Original-Received: (at submit) by debbugs.gnu.org; 23 Sep 2010 13:00:14 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OylPJ-0003Vt-Uf for submit@debbugs.gnu.org; Thu, 23 Sep 2010 09:00:14 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OylPH-0003Vm-9m for submit@debbugs.gnu.org; Thu, 23 Sep 2010 09:00:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OylRn-0008Ju-T5 for submit@debbugs.gnu.org; Thu, 23 Sep 2010 09:02:48 -0400 Original-Received: from lists.gnu.org ([199.232.76.165]:40903) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OylRn-0008Jp-Qo for submit@debbugs.gnu.org; Thu, 23 Sep 2010 09:02:47 -0400 Original-Received: from [140.186.70.92] (port=35785 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OylRm-00037E-GJ for bug-gnu-emacs@gnu.org; Thu, 23 Sep 2010 09:02:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OylRl-0008JI-1S for bug-gnu-emacs@gnu.org; Thu, 23 Sep 2010 09:02:46 -0400 Original-Received: from ppsw-31.csi.cam.ac.uk ([131.111.8.131]:50876) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OylRk-0008Iv-RU for bug-gnu-emacs@gnu.org; Thu, 23 Sep 2010 09:02:45 -0400 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 cpc1-cmbg13-0-0-cust596.5-4.cable.virginmedia.com ([86.9.122.85]:63141 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 1OylRj-0000S8-KT (Exim 4.72) for bug-gnu-emacs@gnu.org (return-path ); Thu, 23 Sep 2010 14:02:43 +0100 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 23 Sep 2010 09:01:04 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org 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:40380 Archived-At: `dnd-get-local-file-name' returns nil when must-exist is nil, which contradicts its doc string. The patch fixes this. diff --git a/lisp/dnd.el b/lisp/dnd.el index d7cbb64..ef41b76 100644 --- a/lisp/dnd.el +++ b/lisp/dnd.el @@ -137,7 +137,7 @@ Return nil if URI is not a local file." (defun dnd-get-local-file-name (uri &optional must-exist) "Return file name converted from file:/// or file: syntax. URI is the uri for the file. If MUST-EXIST is given and non-nil, -only return non-nil if the file exists. +only return non-nil if the file is readable. Return nil if URI is not a local file." (let ((f (cond ((string-match "^file:///" uri) ; XDND format. (substring uri (1- (match-end 0)))) @@ -154,9 +154,11 @@ Return nil if URI is not a local file." (let* ((decoded-f (decode-coding-string f (or file-name-coding-system - default-file-name-coding-system))) - (try-f (if (file-readable-p decoded-f) decoded-f f))) - (when (file-readable-p try-f) try-f))))) + default-file-name-coding-system)))) + (setq f (cond ((file-readable-p decoded-f) decoded-f) + ((file-readable-p f) f) + (t nil))))) + f)) (defun dnd-open-local-file (uri action)