From 241d963df0387874e59ca7b4a5e9140ac09e4b3c Mon Sep 17 00:00:00 2001 From: Michael Kifer Date: Tue, 16 Apr 2002 05:49:11 +0000 Subject: [PATCH] * 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. --- lisp/ChangeLog | 21 +++++++++++++++++++ lisp/ediff-util.el | 45 ++++++++++++++++++++++++---------------- lisp/emulation/viper-ex.el | 51 +++++++++++++++++++++++++++++++++++++++------- lisp/emulation/viper.el | 6 ++++++ man/ediff.texi | 4 ++-- man/viper.texi | 22 ++++++++++++++------ 6 files changed, 117 insertions(+), 32 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e0dec296a54..0839bbb42d1 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,24 @@ +2002-04-16 Michael Kifer + + * 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 * facemenu.el (facemenu-add-new-face): Use this only for faces. diff --git a/lisp/ediff-util.el b/lisp/ediff-util.el index 99d01361624..95074d6ce47 100644 --- a/lisp/ediff-util.el +++ b/lisp/ediff-util.el @@ -42,6 +42,10 @@ (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 (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) diff --git a/lisp/emulation/viper-ex.el b/lisp/emulation/viper-ex.el index cb2f472af5e..f3de49c03d8 100644 --- a/lisp/emulation/viper-ex.el +++ b/lisp/emulation/viper-ex.el @@ -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... @@ -133,6 +135,7 @@ ("next" (ex-next ex-cycle-other-window)) ("p" "print") ("preserve" (ex-preserve)) + ("print" (ex-print)) ("put" (ex-put)) ("pwd" (ex-pwd)) ("quit" (ex-quit)) @@ -176,7 +179,6 @@ ("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 "#")) @@ -279,6 +281,8 @@ (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)))))) + diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el index a0de2e27275..27bcf021e80 100644 --- a/lisp/emulation/viper.el +++ b/lisp/emulation/viper.el @@ -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) diff --git a/man/ediff.texi b/man/ediff.texi index e8d2cec0738..f4256fc55ae 100644 --- a/man/ediff.texi +++ b/man/ediff.texi @@ -2385,9 +2385,9 @@ made it work with VC, Marc Paquette wrote the toolbar support package for Ediff, and Hrvoje Niksic 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), diff --git a/man/viper.texi b/man/viper.texi index ee8722b47b0..60b5fad820d 100644 --- a/man/viper.texi +++ b/man/viper.texi @@ -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 Change upper-case characters in the region to lower-case. @item #C @@ -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 / To the th occurrence of . @@ -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), -- 2.11.4.GIT