emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/ivy-hydra 51fe2ce 097/395: counsel.el (counsel--recentf


From: Basil L. Contovounesios
Subject: [elpa] externals/ivy-hydra 51fe2ce 097/395: counsel.el (counsel--recentf-get-xdg-recent-files): Decode utf-8
Date: Thu, 25 Feb 2021 08:31:39 -0500 (EST)

branch: externals/ivy-hydra
commit 51fe2ce0ae118e378cebfc5e8d6c4f46bf048def
Author: Oleh Krehel <ohwoeowho@gmail.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>

    counsel.el (counsel--recentf-get-xdg-recent-files): Decode utf-8
    
    Re #2403
---
 counsel.el | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/counsel.el b/counsel.el
index 2616b71..fa1afd4 100644
--- a/counsel.el
+++ b/counsel.el
@@ -2254,6 +2254,14 @@ 
https://www.freedesktop.org/wiki/Specifications/desktop-bookmark-spec/.";
                (version< "25" emacs-version)
                (counsel--recentf-get-xdg-recent-files))))
 
+(defun counsel--strip-prefix (prefix str)
+  (let ((l (length prefix)))
+    (when (string= (substring str 0 l) prefix)
+      (substring str l))))
+
+(declare-function dom-attr "dom")
+(declare-function dom-by-tag "dom")
+
 (defun counsel--recentf-get-xdg-recent-files ()
 
   "Get recent files as listed by XDG compliant programs.
@@ -2273,11 +2281,16 @@ provided by the libxml2 bindings and the \"dom\" 
library."
        nil
        (mapcar
         (lambda (bookmark-node)
-          (let ((full-file-name (url-unhex-string
-                                 (substring (dom-attr bookmark-node 'href)
-                                            7)))) ; Strip "file://"
-            (when (file-exists-p full-file-name)
-              full-file-name)))
+          (let ((local-path
+                 (counsel--strip-prefix
+                  "file://" (dom-attr bookmark-node 'href))))
+            (when local-path
+              (let ((full-file-name
+                     (decode-coding-string
+                      (url-unhex-string local-path)
+                      'utf-8)))
+                (when (file-exists-p full-file-name)
+                  full-file-name)))))
         (nreverse (dom-by-tag (with-temp-buffer
                                 (insert-file-contents file-of-recent-files)
                                 (libxml-parse-xml-region (point-min)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]