Commit a1617483 authored by Jonas Bernoulli's avatar Jonas Bernoulli

Split several libraries into more sections

parent 8c42fe28
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
(require 'autorevert) (require 'autorevert)
;;; Options
(defgroup magit-auto-revert nil (defgroup magit-auto-revert nil
"Revert buffers when files in repository change." "Revert buffers when files in repository change."
:link '(custom-group-link auto-revert) :link '(custom-group-link auto-revert)
...@@ -97,6 +99,8 @@ seconds of user inactivity. That is not desirable." ...@@ -97,6 +99,8 @@ seconds of user inactivity. That is not desirable."
:group 'magit-auto-revert :group 'magit-auto-revert
:type 'boolean) :type 'boolean)
;;; Mode
(defun magit-turn-on-auto-revert-mode-if-desired (&optional file) (defun magit-turn-on-auto-revert-mode-if-desired (&optional file)
(if file (if file
(--when-let (find-buffer-visiting file) (--when-let (find-buffer-visiting file)
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
(require 'magit) (require 'magit)
;;; Options
(defcustom magit-bisect-show-graph t (defcustom magit-bisect-show-graph t
"Whether to use `--graph' in the log showing commits yet to be bisected." "Whether to use `--graph' in the log showing commits yet to be bisected."
:package-version '(magit . "2.8.0") :package-version '(magit . "2.8.0")
...@@ -50,6 +52,8 @@ ...@@ -50,6 +52,8 @@
"Face for bad bisect revisions." "Face for bad bisect revisions."
:group 'magit-faces) :group 'magit-faces)
;;; Commands
;;;###autoload (autoload 'magit-bisect-popup "magit-bisect" nil t) ;;;###autoload (autoload 'magit-bisect-popup "magit-bisect" nil t)
(magit-define-popup magit-bisect-popup (magit-define-popup magit-bisect-popup
"Popup console for bisect commands." "Popup console for bisect commands."
...@@ -134,6 +138,8 @@ bisect run'." ...@@ -134,6 +138,8 @@ bisect run'."
(magit-run-git-with-logfile (magit-run-git-with-logfile
(magit-git-dir "BISECT_CMD_OUTPUT") "bisect" subcommand args))) (magit-git-dir "BISECT_CMD_OUTPUT") "bisect" subcommand args)))
;;; Sections
(defun magit-bisect-in-progress-p () (defun magit-bisect-in-progress-p ()
(file-exists-p (magit-git-dir "BISECT_LOG"))) (file-exists-p (magit-git-dir "BISECT_LOG")))
......
...@@ -118,7 +118,7 @@ and then turned on again when turning off the latter." ...@@ -118,7 +118,7 @@ and then turned on again when turning off the latter."
"Face for dates in blame headings." "Face for dates in blame headings."
:group 'magit-faces) :group 'magit-faces)
;;; Code ;;; Mode
(defvar magit-blame-mode-map (defvar magit-blame-mode-map
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
...@@ -197,6 +197,8 @@ and then turned on again when turning off the latter." ...@@ -197,6 +197,8 @@ and then turned on again when turning off the latter."
(advice-add 'auto-revert-handler :before-until (advice-add 'auto-revert-handler :before-until
'auto-revert-handler--unless-magit-blame-mode) 'auto-revert-handler--unless-magit-blame-mode)
;;; Popup
;;;###autoload (autoload 'magit-blame-popup "magit-blame" nil t) ;;;###autoload (autoload 'magit-blame-popup "magit-blame" nil t)
(magit-define-popup magit-blame-popup (magit-define-popup magit-blame-popup
"Popup console for blame commands." "Popup console for blame commands."
...@@ -209,6 +211,8 @@ and then turned on again when turning off the latter." ...@@ -209,6 +211,8 @@ and then turned on again when turning off the latter."
:default-arguments '("-w") :default-arguments '("-w")
:default-action 'magit-blame) :default-action 'magit-blame)
;;; Process
;;;###autoload ;;;###autoload
(defun magit-blame (revision file &optional args line) (defun magit-blame (revision file &optional args line)
"Display edit history of FILE up to REVISION. "Display edit history of FILE up to REVISION.
...@@ -361,6 +365,8 @@ This is intended for debugging purposes.") ...@@ -361,6 +365,8 @@ This is intended for debugging purposes.")
(kill-process process) (kill-process process)
(user-error "Buffer being blamed has been killed"))) (user-error "Buffer being blamed has been killed")))
;;; Display
(defun magit-blame-make-overlay (chunk) (defun magit-blame-make-overlay (chunk)
(let ((ov (save-excursion (let ((ov (save-excursion
(save-restriction (save-restriction
...@@ -424,6 +430,8 @@ This is intended for debugging purposes.") ...@@ -424,6 +430,8 @@ This is intended for debugging purposes.")
(format-time-string (format-time-string
format (seconds-to-time (+ time (* (/ tz 100) 60 60) (* (% tz 100) 60))))) format (seconds-to-time (+ time (* (/ tz 100) 60 60) (* (% tz 100) 60)))))
;;; Commands
(defun magit-blame-quit () (defun magit-blame-quit ()
"Turn off Magit-Blame mode. "Turn off Magit-Blame mode.
If the buffer was created during a recursive blame, If the buffer was created during a recursive blame,
...@@ -502,6 +510,8 @@ like `kill-ring-save' would." ...@@ -502,6 +510,8 @@ like `kill-ring-save' would."
(copy-region-as-kill nil nil 'region) (copy-region-as-kill nil nil 'region)
(kill-new (message "%s" (magit-blame-chunk-get :hash))))) (kill-new (message "%s" (magit-blame-chunk-get :hash)))))
;;; Utilities
(defun magit-blame-chunk-get (key &optional pos) (defun magit-blame-chunk-get (key &optional pos)
(--when-let (magit-blame-overlay-at pos) (--when-let (magit-blame-overlay-at pos)
(plist-get (overlay-get it 'magit-blame) key))) (plist-get (overlay-get it 'magit-blame) key)))
......
...@@ -85,7 +85,7 @@ an error while using those is harder to recover from." ...@@ -85,7 +85,7 @@ an error while using those is harder to recover from."
:group 'magit-commands :group 'magit-commands
:type 'boolean) :type 'boolean)
;;; Code ;;; Popup
(defun magit-commit-popup (&optional arg) (defun magit-commit-popup (&optional arg)
"Popup console for commit commands." "Popup console for commit commands."
...@@ -142,6 +142,8 @@ an error while using those is harder to recover from." ...@@ -142,6 +142,8 @@ an error while using those is harder to recover from."
(car (or magit-gpg-secret-key-hist keys))) (car (or magit-gpg-secret-key-hist keys)))
" ")))) " "))))
;;; Commands
;;;###autoload ;;;###autoload
(defun magit-commit (&optional args) (defun magit-commit (&optional args)
"Create a new commit on HEAD. "Create a new commit on HEAD.
...@@ -311,6 +313,8 @@ depending on the value of option `magit-commit-squash-confirm'." ...@@ -311,6 +313,8 @@ depending on the value of option `magit-commit-squash-confirm'."
(t (t
(user-error "Nothing staged")))) (user-error "Nothing staged"))))
;;; Pending Diff
(defun magit-commit-diff () (defun magit-commit-diff ()
(-when-let (fn (and git-commit-mode (-when-let (fn (and git-commit-mode
magit-commit-show-diff magit-commit-show-diff
...@@ -339,6 +343,8 @@ depending on the value of option `magit-commit-squash-confirm'." ...@@ -339,6 +343,8 @@ depending on the value of option `magit-commit-squash-confirm'."
(add-to-list 'with-editor-server-window-alist (add-to-list 'with-editor-server-window-alist
(cons git-commit-filename-regexp 'switch-to-buffer)) (cons git-commit-filename-regexp 'switch-to-buffer))
;;; Message Utilities
(defun magit-commit-message-buffer () (defun magit-commit-message-buffer ()
(let* ((find-file-visit-truename t) ; git uses truename of COMMIT_EDITMSG (let* ((find-file-visit-truename t) ; git uses truename of COMMIT_EDITMSG
(topdir (magit-toplevel))) (topdir (magit-toplevel)))
......
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
(defvar smerge-ediff-buf) (defvar smerge-ediff-buf)
(defvar smerge-ediff-windows) (defvar smerge-ediff-windows)
;;; Options
(defgroup magit-ediff nil (defgroup magit-ediff nil
"Ediff support for Magit." "Ediff support for Magit."
:link '(info-link "(magit)Ediffing") :link '(info-link "(magit)Ediffing")
...@@ -97,6 +99,8 @@ tree at the time of stashing." ...@@ -97,6 +99,8 @@ tree at the time of stashing."
:group 'magit-ediff :group 'magit-ediff
:type 'boolean) :type 'boolean)
;;; Commands
(defvar magit-ediff-previous-winconf nil) (defvar magit-ediff-previous-winconf nil)
;;;###autoload (autoload 'magit-ediff-popup "magit-ediff" nil t) ;;;###autoload (autoload 'magit-ediff-popup "magit-ediff" nil t)
......
...@@ -325,6 +325,7 @@ the upstream isn't ahead of the current branch) show." ...@@ -325,6 +325,7 @@ the upstream isn't ahead of the current branch) show."
:type '(repeat (string :tag "Argument"))) :type '(repeat (string :tag "Argument")))
;;; Commands ;;; Commands
;;;; Popups
(defvar magit-log-popup (defvar magit-log-popup
'(:variable magit-log-arguments '(:variable magit-log-arguments
...@@ -498,6 +499,8 @@ buffer." ...@@ -498,6 +499,8 @@ buffer."
magit-log-section-arguments)))) magit-log-section-arguments))))
(magit-invoke-popup 'magit-log-refresh-popup nil arg))) (magit-invoke-popup 'magit-log-refresh-popup nil arg)))
;;;; Refresh Commands
(defun magit-log-refresh (args files) (defun magit-log-refresh (args files)
"Set the local log arguments for the current buffer." "Set the local log arguments for the current buffer."
(interactive (magit-log-arguments t)) (interactive (magit-log-arguments t))
...@@ -546,6 +549,8 @@ buffer." ...@@ -546,6 +549,8 @@ buffer."
((derived-mode-p 'magit-cherry-mode) ((derived-mode-p 'magit-cherry-mode)
(user-error "Cannot change log arguments in cherry buffers")))) (user-error "Cannot change log arguments in cherry buffers"))))
;;;; Log Commands
(defvar magit-log-read-revs-map (defvar magit-log-read-revs-map
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
(set-keymap-parent map crm-local-completion-map) (set-keymap-parent map crm-local-completion-map)
...@@ -681,6 +686,8 @@ With a prefix argument or when `--follow' is part of ...@@ -681,6 +686,8 @@ With a prefix argument or when `--follow' is part of
(interactive) (interactive)
(magit-reflog "HEAD")) (magit-reflog "HEAD"))
;;;; Limit Commands
(defun magit-log-toggle-commit-limit () (defun magit-log-toggle-commit-limit ()
"Toggle the number of commits the current log buffer is limited to. "Toggle the number of commits the current log buffer is limited to.
If the number of commits is currently limited, then remove that If the number of commits is currently limited, then remove that
...@@ -715,6 +722,8 @@ limit. Otherwise set it to 256." ...@@ -715,6 +722,8 @@ limit. Otherwise set it to 256."
(car (magit-log-arguments t))) (car (magit-log-arguments t)))
(string-to-number (match-string 1 it)))) (string-to-number (match-string 1 it))))
;;;; Other Commands
(defun magit-log-bury-buffer (&optional arg) (defun magit-log-bury-buffer (&optional arg)
"Bury the current buffer or the revision buffer in the same frame. "Bury the current buffer or the revision buffer in the same frame.
Like `magit-mode-bury-buffer' (which see) but with a negative Like `magit-mode-bury-buffer' (which see) but with a negative
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
(require 'magit) (require 'magit)
;;; Popup
;;;###autoload (autoload 'magit-subtree-popup "magit-subtree" nil t) ;;;###autoload (autoload 'magit-subtree-popup "magit-subtree" nil t)
(magit-define-popup magit-subtree-popup (magit-define-popup magit-subtree-popup
"Popup console for subtree commands." "Popup console for subtree commands."
...@@ -61,6 +63,8 @@ ...@@ -61,6 +63,8 @@
(user-error "%s isn't inside the repository at %s" prefix topdir)) (user-error "%s isn't inside the repository at %s" prefix topdir))
prefix))) prefix)))
;;; Commands
(defun magit-subtree-prefix (prompt) (defun magit-subtree-prefix (prompt)
(--if-let (--first (string-prefix-p "--prefix=" it) (--if-let (--first (string-prefix-p "--prefix=" it)
(magit-subtree-arguments)) (magit-subtree-arguments))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment