changeset 82826:0d52789c865e

(log-view-toggle-mark-entry): New function. (log-view-mode-map): Bind it. (log-view-marked-list): New variable. (log-view-mode): Make it local.
author Dan Nicolaescu <dann@ics.uci.edu>
date Fri, 24 Aug 2007 17:28:00 +0000
parents 28d469c7ec2a
children afbae3f37caf
files lisp/ChangeLog lisp/log-view.el
diffstat 2 files changed, 48 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri Aug 24 17:09:30 2007 +0000
+++ b/lisp/ChangeLog	Fri Aug 24 17:28:00 2007 +0000
@@ -1,3 +1,10 @@
+2007-08-24  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* log-view.el (log-view-toggle-mark-entry): New function.
+	(log-view-mode-map): Bind it.
+	(log-view-marked-list): New variable.
+	(log-view-mode): Make it local.
+
 2007-08-24  Thien-Thi Nguyen  <ttn@gnuvola.org>
 
 	* play/zone.el (zone-pgm-rat-race): New func.
--- a/lisp/log-view.el	Fri Aug 24 17:09:30 2007 +0000
+++ b/lisp/log-view.el	Fri Aug 24 17:28:00 2007 +0000
@@ -89,7 +89,7 @@
 (easy-mmode-defmap log-view-mode-map
   '(("q" . quit-window)
     ("z" . kill-this-buffer)
-    ("m" . set-mark-command)
+    ("m" . log-view-toggle-mark-entry)
     ;; ("e" . cvs-mode-edit-log)
     ("d" . log-view-diff)
     ("f" . log-view-find-version)
@@ -178,6 +178,8 @@
 (defconst log-view-font-lock-defaults
   '(log-view-font-lock-keywords t nil nil nil))
 
+(defvar log-view-marked-list nil)
+
 ;;;;
 ;;;; Actual code
 ;;;;
@@ -186,6 +188,7 @@
 (define-derived-mode log-view-mode fundamental-mode "Log-View"
   "Major mode for browsing CVS log output."
   (setq buffer-read-only t)
+  (make-local-variable 'log-view-marked-list)
   (set (make-local-variable 'font-lock-defaults) log-view-font-lock-defaults)
   (set (make-local-variable 'cvs-minor-wrap-function) 'log-view-minor-wrap))
 
@@ -237,6 +240,43 @@
 	  (unless (re-search-forward log-view-file-re pt t)
 	    rev))))))
 
+(defun log-view-toggle-mark-entry ()
+  "Toggle marking for on log entry."
+  (interactive)
+  (save-excursion
+    (forward-line 1)
+    (let ((pt (point)))
+      (when (re-search-backward log-view-message-re nil t)
+	(let ((beg (match-beginning 0))
+	      end ov ovlist found tag)
+	  (unless (re-search-forward log-view-file-re pt t)
+	    ;; Look to see if the current entry is marked by looking
+	    ;; at the overlays at point.
+	    (setq ovlist (overlays-at (point)))
+	    (dolist (ovl ovlist)
+	      (when (overlay-get ovl 'log-view-marked)
+		(setq found ovl)))
+	    (if found
+		(progn
+		  ;; Remove this entry from the marked list and remove
+		  ;; the overlay.
+		  (setq log-view-marked-list 
+			(delq (overlay-get found 'log-view-marked)
+			      log-view-marked-list))
+		  (delete-overlay found))
+	      ;; Add this entry to the marked list and create an
+	      ;; overlay that covers it.
+	      (setq tag (log-view-current-tag (point)))
+	      (push tag log-view-marked-list)
+	      (forward-line 1)
+	      (setq end 
+		    (if (re-search-forward log-view-message-re nil t)
+			(match-beginning 0)
+		      (point-max)))
+	      (setq ov (make-overlay beg end))
+	      (overlay-put ov 'face 'log-view-file)
+	      (overlay-put ov 'log-view-marked tag))))))))
+
 (defvar cvs-minor-current-files)
 (defvar cvs-branch-prefix)
 (defvar cvs-secondary-branch-prefix)