]> git.eshelyaron.com Git - emacs.git/commitdiff
* viper-ex.el: Patch by Samuel Padgett. Copyright papers received.
authorMichael Kifer <kifer@cs.stonybrook.edu>
Tue, 16 Apr 2002 05:49:11 +0000 (05:49 +0000)
committerMichael Kifer <kifer@cs.stonybrook.edu>
Tue, 16 Apr 2002 05:49:11 +0000 (05:49 +0000)
(viper-ex-print-buf-name): New variable.
(viper-ex-print-buf): New variable.
(ex-token-alist): Invoke ex-print on ":print" Ex commands.
(ex-g-marks): New variable.
(ex-print): New function.
(ex-print-display-lines): New function.

* viper.el (viper-set-hooks): add window-setup-hook, which sets
the cursor color.

* ediff-util.el (ediff-cleanup-mess): delete ctl window on exit
when the window is not in its own frame.
(ediff-clone-buffer-for-region-comparison): more robust window
arrangement while prompting for regions to compare.
(ediff-make-cloned-buffer): use generate-new-buffer-name.
(ediff-inferior-compare-regions): deleted unused vars
ctl-buf and quit-now.

lisp/ChangeLog
lisp/ediff-util.el
lisp/emulation/viper-ex.el
lisp/emulation/viper.el
man/ediff.texi
man/viper.texi

index e0dec296a54b4def5033ac18b4db7d5dfa16f144..0839bbb42d1bde7c1b4c135a768f20ee38181c98 100644 (file)
@@ -1,3 +1,24 @@
+2002-04-16  Michael Kifer  <kifer@cs.stonybrook.edu>
+       
+        * viper-ex.el: Patch by Samuel Padgett. Copyright papers received.
+       (viper-ex-print-buf-name): New variable.
+       (viper-ex-print-buf): New variable.
+       (ex-token-alist): Invoke ex-print on ":print" Ex commands.
+       (ex-g-marks): New variable.
+       (ex-print): New function.
+       (ex-print-display-lines): New function.
+       
+       * viper.el (viper-set-hooks): add window-setup-hook, which sets
+       the cursor color.
+       
+       * ediff-util.el (ediff-cleanup-mess): delete ctl window on exit
+       when the window is not in its own frame.
+       (ediff-clone-buffer-for-region-comparison): more robust window
+       arrangement while prompting for regions to compare.
+       (ediff-make-cloned-buffer): use generate-new-buffer-name.
+       (ediff-inferior-compare-regions): deleted unused vars
+       ctl-buf and quit-now.
+       
 2002-04-15  Richard M. Stallman  <rms@gnu.org>
 
        * facemenu.el (facemenu-add-new-face): Use this only for faces.
index 99d013616246b25de2c72f7861bef805cf6eb901..95074d6ce47b42900bcd9ca67201e557b3665d25 100644 (file)
 
 (defvar ediff-after-quit-hook-internal nil)
 
+(and noninteractive
+     (eval-when-compile
+        (load "reporter" 'noerror)))
+
 (eval-when-compile
   (let ((load-path (cons (expand-file-name ".") load-path)))
     (or (featurep 'ediff-init)
@@ -2554,6 +2558,7 @@ temporarily reverses the meaning of this variable."
         (buff-B ediff-buffer-B)
         (buff-C ediff-buffer-C)
         (ctl-buf  ediff-control-buffer)
+        (ctl-wind  (ediff-get-visible-buffer-window ctl-buf))
         (ctl-frame ediff-control-frame)
         (three-way-job ediff-3way-job)
         (main-frame (cond ((window-live-p ediff-window-A) 
@@ -2571,8 +2576,12 @@ temporarily reverses the meaning of this variable."
     (if (boundp 'ediff-patch-diagnostics)
        (ediff-kill-buffer-carefully ediff-patch-diagnostics))
 
-    (if (and (ediff-window-display-p) (frame-live-p ctl-frame))
-       (delete-frame ctl-frame))
+    ;; delete control frame or window
+    (cond ((and (ediff-window-display-p) (frame-live-p ctl-frame))
+          (delete-frame ctl-frame))
+         ((window-live-p ctl-wind)
+          (delete-window ctl-wind)))
+
     ;; Hide bottom toolbar.  --marcpa
     (if (not (ediff-multiframe-setup-p))
        (ediff-kill-bottom-toolbar))
@@ -2603,9 +2612,9 @@ temporarily reverses the meaning of this variable."
                               (ediff-get-visible-buffer-window buff-B))
                           (ediff-buffer-live-p buff-C))
                      (funcall ediff-split-window-function))
-                 (switch-to-buffer buff-C)
-                 (balance-windows)))
+                 (switch-to-buffer buff-C)))
          (error)))
+    (balance-windows)
     (message "")
     ))
 
@@ -3308,28 +3317,32 @@ Without an argument, it saves customized diff argument, if available
 ;; idea suggested by Hannu Koivisto <azure@iki.fi>
 (defun ediff-clone-buffer-for-region-comparison (buff region-name)
   (let ((cloned-buff (ediff-make-cloned-buffer buff region-name))
-       (wind (ediff-get-visible-buffer-window buff))
        (pop-up-windows t)
+       wind
        other-wind
        msg-buf)
     (ediff-with-current-buffer cloned-buff
       (setq ediff-temp-indirect-buffer t))
-    (if (window-live-p wind)
-       (set-window-buffer wind cloned-buff))
     (pop-to-buffer cloned-buff)
+    (setq wind (ediff-get-visible-buffer-window cloned-buff))
+    (select-window wind)
+    (delete-other-windows)
+    (split-window-vertically)
+    (ediff-select-lowest-window)
+    (setq other-wind (selected-window))
     (with-temp-buffer
       (erase-buffer)
       (insert
        (format "\n   *******  Mark a region in buffer %s  *******\n"
               (buffer-name cloned-buff)))
       (insert
-       (format "\n\t      When done, type %s       Use %s to abort\n    "
-              (ediff-format-bindings-of 'exit-recursive-edit)
-              (ediff-format-bindings-of 'abort-recursive-edit)))
+       (ediff-with-current-buffer buff
+        (format "\n\t      When done, type %s       Use %s to abort\n    "
+                (ediff-format-bindings-of 'exit-recursive-edit)
+                (ediff-format-bindings-of 'abort-recursive-edit))))
       (goto-char (point-min))
       (setq msg-buf (current-buffer))
-      (other-window 1)
-      (set-window-buffer (selected-window) msg-buf)
+      (set-window-buffer other-wind msg-buf)
       (shrink-window-if-larger-than-buffer)
       (if (window-live-p wind)
          (select-window wind))
@@ -3363,9 +3376,9 @@ Without an argument, it saves customized diff argument, if available
 
 (defun ediff-make-cloned-buffer (buff region-name)
   (ediff-make-indirect-buffer
-   buff (concat
-        (if (stringp buff) buff (buffer-name buff))
-        region-name (symbol-name (gensym)))))
+   buff (generate-new-buffer-name
+         (concat (if (stringp buff) buff (buffer-name buff)) region-name))
+   ))
 
 
 (defun ediff-make-indirect-buffer (base-buf indirect-buf-name)
@@ -3444,8 +3457,6 @@ Ediff Control Panel to restore highlighting."
   (let ((answer "")
        (possibilities (list ?A ?B ?C))
        (zmacs-regions t)
-       (ctl-buf (current-buffer))
-       quit-now
        use-current-diff-p
        begA begB endA endB bufA bufB)
 
index cb2f472af5edb4c177ac5e339fdc4685494b1707..f3de49c03d8ea69856c1a7592bfdac887a99f3d7 100644 (file)
@@ -69,6 +69,8 @@
 (defconst viper-ex-work-buf-name " *ex-working-space*")
 (defconst viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
 (defconst viper-ex-tmp-buf-name " *ex-tmp*")
+(defconst viper-ex-print-buf-name " *ex-print*")
+(defconst viper-ex-print-buf (get-buffer-create viper-ex-print-buf-name))
 
 
 ;;; ex-commands...
        ("next"                 (ex-next ex-cycle-other-window))
        ("p"                    "print")
        ("preserve"             (ex-preserve))
+       ("print"                (ex-print))
        ("put"                  (ex-put))
        ("pwd"                  (ex-pwd))
        ("quit"                 (ex-quit))
        ("open"                 (ex-cmd-obsolete "open"))
 
        ("list"                 (ex-cmd-not-yet "list"))
-       ("print"                (ex-cmd-not-yet "print"))
        ("z"                    (ex-cmd-not-yet "z"))
        ("#"                    (ex-cmd-not-yet "#"))
 
 (defvar ex-g-flag nil)
 ;; Flag indicating that :vglobal Ex command is being executed.
 (defvar ex-g-variant nil)
+;; Marks to operate on during a :global Ex command.
+(defvar ex-g-marks nil)
 
 ;; Save reg-exp used in substitute.
 (defvar ex-reg-exp nil)
@@ -1345,8 +1349,8 @@ reversed."
   (if (null ex-addresses)
       (setq ex-addresses (list (point-max) (point-min)))
     (viper-default-ex-addresses))
-  (let ((marks nil)
-       (mark-count 0)
+  (setq ex-g-marks nil)
+  (let ((mark-count 0)
        (end (car ex-addresses))
        (beg (car (cdr ex-addresses)))
        com-str)
@@ -1369,7 +1373,7 @@ reversed."
                (progn
                  (end-of-line)
                  (setq mark-count (1+ mark-count))
-                 (setq marks (cons (point-marker) marks)))))
+                 (setq ex-g-marks (cons (point-marker) ex-g-marks)))))
          (beginning-of-line)
          (if (bobp) (setq cont nil)
            (forward-line -1)
@@ -1379,11 +1383,11 @@ reversed."
       (set-buffer viper-ex-work-buf)
       ;; com-str is the command string, i.e., g/pattern/ or v/pattern'
       (setq com-str (buffer-substring (1+ (point)) (1- (point-max)))))
-    (while marks
-      (goto-char (car marks))
+    (while ex-g-marks
+      (goto-char (car ex-g-marks))
       (viper-ex nil com-str)
       (setq mark-count (1- mark-count))
-      (setq marks (cdr marks)))))
+      (setq ex-g-marks (cdr ex-g-marks)))))
 
 ;; Ex goto command
 (defun ex-goto ()
@@ -2277,6 +2281,39 @@ Type 'mak ' (including the space) to run make with no args."
                                          'none)))
     ))
 
+(defun ex-print ()
+  (viper-default-ex-addresses)
+  (let ((end (car ex-addresses))
+       (beg (car (cdr ex-addresses))))
+    (if (> beg end) (error viper-FirstAddrExceedsSecond))
+    (save-excursion
+      (viper-enlarge-region beg end)
+      (if (or ex-g-flag ex-g-variant)
+         ;; When executing a global command, collect output of each
+         ;; print in viper-ex-print-buf.
+         (progn
+           (append-to-buffer viper-ex-print-buf (point) (mark t))
+           ;; Is this the last mark for the global command?
+           (unless (cdr ex-g-marks)
+             (with-current-buffer viper-ex-print-buf
+               (ex-print-display-lines (buffer-string))
+               (erase-buffer))))
+       (ex-print-display-lines (buffer-substring (point) (mark t)))))))
+
+(defun ex-print-display-lines (lines)
+  (cond
+   ;; String doesn't contain a newline.
+   ((not (string-match "\n" lines))
+    (message "%s" lines))
+   ;; String contains only one newline at the end.  Strip it off.
+   ((= (string-match "\n" lines) (1- (length lines)))
+    (message "%s" (substring lines 0 -1)))
+   ;; String spans more than one line.  Use a temporary buffer.
+   (t
+    (save-current-buffer
+      (with-output-to-temp-buffer " *viper-info*"
+       (princ lines))))))
+
 
 
 
index a0de2e2727510a22a993e0a1355c058405e538f9..27bcf021e803e88c75ca474341e061823bbf43ea 100644 (file)
@@ -834,6 +834,12 @@ remains buffer-local."
   (add-hook 'flyspell-mode-hook
            '(lambda ()
               (define-key flyspell-mouse-map viper-ESC-key nil)))
+  ;; if viper is started from .emacs, it might be impossible to get certain
+  ;; info about the display and windows until emacs initialization is complete
+  ;; So do it via the window-setup-hook
+  (add-hook 'window-setup-hook
+           '(lambda ()
+              (setq viper-vi-state-cursor-color (viper-get-cursor-color))))
 
   ;; Tell vc-diff to put *vc* in Vi mode
   (if (featurep 'vc)
index e8d2cec0738037eaffc3628555c826043f356a8b..f4256fc55aee548b8e0145c1b2086751348e186b 100644 (file)
@@ -2385,9 +2385,9 @@ made it work with VC, Marc Paquette <marcpa@@cam.org> wrote the
 toolbar support package for Ediff, and Hrvoje Niksic <hniksic@@xemacs.org>
 adapted it to the Emacs customization package.
 
-Many people provided help with bug reports, patches, and advice.
+Many people provided help with bug reports, feature suggestions, and advice.
 Without them, Ediff would not be nearly as useful as it is today.
-Here is a full list of contributors (I hope I didn't miss anyone):
+Here is a hopefully full list of contributors:
 
 @example
 Adrian Aichner (aichner@@ecf.teradyne.com),
index ee8722b47b099f2cc5053e66c2b5a5d119802faf..60b5fad820d86ad0d397976473d5be002444f5f8 100644 (file)
@@ -3691,9 +3691,14 @@ Move text between @kbd{x} and @kbd{y} to the position after @kbd{z}.
 @item  &
 Repeat latest Ex substitute command, e.g.
 @kbd{:s/wrong/right}.
-@item C-c /
-Toggle case-sensitive search.  With prefix argument, toggle vanilla/regular
-expression search.
+@item :x,yp
+@itemx :g/Pat/p
+@itemx :v/Pat/p
+The above commands display certain buffer lines in a
+temporary buffer. The first form above displays the buffer lines between
+@kbd{x} and @kbd{y}. The second displays the lines of the buffer, which
+match a given pattern. The third form displays the lines that do @emph{not}
+match the given pattern.
 @item #c<move>
 Change upper-case characters in the region to lower-case.
 @item #C<move>
@@ -3743,6 +3748,9 @@ get literal (non-regular-expression) search and how to stop search from
 wrapping around.
 
 @table @kbd
+@item C-c /
+Toggle case-sensitive search.  With prefix argument, toggle vanilla/regular
+expression search.
 @item <count>  /<string>
 To the <count>th occurrence of <string>.
 
@@ -4436,8 +4444,10 @@ based on the original VIP package by Masahiko Sato and on its enhancement,
 VIP 4.4, by Aamod Sane.  This manual is an adaptation of the manual for VIP
 4.4, which, in turn, was based on Sato's manual for VIP 3.5.
 
-Many contributors on the net pointed out bugs and suggested a number of
-useful features.  Here is a (hopefully) complete list of contributors:
+Many contributors on the Net pointed out bugs and suggested a number of
+useful features. Scott Bronson and Samuel Padgett contributed patches that
+were incorporated in this code.  Here is a hopefully complete list of
+contributors:
 
 @example
 aaronl@@vitelus.com (Aaron Lehmann),
@@ -4452,7 +4462,7 @@ dm@@scs.cs.nyu.edu (David Mazieres),
 dominik@@strw.LeidenUniv.nl (Carsten Dominik),
 dwallach@@cs.princeton.edu (Dan Wallach),
 dwight@@toolucky.llnl.gov (Dwight Shih),
-dxc@@xprt.net (David X. Callaway),
+dxc@@xprt.net (David X Callaway),
 edmonds@@edmonds.home.cs.ubc.ca (Brian Edmonds),
 gin@@mo.msk.ru (Golubev I.N.),
 gviswana@@cs.wisc.edu (Guhan Viswanathan),