有用的emacs快捷键

  • 列编辑C-x r t yourstring RET (参见How to do select column then do editing in GNU Emacs ?)
  • 记录当前位置到register中 C-r SPC (需安装better-registers.el,且要注释掉其中对快捷键’C-x r’的占用)
  • 跳转至某register, C-j (需better-registers.el)
  • Save frame configuration to register, C-r f (要求同上)
  • Comment current line, M-; (需qiang-comment-dwim-line)
  • Vist the next/previous error message, M-g M-n/M-p
  • find-tag/pop-tag-mark, M-./M-*

Perforce Tip: how to apply my default change to the release branch

Create the patch,

p4 diff -du -db main-branch/... > ~/mywork.patch

Go to the work directory of release branch.

cd dir-release-branch/

`p4 edit’ the files I want to patch under release branch. Please note,

  • `lsdiff’ is from the package `patchutils’.
  • `nosl’ will strip the slashes. It’s written by me.
cat ~/mywork.patch|lsdiff|nosl 5|p4 -x - edit

Patch the files and DONE!

patch -p5 < ~/mywork.patch

Here is the source code of nosl. I put it in my .bashrc

function nosl(){
  if [ -z "$1" ]; then
    echo "Usage: echo /hello/world|nosl num"
    echo "strip num leading slashes"
  else
    perl -pe "$n=$1;while($n>0){ $_=~ s/[^/]*/+//;$n--; }"
  fi
}

BTW, you could save all the trouble of Perforce by switching to Git.