emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master be9bc8e: ; Fix previous commit


From: Mark Oteiza
Subject: [Emacs-diffs] master be9bc8e: ; Fix previous commit
Date: Sat, 9 Sep 2017 00:50:06 -0400 (EDT)

branch: master
commit be9bc8e67d6caf6d61fe4f46ac5b640ada16ba95
Author: Mark Oteiza <address@hidden>
Commit: Mark Oteiza <address@hidden>

    ; Fix previous commit
    
    See https://lists.gnu.org/archive/html/emacs-devel/2017-09/msg00101.html
    * test/lisp/xdg.el: Remove match data tests.
    * lisp/xdg.el (xdg-user-dir): Fix docstring. Remove save-match-data.
    (xdg-desktop-read-file, xdg-desktop-strings): Remove save-match-data.
---
 lisp/xdg.el            | 39 ++++++++++++++++++---------------------
 test/lisp/xdg-tests.el | 19 -------------------
 2 files changed, 18 insertions(+), 40 deletions(-)

diff --git a/lisp/xdg.el b/lisp/xdg.el
index 4b25542..c700021 100644
--- a/lisp/xdg.el
+++ b/lisp/xdg.el
@@ -143,12 +143,11 @@ This should be called at the beginning of a line."
     res))
 
 (defun xdg-user-dir (name)
-  "Return the path of user directory referred to by NAME."
+  "Return the directory referred to by NAME."
   (when (null xdg-user-dirs)
-    (save-match-data
-      (setq xdg-user-dirs
-            (xdg--user-dirs-parse-file
-             (expand-file-name "user-dirs.dirs" (xdg-config-home))))))
+    (setq xdg-user-dirs
+          (xdg--user-dirs-parse-file
+           (expand-file-name "user-dirs.dirs" (xdg-config-home)))))
   (let ((dir (cdr (assoc name xdg-user-dirs))))
     (when dir (expand-file-name dir))))
 
@@ -182,27 +181,25 @@ This should be called at the beginning of a line."
   (let ((res (make-hash-table :test #'equal))
         elt group)
     (with-temp-buffer
-      (save-match-data
-        (insert-file-contents-literally filename)
-        (goto-char (point-min))
-        (while (or (= (following-char) ?#)
-                   (string-blank-p (buffer-substring (point) (point-at-eol))))
-          (forward-line))
-        (unless (equal (setq group (xdg--desktop-parse-line)) "Desktop Entry")
-          (error "Wrong first section: %s" group))
-        (while (not (eobp))
-          (when (consp (setq elt (xdg--desktop-parse-line)))
-            (puthash (car elt) (cdr elt) res))
-          (forward-line))))
+      (insert-file-contents-literally filename)
+      (goto-char (point-min))
+      (while (or (= (following-char) ?#)
+                 (string-blank-p (buffer-substring (point) (point-at-eol))))
+        (forward-line))
+      (unless (equal (setq group (xdg--desktop-parse-line)) "Desktop Entry")
+        (error "Wrong first section: %s" group))
+      (while (not (eobp))
+        (when (consp (setq elt (xdg--desktop-parse-line)))
+          (puthash (car elt) (cdr elt) res))
+        (forward-line)))
     res))
 
 (defun xdg-desktop-strings (value)
   "Partition VALUE into elements delimited by unescaped semicolons."
   (let (res)
-    (save-match-data
-      (setq value (string-trim-left value))
-      (dolist (x (split-string (replace-regexp-in-string "\\\\;" "\0" value) 
";"))
-        (push (replace-regexp-in-string "\0" ";" x) res)))
+    (setq value (string-trim-left value))
+    (dolist (x (split-string (replace-regexp-in-string "\\\\;" "\0" value) 
";"))
+      (push (replace-regexp-in-string "\0" ";" x) res))
     (when (null (string-match-p "[^[:blank:]]" (car res))) (pop res))
     (nreverse res)))
 
diff --git a/test/lisp/xdg-tests.el b/test/lisp/xdg-tests.el
index e7e122b..59c850b 100644
--- a/test/lisp/xdg-tests.el
+++ b/test/lisp/xdg-tests.el
@@ -3,7 +3,6 @@
 ;; Copyright (C) 2017  Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
-
 ;; Author: Mark Oteiza <address@hidden>
 
 ;; This file is part of GNU Emacs.
@@ -31,24 +30,6 @@
 (defconst xdg-tests-data-dir
   (expand-file-name "test/data/xdg" source-directory))
 
-(ert-deftest xdg-match-data ()
-  "Ensure public functions do not mangle match data."
-  (let ((data '(1 9)))
-    (save-match-data
-      (set-match-data data)
-      (xdg-user-dir "DOCUMENTS")
-      (should (equal (match-data) data))))
-  (let ((data '(2 9)))
-    (save-match-data
-      (set-match-data data)
-      (xdg-desktop-read-file (expand-file-name "test.desktop" 
xdg-tests-data-dir))
-      (should (equal (match-data) data))))
-  (let ((data '(3 9)))
-    (save-match-data
-      (set-match-data data)
-      (xdg-desktop-strings "a;b")
-      (should (equal (match-data) data)))))
-
 (ert-deftest xdg-desktop-parsing ()
   "Test `xdg-desktop-read-file' parsing of .desktop files."
   (let ((tab (xdg-desktop-read-file



reply via email to

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