summaryrefslogtreecommitdiff
path: root/lisp/log-view.el
diff options
context:
space:
mode:
authorDan Nicolaescu <dann@ics.uci.edu>2007-09-22 00:02:52 +0000
committerDan Nicolaescu <dann@ics.uci.edu>2007-09-22 00:02:52 +0000
commita3f5d84dacc5ca61215c8601a658d995f4210c64 (patch)
treea51b3cf5375e3cd35732712e714119e0ed663f8d /lisp/log-view.el
parent2e2cc4e44dbba6873bc6cffe425b7dd196e74ef9 (diff)
downloademacs-a3f5d84dacc5ca61215c8601a658d995f4210c64.tar.gz
* 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.
Diffstat (limited to 'lisp/log-view.el')
-rw-r--r--lisp/log-view.el59
1 files changed, 59 insertions, 0 deletions
diff --git a/lisp/log-view.el b/lisp/log-view.el
index 41e689f0025..4f699af69bf 100644
--- a/lisp/log-view.el
+++ b/lisp/log-view.el
@@ -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
;;