Klimi's new dotfiles with stow.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

91 行
3.2 KiB

  1. ;;; use-package-delight.el --- Support for the :delight 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 :delight keyword, which is made available by
  25. ;; default by requiring `use-package'.
  26. ;;; Code:
  27. (require 'use-package-core)
  28. (defun use-package-normalize-delight (name args)
  29. "Normalize ARGS for a single call to `delight'."
  30. (when (eq :eval (car args))
  31. ;; Handle likely common mistake.
  32. (use-package-error ":delight mode line constructs must be quoted"))
  33. (cond ((and (= (length args) 1)
  34. (use-package-non-nil-symbolp (car args)))
  35. `(,(nth 0 args) nil ,name))
  36. ((= (length args) 2)
  37. `(,(nth 0 args) ,(nth 1 args) ,name))
  38. ((= (length args) 3)
  39. args)
  40. (t
  41. (use-package-error
  42. ":delight expects `delight' arguments or a list of them"))))
  43. ;;;###autoload
  44. (defun use-package-normalize/:delight (name _keyword args)
  45. "Normalize arguments to delight."
  46. (cond ((null args)
  47. `((,(use-package-as-mode name) nil ,name)))
  48. ((and (= (length args) 1)
  49. (use-package-non-nil-symbolp (car args)))
  50. `((,(car args) nil ,name)))
  51. ((and (= (length args) 1)
  52. (stringp (car args)))
  53. `((,(use-package-as-mode name) ,(car args) ,name)))
  54. ((and (= (length args) 1)
  55. (listp (car args))
  56. (eq 'quote (caar args)))
  57. `((,(use-package-as-mode name) ,@(cdar args) ,name)))
  58. ((and (= (length args) 2)
  59. (listp (nth 1 args))
  60. (eq 'quote (car (nth 1 args))))
  61. `((,(car args) ,@(cdr (nth 1 args)) ,name)))
  62. (t (mapcar
  63. (apply-partially #'use-package-normalize-delight name)
  64. (if (use-package-non-nil-symbolp (car args))
  65. (list args)
  66. args)))))
  67. ;;;###autoload
  68. (defun use-package-handler/:delight (name _keyword args rest state)
  69. (let ((body (use-package-process-keywords name rest state)))
  70. (use-package-concat
  71. body
  72. `((if (fboundp 'delight)
  73. (delight '(,@args)))))))
  74. (add-to-list 'use-package-keywords :delight t)
  75. (provide 'use-package-delight)
  76. ;;; use-package-delight.el ends here