aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2000-08-16 20:27:39 +0000
committerStefan Monnier2000-08-16 20:27:39 +0000
commit44946a4c9e54ff8161c4d6bbbfc16f0ff5244b23 (patch)
tree666b2df4fd157daeee382c2766a9aa47dffec31b
parentffb4b7a11d543b4d05eb998818e9d4fe06ae4fad (diff)
downloademacs-44946a4c9e54ff8161c4d6bbbfc16f0ff5244b23.tar.gz
emacs-44946a4c9e54ff8161c4d6bbbfc16f0ff5244b23.zip
* 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.
-rw-r--r--lisp/emacs-lisp/ewoc.el29
-rw-r--r--lisp/pcvs.el42
2 files changed, 35 insertions, 36 deletions
diff --git a/lisp/emacs-lisp/ewoc.el b/lisp/emacs-lisp/ewoc.el
index 9c03b627f7a..bcf8a732a1d 100644
--- a/lisp/emacs-lisp/ewoc.el
+++ b/lisp/emacs-lisp/ewoc.el
@@ -104,10 +104,10 @@
104;; (defun ewoc-nth (ewoc n) 104;; (defun ewoc-nth (ewoc n)
105;; (defun ewoc-map (map-function ewoc &rest args) 105;; (defun ewoc-map (map-function ewoc &rest args)
106;; (defun ewoc-filter (ewoc predicate &rest args) 106;; (defun ewoc-filter (ewoc predicate &rest args)
107;; (defun ewoc-locate (ewoc pos &optional guess) 107;; (defun ewoc-locate (ewoc &optional pos guess)
108;; (defun ewoc-invalidate (ewoc &rest nodes) 108;; (defun ewoc-invalidate (ewoc &rest nodes)
109;; (defun ewoc-goto-prev (ewoc pos arg) 109;; (defun ewoc-goto-prev (ewoc arg)
110;; (defun ewoc-goto-next (ewoc pos arg) 110;; (defun ewoc-goto-next (ewoc arg)
111;; (defun ewoc-goto-node (ewoc node) 111;; (defun ewoc-goto-node (ewoc node)
112;; (defun ewoc-refresh (ewoc) 112;; (defun ewoc-refresh (ewoc)
113;; (defun ewoc-collect (ewoc predicate &rest args) 113;; (defun ewoc-collect (ewoc predicate &rest args)
@@ -415,14 +415,15 @@ ARGS are given they will be passed to the PREDICATE."
415 (ewoc--delete-node-internal ewoc node)) 415 (ewoc--delete-node-internal ewoc node))
416 (setq node next)))) 416 (setq node next))))
417 417
418(defun ewoc-locate (ewoc pos &optional guess) 418(defun ewoc-locate (ewoc &optional pos guess)
419 "Return the node that POS (a buffer position) is within. 419 "Return the node that POS (a buffer position) is within.
420POS may be a marker or an integer. 420POS may be a marker or an integer. It defaults to point.
421GUESS should be a node that it is likely that POS is near. 421GUESS should be a node that it is likely that POS is near.
422 422
423If POS points before the first element, the first node is returned. 423If POS points before the first element, the first node is returned.
424If POS points after the last element, the last node is returned. 424If POS points after the last element, the last node is returned.
425If the EWOC is empty, nil is returned." 425If the EWOC is empty, nil is returned."
426 (unless pos (setq pos (point)))
426 (ewoc--set-buffer-bind-dll-let* ewoc 427 (ewoc--set-buffer-bind-dll-let* ewoc
427 ((footer (ewoc--footer ewoc))) 428 ((footer (ewoc--footer ewoc)))
428 429
@@ -491,13 +492,16 @@ The pretty-printer that for EWOC will be called for all NODES."
491 (dolist (node nodes) 492 (dolist (node nodes)
492 (ewoc--refresh-node (ewoc--pretty-printer ewoc) node)))) 493 (ewoc--refresh-node (ewoc--pretty-printer ewoc) node))))
493 494
494(defun ewoc-goto-prev (ewoc pos arg) 495(defun ewoc-goto-prev (ewoc arg)
495 "Move point to the ARGth previous element. 496 "Move point to the ARGth previous element.
496Don't move if we are at the first element, or if EWOC is empty. 497Don't move if we are at the first element, or if EWOC is empty.
497Returns the node we moved to." 498Returns the node we moved to."
498 (ewoc--set-buffer-bind-dll-let* ewoc 499 (ewoc--set-buffer-bind-dll-let* ewoc
499 ((node (ewoc-locate ewoc pos (ewoc--last-node ewoc)))) 500 ((node (ewoc-locate ewoc (point) (ewoc--last-node ewoc))))
500 (when node 501 (when node
502 ;; If we were past the last element, first jump to it.
503 (when (>= (point) (ewoc--node-start-marker (ewoc--node-right node)))
504 (setq arg (1- arg)))
501 (while (and node (> arg 0)) 505 (while (and node (> arg 0))
502 (setq arg (1- arg)) 506 (setq arg (1- arg))
503 (setq node (ewoc--node-prev dll node))) 507 (setq node (ewoc--node-prev dll node)))
@@ -506,18 +510,17 @@ Returns the node we moved to."
506 (setq node (ewoc--node-nth dll 1))) 510 (setq node (ewoc--node-nth dll 1)))
507 (ewoc-goto-node ewoc node)))) 511 (ewoc-goto-node ewoc node))))
508 512
509(defun ewoc-goto-next (ewoc pos arg) 513(defun ewoc-goto-next (ewoc arg)
510 "Move point to the ARGth next element. 514 "Move point to the ARGth next element.
511Don't move if we are at the last element. 515Returns the node (or nil if we just passed the last node)."
512Returns the node."
513 (ewoc--set-buffer-bind-dll-let* ewoc 516 (ewoc--set-buffer-bind-dll-let* ewoc
514 ((node (ewoc-locate ewoc pos (ewoc--last-node ewoc)))) 517 ((node (ewoc-locate ewoc (point) (ewoc--last-node ewoc))))
515 (while (and node (> arg 0)) 518 (while (and node (> arg 0))
516 (setq arg (1- arg)) 519 (setq arg (1- arg))
517 (setq node (ewoc--node-next dll node))) 520 (setq node (ewoc--node-next dll node)))
518 ;; Never step below the first element. 521 ;; Never step below the first element.
519 (unless (ewoc--filter-hf-nodes ewoc node) 522 ;; (unless (ewoc--filter-hf-nodes ewoc node)
520 (setq node (ewoc--node-nth dll -2))) 523 ;; (setq node (ewoc--node-nth dll -2)))
521 (ewoc-goto-node ewoc node))) 524 (ewoc-goto-node ewoc node)))
522 525
523(defun ewoc-goto-node (ewoc node) 526(defun ewoc-goto-node (ewoc node)
diff --git a/lisp/pcvs.el b/lisp/pcvs.el
index 638744ec20a..6efd7359aba 100644
--- a/lisp/pcvs.el
+++ b/lisp/pcvs.el
@@ -14,7 +14,7 @@
14;; Maintainer: (Stefan Monnier) monnier+lists/cvs/pcl@flint.cs.yale.edu 14;; Maintainer: (Stefan Monnier) monnier+lists/cvs/pcl@flint.cs.yale.edu
15;; Keywords: CVS, version control, release management 15;; Keywords: CVS, version control, release management
16;; Version: $Name: $ 16;; Version: $Name: $
17;; Revision: $Id: pcvs.el,v 1.7 2000/08/06 09:18:00 gerd Exp $ 17;; Revision: $Id: pcvs.el,v 1.8 2000/08/09 15:27:48 monnier Exp $
18 18
19;; This file is part of GNU Emacs. 19;; This file is part of GNU Emacs.
20 20
@@ -57,12 +57,10 @@
57;; ******** FIX THE DOCUMENTATION ********* 57;; ******** FIX THE DOCUMENTATION *********
58;; 58;;
59;; - hide fileinfos without getting rid of them (will require ewok work). 59;; - hide fileinfos without getting rid of them (will require ewok work).
60;; - proper `g' that passes safe args and uses either cvs-status or cvs-examine
61;; - add toolbar entries 60;; - add toolbar entries
62;; - marking 61;; - marking
63;; marking directories should jump to just after the dir. 62;; marking directories should jump to just after the dir.
64;; allow (un)marking directories at a time with the mouse. 63;; allow (un)marking directories at a time with the mouse.
65;; marking with the mouse should not move point.
66;; - liveness indicator 64;; - liveness indicator
67;; - indicate in docstring if the cmd understands the `b' prefix(es). 65;; - indicate in docstring if the cmd understands the `b' prefix(es).
68;; - call smerge-mode when opening CONFLICT files. 66;; - call smerge-mode when opening CONFLICT files.
@@ -81,8 +79,7 @@
81;; - checks out module, or alternately does update join 79;; - checks out module, or alternately does update join
82;; - does "cvs -n tag LAST_VENDOR" to find old files into *cvs* 80;; - does "cvs -n tag LAST_VENDOR" to find old files into *cvs*
83;; cvs-export 81;; cvs-export
84;; (with completion on tag names and hooks to 82;; (with completion on tag names and hooks to help generate full releases)
85;; help generate full releases)
86;; - allow cvs-cmd-do to either clear the marks or not. 83;; - allow cvs-cmd-do to either clear the marks or not.
87;; - display stickiness information. And current CVS/Tag as well. 84;; - display stickiness information. And current CVS/Tag as well.
88;; - write 'cvs-mode-admin' to do arbitrary 'cvs admin' commands 85;; - write 'cvs-mode-admin' to do arbitrary 'cvs admin' commands
@@ -101,10 +98,8 @@
101;; - maybe poll/check CVS/Entries files to react to external `cvs' commands ? 98;; - maybe poll/check CVS/Entries files to react to external `cvs' commands ?
102;; - some kind of `cvs annotate' support ? 99;; - some kind of `cvs annotate' support ?
103;; but vc-annotate can be used instead. 100;; but vc-annotate can be used instead.
104;; - dynamic `g' mapping 101;; - proper `g' that passes safe args and uses either cvs-status or cvs-examine
105;; Make 'g', and perhaps other commands, use either cvs-update or 102;; maybe also use cvs-update depending on I-don't-know-what.
106;; cvs-examine depending on the read-only status of the cvs buffer, for
107;; instance.
108;; - add message-levels so that we can hide some levels of messages 103;; - add message-levels so that we can hide some levels of messages
109 104
110;;; Code: 105;;; Code:
@@ -138,7 +133,7 @@
138(defun cvs-defaults (&rest defs) 133(defun cvs-defaults (&rest defs)
139 (let ((defs (cvs-first defs cvs-shared-start))) 134 (let ((defs (cvs-first defs cvs-shared-start)))
140 (append defs 135 (append defs
141 (make-list (- cvs-shared-start (length defs)) (nth 0 defs)) 136 (make-list (- cvs-shared-start (length defs)) (car defs))
142 cvs-shared-flags))) 137 cvs-shared-flags)))
143 138
144;; For cvs flags, we need to add "-f" to override the cvsrc settings 139;; For cvs flags, we need to add "-f" to override the cvsrc settings
@@ -860,7 +855,7 @@ With a prefix argument, prompt for cvs FLAGS to use."
860 855
861(defun-cvs-mode (cvs-mode-revert-buffer . SIMPLE) 856(defun-cvs-mode (cvs-mode-revert-buffer . SIMPLE)
862 (&optional ignore-auto noconfirm) 857 (&optional ignore-auto noconfirm)
863 "Rerun cvs-examine on the current directory with the defauls flags." 858 "Rerun `cvs-examine' on the current directory with the defauls flags."
864 (interactive) 859 (interactive)
865 (cvs-examine default-directory t)) 860 (cvs-examine default-directory t))
866 861
@@ -1087,13 +1082,13 @@ Full documentation is in the Texinfo file."
1087 "Go to the previous line. 1082 "Go to the previous line.
1088If a prefix argument is given, move by that many lines." 1083If a prefix argument is given, move by that many lines."
1089 (interactive "p") 1084 (interactive "p")
1090 (ewoc-goto-prev cvs-cookies (point) arg)) 1085 (ewoc-goto-prev cvs-cookies arg))
1091 1086
1092(defun-cvs-mode cvs-mode-next-line (arg) 1087(defun-cvs-mode cvs-mode-next-line (arg)
1093 "Go to the next line. 1088 "Go to the next line.
1094If a prefix argument is given, move by that many lines." 1089If a prefix argument is given, move by that many lines."
1095 (interactive "p") 1090 (interactive "p")
1096 (ewoc-goto-next cvs-cookies (point) arg)) 1091 (ewoc-goto-next cvs-cookies arg))
1097 1092
1098;;;; 1093;;;;
1099;;;; Mark handling 1094;;;; Mark handling
@@ -1104,7 +1099,7 @@ If a prefix argument is given, move by that many lines."
1104If the fileinfo is a directory, all the contents of that directory are 1099If the fileinfo is a directory, all the contents of that directory are
1105marked instead. A directory can never be marked." 1100marked instead. A directory can never be marked."
1106 (interactive) 1101 (interactive)
1107 (let* ((tin (ewoc-locate cvs-cookies (point))) 1102 (let* ((tin (ewoc-locate cvs-cookies))
1108 (fi (ewoc-data tin))) 1103 (fi (ewoc-data tin)))
1109 (if (eq (cvs-fileinfo->type fi) 'DIRCHANGE) 1104 (if (eq (cvs-fileinfo->type fi) 'DIRCHANGE)
1110 ;; it's a directory: let's mark all files inside 1105 ;; it's a directory: let's mark all files inside
@@ -1125,8 +1120,9 @@ marked instead. A directory can never be marked."
1125(defun cvs-mouse-toggle-mark (e) 1120(defun cvs-mouse-toggle-mark (e)
1126 "Toggle the mark of the entry under the mouse." 1121 "Toggle the mark of the entry under the mouse."
1127 (interactive "e") 1122 (interactive "e")
1128 (mouse-set-point e) 1123 (save-excursion
1129 (cvs-mode-mark 'toggle)) 1124 (mouse-set-point e)
1125 (cvs-mode-mark 'toggle)))
1130 1126
1131(defun-cvs-mode cvs-mode-unmark () 1127(defun-cvs-mode cvs-mode-unmark ()
1132 "Unmark the fileinfo on the current line." 1128 "Unmark the fileinfo on the current line."
@@ -1163,7 +1159,7 @@ they should always be unmarked."
1163(defun-cvs-mode cvs-mode-unmark-up () 1159(defun-cvs-mode cvs-mode-unmark-up ()
1164 "Unmark the file on the previous line." 1160 "Unmark the file on the previous line."
1165 (interactive) 1161 (interactive)
1166 (let ((tin (ewoc-goto-prev cvs-cookies (point) 1))) 1162 (let ((tin (ewoc-goto-prev cvs-cookies 1)))
1167 (when tin 1163 (when tin
1168 (setf (cvs-fileinfo->marked (ewoc-data tin)) nil) 1164 (setf (cvs-fileinfo->marked (ewoc-data tin)) nil)
1169 (ewoc-invalidate cvs-cookies tin)))) 1165 (ewoc-invalidate cvs-cookies tin))))
@@ -1235,7 +1231,7 @@ Args: &optional IGNORE-MARKS IGNORE-CONTENTS."
1235 (or (and (not ignore-marks) 1231 (or (and (not ignore-marks)
1236 (ewoc-collect cvs-cookies 1232 (ewoc-collect cvs-cookies
1237 'cvs-fileinfo->marked)) 1233 'cvs-fileinfo->marked))
1238 (list (ewoc-data (ewoc-locate cvs-cookies (point))))))) 1234 (list (ewoc-data (ewoc-locate cvs-cookies))))))
1239 1235
1240 (if (or ignore-contents (not (eq (cvs-fileinfo->type fi) 'DIRCHANGE))) 1236 (if (or ignore-contents (not (eq (cvs-fileinfo->type fi) 'DIRCHANGE)))
1241 (push fi fis) 1237 (push fi fis)
@@ -1547,7 +1543,7 @@ Signal an error if there is no backup file."
1547 (fis (cvs-mode-marked 'diff "idiff" :file t))) 1543 (fis (cvs-mode-marked 'diff "idiff" :file t)))
1548 (when (> (length fis) 2) 1544 (when (> (length fis) 2)
1549 (error "idiff-other cannot be applied to more than 2 files at a time.")) 1545 (error "idiff-other cannot be applied to more than 2 files at a time."))
1550 (let* ((fi1 (nth 0 fis)) 1546 (let* ((fi1 (car fis))
1551 (rev1-buf (if rev1 (cvs-retrieve-revision fi1 rev1) 1547 (rev1-buf (if rev1 (cvs-retrieve-revision fi1 rev1)
1552 (find-file-noselect (cvs-fileinfo->full-path fi1)))) 1548 (find-file-noselect (cvs-fileinfo->full-path fi1))))
1553 rev2-buf) 1549 rev2-buf)
@@ -1990,10 +1986,10 @@ this file, or a list of arguments to send to the program."
1990 (with-current-buffer buffer 1986 (with-current-buffer buffer
1991 (let ((cvs-buf-was-ro buffer-read-only)) 1987 (let ((cvs-buf-was-ro buffer-read-only))
1992 (ignore-errors 1988 (ignore-errors
1993 ;; Ideally, we'd like to prevent changing the (minor) modes. 1989 (revert-buffer 'ignore-auto 'dont-ask 'preserve-modes)
1994 ;; But we do want to reset the mode for some cases, most notably 1990 ;; `preserve-modes' avoids changing the (minor) modes. But we
1995 ;; VC. Maybe it'd better to reset VC explicitely ? 1991 ;; do want to reset the mode for VC, so we do it explicitly.
1996 (revert-buffer 'ignore-auto 'dont-ask)) ; 'preserve-modes 1992 (vc-find-file-hook))
1997 ;; protect the buffer-read-only setting 1993 ;; protect the buffer-read-only setting
1998 (if cvs-buf-was-ro (toggle-read-only 1)))))))) 1994 (if cvs-buf-was-ro (toggle-read-only 1))))))))
1999 1995