changeset 82844:a25b7156354b

(log-view-marked-list): Delete variable. (log-view-mode): Don't use it. (log-view-toggle-mark-entry): Likewise, simplify. (log-view-current-tag): Don't return properties. (log-view-get-marked): New function.
author Dan Nicolaescu <dann@ics.uci.edu>
date Sat, 25 Aug 2007 20:07:23 +0000
parents 768766d373a7
children 652a69b79238
files lisp/ChangeLog lisp/log-view.el
diffstat 2 files changed, 27 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sat Aug 25 20:04:26 2007 +0000
+++ b/lisp/ChangeLog	Sat Aug 25 20:07:23 2007 +0000
@@ -1,3 +1,11 @@
+2007-08-25  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* log-view.el (log-view-marked-list): Delete variable.
+	(log-view-mode): Don't use it.
+	(log-view-toggle-mark-entry): Likewise, simplify.
+	(log-view-current-tag): Don't return properties.
+	(log-view-get-marked): New function.
+
 2007-08-25  Alexandre Julliard  <julliard@winehq.org>
 
 	* vc-git.el (vc-git-mode-line-string): New function.
--- a/lisp/log-view.el	Sat Aug 25 20:04:26 2007 +0000
+++ b/lisp/log-view.el	Sat Aug 25 20:07:23 2007 +0000
@@ -178,8 +178,6 @@
 (defconst log-view-font-lock-defaults
   '(log-view-font-lock-keywords t nil nil nil))
 
-(defvar log-view-marked-list nil)
-
 ;;;;
 ;;;; Actual code
 ;;;;
@@ -188,7 +186,6 @@
 (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))
 
@@ -236,12 +233,11 @@
     (forward-line 1)
     (let ((pt (point)))
       (when (re-search-backward log-view-message-re nil t)
-	(let ((rev (match-string 1)))
+	(let ((rev (match-string-no-properties 1)))
 	  (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)
@@ -250,33 +246,34 @@
 	(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)))
+	    ;; Look to see if the current entry is marked.
+	    (setq found (get-char-property (point) 'log-view-self))
 	    (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.
+		(delete-overlay found)
+	      ;; Create an overlay that covers this entry and change
+	      ;; it's color.
 	      (setq tag (log-view-current-tag (point)))
-	      (push tag log-view-marked-list)
 	      (forward-line 1)
-	      (setq end 
+	      (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)
+	      ;; This is used to check if the overlay is present.
+	      (overlay-put ov 'log-view-self ov)
 	      (overlay-put ov 'log-view-marked tag))))))))
 
+(defun log-view-get-marked ()
+  (save-excursion
+    (let ((pos (point-min))
+	  marked-list ov)
+      (while (setq pos (next-single-property-change pos 'face))
+	(when (setq ov (get-char-property pos 'log-view-self))
+	  (push (overlay-get ov 'log-view-marked) marked-list)
+	  (setq pos (overlay-end ov))))
+      marked-list)))
+
 (defvar cvs-minor-current-files)
 (defvar cvs-branch-prefix)
 (defvar cvs-secondary-branch-prefix)