changeset 30879:3a1ff1caafe2

* emacs-lisp/ewoc.el (ewoc-locate): Default POS to (point). (ewoc-goto-prev, ewoc-goto-next): Remove arg POS. Allow going past the last element. * pcvs.el (cvs-mode-previous-line, cvs-mode-next-line, cvs-mode-mark) (cvs-mode-unmark-up, cvs-get-marked): Update calls to ewoc. (cvs-mouse-toggle-mark): Don't move point. (cvs-revert-if-needed): Avoid re-eval of local variables and modes.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 16 Aug 2000 20:27:39 +0000
parents 13a1a0ec31e5
children 3af33efc3d66
files lisp/emacs-lisp/ewoc.el lisp/pcvs.el
diffstat 2 files changed, 35 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/emacs-lisp/ewoc.el	Wed Aug 16 20:20:43 2000 +0000
+++ b/lisp/emacs-lisp/ewoc.el	Wed Aug 16 20:27:39 2000 +0000
@@ -104,10 +104,10 @@
 ;; (defun ewoc-nth (ewoc n)
 ;; (defun ewoc-map (map-function ewoc &rest args)
 ;; (defun ewoc-filter (ewoc predicate &rest args)
-;; (defun ewoc-locate (ewoc pos &optional guess)
+;; (defun ewoc-locate (ewoc &optional pos guess)
 ;; (defun ewoc-invalidate (ewoc &rest nodes)
-;; (defun ewoc-goto-prev (ewoc pos arg)
-;; (defun ewoc-goto-next (ewoc pos arg)
+;; (defun ewoc-goto-prev (ewoc arg)
+;; (defun ewoc-goto-next (ewoc arg)
 ;; (defun ewoc-goto-node (ewoc node)
 ;; (defun ewoc-refresh (ewoc)
 ;; (defun ewoc-collect (ewoc predicate &rest args)
@@ -415,14 +415,15 @@
 	(ewoc--delete-node-internal ewoc node))
       (setq node next))))
 
-(defun ewoc-locate (ewoc pos &optional guess)
+(defun ewoc-locate (ewoc &optional pos guess)
   "Return the node that POS (a buffer position) is within.
-POS may be a marker or an integer.
+POS may be a marker or an integer.  It defaults to point.
 GUESS should be a node that it is likely that POS is near.
 
 If POS points before the first element, the first node is returned.
 If POS points after the last element, the last node is returned.
 If the EWOC is empty, nil is returned."
+  (unless pos (setq pos (point)))
   (ewoc--set-buffer-bind-dll-let* ewoc
       ((footer (ewoc--footer ewoc)))
 
@@ -491,13 +492,16 @@
     (dolist (node nodes)
       (ewoc--refresh-node (ewoc--pretty-printer ewoc) node))))
 
-(defun ewoc-goto-prev (ewoc pos arg)
+(defun ewoc-goto-prev (ewoc arg)
   "Move point to the ARGth previous element.
 Don't move if we are at the first element, or if EWOC is empty.
 Returns the node we moved to."
   (ewoc--set-buffer-bind-dll-let* ewoc
-      ((node (ewoc-locate ewoc pos (ewoc--last-node ewoc))))
+      ((node (ewoc-locate ewoc (point) (ewoc--last-node ewoc))))
     (when node
+      ;; If we were past the last element, first jump to it.
+      (when (>= (point) (ewoc--node-start-marker (ewoc--node-right node)))
+	(setq arg (1- arg)))
       (while (and node (> arg 0))
 	(setq arg (1- arg))
 	(setq node (ewoc--node-prev dll node)))
@@ -506,18 +510,17 @@
 	(setq node (ewoc--node-nth dll 1)))
       (ewoc-goto-node ewoc node))))
 
-(defun ewoc-goto-next (ewoc pos arg)
+(defun ewoc-goto-next (ewoc arg)
   "Move point to the ARGth next element.
-Don't move if we are at the last element.
-Returns the node."
+Returns the node (or nil if we just passed the last node)."
   (ewoc--set-buffer-bind-dll-let* ewoc
-      ((node (ewoc-locate ewoc pos (ewoc--last-node ewoc))))
+      ((node (ewoc-locate ewoc (point) (ewoc--last-node ewoc))))
     (while (and node (> arg 0))
       (setq arg (1- arg))
       (setq node (ewoc--node-next dll node)))
     ;; Never step below the first element.
-    (unless (ewoc--filter-hf-nodes ewoc node)
-      (setq node (ewoc--node-nth dll -2)))
+    ;; (unless (ewoc--filter-hf-nodes ewoc node)
+    ;;   (setq node (ewoc--node-nth dll -2)))
     (ewoc-goto-node ewoc node)))
 
 (defun ewoc-goto-node (ewoc node)
--- a/lisp/pcvs.el	Wed Aug 16 20:20:43 2000 +0000
+++ b/lisp/pcvs.el	Wed Aug 16 20:27:39 2000 +0000
@@ -14,7 +14,7 @@
 ;; Maintainer: (Stefan Monnier) monnier+lists/cvs/pcl@flint.cs.yale.edu
 ;; Keywords: CVS, version control, release management
 ;; Version: $Name:  $
-;; Revision: $Id: pcvs.el,v 1.7 2000/08/06 09:18:00 gerd Exp $
+;; Revision: $Id: pcvs.el,v 1.8 2000/08/09 15:27:48 monnier Exp $
 
 ;; This file is part of GNU Emacs.
 
@@ -57,12 +57,10 @@
 ;; ******** FIX THE DOCUMENTATION *********
 ;; 
 ;; - hide fileinfos without getting rid of them (will require ewok work).
-;; - proper `g' that passes safe args and uses either cvs-status or cvs-examine
 ;; - add toolbar entries
 ;; - marking
 ;;    marking directories should jump to just after the dir.
 ;;    allow (un)marking directories at a time with the mouse.
-;;    marking with the mouse should not move point.
 ;; - liveness indicator
 ;; - indicate in docstring if the cmd understands the `b' prefix(es).
 ;; - call smerge-mode when opening CONFLICT files.
@@ -81,8 +79,7 @@
 ;; 	- checks out module, or alternately does update join
 ;; 	- does "cvs -n tag LAST_VENDOR" to find old files into *cvs*
 ;;    cvs-export
-;; 	(with completion on tag names and hooks to
-;; 	help generate full releases)
+;; 	(with completion on tag names and hooks to help generate full releases)
 ;; - allow cvs-cmd-do to either clear the marks or not.
 ;; - display stickiness information.  And current CVS/Tag as well.
 ;; - write 'cvs-mode-admin' to do arbitrary 'cvs admin' commands
@@ -101,10 +98,8 @@
 ;; - maybe poll/check CVS/Entries files to react to external `cvs' commands ?
 ;; - some kind of `cvs annotate' support ?
 ;; 	but vc-annotate can be used instead.
-;; - dynamic `g' mapping
-;; 	Make 'g', and perhaps other commands, use either cvs-update or
-;; 	cvs-examine depending on the read-only status of the cvs buffer, for
-;; 	instance.
+;; - proper `g' that passes safe args and uses either cvs-status or cvs-examine
+;;   maybe also use cvs-update depending on I-don't-know-what.
 ;; - add message-levels so that we can hide some levels of messages
 
 ;;; Code:
@@ -138,7 +133,7 @@
 (defun cvs-defaults (&rest defs)
   (let ((defs (cvs-first defs cvs-shared-start)))
     (append defs
-	    (make-list (- cvs-shared-start (length defs)) (nth 0 defs))
+	    (make-list (- cvs-shared-start (length defs)) (car defs))
 	    cvs-shared-flags)))
 
 ;; For cvs flags, we need to add "-f" to override the cvsrc settings
@@ -860,7 +855,7 @@
 
 (defun-cvs-mode (cvs-mode-revert-buffer . SIMPLE)
                 (&optional ignore-auto noconfirm)
-  "Rerun cvs-examine on the current directory with the defauls flags."
+  "Rerun `cvs-examine' on the current directory with the defauls flags."
   (interactive)
   (cvs-examine default-directory t))
 
@@ -1087,13 +1082,13 @@
   "Go to the previous line.
 If a prefix argument is given, move by that many lines."
   (interactive "p")
-  (ewoc-goto-prev cvs-cookies (point) arg))
+  (ewoc-goto-prev cvs-cookies arg))
 
 (defun-cvs-mode cvs-mode-next-line (arg)
   "Go to the next line.
 If a prefix argument is given, move by that many lines."
   (interactive "p")
-  (ewoc-goto-next cvs-cookies (point) arg))
+  (ewoc-goto-next cvs-cookies arg))
 
 ;;;;
 ;;;; Mark handling
@@ -1104,7 +1099,7 @@
 If the fileinfo is a directory, all the contents of that directory are
 marked instead. A directory can never be marked."
   (interactive)
-  (let* ((tin (ewoc-locate cvs-cookies (point)))
+  (let* ((tin (ewoc-locate cvs-cookies))
 	 (fi (ewoc-data tin)))
     (if (eq (cvs-fileinfo->type fi) 'DIRCHANGE)
 	;; it's a directory: let's mark all files inside
@@ -1125,8 +1120,9 @@
 (defun cvs-mouse-toggle-mark (e)
   "Toggle the mark of the entry under the mouse."
   (interactive "e")
-  (mouse-set-point e)
-  (cvs-mode-mark 'toggle))
+  (save-excursion
+    (mouse-set-point e)
+    (cvs-mode-mark 'toggle)))
 
 (defun-cvs-mode cvs-mode-unmark ()
   "Unmark the fileinfo on the current line."
@@ -1163,7 +1159,7 @@
 (defun-cvs-mode cvs-mode-unmark-up ()
   "Unmark the file on the previous line."
   (interactive)
-  (let ((tin (ewoc-goto-prev cvs-cookies (point) 1)))
+  (let ((tin (ewoc-goto-prev cvs-cookies 1)))
     (when tin
       (setf (cvs-fileinfo->marked (ewoc-data tin)) nil)
       (ewoc-invalidate cvs-cookies tin))))
@@ -1235,7 +1231,7 @@
 		  (or (and (not ignore-marks)
 			   (ewoc-collect cvs-cookies
 					      'cvs-fileinfo->marked))
-		      (list (ewoc-data (ewoc-locate cvs-cookies (point)))))))
+		      (list (ewoc-data (ewoc-locate cvs-cookies))))))
 
       (if (or ignore-contents (not (eq (cvs-fileinfo->type fi) 'DIRCHANGE)))
 	  (push fi fis)
@@ -1547,7 +1543,7 @@
 	 (fis (cvs-mode-marked 'diff "idiff" :file t)))
     (when (> (length fis) 2)
       (error "idiff-other cannot be applied to more than 2 files at a time."))
-    (let* ((fi1 (nth 0 fis))
+    (let* ((fi1 (car fis))
 	   (rev1-buf (if rev1 (cvs-retrieve-revision fi1 rev1)
 		       (find-file-noselect (cvs-fileinfo->full-path fi1))))
 	   rev2-buf)
@@ -1990,10 +1986,10 @@
 	(with-current-buffer buffer
 	  (let ((cvs-buf-was-ro buffer-read-only))
 	    (ignore-errors
-	      ;; Ideally, we'd like to prevent changing the (minor) modes.
-	      ;; But we do want to reset the mode for some cases, most notably
-	      ;; VC.  Maybe it'd better to reset VC explicitely ?
-	      (revert-buffer 'ignore-auto 'dont-ask)) ; 'preserve-modes
+	      (revert-buffer 'ignore-auto 'dont-ask 'preserve-modes)
+	      ;; `preserve-modes' avoids changing the (minor) modes.  But we
+	      ;; do want to reset the mode for VC, so we do it explicitly.
+	      (vc-find-file-hook))
 	    ;; protect the buffer-read-only setting
 	    (if cvs-buf-was-ro (toggle-read-only 1))))))))