Klimi's new dotfiles with stow.
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

84 líneas
3.0 KiB

hace 5 años
  1. ;;; use-package-lint.el --- Attempt to find errors in use-package declarations -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 2012-2017 John Wiegley
  3. ;; Author: John Wiegley <johnw@newartisans.com>
  4. ;; Maintainer: John Wiegley <johnw@newartisans.com>
  5. ;; Created: 17 Jun 2012
  6. ;; Modified: 3 Dec 2017
  7. ;; Version: 1.0
  8. ;; Package-Requires: ((emacs "24.3") (use-package "2.4"))
  9. ;; Keywords: dotemacs startup speed config package
  10. ;; URL: https://github.com/jwiegley/use-package
  11. ;; This program is free software; you can redistribute it and/or
  12. ;; modify it under the terms of the GNU General Public License as
  13. ;; published by the Free Software Foundation; either version 3, or (at
  14. ;; your option) any later version.
  15. ;; This program is distributed in the hope that it will be useful, but
  16. ;; WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. ;; General Public License for more details.
  19. ;; You should have received a copy of the GNU General Public License
  20. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  21. ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  22. ;; Boston, MA 02111-1307, USA.
  23. ;;; Commentary:
  24. ;; Provides the command `M-x use-package-lint'.
  25. ;;; Code:
  26. (require 'cl-lib)
  27. (require 'use-package-core)
  28. (defun use-package-lint-declaration (name plist)
  29. (dolist (path (plist-get plist :load-path))
  30. (unless (file-exists-p path)
  31. (display-warning
  32. 'use-package
  33. (format "%s :load-path does not exist: %s"
  34. name path) :error)))
  35. (unless (or (plist-member plist :disabled)
  36. (plist-get plist :no-require)
  37. (locate-library (use-package-as-string name) nil
  38. (plist-get plist :load-path)))
  39. (display-warning
  40. 'use-package
  41. (format "%s module cannot be located" name) :error))
  42. ;; (dolist (command (plist-get plist :commands))
  43. ;; (unless (string= (find-lisp-object-file-name command nil)
  44. ;; (locate-library (use-package-as-string name) nil
  45. ;; (plist-get plist :load-path)))
  46. ;; (display-warning
  47. ;; 'use-package
  48. ;; (format "%s :command is from different path: %s"
  49. ;; name (symbol-name command)) :error)))
  50. )
  51. ;;;###autoload
  52. (defun use-package-lint ()
  53. "Check for errors in use-package declarations.
  54. For example, if the module's `:if' condition is met, but even
  55. with the specified `:load-path' the module cannot be found."
  56. (interactive)
  57. (save-excursion
  58. (goto-char (point-min))
  59. (let ((re (eval use-package-form-regexp-eval)))
  60. (while (re-search-forward re nil t)
  61. (goto-char (match-beginning 0))
  62. (let ((decl (read (current-buffer))))
  63. (when (eq (car decl) 'use-package)
  64. (use-package-lint-declaration
  65. (use-package-as-string (cadr decl))
  66. (use-package-normalize-keywords
  67. (cadr decl) (cddr decl)))))))))
  68. (provide 'use-package-lint)
  69. ;;; use-package-lint.el ends here