Mercurial > emacs
comparison lisp/emacs-lisp/ewoc.el @ 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 | 06cfa273543d |
children | d5d7a3fbf10c |
comparison
equal
deleted
inserted
replaced
30878:13a1a0ec31e5 | 30879:3a1ff1caafe2 |
---|---|
102 ;; (defun ewoc-next (ewoc node) | 102 ;; (defun ewoc-next (ewoc node) |
103 ;; (defun ewoc-prev (ewoc node) | 103 ;; (defun ewoc-prev (ewoc node) |
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) |
114 ;; (defun ewoc-buffer (ewoc) | 114 ;; (defun ewoc-buffer (ewoc) |
115 ;; (defun ewoc-get-hf (ewoc) | 115 ;; (defun ewoc-get-hf (ewoc) |
413 (setq next (ewoc--node-next dll node)) | 413 (setq next (ewoc--node-next dll node)) |
414 (unless (apply predicate (ewoc--node-data node) args) | 414 (unless (apply predicate (ewoc--node-data node) args) |
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. |
420 POS may be a marker or an integer. | 420 POS may be a marker or an integer. It defaults to point. |
421 GUESS should be a node that it is likely that POS is near. | 421 GUESS should be a node that it is likely that POS is near. |
422 | 422 |
423 If POS points before the first element, the first node is returned. | 423 If POS points before the first element, the first node is returned. |
424 If POS points after the last element, the last node is returned. | 424 If POS points after the last element, the last node is returned. |
425 If the EWOC is empty, nil is returned." | 425 If 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 |
429 (cond | 430 (cond |
430 ;; Nothing present? | 431 ;; Nothing present? |
489 The pretty-printer that for EWOC will be called for all NODES." | 490 The pretty-printer that for EWOC will be called for all NODES." |
490 (ewoc--set-buffer-bind-dll ewoc | 491 (ewoc--set-buffer-bind-dll ewoc |
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. |
496 Don't move if we are at the first element, or if EWOC is empty. | 497 Don't move if we are at the first element, or if EWOC is empty. |
497 Returns the node we moved to." | 498 Returns 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))) |
504 ;; Never step above the first element. | 508 ;; Never step above the first element. |
505 (unless (ewoc--filter-hf-nodes ewoc node) | 509 (unless (ewoc--filter-hf-nodes ewoc node) |
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. |
511 Don't move if we are at the last element. | 515 Returns the node (or nil if we just passed the last node)." |
512 Returns 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) |
524 "Move point to NODE." | 527 "Move point to NODE." |
525 (ewoc--set-buffer-bind-dll ewoc | 528 (ewoc--set-buffer-bind-dll ewoc |