branch: master
commit a98b9faaf95eb503fcc92041d0233fbc8ce75bfb
Author: Steven Allen <[email protected]>
Commit: Steven Allen <[email protected]>
Only parse "Desktop Entry" group
* counsel.el (counsel-linux-apps-list): Desktop files can contain multiple
groups (one "Desktop Entry" and multiple "Desktop Actions"). Ensure we
only
look at the "Desktop Entry" group.
---
counsel.el | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/counsel.el b/counsel.el
index 77ac347..19c7695 100644
--- a/counsel.el
+++ b/counsel.el
@@ -2745,20 +2745,25 @@ And insert it into the minibuffer. Useful during
(dolist (file files result)
(with-temp-buffer
(insert-file-contents (cdr file))
- (let (name comment exec)
+ (goto-char (point-min))
+ (let ((start (re-search-forward "^\\[Desktop Entry\\] *$" nil t))
+ (end (re-search-forward "^\\[" nil t))
+ name comment exec)
(catch 'break
- (goto-char (point-min))
- (unless (re-search-forward "^Name *= *\\(.+\\)$" nil t)
+ (unless start (throw 'break))
+
+ (goto-char start)
+ (unless (re-search-forward "^Name *= *\\(.+\\)$" end t)
(message "Warning: File %s has no Name" (cdr file))
(throw 'break nil))
(setq name (match-string 1))
- (goto-char (point-min))
- (when (re-search-forward "^Comment *= *\\(.+\\)$" nil t)
+ (goto-char start)
+ (when (re-search-forward "^Comment *= *\\(.+\\)$" end t)
(setq comment (match-string 1)))
- (goto-char (point-min))
- (unless (re-search-forward "^Exec *= *\\(.+\\)$" nil t)
+ (goto-char start)
+ (unless (re-search-forward "^Exec *= *\\(.+\\)$" end t)
;; Don't warn because this can technically be a valid desktop
file.
(throw 'break nil))
(setq exec (match-string 1))