Emacs personal configuration
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

109 lines
3.8KB

  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. ;; If gpg cannot be found, signature checking will fail, so we
  24. ;; conditionally enable it according to whether gpg is available. We
  25. ;; re-run this check once $PATH has been configured
  26. (defun sanityinc/package-maybe-enable-signatures ()
  27. (setq package-check-signature (when (executable-find "gpg") 'allow-unsigned)))
  28. (sanityinc/package-maybe-enable-signatures)
  29. (after-load 'init-exec-path
  30. (sanityinc/package-maybe-enable-signatures))
  31. ;;; On-demand installation of packages
  32. (defun require-package (package &optional min-version no-refresh)
  33. "Install given PACKAGE, optionally requiring MIN-VERSION.
  34. If NO-REFRESH is non-nil, the available package lists will not be
  35. re-downloaded in order to locate PACKAGE."
  36. (if (package-installed-p package min-version)
  37. t
  38. (if (or (assoc package package-archive-contents) no-refresh)
  39. (if (boundp 'package-selected-packages)
  40. ;; Record this as a package the user installed explicitly
  41. (package-install package nil)
  42. (package-install package))
  43. (progn
  44. (package-refresh-contents)
  45. (require-package package min-version t)))))
  46. (defun maybe-require-package (package &optional min-version no-refresh)
  47. "Try to install PACKAGE, and return non-nil if successful.
  48. In the event of failure, return nil and print a warning message.
  49. Optionally require MIN-VERSION. If NO-REFRESH is non-nil, the
  50. available package lists will not be re-downloaded in order to
  51. locate PACKAGE."
  52. (condition-case err
  53. (require-package package min-version no-refresh)
  54. (error
  55. (message "Couldn't install package `%s': %S" package err)
  56. nil)))
  57. ;;; Fire up package.el
  58. (setq package-enable-at-startup nil)
  59. (package-initialize)
  60. (require-package 'fullframe)
  61. (fullframe list-packages quit-window)
  62. (require-package 'cl-lib)
  63. (require 'cl-lib)
  64. (defun sanityinc/set-tabulated-list-column-width (col-name width)
  65. "Set any column with name COL-NAME to the given WIDTH."
  66. (cl-loop for column across tabulated-list-format
  67. when (string= col-name (car column))
  68. do (setf (elt column 1) width)))
  69. (defun sanityinc/maybe-widen-package-menu-columns ()
  70. "Widen some columns of the package menu table to avoid truncation."
  71. (when (boundp 'tabulated-list-format)
  72. (sanityinc/set-tabulated-list-column-width "Version" 13)
  73. (let ((longest-archive-name (apply 'max (mapcar 'length (mapcar 'car package-archives)))))
  74. (sanityinc/set-tabulated-list-column-width "Archive" longest-archive-name))))
  75. (add-hook 'package-menu-mode-hook 'sanityinc/maybe-widen-package-menu-columns)
  76. (provide 'init-elpa)