Gentoo Archives: gentoo-commits

From: "Ulrich Müller" <ulm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/emacs-tools:ebuild-mode commit in: /
Date: Tue, 28 Feb 2017 19:24:01
Message-Id: 1484505940.c3dd382167167a06ff2abd4b53ffbbd1a16a9e0e.ulm@gentoo
1 commit: c3dd382167167a06ff2abd4b53ffbbd1a16a9e0e
2 Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
3 AuthorDate: Sun Jan 15 18:45:40 2017 +0000
4 Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
5 CommitDate: Sun Jan 15 18:45:40 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/emacs-tools.git/commit/?id=c3dd3821
7
8 Improve error handling when no KEYWORDS line is found.
9
10 * ebuild-mode.el (ebuild-mode-get-keywords)
11 (ebuild-mode-put-keywords): Improve error handling.
12
13 ChangeLog | 5 +++++
14 ebuild-mode.el | 40 ++++++++++++++++++++++------------------
15 2 files changed, 27 insertions(+), 18 deletions(-)
16
17 diff --git a/ChangeLog b/ChangeLog
18 index 0a98fb3..a28c4c4 100644
19 --- a/ChangeLog
20 +++ b/ChangeLog
21 @@ -1,3 +1,8 @@
22 +2017-01-15 Ulrich Müller <ulm@g.o>
23 +
24 + * ebuild-mode.el (ebuild-mode-get-keywords)
25 + (ebuild-mode-put-keywords): Improve error handling.
26 +
27 2016-06-19 Ulrich Müller <ulm@g.o>
28
29 * Version 1.31 released.
30
31 diff --git a/ebuild-mode.el b/ebuild-mode.el
32 index a088db6..5ccc63d 100644
33 --- a/ebuild-mode.el
34 +++ b/ebuild-mode.el
35 @@ -269,29 +269,33 @@ Optional argument LIMIT restarts collection after that number of elements."
36 (save-excursion
37 (goto-char (point-min))
38 (let ((case-fold-search nil))
39 - (and (re-search-forward ebuild-mode-arch-regexp nil noerror)
40 - (not (and (re-search-forward ebuild-mode-arch-regexp nil t)
41 - (or noerror
42 - (error "More than one KEYWORDS assignment found"))))
43 - (mapcar (lambda (s)
44 - (string-match "^\\([-~]?\\)\\(.*\\)" s)
45 - (cons (match-string 2 s) (match-string 1 s)))
46 - (split-string
47 - ;;(match-string-no-properties 1) ; not in XEmacs 21.4
48 - (buffer-substring-no-properties (match-beginning 1)
49 - (match-end 1))))))))
50 + (cond
51 + ((not (re-search-forward ebuild-mode-arch-regexp nil t))
52 + (unless noerror (error "No KEYWORDS assignment found")))
53 + ((re-search-forward ebuild-mode-arch-regexp nil t) ; second search
54 + (unless noerror (error "More than one KEYWORDS assignment found")))
55 + (t
56 + (mapcar (lambda (s)
57 + (string-match "^\\([-~]?\\)\\(.*\\)" s)
58 + (cons (match-string 2 s) (match-string 1 s)))
59 + (split-string
60 + ;;(match-string-no-properties 1) ; not in XEmacs 21.4
61 + (buffer-substring-no-properties (match-beginning 1)
62 + (match-end 1)))))))))
63
64 (defun ebuild-mode-put-keywords (kw &optional noerror)
65 (save-excursion
66 (goto-char (point-min))
67 (let ((case-fold-search nil))
68 - (and (re-search-forward ebuild-mode-arch-regexp nil noerror)
69 - (not (and (re-search-forward ebuild-mode-arch-regexp nil t)
70 - (or noerror
71 - (error "More than one KEYWORDS assignment found"))))
72 - (replace-match
73 - (mapconcat (lambda (e) (concat (cdr e) (car e))) kw " ")
74 - t t nil 1)))))
75 + (cond
76 + ((not (re-search-forward ebuild-mode-arch-regexp nil t))
77 + (unless noerror (error "No KEYWORDS assignment found")))
78 + ((re-search-forward ebuild-mode-arch-regexp nil t)
79 + (unless noerror (error "More than one KEYWORDS assignment found")))
80 + (t
81 + (replace-match
82 + (mapconcat (lambda (e) (concat (cdr e) (car e))) kw " ")
83 + t t nil 1))))))
84
85 (defun ebuild-mode-modify-keywords (kw)
86 "Set keywords. KW is an alist of architectures and leaders."