在版本控制中使用源代码时,我想部分自动化GNU风格的ChangeLog条目的创建。 add-changelog-entry-other-window一次只能处理一个文件,您必须访问该文件才能使用它。

相反,我想看到的是有一些命令将输出diff -u -p(或与VC模式集成以便可以处理svn diff等)并立即创建所有框架条目。

例如,如果svn status显示

D file1.c
M file2.c
A file3.c

该命令将创建
2009-09-05  My Name <my.email>

      * file1.c: Removed.
      * file2.c: WRITE YOUR CHANGES HERE
      * file3.c: New.

更好的是,如果它可以在某种程度上解析某些语言的更改文件,那么它可以提供:
  * file2.c (new_function): New function.
  (deleted_function): Removed.
  (changed_function): WRITE YOUR CHANGES HERE

我已经找到this feature in Emacs manual,但是我看不到如何在这里应用它。

有什么建议么?谢谢。

编辑:一个答案建议vc-update-change-log。不幸的是,它仅支持CVS,并且通过查询已经提交的VC日志来创建ChangeLog条目。因此,即使它支持svn和其他,也无法在同一提交中提交更改和ChangeLog。

EDIT2:显然,add-changelog-entry-other-window(C-x 4 a)不仅可以从访问的文件中获取,而且还可以从涉及该文件的diff Hunk中获取。 (Source)这几乎是我想要的。这与elisp循环一起遍历所有大块应该会解决它。

最佳答案

我不知道执行此操作的函数,但是它应该易于实现。基本上,你想

  • 获取更改的文件
  • 对于每个文件
  • ,调用add-change-log
  • "Find change log file, and add an entry for today and an item for this file.
    Optional arg WHOAMI (interactive prefix) non-nil means prompt for user
    name and email (stored in `add-log-full-name' and `add-log-mailing-address').
    
    Second arg FILE-NAME is file name of the change log.
    If nil, use the value of `change-log-default-name'.
    
    Third arg OTHER-WINDOW non-nil means visit in other window.
    
    Fourth arg NEW-ENTRY non-nil means always create a new entry at the front;
    never append to an existing entry.  Option `add-log-keep-changes-together'
    otherwise affects whether a new entry is created.
    
    Option `add-log-always-start-new-record' non-nil means always create a
    new record, even when the last record was made on the same date and by
    the same person.
    
    The change log file can start with a copyright notice and a copying
    permission notice.  The first blank line indicates the end of these
    notices.
    
    Today's date is calculated according to `add-log-time-zone-rule' if
    non-nil, otherwise in local time."

    so the magic code is going to look something like

    (apply 'make-magic-change-log-entry changed-files-list)
    

    make-magic-change-log-entry只是 curry add-change-log函数,以便唯一的参数是file-name-您可以设置其他参数。

    关于version-control - Emacs:有没有办法从diff生成框架ChangeLog?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/826155/

    10-12 17:06