Commit ab124470 authored by Michael Kifer's avatar Michael Kifer
Browse files

*** empty log message ***

parent 34da0a2b
......@@ -285,6 +285,7 @@ reversed.")
;; A token has a type, \(command, address, end-mark\), and a value
(defun vip-get-ex-token ()
(save-window-excursion
(setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name))
(set-buffer vip-ex-work-buf)
(skip-chars-forward " \t|")
(cond ((looking-at "#")
......@@ -420,6 +421,7 @@ reversed.")
"!*")))
(save-window-excursion ;; put cursor at the end of the Ex working buffer
(setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name))
(set-buffer vip-ex-work-buf)
(goto-char (point-max)))
(cond ((vip-looking-back quit-regex1) (exit-minibuffer))
......@@ -497,8 +499,7 @@ reversed.")
map)))
(save-window-excursion
;; just a precaution
(or (vip-buffer-live-p vip-ex-work-buf)
(setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name)))
(setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name))
(set-buffer vip-ex-work-buf)
(delete-region (point-min) (point-max))
(insert com-str "\n")
......@@ -518,6 +519,8 @@ reversed.")
(t
(vip-execute-ex-command)
(save-window-excursion
(setq vip-ex-work-buf
(get-buffer-create vip-ex-work-buf-name))
(set-buffer vip-ex-work-buf)
(skip-chars-forward " \t")
(cond ((looking-at "|")
......@@ -554,6 +557,7 @@ reversed.")
;; Get a regular expression and set `ex-variant', if found
(defun vip-get-ex-pat ()
(save-window-excursion
(setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name))
(set-buffer vip-ex-work-buf)
(skip-chars-forward " \t")
(if (looking-at "!")
......@@ -590,6 +594,7 @@ reversed.")
;; get an ex command
(defun vip-get-ex-command ()
(save-window-excursion
(setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name))
(set-buffer vip-ex-work-buf)
(if (looking-at "/") (forward-char 1))
(skip-chars-forward " \t")
......@@ -605,6 +610,7 @@ reversed.")
;; Get an Ex option g or c
(defun vip-get-ex-opt-gc (c)
(save-window-excursion
(setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name))
(set-buffer vip-ex-work-buf)
(if (looking-at (format "%c" c)) (forward-char 1))
(skip-chars-forward " \t")
......@@ -716,6 +722,7 @@ reversed.")
(setq ex-count nil)
(setq ex-flag nil)
(save-window-excursion
(setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name))
(set-buffer vip-ex-work-buf)
(skip-chars-forward " \t")
(if (looking-at "[a-zA-Z]")
......@@ -741,6 +748,7 @@ reversed.")
ex-count nil
ex-flag nil)
(save-window-excursion
(setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name))
(set-buffer vip-ex-work-buf)
(skip-chars-forward " \t")
(if (looking-at "!")
......@@ -802,6 +810,7 @@ reversed.")
ex-cmdfile nil)
(save-excursion
(save-window-excursion
(setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name))
(set-buffer vip-ex-work-buf)
(skip-chars-forward " \t")
(if (looking-at "!")
......@@ -1167,12 +1176,14 @@ reversed.")
(if (null (setq file (get-file-buffer ex-file)))
(progn
(ex-find-file ex-file)
(vip-change-state-to-vi)
(or (eq major-mode 'dired-mode)
(vip-change-state-to-vi))
(goto-char (point-min)))
(switch-to-buffer file))
(if ex-offset
(progn
(save-window-excursion
(setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name))
(set-buffer vip-ex-work-buf)
(delete-region (point-min) (point-max))
(insert ex-offset "\n")
......@@ -1181,13 +1192,16 @@ reversed.")
(beginning-of-line)))
(ex-fixup-history vip-last-ex-prompt ex-file))
;; Splits the string FILESPEC into substrings separated by newlines.
;; Find-file FILESPEC if it appears to specify a single file.
;; Otherwise, assume that FILES{EC is a wildcard.
;; In this case, split it into substrings separated by newlines.
;; Each line is assumed to be a file name. find-file's each file thus obtained.
(defun ex-find-file (filespec)
(let ((nonstandard-filename-chars "[^a-zA-Z0-9_.-/,\\]"))
(if (string-match nonstandard-filename-chars filespec)
(funcall ex-nontrivial-find-file-function filespec)
(find-file filespec))
(let ((nonstandard-filename-chars "[^-a-zA-Z0-9_./,~$\\]"))
(cond ((file-exists-p filespec) (find-file filespec))
((string-match nonstandard-filename-chars filespec)
(funcall ex-nontrivial-find-file-function filespec))
(t (find-file filespec)))
))
......@@ -1241,6 +1255,7 @@ reversed.")
(forward-line -1)
(end-of-line)))))
(save-window-excursion
(setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name))
(set-buffer vip-ex-work-buf)
(setq com-str (buffer-substring (1+ (point)) (1- (point-max)))))
(while marks
......@@ -1312,6 +1327,7 @@ reversed.")
(setq ex-addresses
(cons (point) nil)))
(save-window-excursion
(setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name))
(set-buffer vip-ex-work-buf)
(skip-chars-forward " \t")
(if (looking-at "[a-z]")
......@@ -1446,6 +1462,7 @@ reversed.")
(defun ex-quit ()
;; skip "!", if it is q!. In Viper q!, w!, etc., behave as q, w, etc.
(save-excursion
(setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name))
(set-buffer vip-ex-work-buf)
(if (looking-at "!") (forward-char 1)))
(if (< vip-expert-level 3)
......@@ -1679,6 +1696,7 @@ reversed.")
;; special meaning
(defun ex-get-inline-cmd-args (regex-forw &optional chars-back replace-str)
(save-excursion
(setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name))
(set-buffer vip-ex-work-buf)
(goto-char (point-min))
(re-search-forward regex-forw nil t)
......@@ -1812,6 +1830,7 @@ Please contact your system administrator. "
(defun ex-tag ()
(let (tag)
(save-window-excursion
(setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name))
(set-buffer vip-ex-work-buf)
(skip-chars-forward " \t")
(set-mark (point))
......@@ -1945,6 +1964,7 @@ Please contact your system administrator. "
(defun ex-command ()
(let (command)
(save-window-excursion
(setq vip-ex-work-buf (get-buffer-create vip-ex-work-buf-name))
(set-buffer vip-ex-work-buf)
(skip-chars-forward " \t")
(setq command (buffer-substring (point) (point-max)))
......
......@@ -25,6 +25,18 @@
;;; Variables
(defvar vip-toggle-key "\C-z"
"The key used to change states from emacs to Vi and back.
In insert mode, this key also functions as Meta.
Must be set in .vip file or prior to loading Viper.
This setting cannot be changed interactively.")
(defvar vip-ESC-key "\e"
"Key used to ESC.
Must be set in .vip file or prior to loading Viper.
This setting cannot be changed interactively.")
;;; Keymaps
;; Keymaps for vital things like \e and C-z.
......@@ -177,6 +189,8 @@ vip-insert-basic-map. Not recommended, except for novice users.")
(if vip-xemacs-p [(shift tab)] [S-tab]) 'vip-insert-tab)
(define-key vip-insert-basic-map "\C-v" 'quoted-insert)
(define-key vip-insert-basic-map "\C-?" 'vip-del-backward-char-in-insert)
(define-key vip-insert-basic-map "\C-\\" 'vip-alternate-Meta-key)
(define-key vip-insert-basic-map vip-toggle-key 'vip-escape-to-vi)
(define-key vip-insert-basic-map "\C-c\M-p"
'vip-insert-prev-from-insertion-ring)
(define-key vip-insert-basic-map "\C-c\M-n"
......@@ -195,16 +209,15 @@ vip-insert-basic-map. Not recommended, except for novice users.")
(define-key vip-vi-basic-map "\C-^"
(function (lambda () (interactive) (vip-ex "e#"))))
(define-key vip-vi-basic-map "\C-b" 'vip-scroll-back)
(define-key vip-vi-basic-map "\C-b" 'vip-scroll-screen-back)
(define-key vip-vi-basic-map "\C-d" 'vip-scroll-up)
(define-key vip-vi-basic-map "\C-e" 'vip-scroll-up-one)
(define-key vip-vi-basic-map "\C-f" 'vip-scroll)
(define-key vip-vi-basic-map "\C-f" 'vip-scroll-screen)
(define-key vip-vi-basic-map "\C-m" 'vip-next-line-at-bol)
(define-key vip-vi-basic-map "\C-u" 'vip-scroll-down)
(define-key vip-vi-basic-map "\C-y" 'vip-scroll-down-one)
(define-key vip-vi-basic-map "\C-s" 'vip-isearch-forward)
(define-key vip-vi-basic-map "\C-r" 'vip-isearch-backward)
;(define-key vip-vi-basic-map "\C-\\" 'universal-argument)
(define-key vip-vi-basic-map "\C-c/" 'vip-toggle-search-style)
(define-key vip-vi-basic-map "\C-cg" 'vip-info-on-file)
......@@ -279,7 +292,7 @@ vip-insert-basic-map. Not recommended, except for novice users.")
(define-key vip-vi-basic-map "\\" 'vip-escape-to-emacs)
(define-key vip-vi-basic-map "[" 'vip-brac-function)
(define-key vip-vi-basic-map "]" 'vip-ket-function)
(define-key vip-vi-basic-map "_" 'vip-alternate-ESC)
(define-key vip-vi-basic-map "\C-\\" 'vip-alternate-Meta-key)
(define-key vip-vi-basic-map "^" 'vip-bol-and-skip-white)
(define-key vip-vi-basic-map "`" 'vip-goto-mark)
......@@ -321,9 +334,10 @@ vip-insert-basic-map. Not recommended, except for novice users.")
(define-key vip-vi-basic-map "}" 'vip-forward-paragraph)
(define-key vip-vi-basic-map "~" 'vip-toggle-case)
(define-key vip-vi-basic-map "\C-?" 'vip-backward-char)
(define-key vip-vi-basic-map "_" 'vip-nil)
;;; Escape from Emacs to Vi for one command
(global-set-key "\M-\C-z" 'vip-escape-to-vi) ;; in emacs-state
(global-set-key "\C-c\\" 'vip-escape-to-vi) ; everywhere
;;; This is vip-vi-diehard-map. Used when vip-vi-diehard-minor-mode is on.
......@@ -343,10 +357,11 @@ vip-insert-basic-map. Not recommended, except for novice users.")
(define-key vip-vi-diehard-map "\C-v" 'vip-nil)
(define-key vip-vi-diehard-map "\C-w" 'vip-nil)
(define-key vip-vi-diehard-map "@" 'vip-nil)
(define-key vip-vi-diehard-map "_" 'vip-nil)
(define-key vip-vi-diehard-map "*" 'vip-nil)
(define-key vip-vi-diehard-map "#" 'vip-nil)
(define-key vip-vi-diehard-map "\C-_" 'vip-nil)
(define-key vip-vi-diehard-map "\C-]" 'vip-nil);; This is actually tags.
(define-key vip-vi-diehard-map "\C-]" 'vip-nil) ; This is actually tags.
;;; Minibuffer keymap
......@@ -368,8 +383,23 @@ vip-insert-basic-map. Not recommended, except for novice users.")
(define-key ex-read-filename-map " " 'vip-complete-filename-or-exit)
(define-key ex-read-filename-map "!" 'vip-handle-!)
;; Some other maps
(defvar vip-slash-and-colon-map (make-sparse-keymap)
"This map redefines `/' and `:' to behave as in Vi.
Useful in some modes, such as Gnus, MH, etc.")
(define-key vip-slash-and-colon-map ":" 'vip-ex)
(define-key vip-slash-and-colon-map "/" 'vip-search-forward)
(defvar vip-comint-mode-modifier-map (make-sparse-keymap)
"This map modifies comint mode.")
(define-key vip-comint-mode-modifier-map "\C-m" 'comint-send-input)
(define-key vip-comint-mode-modifier-map "\C-d" 'comint-delchar-or-maybe-eof)
(defvar vip-dired-modifier-map (make-sparse-keymap)
"This map modifies Dired behavior.")
(define-key vip-dired-modifier-map ":" 'vip-ex)
;;; Code
......@@ -411,8 +441,8 @@ Usage:
(defun vip-zap-local-keys ()
"Unconditionally reset Viper vip-*-local-user-map's.
Rarely useful, but if u made a mistake by switching to a mode that adds
undesirable local keys, e.g., comint-mode, then this function can return
you to sanity."
undesirable local keys, e.g., comint-mode, then this function can restore
sanity."
(interactive)
(setq vip-vi-local-user-map (make-sparse-keymap)
vip-need-new-vi-local-map nil
......
......@@ -203,6 +203,15 @@ that Viper doesn't know about.")
(cdr (assoc 'cursor-color (frame-parameters)))
(color-instance-name (frame-property (selected-frame) 'cursor-color))))
(defun vip-set-face-pixmap (face pixmap)
"Set face pixmap on a monochrome display."
(if (and (vip-window-display-p) (not (vip-color-display-p)))
(condition-case nil
(set-face-background-pixmap face pixmap)
(error
(message "Pixmap not found for %S: %s" (face-name face) pixmap)
(sit-for 1)))))
;; OS/2
(cond ((eq (vip-device-type) 'pm)
......@@ -426,11 +435,11 @@ appropriately."
;; using cond in anticipation of further additions
(cond (ex-unix-type-shell-options)
))
(command (cond (vip-ms-style-os-p (format "\"ls -1 %s\"" filespec))
(t (format "ls -1 %s" filespec))))
file-list)
(command (cond (vip-ms-style-os-p (format "\"ls -1 -d %s\"" filespec))
(t (format "ls -1 -d %s" filespec))))
file-list status)
(save-excursion
(set-buffer (setq tmp-buf (get-buffer-create vip-ex-tmp-buf-name)))
(set-buffer (get-buffer-create vip-ex-tmp-buf-name))
(erase-buffer)
(setq status
(if gshell-options
......@@ -470,7 +479,7 @@ The users of Unix-type shells should be able to use
`ex-nontrivial-find-file-function'. If this doesn't work, the user may have
to write a custom function, similar to `vip-ex-nontrivial-find-file-unix'."
(save-excursion
(set-buffer (setq tmp-buf (get-buffer-create vip-ex-tmp-buf-name)))
(set-buffer (get-buffer-create vip-ex-tmp-buf-name))
(erase-buffer)
(insert filespec)
(goto-char (point-min))
......@@ -508,7 +517,7 @@ to write a custom function, similar to `vip-ex-nontrivial-find-file-unix'."
;; convert MS-DOS wildcards to regexp
(defun vip-wildcard-to-regexp (wcard)
(save-excursion
(set-buffer (setq tmp-buf (get-buffer-create vip-ex-tmp-buf-name)))
(set-buffer (get-buffer-create vip-ex-tmp-buf-name))
(erase-buffer)
(insert wcard)
(goto-char (point-min))
......@@ -744,6 +753,7 @@ to write a custom function, similar to `vip-ex-nontrivial-find-file-unix'."
(sit-for 2)
(vip-overlay-put vip-search-overlay 'face nil))))
;; Replace state
(defsubst vip-move-replace-overlay (beg end)
......@@ -1136,9 +1146,8 @@ Vi.")
Usually contains ` ', linefeed, TAB or formfeed.")
(defun vip-update-alphanumeric-class ()
"Set the syntactic class of Viper alphanumeric symbols according to
the variable `vip-ALPHA-char-class'. Should be called in order for changes to
`vip-ALPHA-char-class' to take effect."
"Set the syntax class of Viper alphanumerals according to `vip-syntax-preference'.
Must be called in order for changes to `vip-syntax-preference' to take effect."
(interactive)
(setq-default
vip-ALPHA-char-class
......
......@@ -821,13 +821,7 @@ These buffers can be cycled through via :R and :P commands.")
(defvar vip-always t
"t means, arrange that vi-state will be a default.")
(defvar vip-custom-file-name (cond (vip-vms-os-p "sys$login:.vip")
((memq system-type '(emx ms-dos))
"/_vip")
((memq system-type '(windows-nt windows-95))
"~/_vip")
(t ; Unix
"~/.vip"))
(defvar vip-custom-file-name (convert-standard-filename "~/.vip")
"Viper customisation file.
This variable must be set _before_ loading Viper.")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment