GNU bug report logs - #7090
23.2; [PATCH] Fix return value of dnd-get-local-file-name

Previous Next

Package: emacs;

Reported by: Leo <sdl.web <at> gmail.com>

Date: Thu, 23 Sep 2010 13:01:04 UTC

Severity: normal

Tags: patch

Found in version 23.2

Fixed in version 23.3

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Leo <sdl.web <at> gmail.com>
To: 7090 <at> debbugs.gnu.org
Subject: bug#7090: 23.2; [PATCH] Fix return value of dnd-get-local-file-name
Date: Thu, 23 Sep 2010 14:02:42 +0100
`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)




This bug report was last modified 14 years and 169 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.