Emacs personal configuration
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

87 lines
3.0KB

  1. ;;; package --- Git config
  2. ;;; Commentary:
  3. ;; TODO: link commits from vc-log to magit-show-commit
  4. ;; TODO: smerge-mode
  5. ;;; Code:
  6. ;; https://github.com/melpa/melpa/commit/cc3a0ce6c8a4a67b8a8d4b8b2c090694535e6848
  7. (require-package 'git-modes)
  8. (require-package 'git-messenger) ;; Though see also vc-annotate's "n" & "p" bindings
  9. (require-package 'git-timemachine)
  10. (when (maybe-require-package 'magit)
  11. ;; See: https://magit.vc/manual/magit.html#Support-for-Completion-Frameworks
  12. ;; https://github.com/magit/magit/pull/1812/files
  13. (require-package 'ido-completing-read+)
  14. (setq-default
  15. magit-process-popup-time 10
  16. magit-diff-refine-hunk t
  17. magit-completing-read-function 'magit-ido-completing-read)
  18. ;; Hint: customize `magit-repo-dirs' so that you can use C-u M-F12 to
  19. ;; quickly open magit on any one of your projects.
  20. (global-set-key [(meta f12)] 'magit-status)
  21. (global-set-key (kbd "C-x g") 'magit-status)
  22. (global-set-key (kbd "C-x M-g") 'magit-dispatch-popup))
  23. (after-load 'magit
  24. (define-key magit-status-mode-map (kbd "C-M-<up>") 'magit-section-up)
  25. (add-hook 'magit-popup-mode-hook 'sanityinc/no-trailing-whitespace))
  26. (require-package 'fullframe)
  27. (after-load 'magit
  28. (fullframe magit-status magit-mode-quit-window))
  29. (when (maybe-require-package 'git-commit)
  30. (add-hook 'git-commit-mode-hook 'goto-address-mode))
  31. ;; Convenient binding for vc-git-grep
  32. (global-set-key (kbd "C-x v f") 'vc-git-grep)
  33. ;;; git-svn support
  34. ;; (when (maybe-require-package 'magit-svn)
  35. ;; (require-package 'magit-svn)
  36. ;; (autoload 'magit-svn-enabled "magit-svn")
  37. ;; (defun sanityinc/maybe-enable-magit-svn-mode ()
  38. ;; (when (magit-svn-enabled)
  39. ;; (magit-svn-mode)))
  40. ;; (add-hook 'magit-status-mode-hook #'sanityinc/maybe-enable-magit-svn-mode))
  41. (after-load 'compile
  42. (dolist (defn (list '(git-svn-updated "^\t[A-Z]\t\\(.*\\)$" 1 nil nil 0 1)
  43. '(git-svn-needs-update "^\\(.*\\): needs update$" 1 nil nil 2 1)))
  44. (add-to-list 'compilation-error-regexp-alist-alist defn)
  45. (add-to-list 'compilation-error-regexp-alist (car defn))))
  46. (defvar git-svn--available-commands nil "Cached list of git svn subcommands")
  47. (defun git-svn--available-commands ()
  48. (or git-svn--available-commands
  49. (setq git-svn--available-commands
  50. (sanityinc/string-all-matches
  51. "^ \\([a-z\\-]+\\) +"
  52. (shell-command-to-string "git svn help") 1))))
  53. (defun git-svn (dir command)
  54. "Run a git svn subcommand in DIR."
  55. (interactive (list (read-directory-name "Directory: ")
  56. (completing-read "git-svn command: " (git-svn--available-commands) nil t nil nil (git-svn--available-commands))))
  57. (let* ((default-directory (vc-git-root dir))
  58. (compilation-buffer-name-function (lambda (major-mode-name) "*git-svn*")))
  59. (compile (concat "git svn " command))))
  60. (require-package 'git-messenger)
  61. (global-set-key (kbd "C-x v p") #'git-messenger:popup-message)
  62. ;; http://emacs.stackexchange.com/a/17733
  63. (global-git-commit-mode)
  64. (provide 'init-git)
  65. ;;; init-git ends here