Amos Joshua
Amos Joshua

Reputation: 1763

Emacs & DSVN: change default commit message

I am currently using DSVN in emacs 24.1.50.1 on OSX, with svn v 1.7.8.

When I run svn-status from emacs, mark several files and press 'c' to commit I find myself in the svn commit buffer that is pre-filled with the following:

Summary:
Author:

I have a different convention that I would like to follow, how can I change this default commit message?

I've looked through the source for svn-commit but I don't see where this message is coming from. This thread seems relevant but I'm not sure what hooks I might use to leverage the information presented there.

Ideally I would like to be able to determine the message dynamically based on the repository url for the current project, but even just a hint for how to change the message to something static would be great. How might I go about changing this message?

All help appreciated.

Upvotes: 1

Views: 393

Answers (2)

juanleon
juanleon

Reputation: 9390

If you cannot locate the source in your emacs package, chances are this template comes from svn itself.

Take a look to this, you can do a quick test to check if this would be the case for you.

If so, you could use setenv from emacs to recreate the trick described there, or defadvice svn-commit to replace the buffer contents with your own template, as you prefer (the later solution would work even if the template was not coming from svn)

Upvotes: 1

Amos Joshua
Amos Joshua

Reputation: 1763

Based on juanleon's suggestion to use defadvice, here is some advice that will replace the contents of the svn commit buffer with a static message:

(defadvice svn-commit (after modify-default-commit-message activate) 
  (erasebuffer)
  (insert "custom message")) 

This assumes that the buffer containing the commit message is selected after running svn-commit (in my case *svn-commit*).

A more dynamic version that invokes "svn info" and replaces the commit message with a regex-extracted value is:

(defadvice svn-commit (after modify-default-commit-message activate) 
  (erase-buffer)  
  (let ((svninfo (shell-command-to-string "svn info")))
    (string-match "^URL: svn://\\(.+\\)" svninfo)   
    (insert (match-string 1 svninfo))                                          
    (insert ": ")      
    )) 

This advice will replace the commit message with the host and path of the svn url, followed by ": ", so if svn-commit is run from a checkout with url "svn://host.com/path" the commit message will be "host.com/path: ". If the regex fails the commit message will simply be empty.

Upvotes: 0

Related Questions