Klimi's new dotfiles with stow.
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

80 linhas
2.7 KiB

há 4 anos
  1. ;;; use-package-diminish.el --- Support for the :diminish keyword -*- 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 support for the :diminish keyword, which is made available by
  25. ;; default by requiring `use-package'.
  26. ;;; Code:
  27. (require 'use-package-core)
  28. (defun use-package-normalize-diminish (name label arg &optional recursed)
  29. "Normalize the arguments to diminish down to a list of one of two forms:
  30. SYMBOL
  31. (SYMBOL . STRING)"
  32. (cond
  33. ((not arg)
  34. (list (use-package-as-mode name)))
  35. ((use-package-non-nil-symbolp arg)
  36. (list arg))
  37. ((stringp arg)
  38. (list (cons (use-package-as-mode name) arg)))
  39. ((and (consp arg) (stringp (cdr arg)))
  40. (list arg))
  41. ((and (not recursed) (listp arg) (listp (cdr arg)))
  42. (mapcar #'(lambda (x) (car (use-package-normalize-diminish
  43. name label x t))) arg))
  44. (t
  45. (use-package-error
  46. (concat label " wants a string, symbol, "
  47. "(symbol . string) or list of these")))))
  48. ;;;###autoload
  49. (defun use-package-normalize/:diminish (name keyword args)
  50. (use-package-as-one (symbol-name keyword) args
  51. (apply-partially #'use-package-normalize-diminish name) t))
  52. ;;;###autoload
  53. (defun use-package-handler/:diminish (name _keyword arg rest state)
  54. (let ((body (use-package-process-keywords name rest state)))
  55. (use-package-concat
  56. (mapcar #'(lambda (var)
  57. `(if (fboundp 'diminish)
  58. ,(if (consp var)
  59. `(diminish ',(car var) ,(cdr var))
  60. `(diminish ',var))))
  61. arg)
  62. body)))
  63. (add-to-list 'use-package-keywords :diminish t)
  64. (provide 'use-package-diminish)
  65. ;;; use-package-diminish.el ends here