[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/emulation/viper-ex.el
From: |
Juanma Barranquero |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/emulation/viper-ex.el |
Date: |
Tue, 04 Feb 2003 07:56:09 -0500 |
Index: emacs/lisp/emulation/viper-ex.el
diff -c emacs/lisp/emulation/viper-ex.el:1.45
emacs/lisp/emulation/viper-ex.el:1.46
*** emacs/lisp/emulation/viper-ex.el:1.45 Fri Aug 30 07:02:10 2002
--- emacs/lisp/emulation/viper-ex.el Tue Feb 4 07:56:03 2003
***************
*** 150,156 ****
("set" (ex-set))
("shell" (ex-shell))
("source" (ex-source))
! ("stop" (suspend-emacs))
("sr" (ex-substitute t t))
("submitReport" (viper-submit-report))
("substitute" (ex-substitute) is-mashed)
--- 150,156 ----
("set" (ex-set))
("shell" (ex-shell))
("source" (ex-source))
! ("stop" (suspend-emacs))
("sr" (ex-substitute t t))
("submitReport" (viper-submit-report))
("substitute" (ex-substitute) is-mashed)
***************
*** 165,171 ****
("v" "vglobal")
("version" (viper-version))
("vglobal" (ex-global t) is-mashed)
! ("visual" (ex-edit))
("w" "write")
("wq" (ex-write t))
("write" (ex-write nil))
--- 165,171 ----
("v" "vglobal")
("version" (viper-version))
("vglobal" (ex-global t) is-mashed)
! ("visual" (ex-edit))
("w" "write")
("wq" (ex-write t))
("write" (ex-write nil))
***************
*** 238,263 ****
;; A-list of Ex variables that can be set using the :set command.
! (defconst ex-variable-alist
'(("wrapscan") ("ws") ("wrapmargin") ("wm")
("tabstop-global") ("ts-g") ("tabstop") ("ts")
("showmatch") ("sm") ("shiftwidth") ("sw") ("shell") ("sh")
! ("readonly") ("ro")
("nowrapscan") ("nows") ("noshowmatch") ("nosm")
("noreadonly") ("noro") ("nomagic") ("noma")
("noignorecase") ("noic")
("noautoindent-global") ("noai-g") ("noautoindent") ("noai")
("magic") ("ma") ("ignorecase") ("ic")
! ("autoindent-global") ("ai-g") ("autoindent") ("ai")
! ("all")
))
!
;; Token recognized during parsing of Ex commands (e.g., "read", "comma")
(defvar ex-token nil)
! ;; Type of token.
;; If non-nil, gives type of address; if nil, it is a command.
(defvar ex-token-type nil)
--- 238,263 ----
;; A-list of Ex variables that can be set using the :set command.
! (defconst ex-variable-alist
'(("wrapscan") ("ws") ("wrapmargin") ("wm")
("tabstop-global") ("ts-g") ("tabstop") ("ts")
("showmatch") ("sm") ("shiftwidth") ("sw") ("shell") ("sh")
! ("readonly") ("ro")
("nowrapscan") ("nows") ("noshowmatch") ("nosm")
("noreadonly") ("noro") ("nomagic") ("noma")
("noignorecase") ("noic")
("noautoindent-global") ("noai-g") ("noautoindent") ("noai")
("magic") ("ma") ("ignorecase") ("ic")
! ("autoindent-global") ("ai-g") ("autoindent") ("ai")
! ("all")
))
!
;; Token recognized during parsing of Ex commands (e.g., "read", "comma")
(defvar ex-token nil)
! ;; Type of token.
;; If non-nil, gives type of address; if nil, it is a command.
(defvar ex-token-type nil)
***************
*** 323,329 ****
((string-match "\\(bash$\\|bash.exe$\\)" shell-file-name)
"-noprofile") ; bash: ignore .profile
)))
! "Options to pass to the Unix-style shell.
Don't put `-c' here, as it is added automatically."
:type '(choice (const nil) string)
:group 'viper-ex)
--- 323,329 ----
((string-match "\\(bash$\\|bash.exe$\\)" shell-file-name)
"-noprofile") ; bash: ignore .profile
)))
! "Options to pass to the Unix-style shell.
Don't put `-c' here, as it is added automatically."
:type '(choice (const nil) string)
:group 'viper-ex)
***************
*** 344,350 ****
The default tries to set this variable to work with Unix, Windows,
OS/2, and VMS.
! However, if it doesn't work right for some types of Unix shells or some OS,
the user should supply the appropriate function and set this variable to the
corresponding function symbol."
:type 'symbol
--- 344,350 ----
The default tries to set this variable to work with Unix, Windows,
OS/2, and VMS.
! However, if it doesn't work right for some types of Unix shells or some OS,
the user should supply the appropriate function and set this variable to the
corresponding function symbol."
:type 'symbol
***************
*** 370,376 ****
;; e.g., :r !date
(defvar ex-cmdfile nil)
(defvar ex-cmdfile-args "")
!
;; flag used in viper-ex-read-file-name to indicate that we may be reading
;; multiple file names. Used for :edit and :next
(defvar viper-keep-reading-filename nil)
--- 370,376 ----
;; e.g., :r !date
(defvar ex-cmdfile nil)
(defvar ex-cmdfile-args "")
!
;; flag used in viper-ex-read-file-name to indicate that we may be reading
;; multiple file names. Used for :edit and :next
(defvar viper-keep-reading-filename nil)
***************
*** 389,398 ****
;; Last shell command executed with :! command.
(defvar viper-ex-last-shell-com nil)
!
;; Indicates if Minibuffer was exited temporarily in Ex-command.
(defvar viper-incomplete-ex-cmd nil)
!
;; Remembers the last ex-command prompt.
(defvar viper-last-ex-prompt "")
--- 389,398 ----
;; Last shell command executed with :! command.
(defvar viper-ex-last-shell-com nil)
!
;; Indicates if Minibuffer was exited temporarily in Ex-command.
(defvar viper-incomplete-ex-cmd nil)
!
;; Remembers the last ex-command prompt.
(defvar viper-last-ex-prompt "")
***************
*** 414,420 ****
;; A token has a type, \(command, address, end-mark\), and a value
(defun viper-get-ex-token ()
(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|")
(let ((case-fold-search t))
--- 414,420 ----
;; A token has a type, \(command, address, end-mark\), and a value
(defun viper-get-ex-token ()
(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|")
(let ((case-fold-search t))
***************
*** 556,580 ****
"\\|" "![ \t]*[a-zA-Z].*"
"\\)"
"!*")))
!
(save-window-excursion ;; put cursor at the end of the Ex working buffer
! (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
(goto-char (point-max)))
(cond ((viper-looking-back quit-regex1) (exit-minibuffer))
((viper-looking-back stay-regex) (insert " "))
((viper-looking-back quit-regex2) (exit-minibuffer))
(t (insert " ")))))
!
;; complete Ex command
(defun ex-cmd-complete ()
(interactive)
(let (save-pos dist compl-list string-to-complete completion-result)
!
(save-excursion
(setq dist (skip-chars-backward "[a-zA-Z!=>&~]")
save-pos (point)))
!
(if (or (= dist 0)
(viper-looking-back "\\([ \t]*['`][ \t]*[a-z]*\\)")
(viper-looking-back
--- 556,580 ----
"\\|" "![ \t]*[a-zA-Z].*"
"\\)"
"!*")))
!
(save-window-excursion ;; put cursor at the end of the Ex working buffer
! (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
(goto-char (point-max)))
(cond ((viper-looking-back quit-regex1) (exit-minibuffer))
((viper-looking-back stay-regex) (insert " "))
((viper-looking-back quit-regex2) (exit-minibuffer))
(t (insert " ")))))
!
;; complete Ex command
(defun ex-cmd-complete ()
(interactive)
(let (save-pos dist compl-list string-to-complete completion-result)
!
(save-excursion
(setq dist (skip-chars-backward "[a-zA-Z!=>&~]")
save-pos (point)))
!
(if (or (= dist 0)
(viper-looking-back "\\([ \t]*['`][ \t]*[a-z]*\\)")
(viper-looking-back
***************
*** 586,599 ****
(viper-looking-back "\\([ \t]*['`][ \t]*[a-z]*\\)")
(looking-at "[^ \t\n\C-m]"))
nil
! (with-output-to-temp-buffer "*Completions*"
(display-completion-list
(viper-alist-to-list ex-token-alist))))
;; 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))
!
(cond ((eq completion-result t) ; exact match--do nothing
(viper-tmp-insert-at-eob " (Sole completion)"))
((eq completion-result nil)
--- 586,599 ----
(viper-looking-back "\\([ \t]*['`][ \t]*[a-z]*\\)")
(looking-at "[^ \t\n\C-m]"))
nil
! (with-output-to-temp-buffer "*Completions*"
(display-completion-list
(viper-alist-to-list ex-token-alist))))
;; 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))
!
(cond ((eq completion-result t) ; exact match--do nothing
(viper-tmp-insert-at-eob " (Sole completion)"))
((eq completion-result nil)
***************
*** 607,623 ****
(viper-filter-alist (concat "^" completion-result)
ex-token-alist)))
(if (> (length compl-list) 1)
! (with-output-to-temp-buffer "*Completions*"
(display-completion-list
(viper-alist-to-list (reverse compl-list)))))))
)))
-
! ;; Read Ex commands
;; 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
! ;; command.
(defun viper-ex (arg &optional string)
(interactive "P")
(or string
--- 607,623 ----
(viper-filter-alist (concat "^" completion-result)
ex-token-alist)))
(if (> (length compl-list) 1)
! (with-output-to-temp-buffer "*Completions*"
(display-completion-list
(viper-alist-to-list (reverse compl-list)))))))
)))
!
! ;; Read Ex commands
;; 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
! ;; command.
(defun viper-ex (arg &optional string)
(interactive "P")
(or string
***************
*** 648,657 ****
(+ 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)))
!
! (setq com-str
(or string (viper-read-string-with-history
! ":"
initial-str
'viper-ex-history
;; no default when working on region
--- 648,657 ----
(+ 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)))
!
! (setq com-str
(or string (viper-read-string-with-history
! ":"
initial-str
'viper-ex-history
;; no default when working on region
***************
*** 663,669 ****
" [Type command to execute on current region]"))))
(save-window-excursion
;; just a precaution
! (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
(delete-region (point-min) (point-max))
(insert com-str "\n")
--- 663,669 ----
" [Type command to execute on current region]"))))
(save-window-excursion
;; just a precaution
! (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
(delete-region (point-min) (point-max))
(insert com-str "\n")
***************
*** 718,724 ****
(t (let ((ans (viper-get-ex-address-subr address dot)))
(if ans (setq address ans)))))
(setq prev-token-type ex-token-type))))
!
;; Get a regular expression and set `ex-variant', if found
;; Viper doesn't parse the substitution or search patterns.
--- 718,724 ----
(t (let ((ans (viper-get-ex-address-subr address dot)))
(if ans (setq address ans)))))
(setq prev-token-type ex-token-type))))
!
;; Get a regular expression and set `ex-variant', if found
;; Viper doesn't parse the substitution or search patterns.
***************
*** 783,789 ****
;; Get an Ex option g or c
(defun viper-get-ex-opt-gc (c)
(save-window-excursion
! (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
(if (looking-at (format "%c" c)) (forward-char 1))
(skip-chars-forward " \t")
--- 783,789 ----
;; Get an Ex option g or c
(defun viper-get-ex-opt-gc (c)
(save-window-excursion
! (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
(if (looking-at (format "%c" c)) (forward-char 1))
(skip-chars-forward " \t")
***************
*** 872,878 ****
(save-excursion
(if (null ex-token)
(exchange-point-and-mark)
! (goto-char
(viper-register-to-point
(viper-int-to-char (1+ (- ex-token ?a))) 'enforce-buffer)))
(setq address (point-marker)))))
--- 872,878 ----
(save-excursion
(if (null ex-token)
(exchange-point-and-mark)
! (goto-char
(viper-register-to-point
(viper-int-to-char (1+ (- ex-token ?a))) 'enforce-buffer)))
(setq address (point-marker)))))
***************
*** 900,906 ****
(setq ex-count nil)
(setq ex-flag nil)
(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")
(if (looking-at "[a-zA-Z]")
--- 900,906 ----
(setq ex-count nil)
(setq ex-flag nil)
(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")
(if (looking-at "[a-zA-Z]")
***************
*** 926,932 ****
ex-count nil
ex-flag nil)
(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")
(if (looking-at "!")
--- 926,932 ----
ex-count nil
ex-flag nil)
(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")
(if (looking-at "!")
***************
*** 952,958 ****
;; Expand \% and \# in ex command
(defun ex-expand-filsyms (cmd buf)
(let (cf pf ret)
! (save-excursion
(set-buffer buf)
(setq cf buffer-file-name)
(setq pf (ex-next nil t))) ; this finds alternative file name
--- 952,958 ----
;; Expand \% and \# in ex command
(defun ex-expand-filsyms (cmd buf)
(let (cf pf ret)
! (save-excursion
(set-buffer buf)
(setq cf buffer-file-name)
(setq pf (ex-next nil t))) ; this finds alternative file name
***************
*** 966,972 ****
(insert cmd)
(goto-char (point-min))
(while (re-search-forward "%\\|#" nil t)
! (let ((data (match-data))
(char (buffer-substring (match-beginning 0) (match-end 0))))
(if (viper-looking-back (concat "\\\\" char))
(replace-match char)
--- 966,972 ----
(insert cmd)
(goto-char (point-min))
(while (re-search-forward "%\\|#" nil t)
! (let ((data (match-data))
(char (buffer-substring (match-beginning 0) (match-end 0))))
(if (viper-looking-back (concat "\\\\" char))
(replace-match char)
***************
*** 991,997 ****
ex-cmdfile-args "")
(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")
(if (looking-at "!")
--- 991,997 ----
ex-cmdfile-args "")
(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")
(if (looking-at "!")
***************
*** 1052,1060 ****
(skip-chars-backward " \t\n")
(setq prompt (buffer-substring (point-min) (point)))
))
!
(setq viper-last-ex-prompt prompt)
!
;; If we just finished reading command, redisplay prompt
(if viper-incomplete-ex-cmd
(setq ex-file (viper-ex-read-file-name (format ":%s " prompt)))
--- 1052,1060 ----
(skip-chars-backward " \t\n")
(setq prompt (buffer-substring (point-min) (point)))
))
!
(setq viper-last-ex-prompt prompt)
!
;; If we just finished reading command, redisplay prompt
(if viper-incomplete-ex-cmd
(setq ex-file (viper-ex-read-file-name (format ":%s " prompt)))
***************
*** 1067,1074 ****
;; file names, arranges to re-enter the minibuffer.
(defun viper-complete-filename-or-exit ()
(interactive)
! (setq viper-keep-reading-filename t)
! ;; don't exit if directory---ex-commands don't
(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
--- 1067,1074 ----
;; file names, arranges to re-enter the minibuffer.
(defun viper-complete-filename-or-exit ()
(interactive)
! (setq viper-keep-reading-filename t)
! ;; don't exit if directory---ex-commands don't
(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
***************
*** 1098,1109 ****
(minibuffer-local-completion-map
(copy-keymap minibuffer-local-completion-map))
beg end cont val)
!
(viper-add-keymap ex-read-filename-map
! (if viper-emacs-p
minibuffer-local-completion-map
! read-file-name-map))
!
(setq cont (setq viper-keep-reading-filename t))
(while cont
(setq viper-keep-reading-filename nil
--- 1098,1109 ----
(minibuffer-local-completion-map
(copy-keymap minibuffer-local-completion-map))
beg end cont val)
!
(viper-add-keymap ex-read-filename-map
! (if viper-emacs-p
minibuffer-local-completion-map
! read-file-name-map))
!
(setq cont (setq viper-keep-reading-filename t))
(while cont
(setq viper-keep-reading-filename nil
***************
*** 1114,1127 ****
(setq val (concat "\"" val "\"")))
(setq str (concat str (if (equal val "") "" " ")
val (if (equal val "") "" " ")))
!
;; Only edit, next, and Next commands accept multiple files.
;; viper-keep-reading-filename is set in the anonymous function that is
;; bound to " " in ex-read-filename-map.
(setq cont (and viper-keep-reading-filename
(ex-cmd-accepts-multiple-files-p ex-token)))
)
!
(setq beg (string-match "[^ \t]" str) ; delete leading blanks
end (string-match "[ \t]*$" str)) ; delete trailing blanks
(if (member ex-token '("read" "write"))
--- 1114,1127 ----
(setq val (concat "\"" val "\"")))
(setq str (concat str (if (equal val "") "" " ")
val (if (equal val "") "" " ")))
!
;; Only edit, next, and Next commands accept multiple files.
;; viper-keep-reading-filename is set in the anonymous function that is
;; bound to " " in ex-read-filename-map.
(setq cont (and viper-keep-reading-filename
(ex-cmd-accepts-multiple-files-p ex-token)))
)
!
(setq beg (string-match "[^ \t]" str) ; delete leading blanks
end (string-match "[ \t]*$" str)) ; delete trailing blanks
(if (member ex-token '("read" "write"))
***************
*** 1137,1147 ****
(defun viper-undisplayed-files ()
(mapcar
! (lambda (b)
(if (null (get-buffer-window b))
(let ((f (buffer-file-name b)))
(if f f
! (if ex-cycle-through-non-files
(let ((s (buffer-name b)))
(if (string= " " (substring s 0 1))
nil
--- 1137,1147 ----
(defun viper-undisplayed-files ()
(mapcar
! (lambda (b)
(if (null (get-buffer-window b))
(let ((f (buffer-file-name b)))
(if f f
! (if ex-cycle-through-non-files
(let ((s (buffer-name b)))
(if (string= " " (substring s 0 1))
nil
***************
*** 1156,1162 ****
(args "")
(file-count 1))
(while (not (null l))
! (if (car l)
(setq args (format "%s %d) %s\n" args file-count (car l))
file-count (1+ file-count)))
(setq l (cdr l)))
--- 1156,1162 ----
(args "")
(file-count 1))
(while (not (null l))
! (if (car l)
(setq args (format "%s %d) %s\n" args file-count (car l))
file-count (1+ file-count)))
(setq l (cdr l)))
***************
*** 1260,1266 ****
(setq ex-file (viper-abbreviate-file-name (buffer-file-name))))
((string= ex-file "")
(error viper-NoFileSpecified)))
!
(let (msg do-edit)
(if buffer-file-name
(cond ((buffer-modified-p)
--- 1260,1266 ----
(setq ex-file (viper-abbreviate-file-name (buffer-file-name))))
((string= ex-file "")
(error viper-NoFileSpecified)))
!
(let (msg do-edit)
(if buffer-file-name
(cond ((buffer-modified-p)
***************
*** 1274,1280 ****
buffer-file-name)
do-edit t))
(t (setq do-edit nil))))
!
(if do-edit
(if (yes-or-no-p msg)
(progn
--- 1274,1280 ----
buffer-file-name)
do-edit t))
(t (setq do-edit nil))))
!
(if do-edit
(if (yes-or-no-p msg)
(progn
***************
*** 1282,1290 ****
(kill-buffer (current-buffer)))
(message "Buffer %s was left intact" (buffer-name))))
) ; let
!
(if (null (setq file (get-file-buffer ex-file)))
! (progn
;; this also does shell-style globbing
(ex-find-file
;; replace # and % with the previous/current file
--- 1282,1290 ----
(kill-buffer (current-buffer)))
(message "Buffer %s was left intact" (buffer-name))))
) ; let
!
(if (null (setq file (get-file-buffer ex-file)))
! (progn
;; this also does shell-style globbing
(ex-find-file
;; replace # and % with the previous/current file
***************
*** 1296,1302 ****
(if ex-offset
(progn
(save-window-excursion
! (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
(delete-region (point-min) (point-max))
(insert ex-offset "\n")
--- 1296,1302 ----
(if ex-offset
(progn
(save-window-excursion
! (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
(delete-region (point-min) (point-max))
(insert ex-offset "\n")
***************
*** 1339,1345 ****
(viper-get-ex-pat)
(if (null ex-token)
(error "`%s': Missing regular expression" gcommand)))
!
(if (string= ex-token "")
(if (null viper-s-string)
(error viper-NoPrevSearch)
--- 1339,1345 ----
(viper-get-ex-pat)
(if (null ex-token)
(error "`%s': Missing regular expression" gcommand)))
!
(if (string= ex-token "")
(if (null viper-s-string)
(error viper-NoPrevSearch)
***************
*** 1379,1385 ****
(forward-line -1)
(end-of-line)))))
(save-window-excursion
! (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
;; com-str is the command string, i.e., g/pattern/ or v/pattern'
(setq com-str (buffer-substring (1+ (point)) (1- (point-max)))))
--- 1379,1385 ----
(forward-line -1)
(end-of-line)))))
(save-window-excursion
! (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
;; com-str is the command string, i.e., g/pattern/ or v/pattern'
(setq com-str (buffer-substring (1+ (point)) (1- (point-max)))))
***************
*** 1460,1466 ****
(error "`%s': Spurious text \"%s\" after mark name"
name (substring name 1) viper-SpuriousText))
(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")
(if (looking-at "[a-z]")
--- 1460,1466 ----
(error "`%s': Spurious text \"%s\" after mark name"
name (substring name 1) viper-SpuriousText))
(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")
(if (looking-at "[a-z]")
***************
*** 1475,1491 ****
(goto-char (car ex-addresses))
(point-to-register (viper-int-to-char (1+ (- char ?a)))))))
!
!
;; 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)
! (if (not find-alt-file)
(progn
(viper-get-ex-file)
(if (or (char-or-string-p ex-offset)
! (and (not (string= "" ex-file))
(not (string-match "^[0-9]+$" ex-file))))
(progn
(ex-edit t)
--- 1475,1491 ----
(goto-char (car ex-addresses))
(point-to-register (viper-int-to-char (1+ (- char ?a)))))))
!
!
;; 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)
! (if (not find-alt-file)
(progn
(viper-get-ex-file)
(if (or (char-or-string-p ex-offset)
! (and (not (string= "" ex-file))
(not (string-match "^[0-9]+$" ex-file))))
(progn
(ex-edit t)
***************
*** 1515,1555 ****
(defun ex-next-related-buffer (direction &optional no-recursion)
!
(viper-ring-rotate1 viper-related-files-and-buffers-ring direction)
!
! (let ((file-or-buffer-name
(viper-current-ring-item viper-related-files-and-buffers-ring))
(old-ring viper-related-files-and-buffers-ring)
(old-win (selected-window))
skip-rest buf wind)
!
(or (and (ring-p viper-related-files-and-buffers-ring)
(> (ring-length viper-related-files-and-buffers-ring) 0))
(error "This buffer has no related files or buffers"))
!
(or (stringp file-or-buffer-name)
(error
"File and buffer names must be strings, %S" file-or-buffer-name))
!
(setq buf (cond ((get-buffer file-or-buffer-name))
((file-exists-p file-or-buffer-name)
(find-file-noselect file-or-buffer-name))
))
!
(if (not (viper-buffer-live-p buf))
(error "Didn't find buffer %S or file %S"
file-or-buffer-name
(viper-abbreviate-file-name
(expand-file-name file-or-buffer-name))))
!
(if (equal buf (current-buffer))
(or no-recursion
;; try again
(progn
(setq skip-rest t)
(ex-next-related-buffer direction 'norecursion))))
!
(if skip-rest
()
;; setup buffer
--- 1515,1555 ----
(defun ex-next-related-buffer (direction &optional no-recursion)
!
(viper-ring-rotate1 viper-related-files-and-buffers-ring direction)
!
! (let ((file-or-buffer-name
(viper-current-ring-item viper-related-files-and-buffers-ring))
(old-ring viper-related-files-and-buffers-ring)
(old-win (selected-window))
skip-rest buf wind)
!
(or (and (ring-p viper-related-files-and-buffers-ring)
(> (ring-length viper-related-files-and-buffers-ring) 0))
(error "This buffer has no related files or buffers"))
!
(or (stringp file-or-buffer-name)
(error
"File and buffer names must be strings, %S" file-or-buffer-name))
!
(setq buf (cond ((get-buffer file-or-buffer-name))
((file-exists-p file-or-buffer-name)
(find-file-noselect file-or-buffer-name))
))
!
(if (not (viper-buffer-live-p buf))
(error "Didn't find buffer %S or file %S"
file-or-buffer-name
(viper-abbreviate-file-name
(expand-file-name file-or-buffer-name))))
!
(if (equal buf (current-buffer))
(or no-recursion
;; try again
(progn
(setq skip-rest t)
(ex-next-related-buffer direction 'norecursion))))
!
(if skip-rest
()
;; setup buffer
***************
*** 1557,1563 ****
()
(setq wind (get-lru-window (if viper-xemacs-p nil 'visible)))
(set-window-buffer wind buf))
!
(if (viper-window-display-p)
(progn
(raise-frame (window-frame wind))
--- 1557,1563 ----
()
(setq wind (get-lru-window (if viper-xemacs-p nil 'visible)))
(set-window-buffer wind buf))
!
(if (viper-window-display-p)
(progn
(raise-frame (window-frame wind))
***************
*** 1565,1579 ****
(save-window-excursion (select-window wind) (sit-for 1))
(select-window wind)))
(save-window-excursion (select-window wind) (sit-for 1)))
!
(save-excursion
(set-buffer buf)
(setq viper-related-files-and-buffers-ring old-ring))
!
(setq viper-local-search-start-marker (point-marker))
)))
!
!
;; Force auto save
(defun ex-preserve ()
(message "Autosaving all buffers that need to be saved...")
--- 1565,1579 ----
(save-window-excursion (select-window wind) (sit-for 1))
(select-window wind)))
(save-window-excursion (select-window wind) (sit-for 1)))
!
(save-excursion
(set-buffer buf)
(setq viper-related-files-and-buffers-ring old-ring))
!
(setq viper-local-search-start-marker (point-marker))
)))
!
!
;; Force auto save
(defun ex-preserve ()
(message "Autosaving all buffers that need to be saved...")
***************
*** 1595,1601 ****
(defun ex-quit ()
;; skip "!", if it is q!. In Viper q!, w!, etc., behave as q, w, etc.
(save-excursion
! (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
(if (looking-at "!") (forward-char 1)))
(if (< viper-expert-level 3)
--- 1595,1601 ----
(defun ex-quit ()
;; skip "!", if it is q!. In Viper q!, w!, etc., behave as q, w, etc.
(save-excursion
! (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
(if (looking-at "!") (forward-char 1)))
(if (< viper-expert-level 3)
***************
*** 1621,1639 ****
(setq ex-file buffer-file-name)))
(if ex-cmdfile
(progn
! (setq command
;; replace # and % with the previous/current file
(ex-expand-filsyms (concat ex-file ex-cmdfile-args)
(current-buffer)))
(shell-command command t))
(insert-file-contents ex-file)))
(ex-fixup-history viper-last-ex-prompt ex-file ex-cmdfile-args))
!
;; this function fixes ex-history for some commands like ex-read, ex-edit
! (defun ex-fixup-history (&rest args)
(setq viper-ex-history
(cons (mapconcat 'identity args " ") (cdr viper-ex-history))))
!
;; Ex recover from emacs \#file\#
(defun ex-recover ()
--- 1621,1639 ----
(setq ex-file buffer-file-name)))
(if ex-cmdfile
(progn
! (setq command
;; replace # and % with the previous/current file
(ex-expand-filsyms (concat ex-file ex-cmdfile-args)
(current-buffer)))
(shell-command command t))
(insert-file-contents ex-file)))
(ex-fixup-history viper-last-ex-prompt ex-file ex-cmdfile-args))
!
;; this function fixes ex-history for some commands like ex-read, ex-edit
! (defun ex-fixup-history (&rest args)
(setq viper-ex-history
(cons (mapconcat 'identity args " ") (cdr viper-ex-history))))
!
;; Ex recover from emacs \#file\#
(defun ex-recover ()
***************
*** 1674,1680 ****
(viper-set-unread-command-events ?\C-m)))
(message ":set <Variable> [= <Value>]")
(or batch (sit-for 2))
!
(while (string-match "^[ \\t\\n]*$"
(setq str
(completing-read ":set " ex-variable-alist)))
--- 1674,1680 ----
(viper-set-unread-command-events ?\C-m)))
(message ":set <Variable> [= <Value>]")
(or batch (sit-for 2))
!
(while (string-match "^[ \\t\\n]*$"
(setq str
(completing-read ":set " ex-variable-alist)))
***************
*** 1755,1773 ****
(or (viper-set-unread-command-events "") (sit-for 2))
(setq val (read-string (format ":set %s = " var)))
(ex-fixup-history "set" orig-var val)
!
;; check numerical values
(if (member var
'("sw" "shiftwidth"
"ts" "tabstop"
"ts-g" "tabstop-global"
! "wm" "wrapmargin"))
(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))))
!
(cond
((member var '("sw" "shiftwidth"))
(setq var "viper-shift-width"))
--- 1755,1773 ----
(or (viper-set-unread-command-events "") (sit-for 2))
(setq val (read-string (format ":set %s = " var)))
(ex-fixup-history "set" orig-var val)
!
;; check numerical values
(if (member var
'("sw" "shiftwidth"
"ts" "tabstop"
"ts-g" "tabstop-global"
! "wm" "wrapmargin"))
(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))))
!
(cond
((member var '("sw" "shiftwidth"))
(setq var "viper-shift-width"))
***************
*** 1782,1808 ****
set-cmd "setq-default"))
((member var '("wm" "wrapmargin"))
;; make it take effect in curr buff and new bufs
! (kill-local-variable 'fill-column)
! (setq var "fill-column"
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))
!
(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)))
!
(if (and ask-if-save
(y-or-n-p (format "Do you want to save this setting in %s "
viper-custom-file-name)))
(progn
! (viper-save-string-in-file
actual-lisp-cmd viper-custom-file-name
;; del pattern
lisp-cmd-del-pattern)
--- 1782,1808 ----
set-cmd "setq-default"))
((member var '("wm" "wrapmargin"))
;; make it take effect in curr buff and new bufs
! (kill-local-variable 'fill-column)
! (setq var "fill-column"
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))
!
(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)))
!
(if (and ask-if-save
(y-or-n-p (format "Do you want to save this setting in %s "
viper-custom-file-name)))
(progn
! (viper-save-string-in-file
actual-lisp-cmd viper-custom-file-name
;; del pattern
lisp-cmd-del-pattern)
***************
*** 1822,1828 ****
lisp-cmd-del-pattern)
))
))
!
(if set-cmd
(message "%s %s %s"
set-cmd var
--- 1822,1828 ----
lisp-cmd-del-pattern)
))
))
!
(if set-cmd
(message "%s %s %s"
set-cmd var
***************
*** 1843,1849 ****
;; special meaning
(defun ex-get-inline-cmd-args (regex-forw &optional chars-back replace-str)
(save-excursion
! (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
(goto-char (point-min))
(re-search-forward regex-forw nil t)
--- 1843,1849 ----
;; special meaning
(defun ex-get-inline-cmd-args (regex-forw &optional chars-back replace-str)
(save-excursion
! (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
(set-buffer viper-ex-work-buf)
(goto-char (point-min))
(re-search-forward regex-forw nil t)
***************
*** 1868,1874 ****
;; Ex shell command
(defun ex-shell ()
(shell))
!
;; Viper help. Invokes Info
(defun ex-help ()
(condition-case nil
--- 1868,1874 ----
;; Ex shell command
(defun ex-shell ()
(shell))
!
;; Viper help. Invokes Info
(defun ex-help ()
(condition-case nil
***************
*** 1895,1901 ****
;; Ex substitute command
;; If REPEAT use previous regexp which is ex-reg-exp or viper-s-string
! (defun ex-substitute (&optional repeat r-flag)
(let ((opt-g nil)
(opt-c nil)
(matched-pos nil)
--- 1895,1901 ----
;; Ex substitute command
;; If REPEAT use previous regexp which is ex-reg-exp or viper-s-string
! (defun ex-substitute (&optional repeat r-flag)
(let ((opt-g nil)
(opt-c nil)
(matched-pos nil)
***************
*** 1993,1999 ****
(defun ex-tag ()
(let (tag)
(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")
(set-mark (point))
--- 1993,1999 ----
(defun ex-tag ()
(let (tag)
(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")
(set-mark (point))
***************
*** 2013,2025 ****
;; Ex write command
;; ex-write doesn't support wildcards, because file completion is a better
! ;; mechanism. We also don't support # and %
;; because file history is a better mechanism.
(defun ex-write (q-flag)
(viper-default-ex-addresses t)
(viper-get-ex-file)
(let ((end (car ex-addresses))
! (beg (car (cdr ex-addresses)))
(orig-buf (current-buffer))
;;(orig-buf-file-name (buffer-file-name))
;;(orig-buf-name (buffer-name))
--- 2013,2025 ----
;; Ex write command
;; ex-write doesn't support wildcards, because file completion is a better
! ;; mechanism. We also don't support # and %
;; because file history is a better mechanism.
(defun ex-write (q-flag)
(viper-default-ex-addresses t)
(viper-get-ex-file)
(let ((end (car ex-addresses))
! (beg (car (cdr ex-addresses)))
(orig-buf (current-buffer))
;;(orig-buf-file-name (buffer-file-name))
;;(orig-buf-name (buffer-name))
***************
*** 2030,2043 ****
(if ex-cmdfile
(progn
(viper-enlarge-region beg end)
! (shell-command-on-region (point) (mark t)
(concat ex-file ex-cmdfile-args)))
(if (and (string= ex-file "") (not (buffer-file-name)))
(setq ex-file
(read-file-name
(format "Buffer %s isn't visiting any file. File to save in: "
(buffer-name)))))
!
(setq writing-whole-file (and (= (point-min) beg) (= (point-max) end))
ex-file (if (string= ex-file "")
(buffer-file-name)
--- 2030,2043 ----
(if ex-cmdfile
(progn
(viper-enlarge-region beg end)
! (shell-command-on-region (point) (mark t)
(concat ex-file ex-cmdfile-args)))
(if (and (string= ex-file "") (not (buffer-file-name)))
(setq ex-file
(read-file-name
(format "Buffer %s isn't visiting any file. File to save in: "
(buffer-name)))))
!
(setq writing-whole-file (and (= (point-min) beg) (= (point-max) end))
ex-file (if (string= ex-file "")
(buffer-file-name)
***************
*** 2049,2055 ****
(setq ex-file
(concat (file-name-as-directory ex-file)
(file-name-nondirectory buffer-file-name))))
!
(setq file-exists (file-exists-p ex-file)
writing-same-file (string= ex-file (buffer-file-name)))
--- 2049,2055 ----
(setq ex-file
(concat (file-name-as-directory ex-file)
(file-name-nondirectory buffer-file-name))))
!
(setq file-exists (file-exists-p ex-file)
writing-same-file (string= ex-file (buffer-file-name)))
***************
*** 2070,2076 ****
(format "File %s exists. Overwrite? " ex-file))))
(error "Quit"))
;; writing a region or whole buffer to non-visited file
! (unwind-protect
(save-excursion
(viper-enlarge-region beg end)
(setq region (buffer-substring (point) (mark t)))
--- 2070,2076 ----
(format "File %s exists. Overwrite? " ex-file))))
(error "Quit"))
;; writing a region or whole buffer to non-visited file
! (unwind-protect
(save-excursion
(viper-enlarge-region beg end)
(setq region (buffer-substring (point) (mark t)))
***************
*** 2104,2110 ****
(if (and (buffer-file-name) writing-same-file)
(set-visited-file-modtime))
;; prevent loss of data if saving part of the buffer in visited file
! (or writing-whole-file
(not writing-same-file)
(progn
(sit-for 2)
--- 2104,2110 ----
(if (and (buffer-file-name) writing-same-file)
(set-visited-file-modtime))
;; prevent loss of data if saving part of the buffer in visited file
! (or writing-whole-file
(not writing-same-file)
(progn
(sit-for 2)
***************
*** 2115,2121 ****
(save-buffers-kill-emacs)
(kill-buffer (current-buffer))))
)))
!
(defun ex-write-info (exists file-name beg end)
(message "`%s'%s %d lines, %d characters"
--- 2115,2121 ----
(save-buffers-kill-emacs)
(kill-buffer (current-buffer))))
)))
!
(defun ex-write-info (exists file-name beg end)
(message "`%s'%s %d lines, %d characters"
***************
*** 2155,2161 ****
(defun ex-command ()
(let (command)
(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")
(setq command (buffer-substring (point) (point-max)))
--- 2155,2161 ----
(defun ex-command ()
(let (command)
(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")
(setq command (buffer-substring (point) (point-max)))
***************
*** 2262,2268 ****
(with-output-to-temp-buffer " *viper-info*"
(princ (if viper-auto-indent
"autoindent (local)\n" "noautoindent (local)\n"))
! (princ (if (default-value 'viper-auto-indent)
"autoindent (global) \n" "noautoindent (global) \n"))
(princ (if viper-case-fold-search "ignorecase\n" "noignorecase\n"))
(princ (if viper-re-search "magic\n" "nomagic\n"))
--- 2262,2268 ----
(with-output-to-temp-buffer " *viper-info*"
(princ (if viper-auto-indent
"autoindent (local)\n" "noautoindent (local)\n"))
! (princ (if (default-value 'viper-auto-indent)
"autoindent (global) \n" "noautoindent (global) \n"))
(princ (if viper-case-fold-search "ignorecase\n" "noignorecase\n"))
(princ (if viper-re-search "magic\n" "nomagic\n"))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] Changes to emacs/lisp/emulation/viper-ex.el,
Juanma Barranquero <=