(in-package "P4COM") ;; This file, automatically loaded by load.lisp, creates bindings in ;; the LispWorks editor to manage the p4 connection: ;; ;; control-x p e "P4 Edit" ;; control-x p S "P4 Submit" ;; control-x p o "P4 Opened" ;; control-x p r "P4 Revert" ;; [TBD: Doc strings need writing] (editor:defcommand "P4 Edit" (p) "" "" (declare (ignore p)) (when-let* ((buffer (editor:current-buffer)) (pathname (editor:buffer-pathname buffer)) (result-strings (p4-edit pathname))) (editor:revert-buffer-command ()) (editor:message "~a" (svref result-strings 0)))) (editor:bind-key "P4 Edit" #(#\control-\x #\p #\e)) ;; Should revert buffers (as appropriate) after the submit. Should display useful messages. (editor:defcommand "P4 Submit" (p) "" "" (declare (ignore p)) (multiple-value-bind (ignore proceed) (editor:save-all-files-command ()) (declare (ignore ignore)) (unless proceed (return-from p4-submit-command))) (p4-run "change -o") (let* ((p4 (p4-connection)) (possible-files (com:call-dispatch-get-property (p4 ip-4 array-var) "Files"))) (if (plusp (length possible-files)) (multiple-value-bind (options proceed) (prompt-for-description-with-files possible-files) (when proceed (destructuring-bind (description files reopen-p) options (setf (com:call-dispatch-get-property (p4 ip-4 var) "Description") description (com:call-dispatch-get-property (p4 ip-4 array-var) "Files") files) (capi:display-message "~a" (p4-run (if reopen-p "submit -ri" "submit -i"))) #+broken (loop for file across files do ;; e.g. #("//server/code/utils/defsys.lisp //nick-gannet/server/code/utils/defsys.lisp c:\home\mick\p4\code\utils\defsys.lisp") ;; but components might have stray spaces. The following isn't idiot proof, but I would be pleased to meet the idiot who ;; broke it unintentionally. (let* ((where (aref (p4-run "where ~a" file) 0)) (type-starts (position #\. where :from-end t)) (type (subseq where type-starts)) (previous-type-starts (search (format nil "~a " type) where :from-end t :end2 type-starts)) (local (subseq where (+ previous-type-starts (1+ (length type))))) (buffer (editor::find-file-in-buffer-list (make-pathname :name (pathname-name local) :type (pathname-type local) :defaults (truename (pathname-location local)))))) (editor:revert-buffer-command nil buffer nil)))))) (capi:display-message "File(s) not opened on this client.")))) (editor:bind-key "P4 Submit" #(#\control-\x #\p #\S)) (editor:defcommand "P4 Opened" (p) "" "" (let ((opened (p4-opened p))) (if (zerop (length opened)) (capi:display-message "File(s) not opened on this client.") (capi:display-message "~a" opened)))) (editor:bind-key "P4 Opened" #(#\control-\x #\p #\o)) (editor:defcommand "P4 Revert" (p) "" "" (declare (ignore p)) (let* ((buffer (editor:current-buffer)) (file (editor:buffer-pathname buffer))) (if file (if (p4-run "opened \"~a\"" file) (when (capi:prompt-for-confirmation (format nil "Are you sure you wish to revert ~a?" (file-namestring file))) (let ((message (aref (p4-run "revert \"~a\"" file) 0))) (editor:revert-buffer-command nil buffer nil) (capi:display-message message))) (capi:display-message "File ~a not opened on this client." (file-namestring file))) (capi:display-message "There is no file associated with the current buffer")))) (editor:bind-key "P4 Revert" #(#\control-\x #\p #\r)) ;;;;;;;;;;;;;;;;; ;; COPYRIGHT AND LICENCE ;; ;; This file is copyright (c) 2003, Nick Levine. All rights reserved. ;; ;; Redistribution and use in source and binary forms, with or without ;; modification, are permitted provided that the following conditions are ;; met: ;; ;; 1. Redistributions of source code must retain the above copyright ;; notice, this list of conditions and the following disclaimer. ;; ;; 2. Redistributions in binary form must reproduce the above copyright ;; notice, this list of conditions and the following disclaimer in ;; the documentation and/or other materials provided with the ;; distribution. ;; ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;; HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ;; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, ;; BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS ;; OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ;; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ;; TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE ;; USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH ;; DAMAGE. ;; $Id: //info.ravenbrook.com/user/ndl/lisp/p4com/editor-bindings.lisp#5 $