changeset 78867:82b0e30f9888

* files.el (file-name-sans-versions): Allow - and a-z in version names. * log-view.el (log-view-mode-map, log-view-mode-menu): Bind log-view-annotate-version. (log-view-beginning-of-defun, log-view-end-of-defun) (log-view-annotate-version): New functions. (log-view-mode): Use log-view-beginning-of-defun and log-view-end-of-defun.
author Dan Nicolaescu <dann@ics.uci.edu>
date Sat, 22 Sep 2007 00:02:52 +0000
parents b38afb999811
children b77f2b24ff2d
files lisp/ChangeLog lisp/files.el lisp/log-view.el
diffstat 3 files changed, 72 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri Sep 21 23:11:25 2007 +0000
+++ b/lisp/ChangeLog	Sat Sep 22 00:02:52 2007 +0000
@@ -1,3 +1,15 @@
+2007-09-21  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* files.el (file-name-sans-versions): Allow - and a-z in version
+	names.
+
+	* log-view.el (log-view-mode-map, log-view-mode-menu): Bind
+	log-view-annotate-version.
+	(log-view-beginning-of-defun, log-view-end-of-defun)
+	(log-view-annotate-version): New functions.
+	(log-view-mode): Use log-view-beginning-of-defun and
+	log-view-end-of-defun.
+
 2007-09-21  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* emacs-lisp/easy-mmode.el (define-minor-mode): Fix staging brain damage.
--- a/lisp/files.el	Fri Sep 21 23:11:25 2007 +0000
+++ b/lisp/files.el	Sat Sep 22 00:02:52 2007 +0000
@@ -3188,7 +3188,7 @@
 			 (length name))
 		   (if keep-backup-version
 		       (length name)
-		     (or (string-match "\\.~[0-9.]+~\\'" name)
+		     (or (string-match "\\.~[-0-9a-z.]+~\\'" name)
 			 (string-match "~\\'" name)
 			 (length name))))))))
 
--- a/lisp/log-view.el	Fri Sep 21 23:11:25 2007 +0000
+++ b/lisp/log-view.el	Sat Sep 22 00:02:52 2007 +0000
@@ -92,6 +92,7 @@
     ("m" . set-mark-command)
     ;; ("e" . cvs-mode-edit-log)
     ("d" . log-view-diff)
+    ("a" . log-view-annotate-version)
     ("f" . log-view-find-version)
     ("n" . log-view-msg-next)
     ("p" . log-view-msg-prev)
@@ -114,6 +115,7 @@
     ["Mark Log Entry for Diff"  set-mark-command]
     ["Diff Revisions"  log-view-diff]
     ["Visit Version"  log-view-find-version]
+    ["Annotate Version"  log-view-annotate-version]
     ["Next Log Entry"  log-view-msg-next]
     ["Previous Log Entry"  log-view-msg-prev]
     ["Next File"  log-view-file-next]
@@ -184,6 +186,10 @@
   "Major mode for browsing CVS log output."
   (setq buffer-read-only t)
   (set (make-local-variable 'font-lock-defaults) log-view-font-lock-defaults)
+  (set (make-local-variable 'beginning-of-defun-function) 
+       'log-view-beginning-of-defun)
+  (set (make-local-variable 'end-of-defun-function) 
+       'log-view-end-of-defun)
   (set (make-local-variable 'cvs-minor-wrap-function) 'log-view-minor-wrap))
 
 ;;;;
@@ -237,6 +243,51 @@
 	  (unless (re-search-forward log-view-file-re pt t)
 	    rev))))))
 
+(defun log-view-beginning-of-defun ()
+  ;; This assumes that a log entry starts with a line matching
+  ;; `log-view-message-re'.  Modes that derive from `log-view-mode'
+  ;; for which this assumption is not valid will have to provide
+  ;; another implementation of this function.  `log-view-msg-prev'
+  ;; does a similar job to this function, we can't use it here
+  ;; directly because it prints messages that are not appropriate in
+  ;; this context and it does not move to the beginning of the buffer
+  ;; when the point is before the first log entry.
+
+  ;; `log-view-beginning-of-defun' and `log-view-end-of-defun' have
+  ;; been checked to work with logs produced by RCS, CVS, git,
+  ;; mercurial and subversion.
+
+  (re-search-backward log-view-message-re nil 'move))
+
+(defun log-view-end-of-defun ()
+  ;; The idea in this function is to search for the beginning of the
+  ;; next log entry using `log-view-message-re' and then go back one
+  ;; line when finding it.  Modes that derive from `log-view-mode' for
+  ;; which this assumption is not valid will have to provide another
+  ;; implementation of this function.
+
+  ;; Look back and if there is no entry there it means we are before
+  ;; the first log entry, so go forward until finding one.
+  (unless (save-excursion (re-search-backward log-view-message-re nil t))
+    (re-search-forward log-view-message-re nil t))
+
+  ;; In case we are at the end of log entry going forward a line will
+  ;; make us find the next entry when searching. If we are inside of
+  ;; an entry going forward a line will still keep the point inside
+  ;; the same entry.
+  (forward-line 1)
+
+  ;; In case we are at the beginning of an entry, move past it.
+  (when (looking-at log-view-message-re)
+    (goto-char (match-end 0))
+    (forward-line 1))
+
+  ;; Search for the start of the next log entry.  Go to the end of the
+  ;; buffer if we could not find a next entry.
+  (when (re-search-forward log-view-message-re nil 'move)
+    (goto-char (match-beginning 0))
+    (forward-line -1)))
+
 (defvar cvs-minor-current-files)
 (defvar cvs-branch-prefix)
 (defvar cvs-secondary-branch-prefix)
@@ -276,6 +327,14 @@
     (switch-to-buffer (vc-find-version (log-view-current-file)
                                        (log-view-current-tag)))))
 
+(defun log-view-annotate-version (pos)
+  "Annotate the version at point."
+  (interactive "d")
+  (save-excursion
+    (goto-char pos)
+    (switch-to-buffer (vc-annotate (log-view-current-file)
+				   (log-view-current-tag)))))
+
 ;;
 ;; diff
 ;;