Emacs personal configuration
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.

112 satır
4.0KB

  1. ;;; Find and load the correct package.el
  2. ;; When switching between Emacs 23 and 24, we always use the bundled package.el in Emacs 24
  3. (let ((package-el-site-lisp-dir
  4. (expand-file-name "site-lisp/package" user-emacs-directory)))
  5. (when (and (file-directory-p package-el-site-lisp-dir)
  6. (> emacs-major-version 23))
  7. (message "Removing local package.el from load-path to avoid shadowing bundled version")
  8. (setq load-path (remove package-el-site-lisp-dir load-path))))
  9. (require 'package)
  10. ;;; Standard package repositories
  11. (when (< emacs-major-version 24)
  12. ;; Mainly for ruby-mode
  13. (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/")))
  14. ;; We include the org repository for completeness, but don't normally
  15. ;; use it.
  16. (add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))
  17. (when (< emacs-major-version 24)
  18. (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
  19. ;;; Also use Melpa for most packages
  20. (add-to-list 'package-archives `("melpa" . ,(if (< emacs-major-version 24)
  21. "http://melpa.org/packages/"
  22. "https://melpa.org/packages/")))
  23. ;(add-to-list 'package-archives `("stable melpa" . ,(if (< emacs-major-version 24)
  24. ; "http://stable.melpa.org/packages/"
  25. ; "https://stable.melpa.org/packages/")))
  26. ;; If gpg cannot be found, signature checking will fail, so we
  27. ;; conditionally enable it according to whether gpg is available. We
  28. ;; re-run this check once $PATH has been configured
  29. (defun sanityinc/package-maybe-enable-signatures ()
  30. (setq package-check-signature (when (executable-find "gpg") 'allow-unsigned)))
  31. (sanityinc/package-maybe-enable-signatures)
  32. (after-load 'init-exec-path
  33. (sanityinc/package-maybe-enable-signatures))
  34. ;;; On-demand installation of packages
  35. (defun require-package (package &optional min-version no-refresh)
  36. "Install given PACKAGE, optionally requiring MIN-VERSION.
  37. If NO-REFRESH is non-nil, the available package lists will not be
  38. re-downloaded in order to locate PACKAGE."
  39. (if (package-installed-p package min-version)
  40. t
  41. (if (or (assoc package package-archive-contents) no-refresh)
  42. (if (boundp 'package-selected-packages)
  43. ;; Record this as a package the user installed explicitly
  44. (package-install package nil)
  45. (package-install package))
  46. (progn
  47. (package-refresh-contents)
  48. (require-package package min-version t)))))
  49. (defun maybe-require-package (package &optional min-version no-refresh)
  50. "Try to install PACKAGE, and return non-nil if successful.
  51. In the event of failure, return nil and print a warning message.
  52. Optionally require MIN-VERSION. If NO-REFRESH is non-nil, the
  53. available package lists will not be re-downloaded in order to
  54. locate PACKAGE."
  55. (condition-case err
  56. (require-package package min-version no-refresh)
  57. (error
  58. (message "Couldn't install package `%s': %S" package err)
  59. nil)))
  60. ;;; Fire up package.el
  61. (setq package-enable-at-startup nil)
  62. (package-initialize)
  63. (require-package 'fullframe)
  64. (fullframe list-packages quit-window)
  65. (require-package 'cl-lib)
  66. (require 'cl-lib)
  67. (defun sanityinc/set-tabulated-list-column-width (col-name width)
  68. "Set any column with name COL-NAME to the given WIDTH."
  69. (cl-loop for column across tabulated-list-format
  70. when (string= col-name (car column))
  71. do (setf (elt column 1) width)))
  72. (defun sanityinc/maybe-widen-package-menu-columns ()
  73. "Widen some columns of the package menu table to avoid truncation."
  74. (when (boundp 'tabulated-list-format)
  75. (sanityinc/set-tabulated-list-column-width "Version" 13)
  76. (let ((longest-archive-name (apply 'max (mapcar 'length (mapcar 'car package-archives)))))
  77. (sanityinc/set-tabulated-list-column-width "Archive" longest-archive-name))))
  78. (add-hook 'package-menu-mode-hook 'sanityinc/maybe-widen-package-menu-columns)
  79. (provide 'init-elpa)