[oni-vc] Automatically check out files for Perforce
When I start typing, automatically check out the file that I'm working with.
This commit is contained in:
parent
9a979dac06
commit
7980f4dd28
1 changed files with 18 additions and 1 deletions
19
oni-vc.el
19
oni-vc.el
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
;; Author: Tom Willemse <tom@ryuslash.org>
|
;; Author: Tom Willemse <tom@ryuslash.org>
|
||||||
;; Keywords: local
|
;; Keywords: local
|
||||||
;; Version: 2021.1123.002400
|
;; Version: 2022.0222.204847
|
||||||
;; Package-Requires: (vc-p4)
|
;; Package-Requires: (vc-p4)
|
||||||
|
|
||||||
;; This program is free software; you can redistribute it and/or modify
|
;; This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,8 +26,25 @@
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
|
(require 'vc)
|
||||||
|
|
||||||
(when (eql system-type 'windows-nt)
|
(when (eql system-type 'windows-nt)
|
||||||
(require 'vc-p4))
|
(require 'vc-p4))
|
||||||
|
|
||||||
|
(defun oni-vc-maybe-checkout ()
|
||||||
|
"Call ‘vc-checkout’ if the current buffer is read-only and I'm typing."
|
||||||
|
(when (and buffer-read-only
|
||||||
|
(equal this-command 'self-insert-command))
|
||||||
|
(vc-checkout (buffer-file-name))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun oni-vc-enable-auto-checkout-for-perforce ()
|
||||||
|
"Set up a ‘pre-command-hook’ to automatically check out a file if necessary."
|
||||||
|
(when (equal (vc-backend (buffer-file-name)) 'P4)
|
||||||
|
(add-hook 'pre-command-hook 'oni-vc-pre-edit-function nil t)))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(add-hook 'find-file-hook 'oni-vc-find-file-hook)
|
||||||
|
|
||||||
(provide 'oni-vc)
|
(provide 'oni-vc)
|
||||||
;;; oni-vc.el ends here
|
;;; oni-vc.el ends here
|
||||||
|
|
Loading…
Reference in a new issue