aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMark Oteiza2017-09-09 00:46:41 -0400
committerMark Oteiza2017-09-09 00:46:41 -0400
commitbe9bc8e67d6caf6d61fe4f46ac5b640ada16ba95 (patch)
tree4042d8c5def741ddf3397925bfd213f2efba8495 /lisp
parentce9640845155c1dd9c11e46104f223af7cd4f7fa (diff)
downloademacs-be9bc8e67d6caf6d61fe4f46ac5b640ada16ba95.tar.gz
emacs-be9bc8e67d6caf6d61fe4f46ac5b640ada16ba95.zip
; 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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/xdg.el39
1 files changed, 18 insertions, 21 deletions
diff --git a/lisp/xdg.el b/lisp/xdg.el
index 4b255429db4..c7000219487 100644
--- a/lisp/xdg.el
+++ b/lisp/xdg.el
@@ -143,12 +143,11 @@ This should be called at the beginning of a line."
143 res)) 143 res))
144 144
145(defun xdg-user-dir (name) 145(defun xdg-user-dir (name)
146 "Return the path of user directory referred to by NAME." 146 "Return the directory referred to by NAME."
147 (when (null xdg-user-dirs) 147 (when (null xdg-user-dirs)
148 (save-match-data 148 (setq xdg-user-dirs
149 (setq xdg-user-dirs 149 (xdg--user-dirs-parse-file
150 (xdg--user-dirs-parse-file 150 (expand-file-name "user-dirs.dirs" (xdg-config-home)))))
151 (expand-file-name "user-dirs.dirs" (xdg-config-home))))))
152 (let ((dir (cdr (assoc name xdg-user-dirs)))) 151 (let ((dir (cdr (assoc name xdg-user-dirs))))
153 (when dir (expand-file-name dir)))) 152 (when dir (expand-file-name dir))))
154 153
@@ -182,27 +181,25 @@ This should be called at the beginning of a line."
182 (let ((res (make-hash-table :test #'equal)) 181 (let ((res (make-hash-table :test #'equal))
183 elt group) 182 elt group)
184 (with-temp-buffer 183 (with-temp-buffer
185 (save-match-data 184 (insert-file-contents-literally filename)
186 (insert-file-contents-literally filename) 185 (goto-char (point-min))
187 (goto-char (point-min)) 186 (while (or (= (following-char) ?#)
188 (while (or (= (following-char) ?#) 187 (string-blank-p (buffer-substring (point) (point-at-eol))))
189 (string-blank-p (buffer-substring (point) (point-at-eol)))) 188 (forward-line))
190 (forward-line)) 189 (unless (equal (setq group (xdg--desktop-parse-line)) "Desktop Entry")
191 (unless (equal (setq group (xdg--desktop-parse-line)) "Desktop Entry") 190 (error "Wrong first section: %s" group))
192 (error "Wrong first section: %s" group)) 191 (while (not (eobp))
193 (while (not (eobp)) 192 (when (consp (setq elt (xdg--desktop-parse-line)))
194 (when (consp (setq elt (xdg--desktop-parse-line))) 193 (puthash (car elt) (cdr elt) res))
195 (puthash (car elt) (cdr elt) res)) 194 (forward-line)))
196 (forward-line))))
197 res)) 195 res))
198 196
199(defun xdg-desktop-strings (value) 197(defun xdg-desktop-strings (value)
200 "Partition VALUE into elements delimited by unescaped semicolons." 198 "Partition VALUE into elements delimited by unescaped semicolons."
201 (let (res) 199 (let (res)
202 (save-match-data 200 (setq value (string-trim-left value))
203 (setq value (string-trim-left value)) 201 (dolist (x (split-string (replace-regexp-in-string "\\\\;" "\0" value) ";"))
204 (dolist (x (split-string (replace-regexp-in-string "\\\\;" "\0" value) ";")) 202 (push (replace-regexp-in-string "\0" ";" x) res))
205 (push (replace-regexp-in-string "\0" ";" x) res)))
206 (when (null (string-match-p "[^[:blank:]]" (car res))) (pop res)) 203 (when (null (string-match-p "[^[:blank:]]" (car res))) (pop res))
207 (nreverse res))) 204 (nreverse res)))
208 205