我想看看如何使用config file functionality设置perforce的示例,其中emacs用作差异和合并程序(P4DIFF和P4MERGE设置)。如果这是在Windows上,那就更好了。
在使用emacsclientw时,我也在努力让P4EDITOR正常工作,特别是指定备用编辑器功能。
非常欢迎任何提示,建议和示例配置。
答案 0 :(得分:6)
这是我以前使用的另一种技巧。它为emacs添加了一些命令行选项,以便您可以在新的emacs实例中进行差异和合并(再次使用ediff)。
;; -diff
(defun command-line-diff (switch)
(let ((file1 (pop command-line-args-left))
(file2 (pop command-line-args-left)))
(ediff file1 file2)))
(add-to-list 'command-switch-alist '("-diff" . command-line-diff))
;; -merge
(defun command-line-merge (switch)
(let ((base (pop command-line-args-left))
(sccs (pop command-line-args-left))
(mine (pop command-line-args-left))
(merg (pop command-line-args-left)))
(ediff-merge-with-ancestor sccs mine base () merg)))
(add-to-list 'command-switch-alist '("-merge" . command-line-merge))
将它放在.emacs文件中。然后,您可以将P4DIFF程序设置为emacs -diff
,将P4MERGE程序设置为emacs -merge
。
答案 1 :(得分:3)
我假设你已经在使用p4.el。
这是一个允许您轻松设置p4-client-config的功能:
(defun p4-go (config)
(interactive
(list (read-file-name "P4 Config file: "
(concat (getenv "HOME") "/etc/perforce/")
""
t)))
(p4-set-client-config (expand-file-name config))
t)
然后我就跑M-x p4-go <RET> conf <RET>
。
我的〜/ etc / perforce / conf文件如下:
P4CLIENT=ewarmenhoven-ppd
P4PORT=perforce.netflix.com:1666
P4USER=ewarmenhoven
P4EDITOR=emacsclient
P4DIFF=diff -dupU8
P4MERGE=~/bin/emerge
emerge
合并程序只是一个简短的shell脚本,可以恰当地调用emacsclient
:
#!/bin/bash
base=$1
sccs=$2
mine=$3
merg=$4
emacsclient -e "(ediff-merge-files-with-ancestor \"$base\" \"$sccs\" \"$mine\" () \"$merg\")"
emacsclient "$merg"
如果您正在使用cygwin,它应该可以正常工作。
对于做差异,如果它从shell运行,那么我想要在shell中输出,因此只使用普通的差异。如果不是,我使用p4-ediff
,默认情况下绑定到C-x p -
。
答案 2 :(得分:3)
由于欢迎屏幕,Eric在最新的emacs中无法正常工作。为了隐藏欢迎屏幕(以便您可以正确获得差异),请参阅Unable to hide welcome screen in Emacs。
另一个在常规垂直模式下打开差异的漂亮设置是设置以下配置变量
(custom-set-variables
;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
'(ediff-split-window-function (quote split-window-horizontally)))