A JavaScript development environment for Emacs https://indium.readthedocs.io
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.6KB

  1. ;;; indium-seq-fix.el --- Patches for seq.el -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 2017-2018 Nicolas Petton
  3. ;; Author: Nicolas Petton <nicolas@petton.fr>
  4. ;; Keywords:
  5. ;; This program is free software; you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;; This program is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. ;;; Commentary:
  16. ;;
  17. ;;; Code:
  18. ;; HACK: In Emacs 25.1, an older version of seq.el is provided, which can be
  19. ;; loaded before indium or even package.el. If this happens, the feature `seq'
  20. ;; being already provided, the correct version of seq.el won't get loaded.
  21. (require 'seq)
  22. (unless (fboundp 'seq-map-indexed)
  23. (defun seq-map-indexed (function sequence)
  24. "Return the result of applying FUNCTION to each element of SEQUENCE.
  25. Unlike `seq-map', FUNCTION takes two arguments: the element of
  26. the sequence, and its index within the sequence."
  27. (let ((index 0))
  28. (seq-map (lambda (elt)
  29. (prog1
  30. (funcall function elt index)
  31. (setq index (1+ index))))
  32. sequence))))
  33. (provide 'indium-seq-fix)
  34. ;;; indium-seq-fix.el ends here