branch: elpa/magit commit 0a74fb0a60c1b30c485f9b68c660f11768b1e2dc Author: Jonas Bernoulli <jo...@bernoul.li> Commit: Jonas Bernoulli <jo...@bernoul.li>
magit-{stage,unstage}-buffer-file: Move definitions Move them next to the definitions of the related `magit-file-*' commands. --- lisp/magit-apply.el | 30 ++++-------------------------- lisp/magit-files.el | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lisp/magit-apply.el b/lisp/magit-apply.el index 25a62860c4..3a3621dd7a 100644 --- a/lisp/magit-apply.el +++ b/lisp/magit-apply.el @@ -305,19 +305,6 @@ at point, stage the file but not its content." (`(undefined ,_ ,_) (user-error "Cannot stage this change"))) (call-interactively #'magit-stage-file))) -;;;###autoload -(defun magit-stage-buffer-file () - "Stage all changes to the file being visited in the current buffer." - (interactive) - (unless buffer-file-name - (user-error "Not visiting a file")) - (magit-with-toplevel - (magit-stage-1 (and (magit-file-ignored-p buffer-file-name) - (if (y-or-n-p "Visited file is ignored; stage anyway?") - "--force" - (user-error "Abort"))) - (list (magit-file-relative-name))))) - ;;;###autoload (defun magit-stage-file (files &optional force) "Read one or more files and stage all changes in those files. @@ -408,9 +395,9 @@ ignored) files." (defvar magit-post-stage-hook-commands (list #'magit-stage - #'magit-stage-buffer-file #'magit-stage-file - #'magit-stage-modified)) + #'magit-stage-modified + 'magit-stage-buffer-file)) (defun magit-run-post-stage-hook () (when (memq this-command magit-post-stage-hook-commands) @@ -444,15 +431,6 @@ ignored) files." (user-error "Cannot unstage committed changes"))) (`(undefined ,_ ,_) (user-error "Cannot unstage this change"))))) -;;;###autoload -(defun magit-unstage-buffer-file () - "Unstage all changes to the file being visited in the current buffer." - (interactive) - (unless buffer-file-name - (user-error "Not visiting a file")) - (magit-with-toplevel - (magit-unstage-1 (list (magit-file-relative-name))))) - ;;;###autoload (defun magit-unstage-file (files) "Read one or more files and unstage all changes to those files." @@ -496,9 +474,9 @@ ignored) files." (defvar magit-post-unstage-hook-commands (list #'magit-unstage - #'magit-unstage-buffer-file #'magit-unstage-file - #'magit-unstage-all)) + #'magit-unstage-all + 'magit-unstage-buffer-file)) (defun magit-run-post-unstage-hook () (when (memq this-command magit-post-unstage-hook-commands) diff --git a/lisp/magit-files.el b/lisp/magit-files.el index 2519d302df..506ee27e3c 100644 --- a/lisp/magit-files.el +++ b/lisp/magit-files.el @@ -419,6 +419,28 @@ the same location in the respective file in the working tree." ;;; File Commands +;;;###autoload +(defun magit-stage-buffer-file () + "Stage all changes to the file being visited in the current buffer." + (interactive) + (unless buffer-file-name + (user-error "Not visiting a file")) + (magit-with-toplevel + (magit-stage-1 (and (magit-file-ignored-p buffer-file-name) + (if (y-or-n-p "Visited file is ignored; stage anyway?") + "--force" + (user-error "Abort"))) + (list (magit-file-relative-name))))) + +;;;###autoload +(defun magit-unstage-buffer-file () + "Unstage all changes to the file being visited in the current buffer." + (interactive) + (unless buffer-file-name + (user-error "Not visiting a file")) + (magit-with-toplevel + (magit-unstage-1 (list (magit-file-relative-name))))) + ;;;###autoload (defun magit-file-untrack (files &optional force) "Untrack the selected FILES or one file read in the minibuffer.