diff options
| -rw-r--r-- | lisp/emacs-lisp/map.el | 5 | ||||
| -rw-r--r-- | test/automated/map-tests.el | 26 |
2 files changed, 15 insertions, 16 deletions
diff --git a/lisp/emacs-lisp/map.el b/lisp/emacs-lisp/map.el index 4e7d3b91b16..ea56efefe97 100644 --- a/lisp/emacs-lisp/map.el +++ b/lisp/emacs-lisp/map.el | |||
| @@ -262,8 +262,9 @@ MAP can be a list, hash-table or array." | |||
| 262 | MAP can be a list, hash-table or array." | 262 | MAP can be a list, hash-table or array." |
| 263 | (catch 'map--break | 263 | (catch 'map--break |
| 264 | (map-apply (lambda (key value) | 264 | (map-apply (lambda (key value) |
| 265 | (when (funcall pred key value) | 265 | (let ((result (funcall pred key value))) |
| 266 | (throw 'map--break (cons key value)))) | 266 | (when result |
| 267 | (throw 'map--break result)))) | ||
| 267 | map) | 268 | map) |
| 268 | nil)) | 269 | nil)) |
| 269 | 270 | ||
diff --git a/test/automated/map-tests.el b/test/automated/map-tests.el index ca680041944..8693415a784 100644 --- a/test/automated/map-tests.el +++ b/test/automated/map-tests.el | |||
| @@ -262,21 +262,19 @@ Evaluate BODY for each created map. | |||
| 262 | 262 | ||
| 263 | (ert-deftest test-map-some () | 263 | (ert-deftest test-map-some () |
| 264 | (with-maps-do map | 264 | (with-maps-do map |
| 265 | (should (equal (map-some (lambda (k _v) | 265 | (should (map-some (lambda (k _v) |
| 266 | (eq 1 k)) | 266 | (eq 1 k)) |
| 267 | map) | 267 | map)) |
| 268 | (cons 1 4))) | 268 | (should-not (map-some (lambda (k _v) |
| 269 | (should (not (map-some (lambda (k _v) | 269 | (eq 'd k)) |
| 270 | (eq 'd k)) | 270 | map))) |
| 271 | map)))) | ||
| 272 | (let ((vec [a b c])) | 271 | (let ((vec [a b c])) |
| 273 | (should (equal (map-some (lambda (k _v) | 272 | (should (map-some (lambda (k _v) |
| 274 | (> k 1)) | 273 | (> k 1)) |
| 275 | vec) | 274 | vec)) |
| 276 | (cons 2 'c))) | 275 | (should-not (map-some (lambda (k _v) |
| 277 | (should (not (map-some (lambda (k _v) | 276 | (> k 3)) |
| 278 | (> k 3)) | 277 | vec)))) |
| 279 | vec))))) | ||
| 280 | 278 | ||
| 281 | (ert-deftest test-map-every-p () | 279 | (ert-deftest test-map-every-p () |
| 282 | (with-maps-do map | 280 | (with-maps-do map |