1996-06-22 03:20:38 +00:00
|
|
|
;;; viper-ex.el --- functions implementing the Ex commands for Viper
|
1995-10-30 17:35:01 +00:00
|
|
|
|
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
* viper-init.el (viper-cond-compile-for-xemacs-or-emacs):
new macro that replaces viper-emacs-p and viper-xemacs-p in many
cases. Used to reduce the number of warnings.
* viper-cmd.el: use viper-cond-compile-for-xemacs-or-emacs.
(viper-standard-value): moved here from viper.el.
(viper-set-unread-command-events): moved to viper-util.el
(viper-check-minibuffer-overlay): make sure
viper-minibuffer-overlay is moved to cover the entire input field.
* viper-util.el: use viper-cond-compile-for-xemacs-or-emacs.
(viper-read-key-sequence, viper-set-unread-command-events,
viper-char-symbol-sequence-p, viper-char-array-p): moved here.
* viper-ex.el: use viper-cond-compile-for-xemacs-or-emacs.
* viper-keym.el: use viper-cond-compile-for-xemacs-or-emacs.
* viper-mous.el: use viper-cond-compile-for-xemacs-or-emacs.
* viper-macs.el (viper-char-array-p, viper-char-symbol-sequence-p,
viper-event-vector-p): moved to viper-util.el
* viper.el (viper-standard-value): moved to viper-cmd.el.
Use viper-cond-compile-for-xemacs-or-emacs.
* ediff-help.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff-hook.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff-init.el (ediff-cond-compile-for-xemacs-or-emacs): new
macro designed to be used in many places where ediff-emacs-p or
ediff-xemacs-p was previously used. Reduces the number of
warnings.
Use ediff-cond-compile-for-xemacs-or-emacs in many places in lieue
of ediff-xemacs-p.
(ediff-make-current-diff-overlay, ediff-highlight-diff-in-one-buffer,
ediff-convert-fine-diffs-to-overlays, ediff-empty-diff-region-p,
ediff-whitespace-diff-region-p, ediff-get-region-contents):
moved to ediff-util.el.
(ediff-event-key): moved here.
* ediff-merge.el: got rid of unreferenced variables.
* ediff-mult.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff-util.el: use ediff-cond-compile-for-xemacs-or-emacs.
(ediff-cleanup-mess): improved the way windows are set up after
quitting ediff.
(ediff-janitor): use ediff-dispose-of-variant-according-to-user.
(ediff-dispose-of-variant-according-to-user): new function
designed to be smarter and also understands indirect buffers.
(ediff-highlight-diff-in-one-buffer,
ediff-unhighlight-diff-in-one-buffer,
ediff-unhighlight-diffs-totally-in-one-buffer,
ediff-highlight-diff, ediff-highlight-diff,
ediff-unhighlight-diff, ediff-unhighlight-diffs-totally,
ediff-empty-diff-region-p, ediff-whitespace-diff-region-p,
ediff-get-region-contents, ediff-make-current-diff-overlay):
moved here.
(ediff-format-bindings-of): new function by Hannu Koivisto
<azure@iki.fi>.
(ediff-setup): make sure the merge buffer is always widened and
modifiable.
(ediff-write-merge-buffer-and-maybe-kill): refuse to write the
result of a merge into a file visited by another buffer.
(ediff-arrange-autosave-in-merge-jobs): check if the merge file
is visited by another buffer and ask to save/delete that buffer.
(ediff-verify-file-merge-buffer): new function to do the above.
* ediff-vers.el: load ediff-init.el at compile time.
* ediff-wind.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff.el (ediff-windows, ediff-regions-wordwise,
ediff-regions-linewise): use indirect buffers to improve
robustness and make it possible to compare regions of the same
buffer (even overlapping regions).
(ediff-clone-buffer-for-region-comparison,
ediff-clone-buffer-for-window-comparison): new functions.
(ediff-files-internal): refuse to compare identical files.
(ediff-regions-internal): get rid of the warning about comparing
regions of the same buffer.
* ediff-diff.el (ediff-convert-fine-diffs-to-overlays): moved here.
Plus the following fixes courtesy of Dave Love:
Doc fixes.
(ediff-word-1): Use word class and move - to the
front per regexp documentation.
(ediff-wordify): Bind forward-word-function outside loop.
(ediff-copy-to-buffer): Use insert-buffer-substring rather than
consing buffer contents.
(ediff-goto-word): Move syntax table setting outside loop.
2002-01-08 04:36:01 +00:00
|
|
|
;; Copyright (C) 1994, 95, 96, 97, 98, 2000, 01, 02 Free Software Foundation, Inc.
|
1995-02-20 23:15:10 +00:00
|
|
|
|
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
* viper-init.el (viper-cond-compile-for-xemacs-or-emacs):
new macro that replaces viper-emacs-p and viper-xemacs-p in many
cases. Used to reduce the number of warnings.
* viper-cmd.el: use viper-cond-compile-for-xemacs-or-emacs.
(viper-standard-value): moved here from viper.el.
(viper-set-unread-command-events): moved to viper-util.el
(viper-check-minibuffer-overlay): make sure
viper-minibuffer-overlay is moved to cover the entire input field.
* viper-util.el: use viper-cond-compile-for-xemacs-or-emacs.
(viper-read-key-sequence, viper-set-unread-command-events,
viper-char-symbol-sequence-p, viper-char-array-p): moved here.
* viper-ex.el: use viper-cond-compile-for-xemacs-or-emacs.
* viper-keym.el: use viper-cond-compile-for-xemacs-or-emacs.
* viper-mous.el: use viper-cond-compile-for-xemacs-or-emacs.
* viper-macs.el (viper-char-array-p, viper-char-symbol-sequence-p,
viper-event-vector-p): moved to viper-util.el
* viper.el (viper-standard-value): moved to viper-cmd.el.
Use viper-cond-compile-for-xemacs-or-emacs.
* ediff-help.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff-hook.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff-init.el (ediff-cond-compile-for-xemacs-or-emacs): new
macro designed to be used in many places where ediff-emacs-p or
ediff-xemacs-p was previously used. Reduces the number of
warnings.
Use ediff-cond-compile-for-xemacs-or-emacs in many places in lieue
of ediff-xemacs-p.
(ediff-make-current-diff-overlay, ediff-highlight-diff-in-one-buffer,
ediff-convert-fine-diffs-to-overlays, ediff-empty-diff-region-p,
ediff-whitespace-diff-region-p, ediff-get-region-contents):
moved to ediff-util.el.
(ediff-event-key): moved here.
* ediff-merge.el: got rid of unreferenced variables.
* ediff-mult.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff-util.el: use ediff-cond-compile-for-xemacs-or-emacs.
(ediff-cleanup-mess): improved the way windows are set up after
quitting ediff.
(ediff-janitor): use ediff-dispose-of-variant-according-to-user.
(ediff-dispose-of-variant-according-to-user): new function
designed to be smarter and also understands indirect buffers.
(ediff-highlight-diff-in-one-buffer,
ediff-unhighlight-diff-in-one-buffer,
ediff-unhighlight-diffs-totally-in-one-buffer,
ediff-highlight-diff, ediff-highlight-diff,
ediff-unhighlight-diff, ediff-unhighlight-diffs-totally,
ediff-empty-diff-region-p, ediff-whitespace-diff-region-p,
ediff-get-region-contents, ediff-make-current-diff-overlay):
moved here.
(ediff-format-bindings-of): new function by Hannu Koivisto
<azure@iki.fi>.
(ediff-setup): make sure the merge buffer is always widened and
modifiable.
(ediff-write-merge-buffer-and-maybe-kill): refuse to write the
result of a merge into a file visited by another buffer.
(ediff-arrange-autosave-in-merge-jobs): check if the merge file
is visited by another buffer and ask to save/delete that buffer.
(ediff-verify-file-merge-buffer): new function to do the above.
* ediff-vers.el: load ediff-init.el at compile time.
* ediff-wind.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff.el (ediff-windows, ediff-regions-wordwise,
ediff-regions-linewise): use indirect buffers to improve
robustness and make it possible to compare regions of the same
buffer (even overlapping regions).
(ediff-clone-buffer-for-region-comparison,
ediff-clone-buffer-for-window-comparison): new functions.
(ediff-files-internal): refuse to compare identical files.
(ediff-regions-internal): get rid of the warning about comparing
regions of the same buffer.
* ediff-diff.el (ediff-convert-fine-diffs-to-overlays): moved here.
Plus the following fixes courtesy of Dave Love:
Doc fixes.
(ediff-word-1): Use word class and move - to the
front per regexp documentation.
(ediff-wordify): Bind forward-word-function outside loop.
(ediff-copy-to-buffer): Use insert-buffer-substring rather than
consing buffer contents.
(ediff-goto-word): Move syntax table setting outside loop.
2002-01-08 04:36:01 +00:00
|
|
|
;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
|
2001-09-09 22:33:38 +00:00
|
|
|
|
1995-02-20 23:15:10 +00:00
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
;; any later version.
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
1996-06-22 03:20:38 +00:00
|
|
|
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
|
|
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
;; Boston, MA 02111-1307, USA.
|
1995-02-20 23:15:10 +00:00
|
|
|
|
2001-07-15 19:53:53 +00:00
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;;; Code:
|
1996-03-29 01:02:28 +00:00
|
|
|
|
1997-05-31 00:02:53 +00:00
|
|
|
(provide 'viper-ex)
|
1995-02-20 23:15:10 +00:00
|
|
|
|
1996-03-29 01:02:28 +00:00
|
|
|
;; Compiler pacifier
|
1996-06-22 03:20:38 +00:00
|
|
|
(defvar read-file-name-map)
|
1997-08-02 07:40:22 +00:00
|
|
|
(defvar viper-use-register)
|
|
|
|
(defvar viper-s-string)
|
|
|
|
(defvar viper-shift-width)
|
|
|
|
(defvar viper-ex-history)
|
|
|
|
(defvar viper-related-files-and-buffers-ring)
|
|
|
|
(defvar viper-local-search-start-marker)
|
1997-07-17 19:37:07 +00:00
|
|
|
(defvar viper-expert-level)
|
1997-08-02 07:40:22 +00:00
|
|
|
(defvar viper-custom-file-name)
|
|
|
|
(defvar viper-case-fold-search)
|
1997-06-18 01:26:55 +00:00
|
|
|
(defvar explicit-shell-file-name)
|
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
* viper-init.el (viper-cond-compile-for-xemacs-or-emacs):
new macro that replaces viper-emacs-p and viper-xemacs-p in many
cases. Used to reduce the number of warnings.
* viper-cmd.el: use viper-cond-compile-for-xemacs-or-emacs.
(viper-standard-value): moved here from viper.el.
(viper-set-unread-command-events): moved to viper-util.el
(viper-check-minibuffer-overlay): make sure
viper-minibuffer-overlay is moved to cover the entire input field.
* viper-util.el: use viper-cond-compile-for-xemacs-or-emacs.
(viper-read-key-sequence, viper-set-unread-command-events,
viper-char-symbol-sequence-p, viper-char-array-p): moved here.
* viper-ex.el: use viper-cond-compile-for-xemacs-or-emacs.
* viper-keym.el: use viper-cond-compile-for-xemacs-or-emacs.
* viper-mous.el: use viper-cond-compile-for-xemacs-or-emacs.
* viper-macs.el (viper-char-array-p, viper-char-symbol-sequence-p,
viper-event-vector-p): moved to viper-util.el
* viper.el (viper-standard-value): moved to viper-cmd.el.
Use viper-cond-compile-for-xemacs-or-emacs.
* ediff-help.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff-hook.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff-init.el (ediff-cond-compile-for-xemacs-or-emacs): new
macro designed to be used in many places where ediff-emacs-p or
ediff-xemacs-p was previously used. Reduces the number of
warnings.
Use ediff-cond-compile-for-xemacs-or-emacs in many places in lieue
of ediff-xemacs-p.
(ediff-make-current-diff-overlay, ediff-highlight-diff-in-one-buffer,
ediff-convert-fine-diffs-to-overlays, ediff-empty-diff-region-p,
ediff-whitespace-diff-region-p, ediff-get-region-contents):
moved to ediff-util.el.
(ediff-event-key): moved here.
* ediff-merge.el: got rid of unreferenced variables.
* ediff-mult.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff-util.el: use ediff-cond-compile-for-xemacs-or-emacs.
(ediff-cleanup-mess): improved the way windows are set up after
quitting ediff.
(ediff-janitor): use ediff-dispose-of-variant-according-to-user.
(ediff-dispose-of-variant-according-to-user): new function
designed to be smarter and also understands indirect buffers.
(ediff-highlight-diff-in-one-buffer,
ediff-unhighlight-diff-in-one-buffer,
ediff-unhighlight-diffs-totally-in-one-buffer,
ediff-highlight-diff, ediff-highlight-diff,
ediff-unhighlight-diff, ediff-unhighlight-diffs-totally,
ediff-empty-diff-region-p, ediff-whitespace-diff-region-p,
ediff-get-region-contents, ediff-make-current-diff-overlay):
moved here.
(ediff-format-bindings-of): new function by Hannu Koivisto
<azure@iki.fi>.
(ediff-setup): make sure the merge buffer is always widened and
modifiable.
(ediff-write-merge-buffer-and-maybe-kill): refuse to write the
result of a merge into a file visited by another buffer.
(ediff-arrange-autosave-in-merge-jobs): check if the merge file
is visited by another buffer and ask to save/delete that buffer.
(ediff-verify-file-merge-buffer): new function to do the above.
* ediff-vers.el: load ediff-init.el at compile time.
* ediff-wind.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff.el (ediff-windows, ediff-regions-wordwise,
ediff-regions-linewise): use indirect buffers to improve
robustness and make it possible to compare regions of the same
buffer (even overlapping regions).
(ediff-clone-buffer-for-region-comparison,
ediff-clone-buffer-for-window-comparison): new functions.
(ediff-files-internal): refuse to compare identical files.
(ediff-regions-internal): get rid of the warning about comparing
regions of the same buffer.
* ediff-diff.el (ediff-convert-fine-diffs-to-overlays): moved here.
Plus the following fixes courtesy of Dave Love:
Doc fixes.
(ediff-word-1): Use word class and move - to the
front per regexp documentation.
(ediff-wordify): Bind forward-word-function outside loop.
(ediff-copy-to-buffer): Use insert-buffer-substring rather than
consing buffer contents.
(ediff-goto-word): Move syntax table setting outside loop.
2002-01-08 04:36:01 +00:00
|
|
|
(defvar compile-command)
|
1997-05-31 00:02:53 +00:00
|
|
|
|
1997-06-09 04:00:50 +00:00
|
|
|
;; loading happens only in non-interactive compilation
|
|
|
|
;; in order to spare non-viperized emacs from being viperized
|
|
|
|
(if noninteractive
|
|
|
|
(eval-when-compile
|
|
|
|
(let ((load-path (cons (expand-file-name ".") load-path)))
|
|
|
|
(or (featurep 'viper-util)
|
|
|
|
(load "viper-util.el" nil nil 'nosuffix))
|
|
|
|
(or (featurep 'viper-keym)
|
|
|
|
(load "viper-keym.el" nil nil 'nosuffix))
|
|
|
|
(or (featurep 'viper-cmd)
|
|
|
|
(load "viper-cmd.el" nil nil 'nosuffix))
|
|
|
|
)))
|
1997-05-31 00:02:53 +00:00
|
|
|
;; end pacifier
|
|
|
|
|
|
|
|
(require 'viper-util)
|
|
|
|
|
1997-07-17 19:37:07 +00:00
|
|
|
(defgroup viper-ex nil
|
|
|
|
"Viper support for Ex commands"
|
|
|
|
:prefix "ex-"
|
|
|
|
:group 'viper)
|
|
|
|
|
|
|
|
|
1996-03-29 01:02:28 +00:00
|
|
|
|
1995-02-20 23:15:10 +00:00
|
|
|
;;; Variables
|
1996-06-22 01:54:34 +00:00
|
|
|
|
1997-08-02 07:40:22 +00:00
|
|
|
(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*")
|
2002-04-16 05:49:11 +00:00
|
|
|
(defconst viper-ex-print-buf-name " *ex-print*")
|
|
|
|
(defconst viper-ex-print-buf (get-buffer-create viper-ex-print-buf-name))
|
1996-06-22 03:20:38 +00:00
|
|
|
|
|
|
|
|
2001-03-17 Michael Kifer <kifer@cs.sunysb.edu>
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
* viper-util.el: Spaces, indentation.
* viper.el: Changed version, modification time.
2001-03-17 18:59:39 +00:00
|
|
|
;;; ex-commands...
|
|
|
|
|
|
|
|
(defun ex-cmd-obsolete (name)
|
|
|
|
(error "`%s': Obsolete command, not supported by Viper" name))
|
|
|
|
|
|
|
|
(defun ex-cmd-not-yet (name)
|
|
|
|
(error "`%s': Command not implemented in Viper" name))
|
|
|
|
|
|
|
|
;; alist entries: name (in any order), command, cont(??)
|
|
|
|
;; If command is a string, then that is an alias to the real command
|
|
|
|
;; to execute (for instance, ":m" -> ":move").
|
|
|
|
;; command attributes:
|
|
|
|
;; is-mashed: the command's args may be jammed right up against the command
|
|
|
|
;; one-letter: this is a one-letter token. Any text appearing after
|
|
|
|
;; the name gets appended as an argument for the command
|
|
|
|
;; i.e. ":kabc" gets turned into (ex-mark "abc")
|
|
|
|
(defconst ex-token-alist '(
|
|
|
|
("!" (ex-command))
|
|
|
|
("&" (ex-substitute t))
|
|
|
|
("=" (ex-line-no))
|
|
|
|
(">" (ex-line "right"))
|
|
|
|
("<" (ex-line "left"))
|
|
|
|
("Buffer" (if ex-cycle-other-window
|
|
|
|
(viper-switch-to-buffer)
|
|
|
|
(viper-switch-to-buffer-other-window)))
|
|
|
|
("Next" (ex-next (not ex-cycle-other-window)))
|
|
|
|
("PreviousRelatedFile" (ex-next-related-buffer -1))
|
|
|
|
("RelatedFile" (ex-next-related-buffer 1))
|
|
|
|
("W" "Write")
|
|
|
|
("WWrite" (save-some-buffers t))
|
|
|
|
("Write" (save-some-buffers))
|
|
|
|
("a" "append")
|
|
|
|
("args" (ex-args))
|
|
|
|
("buffer" (if ex-cycle-other-window
|
|
|
|
(viper-switch-to-buffer-other-window)
|
|
|
|
(viper-switch-to-buffer)))
|
|
|
|
("c" "change")
|
|
|
|
;; ch should be "change" but maintain old viper compatibility
|
|
|
|
("ch" "chdir")
|
|
|
|
("cd" (ex-cd))
|
|
|
|
("chdir" (ex-cd))
|
|
|
|
("copy" (ex-copy nil))
|
|
|
|
("customize" (customize-group "viper"))
|
|
|
|
("delete" (ex-delete))
|
|
|
|
("edit" (ex-edit))
|
2001-12-24 05:50:31 +00:00
|
|
|
("file" (ex-set-visited-file-name))
|
2001-03-17 Michael Kifer <kifer@cs.sunysb.edu>
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
* viper-util.el: Spaces, indentation.
* viper.el: Changed version, modification time.
2001-03-17 18:59:39 +00:00
|
|
|
("g" "global")
|
|
|
|
("global" (ex-global nil) is-mashed)
|
|
|
|
("goto" (ex-goto))
|
|
|
|
("help" (ex-help))
|
|
|
|
("join" (ex-line "join"))
|
|
|
|
("k" (ex-mark) one-letter)
|
|
|
|
("kmark" (ex-mark))
|
|
|
|
("m" "move")
|
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-compile,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
(viper-get-ex-address-subr): convert registers to char data type.
* viper-util.el (viper-int-to-char,viper-char-equal): new
functions.
(viper-memq-char): use viper-int-to-char.
(viper-file-checked-in-p): use vc-locking-user, if vc doesn't have
vc-locking-state.
(viper-read-key): use viper-read-key-sequence.
* viper.el (viper-major-mode-modifier-list): added
inferior-emacs-lisp-mode.
(this-major-mode-requires-vi-state): new function that uses simple
heuristics to decide if vi state is appropriate.
(set-viper-state-in-major-mode): use this-major-mode-requires-vi-state.
(viper-non-hook-settings): don't advise read-key-sequence.
(viper-read-key-sequence): new function that replaces the
previously used advice to read-key-sequence.
* viper-cmd.el (viper-test-com-defun,viper-exec-change,
viper-exec-Change,viper-execute-com,viper-insert,viper-append,
viper-Append,viper-Insert,viper-open-line,viper-Open-line,
viper-open-line-at-point,viper-substitute,viper-overwrite,
viper-replace-char-subr,viper-forward-word,viper-forward-Word):
got rid of the negative character hack.
(viper-escape-to-state,viper-replace-state-exit-cmd):
use viper-read-key-sequence.
(viper-envelop-ESC-key): no need for ad-get-orig-definition.
(viper-minibuffer-standard-hook,viper-read-string-with-history):
don't override existing minibuffer-setup-hook.
(viper-mark-point,viper-goto-mark-subr,viper-brac-function):
convert registers to char data type.
(viper-autoindent): use viper-indent-line.
* viper-keym.el: use viper-exec-key-in-emacs.
* viper.texi: Added credits, new commands, like :make.
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
(ediff-file-checked-out-p,ediff-file-checked-in-p): check if
vc-state is available.
(ediff-make-temp-file): use ediff-coding-system-for-write.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
(ediff-coding-system-for-read): from ediff-diff.el
(ediff-coding-system-for-write): new variable.
(ediff-highest-priority): fixed the bug having to do with disappearing
overlays.
(ediff-file-remote-p): use file-remote-p, if available.
(ediff-listable-file): new function.
(ediff-file-attributes): use ediff-listable-file.
* ediff-mult.el (ediff-meta-insert-file-info1): use
ediff-listable-file.
* ediff-ptch.el (ediff-prompt-for-patch-file): use
ediff-coding-system-for-read.
(ediff-patch-file-internal): use ediff-coding-system-for-write.
* ediff-diff.el (ediff-coding-system-for-read): moved to ediff-init.el.
(ediff-match-diff3-line,ediff-get-diff3-group): improved pattern.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* ediff.texi: added clarifications, acknowledgements.
2001-07-21 05:28:24 +00:00
|
|
|
("make" (ex-compile))
|
2001-03-17 Michael Kifer <kifer@cs.sunysb.edu>
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
* viper-util.el: Spaces, indentation.
* viper.el: Changed version, modification time.
2001-03-17 18:59:39 +00:00
|
|
|
; old viper doesn't specify a default for "ma" so leave it undefined
|
|
|
|
("map" (ex-map))
|
|
|
|
("mark" (ex-mark))
|
|
|
|
("move" (ex-copy t))
|
|
|
|
("next" (ex-next ex-cycle-other-window))
|
|
|
|
("p" "print")
|
|
|
|
("preserve" (ex-preserve))
|
2002-04-16 05:49:11 +00:00
|
|
|
("print" (ex-print))
|
2001-03-17 Michael Kifer <kifer@cs.sunysb.edu>
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
* viper-util.el: Spaces, indentation.
* viper.el: Changed version, modification time.
2001-03-17 18:59:39 +00:00
|
|
|
("put" (ex-put))
|
|
|
|
("pwd" (ex-pwd))
|
|
|
|
("quit" (ex-quit))
|
|
|
|
("r" "read")
|
|
|
|
("re" "read")
|
|
|
|
("read" (ex-read))
|
|
|
|
("recover" (ex-recover))
|
|
|
|
("rewind" (ex-rewind))
|
|
|
|
("s" "substitute")
|
|
|
|
("su" "substitute")
|
|
|
|
("sub" "substitute")
|
|
|
|
("set" (ex-set))
|
|
|
|
("shell" (ex-shell))
|
|
|
|
("source" (ex-source))
|
2003-02-04 13:24:35 +00:00
|
|
|
("stop" (suspend-emacs))
|
2001-03-17 Michael Kifer <kifer@cs.sunysb.edu>
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
* viper-util.el: Spaces, indentation.
* viper.el: Changed version, modification time.
2001-03-17 18:59:39 +00:00
|
|
|
("sr" (ex-substitute t t))
|
|
|
|
("submitReport" (viper-submit-report))
|
|
|
|
("substitute" (ex-substitute) is-mashed)
|
|
|
|
("suspend" (suspend-emacs))
|
|
|
|
("t" "transfer")
|
|
|
|
("tag" (ex-tag))
|
|
|
|
("transfer" (ex-copy nil))
|
|
|
|
("u" "undo")
|
|
|
|
("un" "undo")
|
|
|
|
("undo" (viper-undo))
|
|
|
|
("unmap" (ex-unmap))
|
|
|
|
("v" "vglobal")
|
|
|
|
("version" (viper-version))
|
|
|
|
("vglobal" (ex-global t) is-mashed)
|
2003-02-04 13:24:35 +00:00
|
|
|
("visual" (ex-edit))
|
2001-03-17 Michael Kifer <kifer@cs.sunysb.edu>
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
* viper-util.el: Spaces, indentation.
* viper.el: Changed version, modification time.
2001-03-17 18:59:39 +00:00
|
|
|
("w" "write")
|
|
|
|
("wq" (ex-write t))
|
|
|
|
("write" (ex-write nil))
|
|
|
|
("xit" (ex-write t))
|
|
|
|
("yank" (ex-yank))
|
|
|
|
("~" (ex-substitute t t))
|
|
|
|
|
|
|
|
("append" (ex-cmd-obsolete "append"))
|
|
|
|
("change" (ex-cmd-obsolete "change"))
|
|
|
|
("insert" (ex-cmd-obsolete "insert"))
|
|
|
|
("open" (ex-cmd-obsolete "open"))
|
|
|
|
|
|
|
|
("list" (ex-cmd-not-yet "list"))
|
|
|
|
("z" (ex-cmd-not-yet "z"))
|
|
|
|
("#" (ex-cmd-not-yet "#"))
|
|
|
|
|
|
|
|
("abbreviate" (error "`%s': Vi abbreviations are obsolete. Use the more powerful Emacs abbrevs" ex-token))
|
|
|
|
("unabbreviate" (error "`%s': Vi abbreviations are obsolete. Use the more powerful Emacs abbrevs" ex-token))
|
|
|
|
))
|
|
|
|
|
|
|
|
;; No code should touch anything in the alist entry! (other than the name,
|
|
|
|
;; "car entry", of course) This way, changing this data structure
|
|
|
|
;; requires changing only the following ex-cmd functions...
|
|
|
|
|
|
|
|
;; Returns cmd if the command may be jammed right up against its
|
|
|
|
;; arguments, nil if there must be a space.
|
|
|
|
;; examples of mashable commands: g// g!// v// s// sno// sm//
|
|
|
|
(defun ex-cmd-is-mashed-with-args (cmd)
|
|
|
|
(if (eq 'is-mashed (car (nthcdr 2 cmd))) cmd))
|
|
|
|
|
|
|
|
;; Returns true if this is a one-letter command that may be followed
|
|
|
|
;; by anything, no whitespace needed. This is a special-case for ":k".
|
|
|
|
(defun ex-cmd-is-one-letter (cmd)
|
|
|
|
(if (eq 'one-letter (car (nthcdr 2 cmd))) cmd))
|
|
|
|
|
|
|
|
;; Executes the function associated with the command
|
|
|
|
(defun ex-cmd-execute (cmd)
|
|
|
|
(eval (cadr cmd)))
|
|
|
|
|
|
|
|
;; If this is a one-letter magic command, splice in args.
|
|
|
|
(defun ex-splice-args-in-1-letr-cmd (key list)
|
|
|
|
(let ((onelet (ex-cmd-is-one-letter (assoc (substring key 0 1) list))))
|
|
|
|
(if onelet
|
|
|
|
(list key
|
|
|
|
(append (cadr onelet)
|
|
|
|
(if (< 1 (length key)) (list (substring key 1))))
|
|
|
|
(caddr onelet)))
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
;; Returns the alist entry for the appropriate key.
|
|
|
|
;; Tries to complete the key before using it in the alist.
|
|
|
|
;; If there is no appropriate key (no match or duplicate matches) return nil
|
|
|
|
(defun ex-cmd-assoc (key list)
|
|
|
|
(let ((entry (try-completion key list))
|
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-compile,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
(viper-get-ex-address-subr): convert registers to char data type.
* viper-util.el (viper-int-to-char,viper-char-equal): new
functions.
(viper-memq-char): use viper-int-to-char.
(viper-file-checked-in-p): use vc-locking-user, if vc doesn't have
vc-locking-state.
(viper-read-key): use viper-read-key-sequence.
* viper.el (viper-major-mode-modifier-list): added
inferior-emacs-lisp-mode.
(this-major-mode-requires-vi-state): new function that uses simple
heuristics to decide if vi state is appropriate.
(set-viper-state-in-major-mode): use this-major-mode-requires-vi-state.
(viper-non-hook-settings): don't advise read-key-sequence.
(viper-read-key-sequence): new function that replaces the
previously used advice to read-key-sequence.
* viper-cmd.el (viper-test-com-defun,viper-exec-change,
viper-exec-Change,viper-execute-com,viper-insert,viper-append,
viper-Append,viper-Insert,viper-open-line,viper-Open-line,
viper-open-line-at-point,viper-substitute,viper-overwrite,
viper-replace-char-subr,viper-forward-word,viper-forward-Word):
got rid of the negative character hack.
(viper-escape-to-state,viper-replace-state-exit-cmd):
use viper-read-key-sequence.
(viper-envelop-ESC-key): no need for ad-get-orig-definition.
(viper-minibuffer-standard-hook,viper-read-string-with-history):
don't override existing minibuffer-setup-hook.
(viper-mark-point,viper-goto-mark-subr,viper-brac-function):
convert registers to char data type.
(viper-autoindent): use viper-indent-line.
* viper-keym.el: use viper-exec-key-in-emacs.
* viper.texi: Added credits, new commands, like :make.
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
(ediff-file-checked-out-p,ediff-file-checked-in-p): check if
vc-state is available.
(ediff-make-temp-file): use ediff-coding-system-for-write.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
(ediff-coding-system-for-read): from ediff-diff.el
(ediff-coding-system-for-write): new variable.
(ediff-highest-priority): fixed the bug having to do with disappearing
overlays.
(ediff-file-remote-p): use file-remote-p, if available.
(ediff-listable-file): new function.
(ediff-file-attributes): use ediff-listable-file.
* ediff-mult.el (ediff-meta-insert-file-info1): use
ediff-listable-file.
* ediff-ptch.el (ediff-prompt-for-patch-file): use
ediff-coding-system-for-read.
(ediff-patch-file-internal): use ediff-coding-system-for-write.
* ediff-diff.el (ediff-coding-system-for-read): moved to ediff-init.el.
(ediff-match-diff3-line,ediff-get-diff3-group): improved pattern.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* ediff.texi: added clarifications, acknowledgements.
2001-07-21 05:28:24 +00:00
|
|
|
result)
|
2001-03-17 Michael Kifer <kifer@cs.sunysb.edu>
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
* viper-util.el: Spaces, indentation.
* viper.el: Changed version, modification time.
2001-03-17 18:59:39 +00:00
|
|
|
(setq result (cond
|
|
|
|
((eq entry t) (assoc key list))
|
|
|
|
((stringp entry) (or (ex-splice-args-in-1-letr-cmd key list)
|
|
|
|
(assoc entry list)))
|
|
|
|
((eq entry nil) (ex-splice-args-in-1-letr-cmd key list))
|
|
|
|
(t nil)
|
|
|
|
))
|
|
|
|
;; If we end up with an alias, look up the alias...
|
|
|
|
(if (stringp (cadr result))
|
|
|
|
(setq result (ex-cmd-assoc (cadr result) list)))
|
|
|
|
;; and return the corresponding alist entry
|
|
|
|
result
|
|
|
|
))
|
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
|
|
|
|
;; A-list of Ex variables that can be set using the :set command.
|
2003-02-04 13:24:35 +00:00
|
|
|
(defconst ex-variable-alist
|
1996-06-22 03:20:38 +00:00
|
|
|
'(("wrapscan") ("ws") ("wrapmargin") ("wm")
|
1997-06-18 01:26:55 +00:00
|
|
|
("tabstop-global") ("ts-g") ("tabstop") ("ts")
|
1996-06-22 03:20:38 +00:00
|
|
|
("showmatch") ("sm") ("shiftwidth") ("sw") ("shell") ("sh")
|
2003-02-04 13:24:35 +00:00
|
|
|
("readonly") ("ro")
|
1996-06-22 03:20:38 +00:00
|
|
|
("nowrapscan") ("nows") ("noshowmatch") ("nosm")
|
|
|
|
("noreadonly") ("noro") ("nomagic") ("noma")
|
|
|
|
("noignorecase") ("noic")
|
1997-06-18 01:26:55 +00:00
|
|
|
("noautoindent-global") ("noai-g") ("noautoindent") ("noai")
|
1996-06-22 03:20:38 +00:00
|
|
|
("magic") ("ma") ("ignorecase") ("ic")
|
2003-02-04 13:24:35 +00:00
|
|
|
("autoindent-global") ("ai-g") ("autoindent") ("ai")
|
|
|
|
("all")
|
1996-06-22 03:20:38 +00:00
|
|
|
))
|
1996-06-22 01:54:34 +00:00
|
|
|
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 01:54:34 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; Token recognized during parsing of Ex commands (e.g., "read", "comma")
|
|
|
|
(defvar ex-token nil)
|
|
|
|
|
2003-02-04 13:24:35 +00:00
|
|
|
;; Type of token.
|
1996-06-22 03:20:38 +00:00
|
|
|
;; If non-nil, gives type of address; if nil, it is a command.
|
|
|
|
(defvar ex-token-type nil)
|
|
|
|
|
|
|
|
;; List of addresses passed to Ex command
|
|
|
|
(defvar ex-addresses nil)
|
|
|
|
|
1997-09-30 01:13:53 +00:00
|
|
|
;; This flag is supposed to be set only by `#', `print', and `list',
|
1999-11-01 07:16:15 +00:00
|
|
|
;; none of which is implemented. So, it and the pices of the code it
|
|
|
|
;; controls are dead weight. We keep it just in case this might be
|
1997-09-30 01:13:53 +00:00
|
|
|
;; needed in the future.
|
1996-06-22 03:20:38 +00:00
|
|
|
(defvar ex-flag nil)
|
|
|
|
|
|
|
|
;; "buffer" where Ex commands keep deleted data.
|
|
|
|
;; In Emacs terms, this is a register.
|
|
|
|
(defvar ex-buffer nil)
|
|
|
|
|
|
|
|
;; Value of ex count.
|
|
|
|
(defvar ex-count nil)
|
|
|
|
|
1997-07-17 19:37:07 +00:00
|
|
|
;; Flag indicating that :global Ex command is being executed.
|
1996-06-22 03:20:38 +00:00
|
|
|
(defvar ex-g-flag nil)
|
1997-07-17 19:37:07 +00:00
|
|
|
;; Flag indicating that :vglobal Ex command is being executed.
|
1996-06-22 03:20:38 +00:00
|
|
|
(defvar ex-g-variant nil)
|
2002-04-16 05:49:11 +00:00
|
|
|
;; Marks to operate on during a :global Ex command.
|
|
|
|
(defvar ex-g-marks nil)
|
1996-06-22 03:20:38 +00:00
|
|
|
|
|
|
|
;; Save reg-exp used in substitute.
|
|
|
|
(defvar ex-reg-exp nil)
|
|
|
|
|
|
|
|
|
|
|
|
;; Replace pattern for substitute.
|
|
|
|
(defvar ex-repl nil)
|
|
|
|
|
|
|
|
;; Pattern for global command.
|
|
|
|
(defvar ex-g-pat nil)
|
|
|
|
|
1997-07-17 19:37:07 +00:00
|
|
|
(defcustom ex-unix-type-shell
|
1996-06-22 03:20:38 +00:00
|
|
|
(let ((case-fold-search t))
|
|
|
|
(and (stringp shell-file-name)
|
|
|
|
(string-match
|
|
|
|
(concat
|
|
|
|
"\\("
|
|
|
|
"csh$\\|csh.exe$"
|
|
|
|
"\\|"
|
|
|
|
"ksh$\\|ksh.exe$"
|
|
|
|
"\\|"
|
|
|
|
"^sh$\\|sh.exe$"
|
|
|
|
"\\|"
|
|
|
|
"[^a-z]sh$\\|[^a-z]sh.exe$"
|
|
|
|
"\\|"
|
|
|
|
"bash$\\|bash.exe$"
|
|
|
|
"\\)")
|
|
|
|
shell-file-name)))
|
1997-07-17 19:37:07 +00:00
|
|
|
"Is the user using a unix-type shell under a non-OS?"
|
1997-09-13 06:12:13 +00:00
|
|
|
:type 'boolean
|
1997-07-17 19:37:07 +00:00
|
|
|
:group 'viper-ex)
|
1996-06-22 03:20:38 +00:00
|
|
|
|
1997-07-17 19:37:07 +00:00
|
|
|
(defcustom ex-unix-type-shell-options
|
1996-06-22 03:20:38 +00:00
|
|
|
(let ((case-fold-search t))
|
|
|
|
(if ex-unix-type-shell
|
|
|
|
(cond ((string-match "\\(csh$\\|csh.exe$\\)" shell-file-name)
|
|
|
|
"-f") ; csh: do it fast
|
|
|
|
((string-match "\\(bash$\\|bash.exe$\\)" shell-file-name)
|
|
|
|
"-noprofile") ; bash: ignore .profile
|
|
|
|
)))
|
2003-02-04 13:24:35 +00:00
|
|
|
"Options to pass to the Unix-style shell.
|
1997-07-17 19:37:07 +00:00
|
|
|
Don't put `-c' here, as it is added automatically."
|
2001-02-07 23:56:22 +00:00
|
|
|
:type '(choice (const nil) string)
|
1997-07-17 19:37:07 +00:00
|
|
|
:group 'viper-ex)
|
1996-06-22 03:20:38 +00:00
|
|
|
|
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-compile,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
(viper-get-ex-address-subr): convert registers to char data type.
* viper-util.el (viper-int-to-char,viper-char-equal): new
functions.
(viper-memq-char): use viper-int-to-char.
(viper-file-checked-in-p): use vc-locking-user, if vc doesn't have
vc-locking-state.
(viper-read-key): use viper-read-key-sequence.
* viper.el (viper-major-mode-modifier-list): added
inferior-emacs-lisp-mode.
(this-major-mode-requires-vi-state): new function that uses simple
heuristics to decide if vi state is appropriate.
(set-viper-state-in-major-mode): use this-major-mode-requires-vi-state.
(viper-non-hook-settings): don't advise read-key-sequence.
(viper-read-key-sequence): new function that replaces the
previously used advice to read-key-sequence.
* viper-cmd.el (viper-test-com-defun,viper-exec-change,
viper-exec-Change,viper-execute-com,viper-insert,viper-append,
viper-Append,viper-Insert,viper-open-line,viper-Open-line,
viper-open-line-at-point,viper-substitute,viper-overwrite,
viper-replace-char-subr,viper-forward-word,viper-forward-Word):
got rid of the negative character hack.
(viper-escape-to-state,viper-replace-state-exit-cmd):
use viper-read-key-sequence.
(viper-envelop-ESC-key): no need for ad-get-orig-definition.
(viper-minibuffer-standard-hook,viper-read-string-with-history):
don't override existing minibuffer-setup-hook.
(viper-mark-point,viper-goto-mark-subr,viper-brac-function):
convert registers to char data type.
(viper-autoindent): use viper-indent-line.
* viper-keym.el: use viper-exec-key-in-emacs.
* viper.texi: Added credits, new commands, like :make.
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
(ediff-file-checked-out-p,ediff-file-checked-in-p): check if
vc-state is available.
(ediff-make-temp-file): use ediff-coding-system-for-write.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
(ediff-coding-system-for-read): from ediff-diff.el
(ediff-coding-system-for-write): new variable.
(ediff-highest-priority): fixed the bug having to do with disappearing
overlays.
(ediff-file-remote-p): use file-remote-p, if available.
(ediff-listable-file): new function.
(ediff-file-attributes): use ediff-listable-file.
* ediff-mult.el (ediff-meta-insert-file-info1): use
ediff-listable-file.
* ediff-ptch.el (ediff-prompt-for-patch-file): use
ediff-coding-system-for-read.
(ediff-patch-file-internal): use ediff-coding-system-for-write.
* ediff-diff.el (ediff-coding-system-for-read): moved to ediff-init.el.
(ediff-match-diff3-line,ediff-get-diff3-group): improved pattern.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* ediff.texi: added clarifications, acknowledgements.
2001-07-21 05:28:24 +00:00
|
|
|
(defcustom ex-compile-command "make"
|
2002-08-30 11:02:10 +00:00
|
|
|
"The command to run when the user types :make."
|
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-compile,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
(viper-get-ex-address-subr): convert registers to char data type.
* viper-util.el (viper-int-to-char,viper-char-equal): new
functions.
(viper-memq-char): use viper-int-to-char.
(viper-file-checked-in-p): use vc-locking-user, if vc doesn't have
vc-locking-state.
(viper-read-key): use viper-read-key-sequence.
* viper.el (viper-major-mode-modifier-list): added
inferior-emacs-lisp-mode.
(this-major-mode-requires-vi-state): new function that uses simple
heuristics to decide if vi state is appropriate.
(set-viper-state-in-major-mode): use this-major-mode-requires-vi-state.
(viper-non-hook-settings): don't advise read-key-sequence.
(viper-read-key-sequence): new function that replaces the
previously used advice to read-key-sequence.
* viper-cmd.el (viper-test-com-defun,viper-exec-change,
viper-exec-Change,viper-execute-com,viper-insert,viper-append,
viper-Append,viper-Insert,viper-open-line,viper-Open-line,
viper-open-line-at-point,viper-substitute,viper-overwrite,
viper-replace-char-subr,viper-forward-word,viper-forward-Word):
got rid of the negative character hack.
(viper-escape-to-state,viper-replace-state-exit-cmd):
use viper-read-key-sequence.
(viper-envelop-ESC-key): no need for ad-get-orig-definition.
(viper-minibuffer-standard-hook,viper-read-string-with-history):
don't override existing minibuffer-setup-hook.
(viper-mark-point,viper-goto-mark-subr,viper-brac-function):
convert registers to char data type.
(viper-autoindent): use viper-indent-line.
* viper-keym.el: use viper-exec-key-in-emacs.
* viper.texi: Added credits, new commands, like :make.
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
(ediff-file-checked-out-p,ediff-file-checked-in-p): check if
vc-state is available.
(ediff-make-temp-file): use ediff-coding-system-for-write.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
(ediff-coding-system-for-read): from ediff-diff.el
(ediff-coding-system-for-write): new variable.
(ediff-highest-priority): fixed the bug having to do with disappearing
overlays.
(ediff-file-remote-p): use file-remote-p, if available.
(ediff-listable-file): new function.
(ediff-file-attributes): use ediff-listable-file.
* ediff-mult.el (ediff-meta-insert-file-info1): use
ediff-listable-file.
* ediff-ptch.el (ediff-prompt-for-patch-file): use
ediff-coding-system-for-read.
(ediff-patch-file-internal): use ediff-coding-system-for-write.
* ediff-diff.el (ediff-coding-system-for-read): moved to ediff-init.el.
(ediff-match-diff3-line,ediff-get-diff3-group): improved pattern.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* ediff.texi: added clarifications, acknowledgements.
2001-07-21 05:28:24 +00:00
|
|
|
:type 'string
|
|
|
|
:group 'viper-ex)
|
|
|
|
|
1999-11-01 07:16:15 +00:00
|
|
|
(defcustom viper-glob-function
|
|
|
|
(cond (ex-unix-type-shell 'viper-glob-unix-files)
|
|
|
|
((eq system-type 'emx) 'viper-glob-mswindows-files) ; OS/2
|
|
|
|
(viper-ms-style-os-p 'viper-glob-mswindows-files) ; Microsoft OS
|
|
|
|
(viper-vms-os-p 'viper-glob-unix-files) ; VMS
|
|
|
|
(t 'viper-glob-unix-files) ; presumably UNIX
|
|
|
|
)
|
|
|
|
"Expand the file spec containing wildcard symbols.
|
|
|
|
The default tries to set this variable to work with Unix, Windows,
|
|
|
|
OS/2, and VMS.
|
|
|
|
|
2003-02-04 13:24:35 +00:00
|
|
|
However, if it doesn't work right for some types of Unix shells or some OS,
|
1999-11-01 07:16:15 +00:00
|
|
|
the user should supply the appropriate function and set this variable to the
|
|
|
|
corresponding function symbol."
|
|
|
|
:type 'symbol
|
|
|
|
:group 'viper-ex)
|
|
|
|
|
1996-06-22 01:54:34 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; Remembers the previous Ex tag.
|
|
|
|
(defvar ex-tag nil)
|
1996-06-22 01:54:34 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; file used by Ex commands like :r, :w, :n
|
|
|
|
(defvar ex-file nil)
|
1996-06-22 01:54:34 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; If t, tells Ex that this is a variant-command, i.e., w>>, r!, etc.
|
|
|
|
(defvar ex-variant nil)
|
1996-06-22 01:54:34 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; Specified the offset of an Ex command, such as :read.
|
|
|
|
(defvar ex-offset nil)
|
1996-06-22 01:54:34 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; Tells Ex that this is a w>> command.
|
|
|
|
(defvar ex-append nil)
|
1996-06-22 01:54:34 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; File containing the shell command to be executed at Ex prompt,
|
|
|
|
;; e.g., :r !date
|
|
|
|
(defvar ex-cmdfile nil)
|
1997-11-01 01:46:51 +00:00
|
|
|
(defvar ex-cmdfile-args "")
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1997-08-02 07:40:22 +00:00
|
|
|
;; flag used in viper-ex-read-file-name to indicate that we may be reading
|
1999-11-01 07:16:15 +00:00
|
|
|
;; multiple file names. Used for :edit and :next
|
1997-08-02 07:40:22 +00:00
|
|
|
(defvar viper-keep-reading-filename nil)
|
1996-06-22 01:54:34 +00:00
|
|
|
|
1997-07-17 19:37:07 +00:00
|
|
|
(defcustom ex-cycle-other-window t
|
1996-06-22 03:20:38 +00:00
|
|
|
"*If t, :n and :b cycles through files and buffers in other window.
|
1999-11-01 07:16:15 +00:00
|
|
|
Then :N and :B cycles in the current window. If nil, this behavior is
|
1997-07-17 19:37:07 +00:00
|
|
|
reversed."
|
|
|
|
:type 'boolean
|
|
|
|
:group 'viper-ex)
|
1996-06-22 01:54:34 +00:00
|
|
|
|
1997-07-17 19:37:07 +00:00
|
|
|
(defcustom ex-cycle-through-non-files nil
|
|
|
|
"*Cycle through *scratch* and other buffers that don't visit any file."
|
|
|
|
:type 'boolean
|
|
|
|
:group 'viper-ex)
|
1996-06-22 01:54:34 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; Last shell command executed with :! command.
|
1997-08-02 07:40:22 +00:00
|
|
|
(defvar viper-ex-last-shell-com nil)
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; Indicates if Minibuffer was exited temporarily in Ex-command.
|
1997-08-02 07:40:22 +00:00
|
|
|
(defvar viper-incomplete-ex-cmd nil)
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; Remembers the last ex-command prompt.
|
1997-08-02 07:40:22 +00:00
|
|
|
(defvar viper-last-ex-prompt "")
|
1996-06-22 01:54:34 +00:00
|
|
|
|
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; Get a complete ex command
|
1997-08-02 07:40:22 +00:00
|
|
|
(defun viper-get-ex-com-subr ()
|
2001-03-17 Michael Kifer <kifer@cs.sunysb.edu>
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
* viper-util.el: Spaces, indentation.
* viper.el: Changed version, modification time.
2001-03-17 18:59:39 +00:00
|
|
|
(let (cmd case-fold-search)
|
1996-06-22 03:20:38 +00:00
|
|
|
(set-mark (point))
|
|
|
|
(re-search-forward "[a-zA-Z][a-zA-Z]*")
|
|
|
|
(setq ex-token-type 'command)
|
|
|
|
(setq ex-token (buffer-substring (point) (mark t)))
|
2001-03-17 Michael Kifer <kifer@cs.sunysb.edu>
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
* viper-util.el: Spaces, indentation.
* viper.el: Changed version, modification time.
2001-03-17 18:59:39 +00:00
|
|
|
(setq cmd (ex-cmd-assoc ex-token ex-token-alist))
|
|
|
|
(if cmd
|
|
|
|
(setq ex-token (car cmd))
|
|
|
|
(setq ex-token-type 'non-command))
|
1996-06-22 03:20:38 +00:00
|
|
|
))
|
1996-06-22 01:54:34 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; Get an ex-token which is either an address or a command.
|
|
|
|
;; A token has a type, \(command, address, end-mark\), and a value
|
1997-08-02 07:40:22 +00:00
|
|
|
(defun viper-get-ex-token ()
|
1996-06-22 03:20:38 +00:00
|
|
|
(save-window-excursion
|
2003-02-04 13:24:35 +00:00
|
|
|
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
|
1997-08-02 07:40:22 +00:00
|
|
|
(set-buffer viper-ex-work-buf)
|
1996-06-22 03:20:38 +00:00
|
|
|
(skip-chars-forward " \t|")
|
1997-09-05 04:48:58 +00:00
|
|
|
(let ((case-fold-search t))
|
|
|
|
(cond ((looking-at "#")
|
|
|
|
(setq ex-token-type 'command)
|
|
|
|
(setq ex-token (char-to-string (following-char)))
|
|
|
|
(forward-char 1))
|
|
|
|
((looking-at "[a-z]") (viper-get-ex-com-subr))
|
|
|
|
((looking-at "\\.")
|
|
|
|
(forward-char 1)
|
|
|
|
(setq ex-token-type 'dot))
|
|
|
|
((looking-at "[0-9]")
|
|
|
|
(set-mark (point))
|
|
|
|
(re-search-forward "[0-9]*")
|
|
|
|
(setq ex-token-type
|
|
|
|
(cond ((eq ex-token-type 'plus) 'add-number)
|
|
|
|
((eq ex-token-type 'minus) 'sub-number)
|
|
|
|
(t 'abs-number)))
|
|
|
|
(setq ex-token
|
|
|
|
(string-to-int (buffer-substring (point) (mark t)))))
|
|
|
|
((looking-at "\\$")
|
|
|
|
(forward-char 1)
|
|
|
|
(setq ex-token-type 'end))
|
|
|
|
((looking-at "%")
|
|
|
|
(forward-char 1)
|
|
|
|
(setq ex-token-type 'whole))
|
|
|
|
((looking-at "+")
|
|
|
|
(cond ((or (looking-at "+[-+]") (looking-at "+[\n|]"))
|
|
|
|
(forward-char 1)
|
|
|
|
(insert "1")
|
|
|
|
(backward-char 1)
|
1996-06-22 03:20:38 +00:00
|
|
|
(setq ex-token-type 'plus))
|
1997-09-05 04:48:58 +00:00
|
|
|
((looking-at "+[0-9]")
|
|
|
|
(forward-char 1)
|
|
|
|
(setq ex-token-type 'plus))
|
|
|
|
(t
|
|
|
|
(error viper-BadAddress))))
|
|
|
|
((looking-at "-")
|
|
|
|
(cond ((or (looking-at "-[-+]") (looking-at "-[\n|]"))
|
|
|
|
(forward-char 1)
|
|
|
|
(insert "1")
|
|
|
|
(backward-char 1)
|
|
|
|
(setq ex-token-type 'minus))
|
|
|
|
((looking-at "-[0-9]")
|
|
|
|
(forward-char 1)
|
|
|
|
(setq ex-token-type 'minus))
|
|
|
|
(t
|
|
|
|
(error viper-BadAddress))))
|
|
|
|
((looking-at "/")
|
|
|
|
(forward-char 1)
|
|
|
|
(set-mark (point))
|
|
|
|
(let ((cont t))
|
|
|
|
(while (and (not (eolp)) cont)
|
|
|
|
;;(re-search-forward "[^/]*/")
|
|
|
|
(re-search-forward "[^/]*\\(/\\|\n\\)")
|
|
|
|
(if (not (viper-looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\/"))
|
|
|
|
(setq cont nil))))
|
|
|
|
(backward-char 1)
|
|
|
|
(setq ex-token (buffer-substring (point) (mark t)))
|
|
|
|
(if (looking-at "/") (forward-char 1))
|
|
|
|
(setq ex-token-type 'search-forward))
|
|
|
|
((looking-at "\\?")
|
|
|
|
(forward-char 1)
|
|
|
|
(set-mark (point))
|
|
|
|
(let ((cont t))
|
|
|
|
(while (and (not (eolp)) cont)
|
|
|
|
;;(re-search-forward "[^\\?]*\\?")
|
|
|
|
(re-search-forward "[^\\?]*\\(\\?\\|\n\\)")
|
|
|
|
(if (not (viper-looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\\\?"))
|
|
|
|
(setq cont nil))
|
|
|
|
(backward-char 1)
|
|
|
|
(if (not (looking-at "\n")) (forward-char 1))))
|
|
|
|
(setq ex-token-type 'search-backward)
|
|
|
|
(setq ex-token (buffer-substring (1- (point)) (mark t))))
|
|
|
|
((looking-at ",")
|
|
|
|
(forward-char 1)
|
|
|
|
(setq ex-token-type 'comma))
|
|
|
|
((looking-at ";")
|
|
|
|
(forward-char 1)
|
|
|
|
(setq ex-token-type 'semi-colon))
|
|
|
|
((looking-at "[!=><&~]")
|
|
|
|
(setq ex-token-type 'command)
|
|
|
|
(setq ex-token (char-to-string (following-char)))
|
|
|
|
(forward-char 1))
|
|
|
|
((looking-at "'")
|
|
|
|
(setq ex-token-type 'goto-mark)
|
|
|
|
(forward-char 1)
|
|
|
|
(cond ((looking-at "'") (setq ex-token nil))
|
|
|
|
((looking-at "[a-z]") (setq ex-token (following-char)))
|
|
|
|
(t (error "Marks are ' and a-z")))
|
|
|
|
(forward-char 1))
|
|
|
|
((looking-at "\n")
|
|
|
|
(setq ex-token-type 'end-mark)
|
|
|
|
(setq ex-token "goto"))
|
|
|
|
(t
|
|
|
|
(error viper-BadExCommand))))))
|
1996-06-22 01:54:34 +00:00
|
|
|
|
1999-11-01 07:16:15 +00:00
|
|
|
;; Reads Ex command. Tries to determine if it has to exit because command
|
|
|
|
;; is complete or invalid. If not, keeps reading command.
|
1996-06-22 03:20:38 +00:00
|
|
|
(defun ex-cmd-read-exit ()
|
|
|
|
(interactive)
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq viper-incomplete-ex-cmd t)
|
1996-06-22 03:20:38 +00:00
|
|
|
(let ((quit-regex1 (concat
|
|
|
|
"\\(" "set[ \t]*"
|
|
|
|
"\\|" "edit[ \t]*"
|
|
|
|
"\\|" "[nN]ext[ \t]*"
|
|
|
|
"\\|" "unm[ \t]*"
|
|
|
|
"\\|" "^[ \t]*rep"
|
|
|
|
"\\)"))
|
|
|
|
(quit-regex2 (concat
|
|
|
|
"[a-zA-Z][ \t]*"
|
|
|
|
"\\(" "!" "\\|" ">>"
|
|
|
|
"\\|" "\\+[0-9]+"
|
|
|
|
"\\)"
|
|
|
|
"*[ \t]*$"))
|
|
|
|
(stay-regex (concat
|
|
|
|
"\\(" "^[ \t]*$"
|
1997-07-17 19:37:07 +00:00
|
|
|
"\\|" "[?/].*"
|
1996-06-22 03:20:38 +00:00
|
|
|
"\\|" "[ktgjmsz][ \t]*$"
|
|
|
|
"\\|" "^[ \t]*ab.*"
|
|
|
|
"\\|" "tr[ansfer \t]*"
|
|
|
|
"\\|" "sr[ \t]*"
|
|
|
|
"\\|" "mo.*"
|
|
|
|
"\\|" "^[ \t]*k?ma[^p]*"
|
|
|
|
"\\|" "^[ \t]*fi.*"
|
|
|
|
"\\|" "v?gl.*"
|
|
|
|
"\\|" "[vg][ \t]*$"
|
|
|
|
"\\|" "jo.*"
|
|
|
|
"\\|" "^[ \t]*ta.*"
|
|
|
|
"\\|" "^[ \t]*una.*"
|
1998-05-04 22:42:59 +00:00
|
|
|
;; don't jump up in :s command
|
|
|
|
"\\|" "^[ \t]*\\([`'][a-z]\\|[.,%]\\)*[ \t]*su.*"
|
|
|
|
"\\|" "^[ \t]*\\([`'][a-z]\\|[.,%]\\)*[ \t]*s[^a-z].*"
|
1997-11-01 01:46:51 +00:00
|
|
|
"\\|" "['`][a-z][ \t]*"
|
|
|
|
;; r! assumes that the next one is a shell command
|
|
|
|
"\\|" "\\(r\\|re\\|rea\\|read\\)[ \t]*!"
|
|
|
|
;; w ! assumes that the next one is a shell command
|
|
|
|
"\\|" "\\(w\\|wr\\|wri\\|writ.?\\)[ \t]+!"
|
1996-06-22 03:20:38 +00:00
|
|
|
"\\|" "![ \t]*[a-zA-Z].*"
|
|
|
|
"\\)"
|
|
|
|
"!*")))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
(save-window-excursion ;; put cursor at the end of the Ex working buffer
|
2003-02-04 13:24:35 +00:00
|
|
|
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
|
1997-08-02 07:40:22 +00:00
|
|
|
(set-buffer viper-ex-work-buf)
|
1996-06-22 03:20:38 +00:00
|
|
|
(goto-char (point-max)))
|
1997-08-02 07:40:22 +00:00
|
|
|
(cond ((viper-looking-back quit-regex1) (exit-minibuffer))
|
|
|
|
((viper-looking-back stay-regex) (insert " "))
|
|
|
|
((viper-looking-back quit-regex2) (exit-minibuffer))
|
1996-06-22 03:20:38 +00:00
|
|
|
(t (insert " ")))))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; complete Ex command
|
|
|
|
(defun ex-cmd-complete ()
|
|
|
|
(interactive)
|
|
|
|
(let (save-pos dist compl-list string-to-complete completion-result)
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
(save-excursion
|
|
|
|
(setq dist (skip-chars-backward "[a-zA-Z!=>&~]")
|
|
|
|
save-pos (point)))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (or (= dist 0)
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-looking-back "\\([ \t]*['`][ \t]*[a-z]*\\)")
|
|
|
|
(viper-looking-back
|
1999-11-01 07:16:15 +00:00
|
|
|
"^[ \t]*[a-zA-Z!=>&~][ \t]*[/?]*[ \t]+[a-zA-Z!=>&~]+"))
|
1996-06-22 03:20:38 +00:00
|
|
|
;; Preceding characters are not the ones allowed in an Ex command
|
|
|
|
;; or we have typed past command name.
|
1999-11-01 07:16:15 +00:00
|
|
|
;; Note: we didn't do parsing, so there can be surprises.
|
1997-08-02 07:40:22 +00:00
|
|
|
(if (or (viper-looking-back "[a-zA-Z!=>&~][ \t]*[/?]*[ \t]*")
|
|
|
|
(viper-looking-back "\\([ \t]*['`][ \t]*[a-z]*\\)")
|
1996-06-22 03:20:38 +00:00
|
|
|
(looking-at "[^ \t\n\C-m]"))
|
|
|
|
nil
|
2003-02-04 13:24:35 +00:00
|
|
|
(with-output-to-temp-buffer "*Completions*"
|
1996-06-22 03:20:38 +00:00
|
|
|
(display-completion-list
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-alist-to-list ex-token-alist))))
|
1996-06-22 03:20:38 +00:00
|
|
|
;; Preceding chars may be part of a command name
|
|
|
|
(setq string-to-complete (buffer-substring save-pos (point)))
|
|
|
|
(setq completion-result
|
|
|
|
(try-completion string-to-complete ex-token-alist))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
(cond ((eq completion-result t) ; exact match--do nothing
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-tmp-insert-at-eob " (Sole completion)"))
|
1996-06-22 03:20:38 +00:00
|
|
|
((eq completion-result nil)
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-tmp-insert-at-eob " (No match)"))
|
1996-06-22 03:20:38 +00:00
|
|
|
(t ;; partial completion
|
|
|
|
(goto-char save-pos)
|
|
|
|
(delete-region (point) (point-max))
|
|
|
|
(insert completion-result)
|
|
|
|
(let (case-fold-search)
|
|
|
|
(setq compl-list
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-filter-alist (concat "^" completion-result)
|
1996-06-22 03:20:38 +00:00
|
|
|
ex-token-alist)))
|
|
|
|
(if (> (length compl-list) 1)
|
2003-02-04 13:24:35 +00:00
|
|
|
(with-output-to-temp-buffer "*Completions*"
|
1996-06-22 03:20:38 +00:00
|
|
|
(display-completion-list
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-alist-to-list (reverse compl-list)))))))
|
1996-06-22 03:20:38 +00:00
|
|
|
)))
|
1996-06-22 01:54:34 +00:00
|
|
|
|
2003-02-04 13:24:35 +00:00
|
|
|
|
|
|
|
;; Read Ex commands
|
1999-11-01 07:16:15 +00:00
|
|
|
;; ARG is a prefix argument. If given, the ex command runs on the region
|
|
|
|
;;(without the user having to specify the address :a,b
|
|
|
|
;; STRING is the command to execute. If nil, then Viper asks you to enter the
|
2003-02-04 13:24:35 +00:00
|
|
|
;; command.
|
1997-11-25 02:10:08 +00:00
|
|
|
(defun viper-ex (arg &optional string)
|
|
|
|
(interactive "P")
|
1996-06-22 03:20:38 +00:00
|
|
|
(or string
|
|
|
|
(setq ex-g-flag nil
|
|
|
|
ex-g-variant nil))
|
|
|
|
(let* ((map (copy-keymap minibuffer-local-map))
|
|
|
|
(address nil)
|
|
|
|
(cont t)
|
|
|
|
(dot (point))
|
1997-11-25 02:10:08 +00:00
|
|
|
reg-beg-line reg-end-line
|
|
|
|
reg-beg reg-end
|
|
|
|
initial-str
|
1996-06-22 03:20:38 +00:00
|
|
|
prev-token-type com-str)
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-add-keymap viper-ex-cmd-map map)
|
1997-11-25 02:10:08 +00:00
|
|
|
|
|
|
|
(if arg
|
|
|
|
(progn
|
|
|
|
(viper-enlarge-region (mark t) (point))
|
|
|
|
(if (> (point) (mark t))
|
|
|
|
(setq reg-beg (mark t)
|
|
|
|
reg-end (point))
|
|
|
|
(setq reg-end (mark t)
|
|
|
|
reg-beg (point)))
|
|
|
|
(save-excursion
|
|
|
|
(goto-char reg-beg)
|
|
|
|
(setq reg-beg-line (1+ (count-lines (point-min) (point)))
|
|
|
|
reg-end-line
|
|
|
|
(+ reg-beg-line (count-lines reg-beg reg-end) -1)))))
|
|
|
|
(if reg-beg-line
|
|
|
|
(setq initial-str (format "%d,%d" reg-beg-line reg-end-line)))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
|
|
|
(setq com-str
|
1997-11-25 02:10:08 +00:00
|
|
|
(or string (viper-read-string-with-history
|
2003-02-04 13:24:35 +00:00
|
|
|
":"
|
1997-11-25 02:10:08 +00:00
|
|
|
initial-str
|
|
|
|
'viper-ex-history
|
|
|
|
;; no default when working on region
|
|
|
|
(if initial-str
|
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-compile,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
(viper-get-ex-address-subr): convert registers to char data type.
* viper-util.el (viper-int-to-char,viper-char-equal): new
functions.
(viper-memq-char): use viper-int-to-char.
(viper-file-checked-in-p): use vc-locking-user, if vc doesn't have
vc-locking-state.
(viper-read-key): use viper-read-key-sequence.
* viper.el (viper-major-mode-modifier-list): added
inferior-emacs-lisp-mode.
(this-major-mode-requires-vi-state): new function that uses simple
heuristics to decide if vi state is appropriate.
(set-viper-state-in-major-mode): use this-major-mode-requires-vi-state.
(viper-non-hook-settings): don't advise read-key-sequence.
(viper-read-key-sequence): new function that replaces the
previously used advice to read-key-sequence.
* viper-cmd.el (viper-test-com-defun,viper-exec-change,
viper-exec-Change,viper-execute-com,viper-insert,viper-append,
viper-Append,viper-Insert,viper-open-line,viper-Open-line,
viper-open-line-at-point,viper-substitute,viper-overwrite,
viper-replace-char-subr,viper-forward-word,viper-forward-Word):
got rid of the negative character hack.
(viper-escape-to-state,viper-replace-state-exit-cmd):
use viper-read-key-sequence.
(viper-envelop-ESC-key): no need for ad-get-orig-definition.
(viper-minibuffer-standard-hook,viper-read-string-with-history):
don't override existing minibuffer-setup-hook.
(viper-mark-point,viper-goto-mark-subr,viper-brac-function):
convert registers to char data type.
(viper-autoindent): use viper-indent-line.
* viper-keym.el: use viper-exec-key-in-emacs.
* viper.texi: Added credits, new commands, like :make.
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
(ediff-file-checked-out-p,ediff-file-checked-in-p): check if
vc-state is available.
(ediff-make-temp-file): use ediff-coding-system-for-write.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
(ediff-coding-system-for-read): from ediff-diff.el
(ediff-coding-system-for-write): new variable.
(ediff-highest-priority): fixed the bug having to do with disappearing
overlays.
(ediff-file-remote-p): use file-remote-p, if available.
(ediff-listable-file): new function.
(ediff-file-attributes): use ediff-listable-file.
* ediff-mult.el (ediff-meta-insert-file-info1): use
ediff-listable-file.
* ediff-ptch.el (ediff-prompt-for-patch-file): use
ediff-coding-system-for-read.
(ediff-patch-file-internal): use ediff-coding-system-for-write.
* ediff-diff.el (ediff-coding-system-for-read): moved to ediff-init.el.
(ediff-match-diff3-line,ediff-get-diff3-group): improved pattern.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* ediff.texi: added clarifications, acknowledgements.
2001-07-21 05:28:24 +00:00
|
|
|
nil
|
1997-11-25 02:10:08 +00:00
|
|
|
(car viper-ex-history))
|
|
|
|
map
|
|
|
|
(if initial-str
|
|
|
|
" [Type command to execute on current region]"))))
|
1996-06-22 03:20:38 +00:00
|
|
|
(save-window-excursion
|
|
|
|
;; just a precaution
|
2003-02-04 13:24:35 +00:00
|
|
|
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
|
1997-08-02 07:40:22 +00:00
|
|
|
(set-buffer viper-ex-work-buf)
|
1996-06-22 03:20:38 +00:00
|
|
|
(delete-region (point-min) (point-max))
|
|
|
|
(insert com-str "\n")
|
|
|
|
(goto-char (point-min)))
|
|
|
|
(setq ex-token-type nil
|
|
|
|
ex-addresses nil)
|
|
|
|
(while cont
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-get-ex-token)
|
1996-06-22 03:20:38 +00:00
|
|
|
(cond ((memq ex-token-type '(command end-mark))
|
|
|
|
(if address (setq ex-addresses (cons address ex-addresses)))
|
2001-03-17 Michael Kifer <kifer@cs.sunysb.edu>
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
* viper-util.el: Spaces, indentation.
* viper.el: Changed version, modification time.
2001-03-17 18:59:39 +00:00
|
|
|
(viper-deactivate-mark)
|
|
|
|
(let ((cmd (ex-cmd-assoc ex-token ex-token-alist)))
|
|
|
|
(if (null cmd)
|
|
|
|
(error "`%s': %s" ex-token viper-BadExCommand))
|
|
|
|
(ex-cmd-execute cmd)
|
|
|
|
(if (or (ex-cmd-is-mashed-with-args cmd)
|
|
|
|
(ex-cmd-is-one-letter cmd))
|
|
|
|
(setq cont nil)
|
|
|
|
(save-excursion
|
|
|
|
(save-window-excursion
|
|
|
|
(setq viper-ex-work-buf
|
|
|
|
(get-buffer-create viper-ex-work-buf-name))
|
|
|
|
(set-buffer viper-ex-work-buf)
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
(cond ((looking-at "|")
|
|
|
|
(forward-char 1))
|
|
|
|
((looking-at "\n")
|
|
|
|
(setq cont nil))
|
|
|
|
(t (error
|
|
|
|
"`%s': %s" ex-token viper-SpuriousText)))
|
|
|
|
)))
|
|
|
|
))
|
1996-06-22 03:20:38 +00:00
|
|
|
((eq ex-token-type 'non-command)
|
1997-08-02 07:40:22 +00:00
|
|
|
(error "`%s': %s" ex-token viper-BadExCommand))
|
1996-06-22 03:20:38 +00:00
|
|
|
((eq ex-token-type 'whole)
|
|
|
|
(setq address nil)
|
|
|
|
(setq ex-addresses
|
|
|
|
(if ex-addresses
|
|
|
|
(cons (point-max) ex-addresses)
|
|
|
|
(cons (point-max) (cons (point-min) ex-addresses)))))
|
|
|
|
((eq ex-token-type 'comma)
|
|
|
|
(if (eq prev-token-type 'whole)
|
|
|
|
(setq address (point-min)))
|
|
|
|
(setq ex-addresses
|
|
|
|
(cons (if (null address) (point) address) ex-addresses)))
|
|
|
|
((eq ex-token-type 'semi-colon)
|
|
|
|
(if (eq prev-token-type 'whole)
|
|
|
|
(setq address (point-min)))
|
|
|
|
(if address (setq dot address))
|
|
|
|
(setq ex-addresses
|
|
|
|
(cons (if (null address) (point) address) ex-addresses)))
|
1997-08-02 07:40:22 +00:00
|
|
|
(t (let ((ans (viper-get-ex-address-subr address dot)))
|
1996-06-22 03:20:38 +00:00
|
|
|
(if ans (setq address ans)))))
|
|
|
|
(setq prev-token-type ex-token-type))))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 01:54:34 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; Get a regular expression and set `ex-variant', if found
|
2001-10-13 21:38:19 +00:00
|
|
|
;; Viper doesn't parse the substitution or search patterns.
|
|
|
|
;; In particular, it doesn't expand ~ into the last substitution.
|
1997-08-02 07:40:22 +00:00
|
|
|
(defun viper-get-ex-pat ()
|
1996-06-22 03:20:38 +00:00
|
|
|
(save-window-excursion
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
|
|
|
|
(set-buffer viper-ex-work-buf)
|
1996-06-22 03:20:38 +00:00
|
|
|
(skip-chars-forward " \t")
|
|
|
|
(if (looking-at "!")
|
1998-05-04 22:42:59 +00:00
|
|
|
;; this is probably a variant command r!
|
1996-06-22 03:20:38 +00:00
|
|
|
(progn
|
|
|
|
(setq ex-g-variant (not ex-g-variant)
|
|
|
|
ex-g-flag (not ex-g-flag))
|
|
|
|
(forward-char 1)
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
(let ((c (following-char)))
|
1998-05-04 22:42:59 +00:00
|
|
|
(cond ((string-match "[0-9A-Za-z]" (format "%c" c))
|
|
|
|
(error
|
|
|
|
"Global regexp must be inside matching non-alphanumeric chars"))
|
|
|
|
((= c ??) (error "`?' is not an allowed pattern delimiter here")))
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (looking-at "[^\\\\\n]")
|
|
|
|
(progn
|
|
|
|
(forward-char 1)
|
|
|
|
(set-mark (point))
|
|
|
|
(let ((cont t))
|
1998-05-04 22:42:59 +00:00
|
|
|
;; the use of eobp instead of eolp permits the use of newlines in
|
|
|
|
;; pat2 in s/pat1/pat2/
|
|
|
|
(while (and (not (eobp)) cont)
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (not (re-search-forward (format "[^%c]*%c" c c) nil t))
|
|
|
|
(if (member ex-token '("global" "vglobal"))
|
1998-05-04 22:42:59 +00:00
|
|
|
(error "Missing closing delimiter for global regexp")
|
1996-06-22 03:20:38 +00:00
|
|
|
(goto-char (point-max))))
|
1997-08-02 07:40:22 +00:00
|
|
|
(if (not (viper-looking-back
|
1996-06-22 03:20:38 +00:00
|
|
|
(format "[^\\\\]\\(\\\\\\\\\\)*\\\\%c" c)))
|
1998-05-04 22:42:59 +00:00
|
|
|
(setq cont nil)
|
|
|
|
;; we are at an escaped delimiter: unescape it and continue
|
|
|
|
(delete-backward-char 2)
|
|
|
|
(insert c)
|
|
|
|
(if (eolp)
|
|
|
|
;; if at eol, exit loop and go to next line
|
|
|
|
;; later, delim will be inserted at the end
|
|
|
|
(progn
|
|
|
|
(setq cont nil)
|
|
|
|
(forward-char))))
|
|
|
|
))
|
1996-06-22 03:20:38 +00:00
|
|
|
(setq ex-token
|
|
|
|
(if (= (mark t) (point)) ""
|
|
|
|
(buffer-substring (1- (point)) (mark t))))
|
1997-07-17 19:37:07 +00:00
|
|
|
(backward-char 1)
|
1998-05-04 22:42:59 +00:00
|
|
|
;; if the user didn't insert the final pattern delimiter, we're
|
1999-11-01 07:16:15 +00:00
|
|
|
;; at newline now. In this case, insert the initial delimiter
|
1997-07-17 19:37:07 +00:00
|
|
|
;; specified in variable c
|
1998-05-04 22:42:59 +00:00
|
|
|
(if (eolp)
|
1997-07-17 19:37:07 +00:00
|
|
|
(progn
|
1998-05-04 22:42:59 +00:00
|
|
|
(insert c)
|
|
|
|
(backward-char 1)))
|
1997-07-17 19:37:07 +00:00
|
|
|
)
|
1996-06-22 03:20:38 +00:00
|
|
|
(setq ex-token nil))
|
|
|
|
c)))
|
1996-06-22 01:54:34 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; Get an Ex option g or c
|
1997-08-02 07:40:22 +00:00
|
|
|
(defun viper-get-ex-opt-gc (c)
|
1996-06-22 03:20:38 +00:00
|
|
|
(save-window-excursion
|
2003-02-04 13:24:35 +00:00
|
|
|
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
|
1997-08-02 07:40:22 +00:00
|
|
|
(set-buffer viper-ex-work-buf)
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (looking-at (format "%c" c)) (forward-char 1))
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
(cond ((looking-at "g")
|
|
|
|
(setq ex-token "g")
|
|
|
|
(forward-char 1)
|
|
|
|
t)
|
|
|
|
((looking-at "c")
|
|
|
|
(setq ex-token "c")
|
|
|
|
(forward-char 1)
|
|
|
|
t)
|
|
|
|
(t nil))))
|
|
|
|
|
|
|
|
;; Compute default addresses. WHOLE-FLAG means use the whole buffer
|
1997-08-02 07:40:22 +00:00
|
|
|
(defun viper-default-ex-addresses (&optional whole-flag)
|
1996-06-22 03:20:38 +00:00
|
|
|
(cond ((null ex-addresses)
|
|
|
|
(setq ex-addresses
|
|
|
|
(if whole-flag
|
1998-05-04 22:42:59 +00:00
|
|
|
(list (point-max) (point-min))
|
|
|
|
(list (point) (point)))))
|
1996-06-22 03:20:38 +00:00
|
|
|
((null (cdr ex-addresses))
|
|
|
|
(setq ex-addresses
|
|
|
|
(cons (car ex-addresses) ex-addresses)))))
|
|
|
|
|
|
|
|
;; Get an ex-address as a marker and set ex-flag if a flag is found
|
1997-08-02 07:40:22 +00:00
|
|
|
(defun viper-get-ex-address ()
|
1997-05-31 00:02:53 +00:00
|
|
|
(let ((address (point-marker))
|
|
|
|
(cont t))
|
1996-06-22 03:20:38 +00:00
|
|
|
(setq ex-token "")
|
|
|
|
(setq ex-flag nil)
|
|
|
|
(while cont
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-get-ex-token)
|
1996-06-22 03:20:38 +00:00
|
|
|
(cond ((eq ex-token-type 'command)
|
|
|
|
(if (member ex-token '("print" "list" "#"))
|
|
|
|
(progn
|
|
|
|
(setq ex-flag t
|
|
|
|
cont nil))
|
|
|
|
(error "Address expected in this Ex command")))
|
|
|
|
((eq ex-token-type 'end-mark)
|
|
|
|
(setq cont nil))
|
|
|
|
((eq ex-token-type 'whole)
|
|
|
|
(error "Trailing address expected"))
|
|
|
|
((eq ex-token-type 'comma)
|
1997-08-02 07:40:22 +00:00
|
|
|
(error "`%s': %s" ex-token viper-SpuriousText))
|
|
|
|
(t (let ((ans (viper-get-ex-address-subr address (point-marker))))
|
1996-06-22 03:20:38 +00:00
|
|
|
(if ans (setq address ans))))))
|
|
|
|
address))
|
|
|
|
|
|
|
|
;; Returns an address as a point
|
1997-08-02 07:40:22 +00:00
|
|
|
(defun viper-get-ex-address-subr (old-address dot)
|
1996-06-22 03:20:38 +00:00
|
|
|
(let ((address nil))
|
|
|
|
(if (null old-address) (setq old-address dot))
|
|
|
|
(cond ((eq ex-token-type 'dot)
|
|
|
|
(setq address dot))
|
|
|
|
((eq ex-token-type 'add-number)
|
|
|
|
(save-excursion
|
|
|
|
(goto-char old-address)
|
|
|
|
(forward-line (if (= old-address 0) (1- ex-token) ex-token))
|
|
|
|
(setq address (point-marker))))
|
|
|
|
((eq ex-token-type 'sub-number)
|
|
|
|
(save-excursion
|
|
|
|
(goto-char old-address)
|
|
|
|
(forward-line (- ex-token))
|
|
|
|
(setq address (point-marker))))
|
|
|
|
((eq ex-token-type 'abs-number)
|
|
|
|
(save-excursion
|
|
|
|
(goto-char (point-min))
|
|
|
|
(if (= ex-token 0) (setq address 0)
|
|
|
|
(forward-line (1- ex-token))
|
|
|
|
(setq address (point-marker)))))
|
|
|
|
((eq ex-token-type 'end)
|
2001-10-13 21:38:19 +00:00
|
|
|
(save-excursion
|
|
|
|
(goto-char (1- (point-max)))
|
|
|
|
(setq address (point-marker))))
|
1996-06-22 03:20:38 +00:00
|
|
|
((eq ex-token-type 'plus) t) ; do nothing
|
|
|
|
((eq ex-token-type 'minus) t) ; do nothing
|
|
|
|
((eq ex-token-type 'search-forward)
|
|
|
|
(save-excursion
|
|
|
|
(ex-search-address t)
|
|
|
|
(setq address (point-marker))))
|
|
|
|
((eq ex-token-type 'search-backward)
|
|
|
|
(save-excursion
|
|
|
|
(ex-search-address nil)
|
|
|
|
(setq address (point-marker))))
|
|
|
|
((eq ex-token-type 'goto-mark)
|
|
|
|
(save-excursion
|
|
|
|
(if (null ex-token)
|
|
|
|
(exchange-point-and-mark)
|
2003-02-04 13:24:35 +00:00
|
|
|
(goto-char
|
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-compile,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
(viper-get-ex-address-subr): convert registers to char data type.
* viper-util.el (viper-int-to-char,viper-char-equal): new
functions.
(viper-memq-char): use viper-int-to-char.
(viper-file-checked-in-p): use vc-locking-user, if vc doesn't have
vc-locking-state.
(viper-read-key): use viper-read-key-sequence.
* viper.el (viper-major-mode-modifier-list): added
inferior-emacs-lisp-mode.
(this-major-mode-requires-vi-state): new function that uses simple
heuristics to decide if vi state is appropriate.
(set-viper-state-in-major-mode): use this-major-mode-requires-vi-state.
(viper-non-hook-settings): don't advise read-key-sequence.
(viper-read-key-sequence): new function that replaces the
previously used advice to read-key-sequence.
* viper-cmd.el (viper-test-com-defun,viper-exec-change,
viper-exec-Change,viper-execute-com,viper-insert,viper-append,
viper-Append,viper-Insert,viper-open-line,viper-Open-line,
viper-open-line-at-point,viper-substitute,viper-overwrite,
viper-replace-char-subr,viper-forward-word,viper-forward-Word):
got rid of the negative character hack.
(viper-escape-to-state,viper-replace-state-exit-cmd):
use viper-read-key-sequence.
(viper-envelop-ESC-key): no need for ad-get-orig-definition.
(viper-minibuffer-standard-hook,viper-read-string-with-history):
don't override existing minibuffer-setup-hook.
(viper-mark-point,viper-goto-mark-subr,viper-brac-function):
convert registers to char data type.
(viper-autoindent): use viper-indent-line.
* viper-keym.el: use viper-exec-key-in-emacs.
* viper.texi: Added credits, new commands, like :make.
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
(ediff-file-checked-out-p,ediff-file-checked-in-p): check if
vc-state is available.
(ediff-make-temp-file): use ediff-coding-system-for-write.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
(ediff-coding-system-for-read): from ediff-diff.el
(ediff-coding-system-for-write): new variable.
(ediff-highest-priority): fixed the bug having to do with disappearing
overlays.
(ediff-file-remote-p): use file-remote-p, if available.
(ediff-listable-file): new function.
(ediff-file-attributes): use ediff-listable-file.
* ediff-mult.el (ediff-meta-insert-file-info1): use
ediff-listable-file.
* ediff-ptch.el (ediff-prompt-for-patch-file): use
ediff-coding-system-for-read.
(ediff-patch-file-internal): use ediff-coding-system-for-write.
* ediff-diff.el (ediff-coding-system-for-read): moved to ediff-init.el.
(ediff-match-diff3-line,ediff-get-diff3-group): improved pattern.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* ediff.texi: added clarifications, acknowledgements.
2001-07-21 05:28:24 +00:00
|
|
|
(viper-register-to-point
|
|
|
|
(viper-int-to-char (1+ (- ex-token ?a))) 'enforce-buffer)))
|
1996-06-22 03:20:38 +00:00
|
|
|
(setq address (point-marker)))))
|
|
|
|
address))
|
|
|
|
|
|
|
|
|
|
|
|
;; Search pattern and set address
|
2001-10-13 21:38:19 +00:00
|
|
|
;; Doesn't wrap around. Should it?
|
1996-06-22 03:20:38 +00:00
|
|
|
(defun ex-search-address (forward)
|
|
|
|
(if (string= ex-token "")
|
1997-08-02 07:40:22 +00:00
|
|
|
(if (null viper-s-string)
|
|
|
|
(error viper-NoPrevSearch)
|
|
|
|
(setq ex-token viper-s-string))
|
|
|
|
(setq viper-s-string ex-token))
|
1996-06-22 03:20:38 +00:00
|
|
|
(if forward
|
|
|
|
(progn
|
|
|
|
(forward-line 1)
|
|
|
|
(re-search-forward ex-token))
|
|
|
|
(forward-line -1)
|
|
|
|
(re-search-backward ex-token)))
|
|
|
|
|
|
|
|
;; Get a buffer name and set `ex-count' and `ex-flag' if found
|
1997-08-02 07:40:22 +00:00
|
|
|
(defun viper-get-ex-buffer ()
|
1996-06-22 03:20:38 +00:00
|
|
|
(setq ex-buffer nil)
|
|
|
|
(setq ex-count nil)
|
|
|
|
(setq ex-flag nil)
|
|
|
|
(save-window-excursion
|
2003-02-04 13:24:35 +00:00
|
|
|
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
|
1997-08-02 07:40:22 +00:00
|
|
|
(set-buffer viper-ex-work-buf)
|
1996-06-22 03:20:38 +00:00
|
|
|
(skip-chars-forward " \t")
|
|
|
|
(if (looking-at "[a-zA-Z]")
|
|
|
|
(progn
|
|
|
|
(setq ex-buffer (following-char))
|
|
|
|
(forward-char 1)
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
(if (looking-at "[0-9]")
|
|
|
|
(progn
|
|
|
|
(set-mark (point))
|
|
|
|
(re-search-forward "[0-9][0-9]*")
|
|
|
|
(setq ex-count (string-to-int (buffer-substring (point) (mark t))))
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
(if (looking-at "[pl#]")
|
|
|
|
(progn
|
|
|
|
(setq ex-flag t)
|
|
|
|
(forward-char 1)))
|
|
|
|
(if (not (looking-at "[\n|]"))
|
1997-08-02 07:40:22 +00:00
|
|
|
(error "`%s': %s" ex-token viper-SpuriousText))))
|
1996-06-22 03:20:38 +00:00
|
|
|
|
1997-08-02 07:40:22 +00:00
|
|
|
(defun viper-get-ex-count ()
|
1996-06-22 03:20:38 +00:00
|
|
|
(setq ex-variant nil
|
|
|
|
ex-count nil
|
|
|
|
ex-flag nil)
|
|
|
|
(save-window-excursion
|
2003-02-04 13:24:35 +00:00
|
|
|
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
|
1997-08-02 07:40:22 +00:00
|
|
|
(set-buffer viper-ex-work-buf)
|
1996-06-22 03:20:38 +00:00
|
|
|
(skip-chars-forward " \t")
|
|
|
|
(if (looking-at "!")
|
|
|
|
(progn
|
|
|
|
(setq ex-variant t)
|
|
|
|
(forward-char 1)))
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
(if (looking-at "[0-9]")
|
|
|
|
(progn
|
|
|
|
(set-mark (point))
|
|
|
|
(re-search-forward "[0-9][0-9]*")
|
|
|
|
(setq ex-count (string-to-int (buffer-substring (point) (mark t))))
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
(if (looking-at "[pl#]")
|
|
|
|
(progn
|
|
|
|
(setq ex-flag t)
|
|
|
|
(forward-char 1)))
|
|
|
|
(if (not (looking-at "[\n|]"))
|
|
|
|
(error "`%s': %s"
|
1997-08-02 07:40:22 +00:00
|
|
|
(buffer-substring
|
|
|
|
(point-min) (1- (point-max))) viper-BadExCommand))))
|
1996-06-22 03:20:38 +00:00
|
|
|
|
|
|
|
;; Expand \% and \# in ex command
|
|
|
|
(defun ex-expand-filsyms (cmd buf)
|
|
|
|
(let (cf pf ret)
|
2003-02-04 13:24:35 +00:00
|
|
|
(save-excursion
|
1996-06-22 03:20:38 +00:00
|
|
|
(set-buffer buf)
|
|
|
|
(setq cf buffer-file-name)
|
|
|
|
(setq pf (ex-next nil t))) ; this finds alternative file name
|
|
|
|
(if (and (null cf) (string-match "[^\\]%\\|\\`%" cmd))
|
|
|
|
(error "No current file to substitute for `%%'"))
|
|
|
|
(if (and (null pf) (string-match "[^\\]#\\|\\`#" cmd))
|
|
|
|
(error "No alternate file to substitute for `#'"))
|
|
|
|
(save-excursion
|
1997-08-02 07:40:22 +00:00
|
|
|
(set-buffer (get-buffer-create viper-ex-tmp-buf-name))
|
1996-06-22 03:20:38 +00:00
|
|
|
(erase-buffer)
|
|
|
|
(insert cmd)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(while (re-search-forward "%\\|#" nil t)
|
2003-02-04 13:24:35 +00:00
|
|
|
(let ((data (match-data))
|
1996-06-22 03:20:38 +00:00
|
|
|
(char (buffer-substring (match-beginning 0) (match-end 0))))
|
1997-08-02 07:40:22 +00:00
|
|
|
(if (viper-looking-back (concat "\\\\" char))
|
1996-06-22 03:20:38 +00:00
|
|
|
(replace-match char)
|
1998-05-04 22:42:59 +00:00
|
|
|
(store-match-data data)
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (string= char "%")
|
|
|
|
(replace-match cf)
|
|
|
|
(replace-match pf)))))
|
|
|
|
(end-of-line)
|
|
|
|
(setq ret (buffer-substring (point-min) (point)))
|
|
|
|
(message "%s" ret))
|
|
|
|
ret))
|
|
|
|
|
1997-11-01 01:46:51 +00:00
|
|
|
;; Get a file name and set `ex-variant', `ex-append' and `ex-offset' if found
|
|
|
|
;; If it is r!, then get the command name and whatever args
|
1997-08-02 07:40:22 +00:00
|
|
|
(defun viper-get-ex-file ()
|
1996-06-22 03:20:38 +00:00
|
|
|
(let (prompt)
|
|
|
|
(setq ex-file nil
|
|
|
|
ex-variant nil
|
|
|
|
ex-append nil
|
|
|
|
ex-offset nil
|
1997-11-01 01:46:51 +00:00
|
|
|
ex-cmdfile nil
|
|
|
|
ex-cmdfile-args "")
|
1996-06-22 03:20:38 +00:00
|
|
|
(save-excursion
|
|
|
|
(save-window-excursion
|
2003-02-04 13:24:35 +00:00
|
|
|
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
|
1997-08-02 07:40:22 +00:00
|
|
|
(set-buffer viper-ex-work-buf)
|
1996-06-22 03:20:38 +00:00
|
|
|
(skip-chars-forward " \t")
|
|
|
|
(if (looking-at "!")
|
1997-08-02 07:40:22 +00:00
|
|
|
(if (and (not (viper-looking-back "[ \t]"))
|
1996-06-22 03:20:38 +00:00
|
|
|
;; read doesn't have a corresponding :r! form, so ! is
|
|
|
|
;; immediately interpreted as a shell command.
|
|
|
|
(not (string= ex-token "read")))
|
|
|
|
(progn
|
|
|
|
(setq ex-variant t)
|
|
|
|
(forward-char 1)
|
|
|
|
(skip-chars-forward " \t"))
|
|
|
|
(setq ex-cmdfile t)
|
|
|
|
(forward-char 1)
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
(if (looking-at ">>")
|
|
|
|
(progn
|
|
|
|
(setq ex-append t
|
|
|
|
ex-variant t)
|
|
|
|
(forward-char 2)
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
(if (looking-at "+")
|
|
|
|
(progn
|
|
|
|
(forward-char 1)
|
|
|
|
(set-mark (point))
|
|
|
|
(re-search-forward "[ \t\n]")
|
|
|
|
(backward-char 1)
|
|
|
|
(setq ex-offset (buffer-substring (point) (mark t)))
|
|
|
|
(forward-char 1)
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
;; this takes care of :r, :w, etc., when they get file names
|
|
|
|
;; from the history list
|
|
|
|
(if (member ex-token '("read" "write" "edit" "visual" "next"))
|
|
|
|
(progn
|
|
|
|
(setq ex-file (buffer-substring (point) (1- (point-max))))
|
|
|
|
(setq ex-file
|
|
|
|
;; For :e, match multiple non-white strings separated
|
1999-11-01 07:16:15 +00:00
|
|
|
;; by white. For others, find the first non-white string
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (string-match
|
|
|
|
(if (string= ex-token "edit")
|
|
|
|
"[^ \t\n]+\\([ \t]+[^ \t\n]+\\)*"
|
|
|
|
"[^ \t\n]+")
|
|
|
|
ex-file)
|
|
|
|
(progn
|
|
|
|
;; if file name comes from history, don't leave
|
|
|
|
;; minibuffer when the user types space
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq viper-incomplete-ex-cmd nil)
|
1997-11-01 01:46:51 +00:00
|
|
|
(setq ex-cmdfile-args
|
|
|
|
(substring ex-file (match-end 0) nil))
|
1996-06-22 03:20:38 +00:00
|
|
|
;; this must be the last clause in this progn
|
|
|
|
(substring ex-file (match-beginning 0) (match-end 0))
|
|
|
|
)
|
|
|
|
""))
|
|
|
|
;; this leaves only the command name in the work area
|
|
|
|
;; file names are gone
|
|
|
|
(delete-region (point) (1- (point-max)))
|
|
|
|
))
|
|
|
|
(goto-char (point-max))
|
|
|
|
(skip-chars-backward " \t\n")
|
|
|
|
(setq prompt (buffer-substring (point-min) (point)))
|
|
|
|
))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq viper-last-ex-prompt prompt)
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; If we just finished reading command, redisplay prompt
|
1997-08-02 07:40:22 +00:00
|
|
|
(if viper-incomplete-ex-cmd
|
|
|
|
(setq ex-file (viper-ex-read-file-name (format ":%s " prompt)))
|
1996-06-22 03:20:38 +00:00
|
|
|
;; file was typed in-line
|
|
|
|
(setq ex-file (or ex-file "")))
|
|
|
|
))
|
1996-06-22 01:54:34 +00:00
|
|
|
|
|
|
|
|
1999-11-01 07:16:15 +00:00
|
|
|
;; Completes file name or exits minibuffer. If Ex command accepts multiple
|
1996-06-22 03:20:38 +00:00
|
|
|
;; file names, arranges to re-enter the minibuffer.
|
1997-08-02 07:40:22 +00:00
|
|
|
(defun viper-complete-filename-or-exit ()
|
1996-06-22 03:20:38 +00:00
|
|
|
(interactive)
|
2003-02-04 13:24:35 +00:00
|
|
|
(setq viper-keep-reading-filename t)
|
|
|
|
;; don't exit if directory---ex-commands don't
|
1996-06-22 03:20:38 +00:00
|
|
|
(cond ((ex-cmd-accepts-multiple-files-p ex-token) (exit-minibuffer))
|
|
|
|
;; apparently the argument to an Ex command is
|
|
|
|
;; supposed to be a shell command
|
1997-08-02 07:40:22 +00:00
|
|
|
((viper-looking-back "^[ \t]*!.*")
|
1996-06-22 03:20:38 +00:00
|
|
|
(setq ex-cmdfile t)
|
|
|
|
(insert " "))
|
|
|
|
(t
|
|
|
|
(setq ex-cmdfile nil)
|
|
|
|
(minibuffer-complete-word))))
|
1996-06-22 01:54:34 +00:00
|
|
|
|
1997-08-02 07:40:22 +00:00
|
|
|
(defun viper-handle-! ()
|
1996-06-22 03:20:38 +00:00
|
|
|
(interactive)
|
|
|
|
(if (and (string=
|
1997-08-02 07:40:22 +00:00
|
|
|
(buffer-string) (viper-abbreviate-file-name default-directory))
|
1996-06-22 03:20:38 +00:00
|
|
|
(member ex-token '("read" "write")))
|
|
|
|
(erase-buffer))
|
|
|
|
(insert "!"))
|
|
|
|
|
|
|
|
(defun ex-cmd-accepts-multiple-files-p (token)
|
|
|
|
(member token '("edit" "next" "Next")))
|
|
|
|
|
1997-11-01 01:46:51 +00:00
|
|
|
;; Read file name from the minibuffer in an ex command.
|
1996-06-22 03:20:38 +00:00
|
|
|
;; If user doesn't enter anything, then "" is returned, i.e., the
|
|
|
|
;; prompt-directory is not returned.
|
1997-08-02 07:40:22 +00:00
|
|
|
(defun viper-ex-read-file-name (prompt)
|
1996-06-22 03:20:38 +00:00
|
|
|
(let* ((str "")
|
|
|
|
(minibuffer-local-completion-map
|
|
|
|
(copy-keymap minibuffer-local-completion-map))
|
|
|
|
beg end cont val)
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-add-keymap ex-read-filename-map
|
2003-02-04 13:24:35 +00:00
|
|
|
(if viper-emacs-p
|
1996-06-22 03:20:38 +00:00
|
|
|
minibuffer-local-completion-map
|
2003-02-04 13:24:35 +00:00
|
|
|
read-file-name-map))
|
|
|
|
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq cont (setq viper-keep-reading-filename t))
|
1996-06-22 03:20:38 +00:00
|
|
|
(while cont
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq viper-keep-reading-filename nil
|
1996-06-22 03:20:38 +00:00
|
|
|
val (read-file-name (concat prompt str) nil default-directory))
|
1998-05-04 22:42:59 +00:00
|
|
|
(setq val (expand-file-name val))
|
|
|
|
(if (and (string-match " " val)
|
|
|
|
(ex-cmd-accepts-multiple-files-p ex-token))
|
|
|
|
(setq val (concat "\"" val "\"")))
|
1996-06-22 03:20:38 +00:00
|
|
|
(setq str (concat str (if (equal val "") "" " ")
|
|
|
|
val (if (equal val "") "" " ")))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; Only edit, next, and Next commands accept multiple files.
|
1997-08-02 07:40:22 +00:00
|
|
|
;; viper-keep-reading-filename is set in the anonymous function that is
|
1996-06-22 03:20:38 +00:00
|
|
|
;; bound to " " in ex-read-filename-map.
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq cont (and viper-keep-reading-filename
|
1996-06-22 03:20:38 +00:00
|
|
|
(ex-cmd-accepts-multiple-files-p ex-token)))
|
|
|
|
)
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
(setq beg (string-match "[^ \t]" str) ; delete leading blanks
|
|
|
|
end (string-match "[ \t]*$" str)) ; delete trailing blanks
|
|
|
|
(if (member ex-token '("read" "write"))
|
|
|
|
(if (string-match "[\t ]*!" str)
|
|
|
|
;; this is actually a shell command
|
|
|
|
(progn
|
|
|
|
(setq ex-cmdfile t)
|
|
|
|
(setq beg (1+ beg))
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq viper-last-ex-prompt
|
|
|
|
(concat viper-last-ex-prompt " !")))))
|
1996-06-22 03:20:38 +00:00
|
|
|
(substring str (or beg 0) end)))
|
1996-06-22 01:54:34 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
|
1997-08-02 07:40:22 +00:00
|
|
|
(defun viper-undisplayed-files ()
|
1996-06-22 03:20:38 +00:00
|
|
|
(mapcar
|
2003-02-04 13:24:35 +00:00
|
|
|
(lambda (b)
|
1999-11-01 07:16:15 +00:00
|
|
|
(if (null (get-buffer-window b))
|
|
|
|
(let ((f (buffer-file-name b)))
|
|
|
|
(if f f
|
2003-02-04 13:24:35 +00:00
|
|
|
(if ex-cycle-through-non-files
|
1999-11-01 07:16:15 +00:00
|
|
|
(let ((s (buffer-name b)))
|
|
|
|
(if (string= " " (substring s 0 1))
|
|
|
|
nil
|
|
|
|
s))
|
|
|
|
nil)))
|
|
|
|
nil))
|
1996-06-22 03:20:38 +00:00
|
|
|
(buffer-list)))
|
|
|
|
|
|
|
|
|
|
|
|
(defun ex-args ()
|
1997-08-02 07:40:22 +00:00
|
|
|
(let ((l (viper-undisplayed-files))
|
1996-06-22 03:20:38 +00:00
|
|
|
(args "")
|
|
|
|
(file-count 1))
|
|
|
|
(while (not (null l))
|
2003-02-04 13:24:35 +00:00
|
|
|
(if (car l)
|
1996-06-22 03:20:38 +00:00
|
|
|
(setq args (format "%s %d) %s\n" args file-count (car l))
|
|
|
|
file-count (1+ file-count)))
|
|
|
|
(setq l (cdr l)))
|
|
|
|
(if (string= args "")
|
|
|
|
(message "All files are already displayed")
|
|
|
|
(save-excursion
|
|
|
|
(save-window-excursion
|
1997-08-02 07:40:22 +00:00
|
|
|
(with-output-to-temp-buffer " *viper-info*"
|
1996-06-22 03:20:38 +00:00
|
|
|
(princ "\n\nThese files are not displayed in any window.\n")
|
|
|
|
(princ "\n=============\n")
|
|
|
|
(princ args)
|
|
|
|
(princ "\n=============\n")
|
|
|
|
(princ "\nThe numbers can be given as counts to :next. ")
|
|
|
|
(princ "\n\nPress any key to continue...\n\n"))
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-read-event))))))
|
1996-06-22 03:20:38 +00:00
|
|
|
|
1999-11-01 07:16:15 +00:00
|
|
|
;; Ex cd command. Default directory of this buffer changes
|
1996-06-22 03:20:38 +00:00
|
|
|
(defun ex-cd ()
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-get-ex-file)
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (string= ex-file "")
|
|
|
|
(setq ex-file "~"))
|
|
|
|
(setq default-directory (file-name-as-directory (expand-file-name ex-file))))
|
|
|
|
|
|
|
|
;; Ex copy and move command. DEL-FLAG means delete
|
|
|
|
(defun ex-copy (del-flag)
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-default-ex-addresses)
|
|
|
|
(let ((address (viper-get-ex-address))
|
1996-06-22 03:20:38 +00:00
|
|
|
(end (car ex-addresses)) (beg (car (cdr ex-addresses))))
|
|
|
|
(goto-char end)
|
|
|
|
(save-excursion
|
|
|
|
(push-mark beg t)
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-enlarge-region (mark t) (point))
|
1996-06-22 03:20:38 +00:00
|
|
|
(if del-flag
|
|
|
|
(kill-region (point) (mark t))
|
|
|
|
(copy-region-as-kill (point) (mark t)))
|
|
|
|
(if ex-flag
|
|
|
|
(progn
|
1997-09-30 01:13:53 +00:00
|
|
|
(with-output-to-temp-buffer " *copy text*"
|
1996-06-22 03:20:38 +00:00
|
|
|
(princ
|
|
|
|
(if (or del-flag ex-g-flag ex-g-variant)
|
|
|
|
(current-kill 0)
|
|
|
|
(buffer-substring (point) (mark t)))))
|
|
|
|
(condition-case nil
|
|
|
|
(progn
|
1997-09-30 01:13:53 +00:00
|
|
|
(read-string "[Hit return to confirm] ")
|
|
|
|
(save-excursion (kill-buffer " *copy text*")))
|
|
|
|
(quit (save-excursion (kill-buffer " *copy text*"))
|
1996-06-22 03:20:38 +00:00
|
|
|
(signal 'quit nil))))))
|
|
|
|
(if (= address 0)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(goto-char address)
|
|
|
|
(forward-line 1))
|
|
|
|
(insert (current-kill 0))))
|
|
|
|
|
|
|
|
;; Ex delete command
|
|
|
|
(defun ex-delete ()
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-default-ex-addresses)
|
|
|
|
(viper-get-ex-buffer)
|
1996-06-22 03:20:38 +00:00
|
|
|
(let ((end (car ex-addresses)) (beg (car (cdr ex-addresses))))
|
1997-08-02 07:40:22 +00:00
|
|
|
(if (> beg end) (error viper-FirstAddrExceedsSecond))
|
1996-06-22 03:20:38 +00:00
|
|
|
(save-excursion
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-enlarge-region beg end)
|
1996-06-22 03:20:38 +00:00
|
|
|
(exchange-point-and-mark)
|
|
|
|
(if ex-count
|
|
|
|
(progn
|
|
|
|
(set-mark (point))
|
|
|
|
(forward-line (1- ex-count)))
|
|
|
|
(set-mark end))
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-enlarge-region (point) (mark t))
|
1996-06-22 03:20:38 +00:00
|
|
|
(if ex-flag
|
|
|
|
;; show text to be deleted and ask for confirmation
|
|
|
|
(progn
|
|
|
|
(with-output-to-temp-buffer " *delete text*"
|
|
|
|
(princ (buffer-substring (point) (mark t))))
|
|
|
|
(condition-case nil
|
1997-09-30 01:13:53 +00:00
|
|
|
(read-string "[Hit return to confirm] ")
|
1996-06-22 03:20:38 +00:00
|
|
|
(quit
|
|
|
|
(save-excursion (kill-buffer " *delete text*"))
|
|
|
|
(error "")))
|
|
|
|
(save-excursion (kill-buffer " *delete text*")))
|
|
|
|
(if ex-buffer
|
1997-08-02 07:40:22 +00:00
|
|
|
(cond ((viper-valid-register ex-buffer '(Letter))
|
|
|
|
(viper-append-to-register
|
1996-06-22 03:20:38 +00:00
|
|
|
(downcase ex-buffer) (point) (mark t)))
|
1997-08-02 07:40:22 +00:00
|
|
|
((viper-valid-register ex-buffer)
|
1996-06-22 03:20:38 +00:00
|
|
|
(copy-to-register ex-buffer (point) (mark t) nil))
|
1997-08-02 07:40:22 +00:00
|
|
|
(t (error viper-InvalidRegister ex-buffer))))
|
1996-06-22 03:20:38 +00:00
|
|
|
(kill-region (point) (mark t))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Ex edit command
|
1999-11-01 07:16:15 +00:00
|
|
|
;; In Viper, `e' and `e!' behave identically. In both cases, the user is
|
1996-06-22 03:20:38 +00:00
|
|
|
;; asked if current buffer should really be discarded.
|
1999-11-01 07:16:15 +00:00
|
|
|
;; This command can take multiple file names. It replaces the current buffer
|
1996-06-22 03:20:38 +00:00
|
|
|
;; with the first file in its argument list
|
|
|
|
(defun ex-edit (&optional file)
|
|
|
|
(if (not file)
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-get-ex-file))
|
1996-06-22 03:20:38 +00:00
|
|
|
(cond ((and (string= ex-file "") buffer-file-name)
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq ex-file (viper-abbreviate-file-name (buffer-file-name))))
|
1996-06-22 03:20:38 +00:00
|
|
|
((string= ex-file "")
|
1997-08-02 07:40:22 +00:00
|
|
|
(error viper-NoFileSpecified)))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
2001-10-13 21:38:19 +00:00
|
|
|
(let (msg do-edit)
|
|
|
|
(if buffer-file-name
|
|
|
|
(cond ((buffer-modified-p)
|
|
|
|
(setq msg
|
|
|
|
(format "Buffer %s is modified. Discard changes? "
|
|
|
|
(buffer-name))
|
|
|
|
do-edit t))
|
|
|
|
((not (verify-visited-file-modtime (current-buffer)))
|
|
|
|
(setq msg
|
|
|
|
(format "File %s changed on disk. Reread from disk? "
|
|
|
|
buffer-file-name)
|
|
|
|
do-edit t))
|
|
|
|
(t (setq do-edit nil))))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
2001-10-13 21:38:19 +00:00
|
|
|
(if do-edit
|
|
|
|
(if (yes-or-no-p msg)
|
|
|
|
(progn
|
|
|
|
(set-buffer-modified-p nil)
|
|
|
|
(kill-buffer (current-buffer)))
|
|
|
|
(message "Buffer %s was left intact" (buffer-name))))
|
|
|
|
) ; let
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (null (setq file (get-file-buffer ex-file)))
|
2003-02-04 13:24:35 +00:00
|
|
|
(progn
|
1999-11-01 07:16:15 +00:00
|
|
|
;; this also does shell-style globbing
|
|
|
|
(ex-find-file
|
|
|
|
;; replace # and % with the previous/current file
|
|
|
|
(ex-expand-filsyms ex-file (current-buffer)))
|
1996-09-06 02:13:39 +00:00
|
|
|
(or (eq major-mode 'dired-mode)
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-change-state-to-vi))
|
1996-06-22 03:20:38 +00:00
|
|
|
(goto-char (point-min)))
|
|
|
|
(switch-to-buffer file))
|
|
|
|
(if ex-offset
|
|
|
|
(progn
|
|
|
|
(save-window-excursion
|
2003-02-04 13:24:35 +00:00
|
|
|
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
|
1997-08-02 07:40:22 +00:00
|
|
|
(set-buffer viper-ex-work-buf)
|
1996-06-22 03:20:38 +00:00
|
|
|
(delete-region (point-min) (point-max))
|
|
|
|
(insert ex-offset "\n")
|
|
|
|
(goto-char (point-min)))
|
1997-08-02 07:40:22 +00:00
|
|
|
(goto-char (viper-get-ex-address))
|
1996-06-22 03:20:38 +00:00
|
|
|
(beginning-of-line)))
|
1997-08-02 07:40:22 +00:00
|
|
|
(ex-fixup-history viper-last-ex-prompt ex-file))
|
1996-06-22 03:20:38 +00:00
|
|
|
|
1996-09-06 02:13:39 +00:00
|
|
|
;; Find-file FILESPEC if it appears to specify a single file.
|
1998-05-04 22:42:59 +00:00
|
|
|
;; Otherwise, assume that FILESPEC is a wildcard.
|
1996-09-06 02:13:39 +00:00
|
|
|
;; In this case, split it into substrings separated by newlines.
|
1999-11-01 07:16:15 +00:00
|
|
|
;; Each line is assumed to be a file name.
|
1996-06-22 03:20:38 +00:00
|
|
|
(defun ex-find-file (filespec)
|
1996-09-06 02:13:39 +00:00
|
|
|
(let ((nonstandard-filename-chars "[^-a-zA-Z0-9_./,~$\\]"))
|
|
|
|
(cond ((file-exists-p filespec) (find-file filespec))
|
|
|
|
((string-match nonstandard-filename-chars filespec)
|
1999-11-01 07:16:15 +00:00
|
|
|
(mapcar 'find-file (funcall viper-glob-function filespec)))
|
1996-09-06 02:13:39 +00:00
|
|
|
(t (find-file filespec)))
|
1996-06-22 03:20:38 +00:00
|
|
|
))
|
1996-06-22 01:54:34 +00:00
|
|
|
|
1995-02-20 23:15:10 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; Ex global command
|
1997-07-17 19:37:07 +00:00
|
|
|
;; This is executed in response to:
|
|
|
|
;; :global "pattern" ex-command
|
|
|
|
;; :vglobal "pattern" ex-command
|
|
|
|
;; :global executes ex-command on all lines matching <pattern>
|
|
|
|
;; :vglobal executes ex-command on all lines that don't match <pattern>
|
|
|
|
;;
|
|
|
|
;; With VARIANT nil, this functions executes :global
|
|
|
|
;; With VARIANT t, executes :vglobal
|
1996-06-22 03:20:38 +00:00
|
|
|
(defun ex-global (variant)
|
|
|
|
(let ((gcommand ex-token))
|
|
|
|
(if (or ex-g-flag ex-g-variant)
|
|
|
|
(error "`%s' within `global' is not allowed" gcommand)
|
|
|
|
(if variant
|
|
|
|
(setq ex-g-flag nil
|
|
|
|
ex-g-variant t)
|
|
|
|
(setq ex-g-flag t
|
|
|
|
ex-g-variant nil)))
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-get-ex-pat)
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (null ex-token)
|
|
|
|
(error "`%s': Missing regular expression" gcommand)))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (string= ex-token "")
|
1997-08-02 07:40:22 +00:00
|
|
|
(if (null viper-s-string)
|
|
|
|
(error viper-NoPrevSearch)
|
|
|
|
(setq ex-g-pat viper-s-string))
|
1996-06-22 03:20:38 +00:00
|
|
|
(setq ex-g-pat ex-token
|
1997-08-02 07:40:22 +00:00
|
|
|
viper-s-string ex-token))
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (null ex-addresses)
|
|
|
|
(setq ex-addresses (list (point-max) (point-min)))
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-default-ex-addresses))
|
2002-04-16 05:49:11 +00:00
|
|
|
(setq ex-g-marks nil)
|
|
|
|
(let ((mark-count 0)
|
1997-07-17 19:37:07 +00:00
|
|
|
(end (car ex-addresses))
|
|
|
|
(beg (car (cdr ex-addresses)))
|
|
|
|
com-str)
|
1997-08-02 07:40:22 +00:00
|
|
|
(if (> beg end) (error viper-FirstAddrExceedsSecond))
|
1996-06-22 03:20:38 +00:00
|
|
|
(save-excursion
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-enlarge-region beg end)
|
1996-06-22 03:20:38 +00:00
|
|
|
(exchange-point-and-mark)
|
|
|
|
(let ((cont t) (limit (point-marker)))
|
|
|
|
(exchange-point-and-mark)
|
|
|
|
;; skip the last line if empty
|
|
|
|
(beginning-of-line)
|
1997-08-02 07:40:22 +00:00
|
|
|
(if (eobp) (viper-backward-char-carefully))
|
1996-06-22 03:20:38 +00:00
|
|
|
(while (and cont (not (bobp)) (>= (point) limit))
|
|
|
|
(beginning-of-line)
|
|
|
|
(set-mark (point))
|
|
|
|
(end-of-line)
|
|
|
|
(let ((found (re-search-backward ex-g-pat (mark t) t)))
|
|
|
|
(if (or (and ex-g-flag found)
|
|
|
|
(and ex-g-variant (not found)))
|
|
|
|
(progn
|
|
|
|
(end-of-line)
|
|
|
|
(setq mark-count (1+ mark-count))
|
2002-04-16 05:49:11 +00:00
|
|
|
(setq ex-g-marks (cons (point-marker) ex-g-marks)))))
|
1996-06-22 03:20:38 +00:00
|
|
|
(beginning-of-line)
|
|
|
|
(if (bobp) (setq cont nil)
|
|
|
|
(forward-line -1)
|
|
|
|
(end-of-line)))))
|
|
|
|
(save-window-excursion
|
2003-02-04 13:24:35 +00:00
|
|
|
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
|
1997-08-02 07:40:22 +00:00
|
|
|
(set-buffer viper-ex-work-buf)
|
1999-11-01 07:16:15 +00:00
|
|
|
;; com-str is the command string, i.e., g/pattern/ or v/pattern'
|
1996-06-22 03:20:38 +00:00
|
|
|
(setq com-str (buffer-substring (1+ (point)) (1- (point-max)))))
|
2002-04-16 05:49:11 +00:00
|
|
|
(while ex-g-marks
|
|
|
|
(goto-char (car ex-g-marks))
|
1999-11-01 07:16:15 +00:00
|
|
|
(viper-ex nil com-str)
|
1996-06-22 03:20:38 +00:00
|
|
|
(setq mark-count (1- mark-count))
|
2002-04-16 05:49:11 +00:00
|
|
|
(setq ex-g-marks (cdr ex-g-marks)))))
|
1996-06-22 03:20:38 +00:00
|
|
|
|
|
|
|
;; Ex goto command
|
|
|
|
(defun ex-goto ()
|
|
|
|
(if (null ex-addresses)
|
|
|
|
(setq ex-addresses (cons (point) nil)))
|
|
|
|
(push-mark (point) t)
|
|
|
|
(goto-char (car ex-addresses))
|
1999-11-01 07:16:15 +00:00
|
|
|
(beginning-of-line)
|
|
|
|
)
|
1996-06-22 03:20:38 +00:00
|
|
|
|
|
|
|
;; Ex line commands. COM is join, shift-right or shift-left
|
|
|
|
(defun ex-line (com)
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-default-ex-addresses)
|
|
|
|
(viper-get-ex-count)
|
1996-06-22 03:20:38 +00:00
|
|
|
(let ((end (car ex-addresses)) (beg (car (cdr ex-addresses))) point)
|
1997-08-02 07:40:22 +00:00
|
|
|
(if (> beg end) (error viper-FirstAddrExceedsSecond))
|
1996-06-22 03:20:38 +00:00
|
|
|
(save-excursion
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-enlarge-region beg end)
|
1996-06-22 03:20:38 +00:00
|
|
|
(exchange-point-and-mark)
|
|
|
|
(if ex-count
|
|
|
|
(progn
|
|
|
|
(set-mark (point))
|
|
|
|
(forward-line ex-count)))
|
|
|
|
(if ex-flag
|
|
|
|
;; show text to be joined and ask for confirmation
|
|
|
|
(progn
|
1997-09-30 01:13:53 +00:00
|
|
|
(with-output-to-temp-buffer " *join text*"
|
1996-06-22 03:20:38 +00:00
|
|
|
(princ (buffer-substring (point) (mark t))))
|
|
|
|
(condition-case nil
|
|
|
|
(progn
|
1997-09-30 01:13:53 +00:00
|
|
|
(read-string "[Hit return to confirm] ")
|
1996-06-22 03:20:38 +00:00
|
|
|
(ex-line-subr com (point) (mark t)))
|
|
|
|
(quit (ding)))
|
1997-09-30 01:13:53 +00:00
|
|
|
(save-excursion (kill-buffer " *join text*")))
|
1996-06-22 03:20:38 +00:00
|
|
|
(ex-line-subr com (point) (mark t)))
|
|
|
|
(setq point (point)))
|
|
|
|
(goto-char (1- point))
|
|
|
|
(beginning-of-line)))
|
|
|
|
|
|
|
|
(defun ex-line-subr (com beg end)
|
|
|
|
(cond ((string= com "join")
|
|
|
|
(goto-char (min beg end))
|
|
|
|
(while (and (not (eobp)) (< (point) (max beg end)))
|
|
|
|
(end-of-line)
|
|
|
|
(if (and (<= (point) (max beg end)) (not (eobp)))
|
|
|
|
(progn
|
|
|
|
(forward-line 1)
|
|
|
|
(delete-region (point) (1- (point)))
|
|
|
|
(if (not ex-variant) (fixup-whitespace))))))
|
|
|
|
((or (string= com "right") (string= com "left"))
|
|
|
|
(indent-rigidly
|
|
|
|
(min beg end) (max beg end)
|
1997-08-02 07:40:22 +00:00
|
|
|
(if (string= com "right") viper-shift-width (- viper-shift-width)))
|
1996-06-22 03:20:38 +00:00
|
|
|
(goto-char (max beg end))
|
|
|
|
(end-of-line)
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-forward-char-carefully))))
|
1996-06-22 03:20:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
;; Ex mark command
|
2001-03-17 Michael Kifer <kifer@cs.sunysb.edu>
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
* viper-util.el: Spaces, indentation.
* viper.el: Changed version, modification time.
2001-03-17 18:59:39 +00:00
|
|
|
;; Sets the mark to the current point.
|
|
|
|
;; If name is omitted, get the name straight from the work buffer."
|
|
|
|
(defun ex-mark (&optional name)
|
1996-06-22 03:20:38 +00:00
|
|
|
(let (char)
|
|
|
|
(if (null ex-addresses)
|
|
|
|
(setq ex-addresses
|
|
|
|
(cons (point) nil)))
|
2001-03-17 Michael Kifer <kifer@cs.sunysb.edu>
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
* viper-util.el: Spaces, indentation.
* viper.el: Changed version, modification time.
2001-03-17 18:59:39 +00:00
|
|
|
(if name
|
|
|
|
(if (eq 1 (length name))
|
|
|
|
(setq char (string-to-char name))
|
2001-07-15 19:53:53 +00:00
|
|
|
(error "`%s': Spurious text \"%s\" after mark name"
|
2001-03-17 Michael Kifer <kifer@cs.sunysb.edu>
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
* viper-util.el: Spaces, indentation.
* viper.el: Changed version, modification time.
2001-03-17 18:59:39 +00:00
|
|
|
name (substring name 1) viper-SpuriousText))
|
1996-06-22 03:20:38 +00:00
|
|
|
(save-window-excursion
|
2003-02-04 13:24:35 +00:00
|
|
|
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
|
1997-08-02 07:40:22 +00:00
|
|
|
(set-buffer viper-ex-work-buf)
|
1996-06-22 03:20:38 +00:00
|
|
|
(skip-chars-forward " \t")
|
|
|
|
(if (looking-at "[a-z]")
|
|
|
|
(progn
|
|
|
|
(setq char (following-char))
|
|
|
|
(forward-char 1)
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
(if (not (looking-at "[\n|]"))
|
1997-08-02 07:40:22 +00:00
|
|
|
(error "`%s': %s" ex-token viper-SpuriousText)))
|
2001-03-17 Michael Kifer <kifer@cs.sunysb.edu>
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
* viper-util.el: Spaces, indentation.
* viper.el: Changed version, modification time.
2001-03-17 18:59:39 +00:00
|
|
|
(error "`%s' requires a following letter" ex-token))))
|
1996-06-22 03:20:38 +00:00
|
|
|
(save-excursion
|
|
|
|
(goto-char (car ex-addresses))
|
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-compile,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
(viper-get-ex-address-subr): convert registers to char data type.
* viper-util.el (viper-int-to-char,viper-char-equal): new
functions.
(viper-memq-char): use viper-int-to-char.
(viper-file-checked-in-p): use vc-locking-user, if vc doesn't have
vc-locking-state.
(viper-read-key): use viper-read-key-sequence.
* viper.el (viper-major-mode-modifier-list): added
inferior-emacs-lisp-mode.
(this-major-mode-requires-vi-state): new function that uses simple
heuristics to decide if vi state is appropriate.
(set-viper-state-in-major-mode): use this-major-mode-requires-vi-state.
(viper-non-hook-settings): don't advise read-key-sequence.
(viper-read-key-sequence): new function that replaces the
previously used advice to read-key-sequence.
* viper-cmd.el (viper-test-com-defun,viper-exec-change,
viper-exec-Change,viper-execute-com,viper-insert,viper-append,
viper-Append,viper-Insert,viper-open-line,viper-Open-line,
viper-open-line-at-point,viper-substitute,viper-overwrite,
viper-replace-char-subr,viper-forward-word,viper-forward-Word):
got rid of the negative character hack.
(viper-escape-to-state,viper-replace-state-exit-cmd):
use viper-read-key-sequence.
(viper-envelop-ESC-key): no need for ad-get-orig-definition.
(viper-minibuffer-standard-hook,viper-read-string-with-history):
don't override existing minibuffer-setup-hook.
(viper-mark-point,viper-goto-mark-subr,viper-brac-function):
convert registers to char data type.
(viper-autoindent): use viper-indent-line.
* viper-keym.el: use viper-exec-key-in-emacs.
* viper.texi: Added credits, new commands, like :make.
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
(ediff-file-checked-out-p,ediff-file-checked-in-p): check if
vc-state is available.
(ediff-make-temp-file): use ediff-coding-system-for-write.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
(ediff-coding-system-for-read): from ediff-diff.el
(ediff-coding-system-for-write): new variable.
(ediff-highest-priority): fixed the bug having to do with disappearing
overlays.
(ediff-file-remote-p): use file-remote-p, if available.
(ediff-listable-file): new function.
(ediff-file-attributes): use ediff-listable-file.
* ediff-mult.el (ediff-meta-insert-file-info1): use
ediff-listable-file.
* ediff-ptch.el (ediff-prompt-for-patch-file): use
ediff-coding-system-for-read.
(ediff-patch-file-internal): use ediff-coding-system-for-write.
* ediff-diff.el (ediff-coding-system-for-read): moved to ediff-init.el.
(ediff-match-diff3-line,ediff-get-diff3-group): improved pattern.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* ediff.texi: added clarifications, acknowledgements.
2001-07-21 05:28:24 +00:00
|
|
|
(point-to-register (viper-int-to-char (1+ (- char ?a)))))))
|
1995-02-20 23:15:10 +00:00
|
|
|
|
2003-02-04 13:24:35 +00:00
|
|
|
|
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; Alternate file is the file next to the first one in the buffer ring
|
|
|
|
(defun ex-next (cycle-other-window &optional find-alt-file)
|
|
|
|
(catch 'ex-edit
|
|
|
|
(let (count l)
|
2003-02-04 13:24:35 +00:00
|
|
|
(if (not find-alt-file)
|
1996-06-22 01:54:34 +00:00
|
|
|
(progn
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-get-ex-file)
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (or (char-or-string-p ex-offset)
|
2003-02-04 13:24:35 +00:00
|
|
|
(and (not (string= "" ex-file))
|
1996-06-22 03:20:38 +00:00
|
|
|
(not (string-match "^[0-9]+$" ex-file))))
|
1996-06-22 01:54:34 +00:00
|
|
|
(progn
|
1996-06-22 03:20:38 +00:00
|
|
|
(ex-edit t)
|
|
|
|
(throw 'ex-edit nil))
|
|
|
|
(setq count (string-to-int ex-file))
|
|
|
|
(if (= count 0) (setq count 1))
|
|
|
|
(if (< count 0) (error "Usage: `next <count>' (count >= 0)"))))
|
|
|
|
(setq count 1))
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq l (viper-undisplayed-files))
|
1996-06-22 03:20:38 +00:00
|
|
|
(while (> count 0)
|
|
|
|
(while (and (not (null l)) (null (car l)))
|
|
|
|
(setq l (cdr l)))
|
|
|
|
(setq count (1- count))
|
|
|
|
(if (> count 0)
|
|
|
|
(setq l (cdr l))))
|
|
|
|
(if find-alt-file (car l)
|
|
|
|
(progn
|
|
|
|
(if (and (car l) (get-file-buffer (car l)))
|
|
|
|
(let* ((w (if cycle-other-window
|
|
|
|
(get-lru-window) (selected-window)))
|
|
|
|
(b (window-buffer w)))
|
|
|
|
(set-window-buffer w (get-file-buffer (car l)))
|
|
|
|
(bury-buffer b)
|
|
|
|
;; this puts "next <count>" in the ex-command history
|
1997-08-02 07:40:22 +00:00
|
|
|
(ex-fixup-history viper-last-ex-prompt ex-file))
|
1996-06-22 03:20:38 +00:00
|
|
|
(error "Not that many undisplayed files")))))))
|
|
|
|
|
|
|
|
|
|
|
|
(defun ex-next-related-buffer (direction &optional no-recursion)
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-ring-rotate1 viper-related-files-and-buffers-ring direction)
|
2003-02-04 13:24:35 +00:00
|
|
|
|
|
|
|
(let ((file-or-buffer-name
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-current-ring-item viper-related-files-and-buffers-ring))
|
|
|
|
(old-ring viper-related-files-and-buffers-ring)
|
1996-06-22 03:20:38 +00:00
|
|
|
(old-win (selected-window))
|
|
|
|
skip-rest buf wind)
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1997-08-02 07:40:22 +00:00
|
|
|
(or (and (ring-p viper-related-files-and-buffers-ring)
|
|
|
|
(> (ring-length viper-related-files-and-buffers-ring) 0))
|
1996-06-22 03:20:38 +00:00
|
|
|
(error "This buffer has no related files or buffers"))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
(or (stringp file-or-buffer-name)
|
|
|
|
(error
|
|
|
|
"File and buffer names must be strings, %S" file-or-buffer-name))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
(setq buf (cond ((get-buffer file-or-buffer-name))
|
|
|
|
((file-exists-p file-or-buffer-name)
|
|
|
|
(find-file-noselect file-or-buffer-name))
|
|
|
|
))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1997-08-02 07:40:22 +00:00
|
|
|
(if (not (viper-buffer-live-p buf))
|
1996-06-22 03:20:38 +00:00
|
|
|
(error "Didn't find buffer %S or file %S"
|
|
|
|
file-or-buffer-name
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-abbreviate-file-name
|
1996-06-22 03:20:38 +00:00
|
|
|
(expand-file-name file-or-buffer-name))))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (equal buf (current-buffer))
|
|
|
|
(or no-recursion
|
|
|
|
;; try again
|
|
|
|
(progn
|
|
|
|
(setq skip-rest t)
|
|
|
|
(ex-next-related-buffer direction 'norecursion))))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
(if skip-rest
|
|
|
|
()
|
|
|
|
;; setup buffer
|
1997-08-02 07:40:22 +00:00
|
|
|
(if (setq wind (viper-get-visible-buffer-window buf))
|
1996-06-22 03:20:38 +00:00
|
|
|
()
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq wind (get-lru-window (if viper-xemacs-p nil 'visible)))
|
1996-06-22 03:20:38 +00:00
|
|
|
(set-window-buffer wind buf))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1997-08-02 07:40:22 +00:00
|
|
|
(if (viper-window-display-p)
|
1996-06-22 03:20:38 +00:00
|
|
|
(progn
|
|
|
|
(raise-frame (window-frame wind))
|
|
|
|
(if (equal (window-frame wind) (window-frame old-win))
|
|
|
|
(save-window-excursion (select-window wind) (sit-for 1))
|
|
|
|
(select-window wind)))
|
|
|
|
(save-window-excursion (select-window wind) (sit-for 1)))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
(save-excursion
|
|
|
|
(set-buffer buf)
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq viper-related-files-and-buffers-ring old-ring))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq viper-local-search-start-marker (point-marker))
|
1996-06-22 03:20:38 +00:00
|
|
|
)))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; Force auto save
|
|
|
|
(defun ex-preserve ()
|
|
|
|
(message "Autosaving all buffers that need to be saved...")
|
|
|
|
(do-auto-save t))
|
|
|
|
|
|
|
|
;; Ex put
|
|
|
|
(defun ex-put ()
|
|
|
|
(let ((point (if (null ex-addresses) (point) (car ex-addresses))))
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-get-ex-buffer)
|
|
|
|
(setq viper-use-register ex-buffer)
|
1996-06-22 03:20:38 +00:00
|
|
|
(goto-char point)
|
1997-08-02 07:40:22 +00:00
|
|
|
(if (bobp) (viper-Put-back 1) (viper-put-back 1))))
|
1996-06-22 03:20:38 +00:00
|
|
|
|
|
|
|
;; Ex print working directory
|
|
|
|
(defun ex-pwd ()
|
|
|
|
(message default-directory))
|
|
|
|
|
|
|
|
;; Ex quit command
|
|
|
|
(defun ex-quit ()
|
1999-11-01 07:16:15 +00:00
|
|
|
;; skip "!", if it is q!. In Viper q!, w!, etc., behave as q, w, etc.
|
1996-06-22 03:20:38 +00:00
|
|
|
(save-excursion
|
2003-02-04 13:24:35 +00:00
|
|
|
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
|
1997-08-02 07:40:22 +00:00
|
|
|
(set-buffer viper-ex-work-buf)
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (looking-at "!") (forward-char 1)))
|
1997-07-17 19:37:07 +00:00
|
|
|
(if (< viper-expert-level 3)
|
1996-06-22 03:20:38 +00:00
|
|
|
(save-buffers-kill-emacs)
|
|
|
|
(kill-buffer (current-buffer))))
|
1995-02-20 23:15:10 +00:00
|
|
|
|
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; Ex read command
|
1999-11-01 07:16:15 +00:00
|
|
|
;; ex-read doesn't support wildcards, because file completion is a better
|
|
|
|
;; mechanism. We also don't support # and % (except in :r <shell-command>
|
|
|
|
;; because file history is a better mechanism.
|
1996-06-22 03:20:38 +00:00
|
|
|
(defun ex-read ()
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-get-ex-file)
|
1996-06-22 03:20:38 +00:00
|
|
|
(let ((point (if (null ex-addresses) (point) (car ex-addresses)))
|
|
|
|
command)
|
|
|
|
(goto-char point)
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-add-newline-at-eob-if-necessary)
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (not (or (bobp) (eobp))) (forward-line 1))
|
|
|
|
(if (and (not ex-variant) (string= ex-file ""))
|
|
|
|
(progn
|
|
|
|
(if (null buffer-file-name)
|
1997-08-02 07:40:22 +00:00
|
|
|
(error viper-NoFileSpecified))
|
1996-06-22 03:20:38 +00:00
|
|
|
(setq ex-file buffer-file-name)))
|
|
|
|
(if ex-cmdfile
|
|
|
|
(progn
|
2003-02-04 13:24:35 +00:00
|
|
|
(setq command
|
1999-11-01 07:16:15 +00:00
|
|
|
;; replace # and % with the previous/current file
|
|
|
|
(ex-expand-filsyms (concat ex-file ex-cmdfile-args)
|
|
|
|
(current-buffer)))
|
1996-06-22 03:20:38 +00:00
|
|
|
(shell-command command t))
|
|
|
|
(insert-file-contents ex-file)))
|
1997-11-01 01:46:51 +00:00
|
|
|
(ex-fixup-history viper-last-ex-prompt ex-file ex-cmdfile-args))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; this function fixes ex-history for some commands like ex-read, ex-edit
|
2003-02-04 13:24:35 +00:00
|
|
|
(defun ex-fixup-history (&rest args)
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq viper-ex-history
|
|
|
|
(cons (mapconcat 'identity args " ") (cdr viper-ex-history))))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
|
|
|
|
;; Ex recover from emacs \#file\#
|
|
|
|
(defun ex-recover ()
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-get-ex-file)
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (or ex-append ex-offset)
|
1997-08-02 07:40:22 +00:00
|
|
|
(error "`recover': %s" viper-SpuriousText))
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (string= ex-file "")
|
|
|
|
(progn
|
|
|
|
(if (null buffer-file-name)
|
|
|
|
(error "This buffer isn't visiting any file"))
|
|
|
|
(setq ex-file buffer-file-name))
|
|
|
|
(setq ex-file (expand-file-name ex-file)))
|
|
|
|
(if (and (not (string= ex-file (buffer-file-name)))
|
|
|
|
(buffer-modified-p)
|
|
|
|
(not ex-variant))
|
|
|
|
(error "No write since last change \(:rec! overrides\)"))
|
|
|
|
(recover-file ex-file))
|
|
|
|
|
|
|
|
;; Tell that `rewind' is obsolete and to use `:next count' instead
|
|
|
|
(defun ex-rewind ()
|
|
|
|
(message
|
1999-11-01 07:16:15 +00:00
|
|
|
"Use `:n <count>' instead. Counts are obtained from the `:args' command"))
|
1996-06-22 03:20:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
;; read variable name for ex-set
|
|
|
|
(defun ex-set-read-variable ()
|
|
|
|
(let ((minibuffer-local-completion-map
|
|
|
|
(copy-keymap minibuffer-local-completion-map))
|
|
|
|
(cursor-in-echo-area t)
|
|
|
|
str batch)
|
|
|
|
(define-key
|
|
|
|
minibuffer-local-completion-map " " 'minibuffer-complete-and-exit)
|
|
|
|
(define-key minibuffer-local-completion-map "=" 'exit-minibuffer)
|
1997-08-02 07:40:22 +00:00
|
|
|
(if (viper-set-unread-command-events
|
1996-06-22 03:20:38 +00:00
|
|
|
(ex-get-inline-cmd-args "[ \t]*[a-zA-Z]*[ \t]*" nil "\C-m"))
|
|
|
|
(progn
|
|
|
|
(setq batch t)
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-set-unread-command-events ?\C-m)))
|
1996-06-22 03:20:38 +00:00
|
|
|
(message ":set <Variable> [= <Value>]")
|
|
|
|
(or batch (sit-for 2))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
(while (string-match "^[ \\t\\n]*$"
|
|
|
|
(setq str
|
|
|
|
(completing-read ":set " ex-variable-alist)))
|
1997-06-18 01:26:55 +00:00
|
|
|
(message ":set <Variable> [= <Value>]")
|
1996-06-22 03:20:38 +00:00
|
|
|
;; if there are unread events, don't wait
|
1997-08-02 07:40:22 +00:00
|
|
|
(or (viper-set-unread-command-events "") (sit-for 2))
|
1996-06-22 03:20:38 +00:00
|
|
|
) ; while
|
|
|
|
str))
|
|
|
|
|
|
|
|
|
|
|
|
(defun ex-set ()
|
|
|
|
(let ((var (ex-set-read-variable))
|
|
|
|
(val 0)
|
|
|
|
(set-cmd "setq")
|
|
|
|
(ask-if-save t)
|
|
|
|
(auto-cmd-label "; don't touch or else...")
|
|
|
|
(delete-turn-on-auto-fill-pattern
|
1998-05-04 22:42:59 +00:00
|
|
|
"([ \t]*add-hook[ \t]+'viper-insert-state-hook[ \t]+'turn-on-auto-fill.*)")
|
1996-06-22 03:20:38 +00:00
|
|
|
actual-lisp-cmd lisp-cmd-del-pattern
|
|
|
|
val2 orig-var)
|
|
|
|
(setq orig-var var)
|
1997-06-18 01:26:55 +00:00
|
|
|
(cond ((string= var "all")
|
|
|
|
(setq ask-if-save nil
|
|
|
|
set-cmd nil))
|
|
|
|
((member var '("ai" "autoindent"))
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq var "viper-auto-indent"
|
1996-06-22 03:20:38 +00:00
|
|
|
set-cmd "setq"
|
|
|
|
ask-if-save nil
|
|
|
|
val "t"))
|
1997-06-18 01:26:55 +00:00
|
|
|
((member var '("ai-g" "autoindent-global"))
|
1997-08-02 07:40:22 +00:00
|
|
|
(kill-local-variable 'viper-auto-indent)
|
|
|
|
(setq var "viper-auto-indent"
|
1996-06-22 03:20:38 +00:00
|
|
|
set-cmd "setq-default"
|
|
|
|
val "t"))
|
|
|
|
((member var '("noai" "noautoindent"))
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq var "viper-auto-indent"
|
1996-06-22 03:20:38 +00:00
|
|
|
ask-if-save nil
|
|
|
|
val "nil"))
|
1997-06-18 01:26:55 +00:00
|
|
|
((member var '("noai-g" "noautoindent-global"))
|
1997-08-02 07:40:22 +00:00
|
|
|
(kill-local-variable 'viper-auto-indent)
|
|
|
|
(setq var "viper-auto-indent"
|
1996-06-22 03:20:38 +00:00
|
|
|
set-cmd "setq-default"
|
|
|
|
val "nil"))
|
|
|
|
((member var '("ic" "ignorecase"))
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq var "viper-case-fold-search"
|
1996-06-22 03:20:38 +00:00
|
|
|
val "t"))
|
|
|
|
((member var '("noic" "noignorecase"))
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq var "viper-case-fold-search"
|
1996-06-22 03:20:38 +00:00
|
|
|
val "nil"))
|
|
|
|
((member var '("ma" "magic"))
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq var "viper-re-search"
|
1996-06-22 03:20:38 +00:00
|
|
|
val "t"))
|
1997-06-18 01:26:55 +00:00
|
|
|
((member var '("noma" "nomagic"))
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq var "viper-re-search"
|
1996-06-22 03:20:38 +00:00
|
|
|
val "nil"))
|
|
|
|
((member var '("ro" "readonly"))
|
|
|
|
(setq var "buffer-read-only"
|
|
|
|
val "t"))
|
|
|
|
((member var '("noro" "noreadonly"))
|
|
|
|
(setq var "buffer-read-only"
|
|
|
|
val "nil"))
|
|
|
|
((member var '("sm" "showmatch"))
|
|
|
|
(setq var "blink-matching-paren"
|
|
|
|
val "t"))
|
|
|
|
((member var '("nosm" "noshowmatch"))
|
|
|
|
(setq var "blink-matching-paren"
|
|
|
|
val "nil"))
|
|
|
|
((member var '("ws" "wrapscan"))
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq var "viper-search-wrap-around-t"
|
1996-06-22 03:20:38 +00:00
|
|
|
val "t"))
|
|
|
|
((member var '("nows" "nowrapscan"))
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq var "viper-search-wrap-around-t"
|
1996-06-22 03:20:38 +00:00
|
|
|
val "nil")))
|
1997-06-18 01:26:55 +00:00
|
|
|
(if (and set-cmd (eq val 0)) ; value must be set by the user
|
1996-06-22 03:20:38 +00:00
|
|
|
(let ((cursor-in-echo-area t))
|
|
|
|
(message ":set %s = <Value>" var)
|
|
|
|
;; if there are unread events, don't wait
|
1997-08-02 07:40:22 +00:00
|
|
|
(or (viper-set-unread-command-events "") (sit-for 2))
|
1996-06-22 03:20:38 +00:00
|
|
|
(setq val (read-string (format ":set %s = " var)))
|
|
|
|
(ex-fixup-history "set" orig-var val)
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; check numerical values
|
|
|
|
(if (member var
|
|
|
|
'("sw" "shiftwidth"
|
|
|
|
"ts" "tabstop"
|
1997-06-18 01:26:55 +00:00
|
|
|
"ts-g" "tabstop-global"
|
2003-02-04 13:24:35 +00:00
|
|
|
"wm" "wrapmargin"))
|
1996-06-22 03:20:38 +00:00
|
|
|
(condition-case nil
|
|
|
|
(or (numberp (setq val2 (car (read-from-string val))))
|
|
|
|
(error "%s: Invalid value, numberp, %S" var val))
|
|
|
|
(error
|
|
|
|
(error "%s: Invalid value, numberp, %S" var val))))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
(cond
|
|
|
|
((member var '("sw" "shiftwidth"))
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq var "viper-shift-width"))
|
1996-06-22 03:20:38 +00:00
|
|
|
((member var '("ts" "tabstop"))
|
|
|
|
;; make it take effect in curr buff and new bufs
|
|
|
|
(setq var "tab-width"
|
|
|
|
set-cmd "setq"
|
|
|
|
ask-if-save nil))
|
1997-06-18 01:26:55 +00:00
|
|
|
((member var '("ts-g" "tabstop-global"))
|
1996-06-22 03:20:38 +00:00
|
|
|
(kill-local-variable 'tab-width)
|
|
|
|
(setq var "tab-width"
|
|
|
|
set-cmd "setq-default"))
|
|
|
|
((member var '("wm" "wrapmargin"))
|
|
|
|
;; make it take effect in curr buff and new bufs
|
2003-02-04 13:24:35 +00:00
|
|
|
(kill-local-variable 'fill-column)
|
|
|
|
(setq var "fill-column"
|
1996-06-22 03:20:38 +00:00
|
|
|
val (format "(- (window-width) %s)" val)
|
|
|
|
set-cmd "setq-default"))
|
|
|
|
((member var '("sh" "shell"))
|
|
|
|
(setq var "explicit-shell-file-name"
|
|
|
|
val (format "\"%s\"" val)))))
|
|
|
|
(ex-fixup-history "set" orig-var))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1997-06-18 01:26:55 +00:00
|
|
|
(if set-cmd
|
|
|
|
(setq actual-lisp-cmd
|
|
|
|
(format "\n(%s %s %s) %s" set-cmd var val auto-cmd-label)
|
|
|
|
lisp-cmd-del-pattern
|
|
|
|
(format "^\n?[ \t]*([ \t]*%s[ \t]+%s[ \t].*)[ \t]*%s"
|
|
|
|
set-cmd var auto-cmd-label)))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (and ask-if-save
|
|
|
|
(y-or-n-p (format "Do you want to save this setting in %s "
|
1997-08-02 07:40:22 +00:00
|
|
|
viper-custom-file-name)))
|
1996-06-22 03:20:38 +00:00
|
|
|
(progn
|
2003-02-04 13:24:35 +00:00
|
|
|
(viper-save-string-in-file
|
1997-08-02 07:40:22 +00:00
|
|
|
actual-lisp-cmd viper-custom-file-name
|
1996-06-22 03:20:38 +00:00
|
|
|
;; del pattern
|
|
|
|
lisp-cmd-del-pattern)
|
|
|
|
(if (string= var "fill-column")
|
|
|
|
(if (> val2 0)
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-save-string-in-file
|
1996-06-22 03:20:38 +00:00
|
|
|
(concat
|
1998-05-04 22:42:59 +00:00
|
|
|
"(add-hook 'viper-insert-state-hook 'turn-on-auto-fill) "
|
1996-06-22 03:20:38 +00:00
|
|
|
auto-cmd-label)
|
1997-08-02 07:40:22 +00:00
|
|
|
viper-custom-file-name
|
1996-06-22 03:20:38 +00:00
|
|
|
delete-turn-on-auto-fill-pattern)
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-save-string-in-file
|
|
|
|
nil viper-custom-file-name delete-turn-on-auto-fill-pattern)
|
|
|
|
(viper-save-string-in-file
|
|
|
|
nil viper-custom-file-name
|
1996-06-22 03:20:38 +00:00
|
|
|
;; del pattern
|
|
|
|
lisp-cmd-del-pattern)
|
|
|
|
))
|
|
|
|
))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1997-06-18 01:26:55 +00:00
|
|
|
(if set-cmd
|
|
|
|
(message "%s %s %s"
|
|
|
|
set-cmd var
|
|
|
|
(if (string-match "^[ \t]*$" val)
|
|
|
|
(format "%S" val)
|
|
|
|
val)))
|
|
|
|
(if actual-lisp-cmd
|
|
|
|
(eval (car (read-from-string actual-lisp-cmd))))
|
|
|
|
(if (string= var "fill-column")
|
|
|
|
(if (> val2 0)
|
|
|
|
(auto-fill-mode 1)
|
|
|
|
(auto-fill-mode -1)))
|
|
|
|
(if (string= var "all") (ex-show-vars))
|
1996-06-22 03:20:38 +00:00
|
|
|
))
|
1995-02-20 23:15:10 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; In inline args, skip regex-forw and (optionally) chars-back.
|
|
|
|
;; Optional 3d arg is a string that should replace ' ' to prevent its
|
|
|
|
;; special meaning
|
|
|
|
(defun ex-get-inline-cmd-args (regex-forw &optional chars-back replace-str)
|
|
|
|
(save-excursion
|
2003-02-04 13:24:35 +00:00
|
|
|
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
|
1997-08-02 07:40:22 +00:00
|
|
|
(set-buffer viper-ex-work-buf)
|
1996-06-22 03:20:38 +00:00
|
|
|
(goto-char (point-min))
|
|
|
|
(re-search-forward regex-forw nil t)
|
|
|
|
(let ((beg (point))
|
|
|
|
end)
|
|
|
|
(goto-char (point-max))
|
|
|
|
(if chars-back
|
|
|
|
(skip-chars-backward chars-back)
|
|
|
|
(skip-chars-backward " \t\n\C-m"))
|
|
|
|
(setq end (point))
|
|
|
|
;; replace SPC with `=' to suppress the special meaning SPC has
|
|
|
|
;; in Ex commands
|
|
|
|
(goto-char beg)
|
|
|
|
(if replace-str
|
|
|
|
(while (re-search-forward " +" nil t)
|
|
|
|
(replace-match replace-str nil t)
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-forward-char-carefully)))
|
1996-06-22 03:20:38 +00:00
|
|
|
(goto-char end)
|
|
|
|
(buffer-substring beg end))))
|
|
|
|
|
|
|
|
|
|
|
|
;; Ex shell command
|
|
|
|
(defun ex-shell ()
|
|
|
|
(shell))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1999-11-01 07:16:15 +00:00
|
|
|
;; Viper help. Invokes Info
|
1996-06-22 03:20:38 +00:00
|
|
|
(defun ex-help ()
|
|
|
|
(condition-case nil
|
|
|
|
(progn
|
|
|
|
(pop-to-buffer (get-buffer-create "*info*"))
|
1997-08-02 07:40:22 +00:00
|
|
|
(info (if viper-xemacs-p "viper.info" "viper"))
|
1996-06-22 03:20:38 +00:00
|
|
|
(message "Type `i' to search for a specific topic"))
|
|
|
|
(error (beep 1)
|
1997-08-02 07:40:22 +00:00
|
|
|
(with-output-to-temp-buffer " *viper-info*"
|
1996-06-22 03:20:38 +00:00
|
|
|
(princ (format "
|
|
|
|
The Info file for Viper does not seem to be installed.
|
|
|
|
|
|
|
|
This file is part of the standard distribution of %sEmacs.
|
|
|
|
Please contact your system administrator. "
|
1997-08-02 07:40:22 +00:00
|
|
|
(if viper-xemacs-p "X" "")
|
1996-06-22 03:20:38 +00:00
|
|
|
))))))
|
|
|
|
|
1999-11-01 07:16:15 +00:00
|
|
|
;; Ex source command. Loads the file specified as argument or `~/.viper'
|
1996-06-22 03:20:38 +00:00
|
|
|
(defun ex-source ()
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-get-ex-file)
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (string= ex-file "")
|
1997-08-02 07:40:22 +00:00
|
|
|
(load viper-custom-file-name)
|
1996-06-22 03:20:38 +00:00
|
|
|
(load ex-file)))
|
|
|
|
|
|
|
|
;; Ex substitute command
|
1997-08-02 07:40:22 +00:00
|
|
|
;; If REPEAT use previous regexp which is ex-reg-exp or viper-s-string
|
2003-02-04 13:24:35 +00:00
|
|
|
(defun ex-substitute (&optional repeat r-flag)
|
1996-06-22 03:20:38 +00:00
|
|
|
(let ((opt-g nil)
|
|
|
|
(opt-c nil)
|
|
|
|
(matched-pos nil)
|
1997-08-02 07:40:22 +00:00
|
|
|
(case-fold-search viper-case-fold-search)
|
1996-06-22 03:20:38 +00:00
|
|
|
delim pat repl)
|
1997-08-02 07:40:22 +00:00
|
|
|
(if repeat (setq ex-token nil) (setq delim (viper-get-ex-pat)))
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (null ex-token)
|
|
|
|
(progn
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq pat (if r-flag viper-s-string ex-reg-exp))
|
1996-06-22 03:20:38 +00:00
|
|
|
(or (stringp pat)
|
|
|
|
(error "No previous pattern to use in substitution"))
|
|
|
|
(setq repl ex-repl
|
|
|
|
delim (string-to-char pat)))
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq pat (if (string= ex-token "") viper-s-string ex-token))
|
|
|
|
(setq viper-s-string pat
|
1996-06-22 03:20:38 +00:00
|
|
|
ex-reg-exp pat)
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq delim (viper-get-ex-pat))
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (null ex-token)
|
|
|
|
(setq ex-token ""
|
|
|
|
ex-repl "")
|
|
|
|
(setq repl ex-token
|
|
|
|
ex-repl ex-token)))
|
1997-08-02 07:40:22 +00:00
|
|
|
(while (viper-get-ex-opt-gc delim)
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (string= ex-token "g") (setq opt-g t) (setq opt-c t)))
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-get-ex-count)
|
1996-06-22 03:20:38 +00:00
|
|
|
(if ex-count
|
|
|
|
(save-excursion
|
|
|
|
(if ex-addresses (goto-char (car ex-addresses)))
|
|
|
|
(set-mark (point))
|
|
|
|
(forward-line (1- ex-count))
|
|
|
|
(setq ex-addresses (cons (point) (cons (mark t) nil))))
|
|
|
|
(if (null ex-addresses)
|
|
|
|
(setq ex-addresses (cons (point) (cons (point) nil)))
|
|
|
|
(if (null (cdr ex-addresses))
|
|
|
|
(setq ex-addresses (cons (car ex-addresses) ex-addresses)))))
|
|
|
|
;(setq G opt-g)
|
|
|
|
(let ((beg (car ex-addresses))
|
|
|
|
(end (car (cdr ex-addresses)))
|
|
|
|
eol-mark)
|
|
|
|
(save-excursion
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-enlarge-region beg end)
|
1996-06-22 03:20:38 +00:00
|
|
|
(let ((limit (save-excursion
|
|
|
|
(goto-char (max (point) (mark t)))
|
|
|
|
(point-marker))))
|
|
|
|
(goto-char (min (point) (mark t)))
|
|
|
|
(while (< (point) limit)
|
1998-05-04 22:42:59 +00:00
|
|
|
(save-excursion
|
|
|
|
(end-of-line)
|
|
|
|
;; This move allows the use of newline as the last character in
|
|
|
|
;; the substitution pattern
|
|
|
|
(viper-forward-char-carefully)
|
|
|
|
(setq eol-mark (point-marker)))
|
1996-06-22 03:20:38 +00:00
|
|
|
(beginning-of-line)
|
|
|
|
(if opt-g
|
|
|
|
(progn
|
|
|
|
(while (and (not (eolp))
|
|
|
|
(re-search-forward pat eol-mark t))
|
2000-04-07 16:10:04 +00:00
|
|
|
(if (or (not opt-c)
|
|
|
|
(progn
|
|
|
|
(viper-put-on-search-overlay (match-beginning 0)
|
|
|
|
(match-end 0))
|
|
|
|
(y-or-n-p "Replace? ")))
|
1996-06-22 03:20:38 +00:00
|
|
|
(progn
|
2000-04-07 16:10:04 +00:00
|
|
|
(viper-hide-search-overlay)
|
1996-06-22 03:20:38 +00:00
|
|
|
(setq matched-pos (point))
|
|
|
|
(if (not (stringp repl))
|
|
|
|
(error "Can't perform Ex substitution: No previous replacement pattern"))
|
|
|
|
(replace-match repl t))))
|
|
|
|
(end-of-line)
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-forward-char-carefully))
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (null pat)
|
|
|
|
(error
|
|
|
|
"Can't repeat Ex substitution: No previous regular expression"))
|
|
|
|
(if (and (re-search-forward pat eol-mark t)
|
2000-04-07 16:10:04 +00:00
|
|
|
(or (not opt-c)
|
|
|
|
(progn
|
|
|
|
(viper-put-on-search-overlay (match-beginning 0)
|
|
|
|
(match-end 0))
|
|
|
|
(y-or-n-p "Replace? "))))
|
1996-06-22 03:20:38 +00:00
|
|
|
(progn
|
2000-04-07 16:10:04 +00:00
|
|
|
(viper-hide-search-overlay)
|
1996-06-22 03:20:38 +00:00
|
|
|
(setq matched-pos (point))
|
|
|
|
(if (not (stringp repl))
|
|
|
|
(error "Can't perform Ex substitution: No previous replacement pattern"))
|
|
|
|
(replace-match repl t)))
|
1998-05-04 22:42:59 +00:00
|
|
|
;;(end-of-line)
|
|
|
|
;;(viper-forward-char-carefully)
|
|
|
|
(goto-char eol-mark)
|
|
|
|
)))))
|
1996-06-22 03:20:38 +00:00
|
|
|
(if matched-pos (goto-char matched-pos))
|
|
|
|
(beginning-of-line)
|
|
|
|
(if opt-c (message "done"))))
|
1995-06-09 00:11:23 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; Ex tag command
|
|
|
|
(defun ex-tag ()
|
|
|
|
(let (tag)
|
|
|
|
(save-window-excursion
|
2003-02-04 13:24:35 +00:00
|
|
|
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
|
1997-08-02 07:40:22 +00:00
|
|
|
(set-buffer viper-ex-work-buf)
|
1996-06-22 03:20:38 +00:00
|
|
|
(skip-chars-forward " \t")
|
|
|
|
(set-mark (point))
|
|
|
|
(skip-chars-forward "^ |\t\n")
|
|
|
|
(setq tag (buffer-substring (mark t) (point))))
|
|
|
|
(if (not (string= tag "")) (setq ex-tag tag))
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-change-state-to-emacs)
|
1996-06-22 03:20:38 +00:00
|
|
|
(condition-case conds
|
|
|
|
(progn
|
|
|
|
(if (string= tag "")
|
|
|
|
(find-tag ex-tag t)
|
|
|
|
(find-tag-other-window ex-tag))
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-change-state-to-vi))
|
1996-06-22 03:20:38 +00:00
|
|
|
(error
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-change-state-to-vi)
|
|
|
|
(viper-message-conditions conds)))))
|
1996-06-22 01:54:34 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; Ex write command
|
1999-11-01 07:16:15 +00:00
|
|
|
;; ex-write doesn't support wildcards, because file completion is a better
|
2003-02-04 13:24:35 +00:00
|
|
|
;; mechanism. We also don't support # and %
|
1999-11-01 07:16:15 +00:00
|
|
|
;; because file history is a better mechanism.
|
1996-06-22 03:20:38 +00:00
|
|
|
(defun ex-write (q-flag)
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-default-ex-addresses t)
|
|
|
|
(viper-get-ex-file)
|
1997-05-31 00:02:53 +00:00
|
|
|
(let ((end (car ex-addresses))
|
2003-02-04 13:24:35 +00:00
|
|
|
(beg (car (cdr ex-addresses)))
|
1997-05-31 00:02:53 +00:00
|
|
|
(orig-buf (current-buffer))
|
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
* viper-init.el (viper-cond-compile-for-xemacs-or-emacs):
new macro that replaces viper-emacs-p and viper-xemacs-p in many
cases. Used to reduce the number of warnings.
* viper-cmd.el: use viper-cond-compile-for-xemacs-or-emacs.
(viper-standard-value): moved here from viper.el.
(viper-set-unread-command-events): moved to viper-util.el
(viper-check-minibuffer-overlay): make sure
viper-minibuffer-overlay is moved to cover the entire input field.
* viper-util.el: use viper-cond-compile-for-xemacs-or-emacs.
(viper-read-key-sequence, viper-set-unread-command-events,
viper-char-symbol-sequence-p, viper-char-array-p): moved here.
* viper-ex.el: use viper-cond-compile-for-xemacs-or-emacs.
* viper-keym.el: use viper-cond-compile-for-xemacs-or-emacs.
* viper-mous.el: use viper-cond-compile-for-xemacs-or-emacs.
* viper-macs.el (viper-char-array-p, viper-char-symbol-sequence-p,
viper-event-vector-p): moved to viper-util.el
* viper.el (viper-standard-value): moved to viper-cmd.el.
Use viper-cond-compile-for-xemacs-or-emacs.
* ediff-help.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff-hook.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff-init.el (ediff-cond-compile-for-xemacs-or-emacs): new
macro designed to be used in many places where ediff-emacs-p or
ediff-xemacs-p was previously used. Reduces the number of
warnings.
Use ediff-cond-compile-for-xemacs-or-emacs in many places in lieue
of ediff-xemacs-p.
(ediff-make-current-diff-overlay, ediff-highlight-diff-in-one-buffer,
ediff-convert-fine-diffs-to-overlays, ediff-empty-diff-region-p,
ediff-whitespace-diff-region-p, ediff-get-region-contents):
moved to ediff-util.el.
(ediff-event-key): moved here.
* ediff-merge.el: got rid of unreferenced variables.
* ediff-mult.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff-util.el: use ediff-cond-compile-for-xemacs-or-emacs.
(ediff-cleanup-mess): improved the way windows are set up after
quitting ediff.
(ediff-janitor): use ediff-dispose-of-variant-according-to-user.
(ediff-dispose-of-variant-according-to-user): new function
designed to be smarter and also understands indirect buffers.
(ediff-highlight-diff-in-one-buffer,
ediff-unhighlight-diff-in-one-buffer,
ediff-unhighlight-diffs-totally-in-one-buffer,
ediff-highlight-diff, ediff-highlight-diff,
ediff-unhighlight-diff, ediff-unhighlight-diffs-totally,
ediff-empty-diff-region-p, ediff-whitespace-diff-region-p,
ediff-get-region-contents, ediff-make-current-diff-overlay):
moved here.
(ediff-format-bindings-of): new function by Hannu Koivisto
<azure@iki.fi>.
(ediff-setup): make sure the merge buffer is always widened and
modifiable.
(ediff-write-merge-buffer-and-maybe-kill): refuse to write the
result of a merge into a file visited by another buffer.
(ediff-arrange-autosave-in-merge-jobs): check if the merge file
is visited by another buffer and ask to save/delete that buffer.
(ediff-verify-file-merge-buffer): new function to do the above.
* ediff-vers.el: load ediff-init.el at compile time.
* ediff-wind.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff.el (ediff-windows, ediff-regions-wordwise,
ediff-regions-linewise): use indirect buffers to improve
robustness and make it possible to compare regions of the same
buffer (even overlapping regions).
(ediff-clone-buffer-for-region-comparison,
ediff-clone-buffer-for-window-comparison): new functions.
(ediff-files-internal): refuse to compare identical files.
(ediff-regions-internal): get rid of the warning about comparing
regions of the same buffer.
* ediff-diff.el (ediff-convert-fine-diffs-to-overlays): moved here.
Plus the following fixes courtesy of Dave Love:
Doc fixes.
(ediff-word-1): Use word class and move - to the
front per regexp documentation.
(ediff-wordify): Bind forward-word-function outside loop.
(ediff-copy-to-buffer): Use insert-buffer-substring rather than
consing buffer contents.
(ediff-goto-word): Move syntax table setting outside loop.
2002-01-08 04:36:01 +00:00
|
|
|
;;(orig-buf-file-name (buffer-file-name))
|
|
|
|
;;(orig-buf-name (buffer-name))
|
|
|
|
;;(buff-changed-p (buffer-modified-p))
|
1996-06-22 03:20:38 +00:00
|
|
|
temp-buf writing-same-file region
|
|
|
|
file-exists writing-whole-file)
|
1997-08-02 07:40:22 +00:00
|
|
|
(if (> beg end) (error viper-FirstAddrExceedsSecond))
|
1996-06-22 03:20:38 +00:00
|
|
|
(if ex-cmdfile
|
|
|
|
(progn
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-enlarge-region beg end)
|
2003-02-04 13:24:35 +00:00
|
|
|
(shell-command-on-region (point) (mark t)
|
1997-11-01 01:46:51 +00:00
|
|
|
(concat ex-file ex-cmdfile-args)))
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (and (string= ex-file "") (not (buffer-file-name)))
|
|
|
|
(setq ex-file
|
|
|
|
(read-file-name
|
1999-11-01 07:16:15 +00:00
|
|
|
(format "Buffer %s isn't visiting any file. File to save in: "
|
1996-06-22 03:20:38 +00:00
|
|
|
(buffer-name)))))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
(setq writing-whole-file (and (= (point-min) beg) (= (point-max) end))
|
|
|
|
ex-file (if (string= ex-file "")
|
|
|
|
(buffer-file-name)
|
|
|
|
(expand-file-name ex-file)))
|
|
|
|
;; if ex-file is a directory use the file portion of the buffer file name
|
|
|
|
(if (and (file-directory-p ex-file)
|
|
|
|
buffer-file-name
|
|
|
|
(not (file-directory-p buffer-file-name)))
|
|
|
|
(setq ex-file
|
1997-05-31 00:02:53 +00:00
|
|
|
(concat (file-name-as-directory ex-file)
|
|
|
|
(file-name-nondirectory buffer-file-name))))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
(setq file-exists (file-exists-p ex-file)
|
|
|
|
writing-same-file (string= ex-file (buffer-file-name)))
|
|
|
|
|
1998-05-04 22:42:59 +00:00
|
|
|
;; do actual writing
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (and writing-whole-file writing-same-file)
|
1998-05-04 22:42:59 +00:00
|
|
|
;; saving whole buffer in visited file
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (not (buffer-modified-p))
|
|
|
|
(message "(No changes need to be saved)")
|
1998-05-04 22:42:59 +00:00
|
|
|
(viper-maybe-checkout (current-buffer))
|
1996-06-22 03:20:38 +00:00
|
|
|
(save-buffer)
|
1997-05-31 00:02:53 +00:00
|
|
|
(save-restriction
|
|
|
|
(widen)
|
|
|
|
(ex-write-info file-exists ex-file (point-min) (point-max))
|
|
|
|
))
|
1998-05-04 22:42:59 +00:00
|
|
|
;; writing to non-visited file and it already exists
|
|
|
|
(if (and file-exists (not writing-same-file)
|
|
|
|
(not (yes-or-no-p
|
1999-11-01 07:16:15 +00:00
|
|
|
(format "File %s exists. Overwrite? " ex-file))))
|
1998-05-04 22:42:59 +00:00
|
|
|
(error "Quit"))
|
|
|
|
;; writing a region or whole buffer to non-visited file
|
2003-02-04 13:24:35 +00:00
|
|
|
(unwind-protect
|
1998-05-04 22:42:59 +00:00
|
|
|
(save-excursion
|
|
|
|
(viper-enlarge-region beg end)
|
|
|
|
(setq region (buffer-substring (point) (mark t)))
|
|
|
|
;; create temp buffer for the region
|
|
|
|
(setq temp-buf (get-buffer-create " *ex-write*"))
|
|
|
|
(set-buffer temp-buf)
|
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
* viper-init.el (viper-cond-compile-for-xemacs-or-emacs):
new macro that replaces viper-emacs-p and viper-xemacs-p in many
cases. Used to reduce the number of warnings.
* viper-cmd.el: use viper-cond-compile-for-xemacs-or-emacs.
(viper-standard-value): moved here from viper.el.
(viper-set-unread-command-events): moved to viper-util.el
(viper-check-minibuffer-overlay): make sure
viper-minibuffer-overlay is moved to cover the entire input field.
* viper-util.el: use viper-cond-compile-for-xemacs-or-emacs.
(viper-read-key-sequence, viper-set-unread-command-events,
viper-char-symbol-sequence-p, viper-char-array-p): moved here.
* viper-ex.el: use viper-cond-compile-for-xemacs-or-emacs.
* viper-keym.el: use viper-cond-compile-for-xemacs-or-emacs.
* viper-mous.el: use viper-cond-compile-for-xemacs-or-emacs.
* viper-macs.el (viper-char-array-p, viper-char-symbol-sequence-p,
viper-event-vector-p): moved to viper-util.el
* viper.el (viper-standard-value): moved to viper-cmd.el.
Use viper-cond-compile-for-xemacs-or-emacs.
* ediff-help.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff-hook.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff-init.el (ediff-cond-compile-for-xemacs-or-emacs): new
macro designed to be used in many places where ediff-emacs-p or
ediff-xemacs-p was previously used. Reduces the number of
warnings.
Use ediff-cond-compile-for-xemacs-or-emacs in many places in lieue
of ediff-xemacs-p.
(ediff-make-current-diff-overlay, ediff-highlight-diff-in-one-buffer,
ediff-convert-fine-diffs-to-overlays, ediff-empty-diff-region-p,
ediff-whitespace-diff-region-p, ediff-get-region-contents):
moved to ediff-util.el.
(ediff-event-key): moved here.
* ediff-merge.el: got rid of unreferenced variables.
* ediff-mult.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff-util.el: use ediff-cond-compile-for-xemacs-or-emacs.
(ediff-cleanup-mess): improved the way windows are set up after
quitting ediff.
(ediff-janitor): use ediff-dispose-of-variant-according-to-user.
(ediff-dispose-of-variant-according-to-user): new function
designed to be smarter and also understands indirect buffers.
(ediff-highlight-diff-in-one-buffer,
ediff-unhighlight-diff-in-one-buffer,
ediff-unhighlight-diffs-totally-in-one-buffer,
ediff-highlight-diff, ediff-highlight-diff,
ediff-unhighlight-diff, ediff-unhighlight-diffs-totally,
ediff-empty-diff-region-p, ediff-whitespace-diff-region-p,
ediff-get-region-contents, ediff-make-current-diff-overlay):
moved here.
(ediff-format-bindings-of): new function by Hannu Koivisto
<azure@iki.fi>.
(ediff-setup): make sure the merge buffer is always widened and
modifiable.
(ediff-write-merge-buffer-and-maybe-kill): refuse to write the
result of a merge into a file visited by another buffer.
(ediff-arrange-autosave-in-merge-jobs): check if the merge file
is visited by another buffer and ask to save/delete that buffer.
(ediff-verify-file-merge-buffer): new function to do the above.
* ediff-vers.el: load ediff-init.el at compile time.
* ediff-wind.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff.el (ediff-windows, ediff-regions-wordwise,
ediff-regions-linewise): use indirect buffers to improve
robustness and make it possible to compare regions of the same
buffer (even overlapping regions).
(ediff-clone-buffer-for-region-comparison,
ediff-clone-buffer-for-window-comparison): new functions.
(ediff-files-internal): refuse to compare identical files.
(ediff-regions-internal): get rid of the warning about comparing
regions of the same buffer.
* ediff-diff.el (ediff-convert-fine-diffs-to-overlays): moved here.
Plus the following fixes courtesy of Dave Love:
Doc fixes.
(ediff-word-1): Use word class and move - to the
front per regexp documentation.
(ediff-wordify): Bind forward-word-function outside loop.
(ediff-copy-to-buffer): Use insert-buffer-substring rather than
consing buffer contents.
(ediff-goto-word): Move syntax table setting outside loop.
2002-01-08 04:36:01 +00:00
|
|
|
(viper-cond-compile-for-xemacs-or-emacs
|
|
|
|
(set-visited-file-name ex-file) ; xemacs
|
|
|
|
(set-visited-file-name ex-file 'noquerry) ; emacs
|
|
|
|
)
|
1998-05-04 22:42:59 +00:00
|
|
|
(erase-buffer)
|
|
|
|
(if (and file-exists ex-append)
|
|
|
|
(insert-file-contents ex-file))
|
|
|
|
(goto-char (point-max))
|
|
|
|
(insert region)
|
|
|
|
;; ask user
|
|
|
|
(viper-maybe-checkout (current-buffer))
|
2000-05-24 16:32:18 +00:00
|
|
|
(setq selective-display nil)
|
1998-05-04 22:42:59 +00:00
|
|
|
(save-buffer)
|
|
|
|
(ex-write-info
|
|
|
|
file-exists ex-file (point-min) (point-max))
|
|
|
|
)
|
|
|
|
;; this must be under unwind-protect so that
|
|
|
|
;; temp-buf will be deleted in case of an error
|
|
|
|
(set-buffer temp-buf)
|
|
|
|
(set-buffer-modified-p nil)
|
|
|
|
(kill-buffer temp-buf)
|
|
|
|
;; buffer/region has been written, now take care of details
|
|
|
|
(set-buffer orig-buf)))
|
|
|
|
;; set the right file modification time
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (and (buffer-file-name) writing-same-file)
|
|
|
|
(set-visited-file-modtime))
|
1998-05-04 22:42:59 +00:00
|
|
|
;; prevent loss of data if saving part of the buffer in visited file
|
2003-02-04 13:24:35 +00:00
|
|
|
(or writing-whole-file
|
1996-06-22 03:20:38 +00:00
|
|
|
(not writing-same-file)
|
1998-05-04 22:42:59 +00:00
|
|
|
(progn
|
|
|
|
(sit-for 2)
|
|
|
|
(message "Warning: you have saved only part of the buffer!")
|
|
|
|
(set-buffer-modified-p t)))
|
1996-06-22 03:20:38 +00:00
|
|
|
(if q-flag
|
1997-07-17 19:37:07 +00:00
|
|
|
(if (< viper-expert-level 2)
|
1996-06-22 03:20:38 +00:00
|
|
|
(save-buffers-kill-emacs)
|
|
|
|
(kill-buffer (current-buffer))))
|
|
|
|
)))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
1996-06-22 01:54:34 +00:00
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
(defun ex-write-info (exists file-name beg end)
|
|
|
|
(message "`%s'%s %d lines, %d characters"
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-abbreviate-file-name file-name)
|
1996-06-22 03:20:38 +00:00
|
|
|
(if exists "" " [New file]")
|
|
|
|
(count-lines beg (min (1+ end) (point-max)))
|
|
|
|
(- end beg)))
|
|
|
|
|
|
|
|
;; Ex yank command
|
|
|
|
(defun ex-yank ()
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-default-ex-addresses)
|
|
|
|
(viper-get-ex-buffer)
|
1996-06-22 03:20:38 +00:00
|
|
|
(let ((end (car ex-addresses)) (beg (car (cdr ex-addresses))))
|
1997-08-02 07:40:22 +00:00
|
|
|
(if (> beg end) (error viper-FirstAddrExceedsSecond))
|
1996-06-22 03:20:38 +00:00
|
|
|
(save-excursion
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-enlarge-region beg end)
|
1996-06-22 03:20:38 +00:00
|
|
|
(exchange-point-and-mark)
|
|
|
|
(if (or ex-g-flag ex-g-variant)
|
|
|
|
(error "Can't execute `yank' within `global'"))
|
|
|
|
(if ex-count
|
1996-06-22 01:54:34 +00:00
|
|
|
(progn
|
1996-06-22 03:20:38 +00:00
|
|
|
(set-mark (point))
|
|
|
|
(forward-line (1- ex-count)))
|
|
|
|
(set-mark end))
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-enlarge-region (point) (mark t))
|
|
|
|
(if ex-flag (error "`yank': %s" viper-SpuriousText))
|
1996-06-22 03:20:38 +00:00
|
|
|
(if ex-buffer
|
1997-08-02 07:40:22 +00:00
|
|
|
(cond ((viper-valid-register ex-buffer '(Letter))
|
|
|
|
(viper-append-to-register
|
1996-06-22 03:20:38 +00:00
|
|
|
(downcase ex-buffer) (point) (mark t)))
|
1997-08-02 07:40:22 +00:00
|
|
|
((viper-valid-register ex-buffer)
|
1996-06-22 03:20:38 +00:00
|
|
|
(copy-to-register ex-buffer (point) (mark t) nil))
|
1997-08-02 07:40:22 +00:00
|
|
|
(t (error viper-InvalidRegister ex-buffer))))
|
1996-06-22 03:20:38 +00:00
|
|
|
(copy-region-as-kill (point) (mark t)))))
|
|
|
|
|
|
|
|
;; Execute shell command
|
|
|
|
(defun ex-command ()
|
|
|
|
(let (command)
|
|
|
|
(save-window-excursion
|
2003-02-04 13:24:35 +00:00
|
|
|
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
|
1997-08-02 07:40:22 +00:00
|
|
|
(set-buffer viper-ex-work-buf)
|
1996-06-22 03:20:38 +00:00
|
|
|
(skip-chars-forward " \t")
|
|
|
|
(setq command (buffer-substring (point) (point-max)))
|
|
|
|
(end-of-line))
|
1999-11-01 07:16:15 +00:00
|
|
|
;; replace # and % with the previous/current file
|
1996-06-22 03:20:38 +00:00
|
|
|
(setq command (ex-expand-filsyms command (current-buffer)))
|
|
|
|
(if (and (> (length command) 0) (string= "!" (substring command 0 1)))
|
1997-08-02 07:40:22 +00:00
|
|
|
(if viper-ex-last-shell-com
|
|
|
|
(setq command
|
|
|
|
(concat viper-ex-last-shell-com (substring command 1)))
|
1996-06-22 03:20:38 +00:00
|
|
|
(error "No previous shell command")))
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq viper-ex-last-shell-com command)
|
1996-06-22 03:20:38 +00:00
|
|
|
(if (null ex-addresses)
|
|
|
|
(shell-command command)
|
|
|
|
(let ((end (car ex-addresses)) (beg (car (cdr ex-addresses))))
|
|
|
|
(if (null beg) (setq beg end))
|
1995-02-20 23:15:10 +00:00
|
|
|
(save-excursion
|
1996-06-22 03:20:38 +00:00
|
|
|
(goto-char beg)
|
|
|
|
(set-mark end)
|
1997-08-02 07:40:22 +00:00
|
|
|
(viper-enlarge-region (point) (mark t))
|
1996-06-22 03:20:38 +00:00
|
|
|
(shell-command-on-region (point) (mark t) command t))
|
|
|
|
(goto-char beg)))))
|
|
|
|
|
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-compile,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
(viper-get-ex-address-subr): convert registers to char data type.
* viper-util.el (viper-int-to-char,viper-char-equal): new
functions.
(viper-memq-char): use viper-int-to-char.
(viper-file-checked-in-p): use vc-locking-user, if vc doesn't have
vc-locking-state.
(viper-read-key): use viper-read-key-sequence.
* viper.el (viper-major-mode-modifier-list): added
inferior-emacs-lisp-mode.
(this-major-mode-requires-vi-state): new function that uses simple
heuristics to decide if vi state is appropriate.
(set-viper-state-in-major-mode): use this-major-mode-requires-vi-state.
(viper-non-hook-settings): don't advise read-key-sequence.
(viper-read-key-sequence): new function that replaces the
previously used advice to read-key-sequence.
* viper-cmd.el (viper-test-com-defun,viper-exec-change,
viper-exec-Change,viper-execute-com,viper-insert,viper-append,
viper-Append,viper-Insert,viper-open-line,viper-Open-line,
viper-open-line-at-point,viper-substitute,viper-overwrite,
viper-replace-char-subr,viper-forward-word,viper-forward-Word):
got rid of the negative character hack.
(viper-escape-to-state,viper-replace-state-exit-cmd):
use viper-read-key-sequence.
(viper-envelop-ESC-key): no need for ad-get-orig-definition.
(viper-minibuffer-standard-hook,viper-read-string-with-history):
don't override existing minibuffer-setup-hook.
(viper-mark-point,viper-goto-mark-subr,viper-brac-function):
convert registers to char data type.
(viper-autoindent): use viper-indent-line.
* viper-keym.el: use viper-exec-key-in-emacs.
* viper.texi: Added credits, new commands, like :make.
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
(ediff-file-checked-out-p,ediff-file-checked-in-p): check if
vc-state is available.
(ediff-make-temp-file): use ediff-coding-system-for-write.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
(ediff-coding-system-for-read): from ediff-diff.el
(ediff-coding-system-for-write): new variable.
(ediff-highest-priority): fixed the bug having to do with disappearing
overlays.
(ediff-file-remote-p): use file-remote-p, if available.
(ediff-listable-file): new function.
(ediff-file-attributes): use ediff-listable-file.
* ediff-mult.el (ediff-meta-insert-file-info1): use
ediff-listable-file.
* ediff-ptch.el (ediff-prompt-for-patch-file): use
ediff-coding-system-for-read.
(ediff-patch-file-internal): use ediff-coding-system-for-write.
* ediff-diff.el (ediff-coding-system-for-read): moved to ediff-init.el.
(ediff-match-diff3-line,ediff-get-diff3-group): improved pattern.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* ediff.texi: added clarifications, acknowledgements.
2001-07-21 05:28:24 +00:00
|
|
|
(defun ex-compile ()
|
|
|
|
"Reads args from the command line, then runs make with the args.
|
|
|
|
If no args are given, then it runs the last compile command.
|
|
|
|
Type 'mak ' (including the space) to run make with no args."
|
|
|
|
(let (args)
|
|
|
|
(save-window-excursion
|
|
|
|
(setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
|
|
|
|
(set-buffer viper-ex-work-buf)
|
|
|
|
(setq args (buffer-substring (point) (point-max)))
|
|
|
|
(end-of-line))
|
|
|
|
;; Remove the newline that may (will?) be at the end of the args
|
|
|
|
(if (string= "\n" (substring args (1- (length args))))
|
|
|
|
(setq args (substring args 0 (1- (length args)))))
|
|
|
|
;; Run last command if no args given, else construct a new command.
|
|
|
|
(setq args
|
|
|
|
(if (string= "" args)
|
|
|
|
(if (boundp 'compile-command)
|
|
|
|
compile-command
|
|
|
|
ex-compile-command)
|
|
|
|
(concat ex-compile-command " " args)))
|
|
|
|
(compile args)
|
|
|
|
))
|
|
|
|
|
1996-06-22 03:20:38 +00:00
|
|
|
;; Print line number
|
|
|
|
(defun ex-line-no ()
|
|
|
|
(message "%d"
|
|
|
|
(1+ (count-lines
|
|
|
|
(point-min)
|
|
|
|
(if (null ex-addresses) (point-max) (car ex-addresses))))))
|
|
|
|
|
|
|
|
;; Give information on the file visited by the current buffer
|
1997-08-02 07:40:22 +00:00
|
|
|
(defun viper-info-on-file ()
|
1995-02-20 23:15:10 +00:00
|
|
|
(interactive)
|
1997-08-02 07:40:22 +00:00
|
|
|
(let ((pos1 (viper-line-pos 'start))
|
|
|
|
(pos2 (viper-line-pos 'end))
|
1996-06-22 03:20:38 +00:00
|
|
|
lines file info)
|
1997-08-02 07:40:22 +00:00
|
|
|
(setq lines (count-lines (point-min) (viper-line-pos 'end))
|
1996-06-22 03:20:38 +00:00
|
|
|
file (if (buffer-file-name)
|
1997-08-02 07:40:22 +00:00
|
|
|
(concat (viper-abbreviate-file-name (buffer-file-name)) ":")
|
1996-06-22 03:20:38 +00:00
|
|
|
(concat (buffer-name) " [Not visiting any file]:"))
|
|
|
|
info (format "line=%d/%d pos=%d/%d col=%d %s"
|
|
|
|
(if (= pos1 pos2)
|
|
|
|
(1+ lines)
|
|
|
|
lines)
|
|
|
|
(count-lines (point-min) (point-max))
|
|
|
|
(point) (1- (point-max))
|
|
|
|
(1+ (current-column))
|
|
|
|
(if (buffer-modified-p) "[Modified]" "[Unchanged]")))
|
|
|
|
(if (< (+ 1 (length info) (length file))
|
|
|
|
(window-width (minibuffer-window)))
|
|
|
|
(message (concat file " " info))
|
|
|
|
(save-window-excursion
|
1997-08-02 07:40:22 +00:00
|
|
|
(with-output-to-temp-buffer " *viper-info*"
|
1997-09-30 01:13:53 +00:00
|
|
|
(princ (concat "\n" file "\n\n\t" info "\n\n")))
|
|
|
|
(let ((inhibit-quit t))
|
|
|
|
(viper-set-unread-command-events (viper-read-event)))
|
1997-08-02 07:40:22 +00:00
|
|
|
(kill-buffer " *viper-info*")))
|
1995-02-22 00:38:59 +00:00
|
|
|
))
|
1995-02-20 23:15:10 +00:00
|
|
|
|
2001-12-24 05:50:31 +00:00
|
|
|
|
|
|
|
;; Without arguments displays info on file. With an arg, sets the visited file
|
|
|
|
;; name to that arg
|
|
|
|
(defun ex-set-visited-file-name ()
|
|
|
|
(viper-get-ex-file)
|
|
|
|
(if (string= ex-file "")
|
|
|
|
(viper-info-on-file)
|
|
|
|
;; If ex-file is a directory, use the file portion of the buffer
|
|
|
|
;; file name (like ex-write). Do this even if ex-file is a
|
|
|
|
;; non-existent directory, since set-visited-file-name signals an
|
|
|
|
;; error on this condition, too.
|
|
|
|
(if (and (string= (file-name-nondirectory ex-file) "")
|
|
|
|
buffer-file-name
|
|
|
|
(not (file-directory-p buffer-file-name)))
|
|
|
|
(setq ex-file (concat (file-name-as-directory ex-file)
|
|
|
|
(file-name-nondirectory buffer-file-name))))
|
|
|
|
(set-visited-file-name ex-file)))
|
|
|
|
|
|
|
|
|
1997-06-18 01:26:55 +00:00
|
|
|
;; display all variables set through :set
|
|
|
|
(defun ex-show-vars ()
|
1997-08-02 07:40:22 +00:00
|
|
|
(with-output-to-temp-buffer " *viper-info*"
|
|
|
|
(princ (if viper-auto-indent
|
1997-06-18 01:26:55 +00:00
|
|
|
"autoindent (local)\n" "noautoindent (local)\n"))
|
2003-02-04 13:24:35 +00:00
|
|
|
(princ (if (default-value 'viper-auto-indent)
|
1997-06-18 01:26:55 +00:00
|
|
|
"autoindent (global) \n" "noautoindent (global) \n"))
|
1997-08-02 07:40:22 +00:00
|
|
|
(princ (if viper-case-fold-search "ignorecase\n" "noignorecase\n"))
|
|
|
|
(princ (if viper-re-search "magic\n" "nomagic\n"))
|
1997-06-18 01:26:55 +00:00
|
|
|
(princ (if buffer-read-only "readonly\n" "noreadonly\n"))
|
|
|
|
(princ (if blink-matching-paren "showmatch\n" "noshowmatch\n"))
|
1997-08-02 07:40:22 +00:00
|
|
|
(princ (if viper-search-wrap-around-t "wrapscan\n" "nowrapscan\n"))
|
|
|
|
(princ (format "shiftwidth \t\t= %S\n" viper-shift-width))
|
1997-06-18 01:26:55 +00:00
|
|
|
(princ (format "tabstop (local) \t= %S\n" tab-width))
|
|
|
|
(princ (format "tabstop (global) \t= %S\n" (default-value 'tab-width)))
|
|
|
|
(princ (format "wrapmargin (local) \t= %S\n"
|
|
|
|
(- (window-width) fill-column)))
|
|
|
|
(princ (format "wrapmargin (global) \t= %S\n"
|
|
|
|
(- (window-width) (default-value 'fill-column))))
|
|
|
|
(princ (format "shell \t\t\t= %S\n" (if (boundp 'explicit-shell-file-name)
|
|
|
|
explicit-shell-file-name
|
|
|
|
'none)))
|
|
|
|
))
|
|
|
|
|
2002-04-16 05:49:11 +00:00
|
|
|
(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))))))
|
|
|
|
|
1997-06-18 01:26:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
1995-02-20 23:15:10 +00:00
|
|
|
|
2001-07-15 19:53:53 +00:00
|
|
|
;;; viper-ex.el ends here
|