Re: Please test this apps-menu.jl fix



Teika Kazura <teika lavabit com> writes:

> Thanks Matthew, for testing and kind offer. Please do it, if there
> indeed exists such file which is in fact totally legitimate.
>
> Regards,
> Teika (Teika kazura)
>
>

Hi Teika and list,

Here it is, please test if you have time.  This will now allow a
.desktop file to have a comment or white space at the begining of the
file, and will still skip the file if the first valid line is not the
expected '[Desktop Entry]'.


Cheers

diff --git a/lisp/sawfish/wm/ext/apps-menu.jl b/lisp/sawfish/wm/ext/apps-menu.jl
index 19e1e8f..2eaddf6 100644
--- a/lisp/sawfish/wm/ext/apps-menu.jl
+++ b/lisp/sawfish/wm/ext/apps-menu.jl
@@ -82,17 +82,25 @@ set this to non-nil.")
 
   ;; fdo-desktop-file-parsing
 
+  (define (desktop-skip-line-p instring)
+    (or (eq (aref instring 0) ?#)
+	(eq (aref instring 0) ?\n)))
+
+  (define (check-if-desktop-stream instream)
+    (let ((check-stream (read-line instream)))
+      (if check-stream
+	  (if (string= check-stream "[Desktop Entry]\n") 
+	      't
+	    (if (desktop-skip-line-p check-stream)
+		(check-desktop-file instream))))))
+
   (define (desktop-file-p directory-file)
     (condition-case nil
 	(let ((this-file (open-file directory-file 'read)))
-	  (string= (read-line this-file) "[Desktop Entry]\n"))
+	  (check-if-desktop-stream this-file))
       ;; unreadable -> return nil
       (file-error)))
 
-  (define (desktop-skip-line-p instring)
-    (or (eq (aref instring 0) ?#)
-	(eq (aref instring 0) ?\n)))
-
   (define (desktop-group-p instring)
     (eq (aref instring 0) ?\[))
 
-- 

Matthew


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]