zoukankan      html  css  js  c++  java
  • 配置emacs自动加载上一次git comment

    不想每次都去复制粘贴comment到editor,就在emacs里捣腾,LISP还不会用,不过总是凑出两个函数可以用了,可能很蹩脚,以后会用ELISP了再优化吧。

    大概意思就是把每次提交的comment存到一个文件里,下次再加载commit msg 文件时,就从备份的文件里读出来。

    保存的comment是Signed-off-by前面那一部分。

    (defun my-load-file-mode ()
      (when (and (stringp buffer-file-name)
                 (string-match "\\COMMIT_EDITMSG\\'" buffer-file-name))
        (when (file-exists-p "COMMIT_EDITMSG_1")
          (insert-file-contents  "COMMIT_EDITMSG_1" nil 0 500 )
          ))
          (set-buffer-file-coding-system  'utf-8))
    
    (defun my-save-file-hook ()
      (when (and (stringp buffer-file-name)
                 (string-match "\\COMMIT_EDITMSG\\'" buffer-file-name))
        (save-excursion
          (beginning-of-buffer)
          (write-region (point)
    		    (progn
    		    (re-search-forward "Signed-off-by")
    		    (previous-line)(end-of-line)
    		    (point)) "COMMIT_EDITMSG_1" nil nil nil nil))))
    
    (add-hook 'find-file-hook 'my-load-file-mode)
    (add-hook 'after-save-hook 'my-save-file-hook)
    
  • 相关阅读:
    POJ 1095 Trees Made to Order 最详细的解题报告
    Producter and Consumer
    How to use the function of bind
    How to use the functions of apply and call
    Configurate vim tool
    #4713. 方程
    #4709. 树
    #4718. 管理
    #4710. 并
    #4707. 点分治
  • 原文地址:https://www.cnblogs.com/jiangli/p/git_emacs_last_comment.html
Copyright © 2011-2022 走看看