comparison lisp/emulation/viper-ex.el @ 38514:10482dd382e7

* 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.
author Michael Kifer <kifer@cs.stonybrook.edu>
date Sat, 21 Jul 2001 05:28:24 +0000
parents 67b464da13ec
children 8dccf2552307
comparison
equal deleted inserted replaced
38513:144b56521d1d 38514:10482dd382e7
120 ("help" (ex-help)) 120 ("help" (ex-help))
121 ("join" (ex-line "join")) 121 ("join" (ex-line "join"))
122 ("k" (ex-mark) one-letter) 122 ("k" (ex-mark) one-letter)
123 ("kmark" (ex-mark)) 123 ("kmark" (ex-mark))
124 ("m" "move") 124 ("m" "move")
125 ("make" (ex-compile))
125 ; old viper doesn't specify a default for "ma" so leave it undefined 126 ; old viper doesn't specify a default for "ma" so leave it undefined
126 ("map" (ex-map)) 127 ("map" (ex-map))
127 ("mark" (ex-mark)) 128 ("mark" (ex-mark))
128 ("move" (ex-copy t)) 129 ("move" (ex-copy t))
129 ("next" (ex-next ex-cycle-other-window)) 130 ("next" (ex-next ex-cycle-other-window))
213 ;; Returns the alist entry for the appropriate key. 214 ;; Returns the alist entry for the appropriate key.
214 ;; Tries to complete the key before using it in the alist. 215 ;; Tries to complete the key before using it in the alist.
215 ;; If there is no appropriate key (no match or duplicate matches) return nil 216 ;; If there is no appropriate key (no match or duplicate matches) return nil
216 (defun ex-cmd-assoc (key list) 217 (defun ex-cmd-assoc (key list)
217 (let ((entry (try-completion key list)) 218 (let ((entry (try-completion key list))
218 result onelet) 219 result)
219 (setq result (cond 220 (setq result (cond
220 ((eq entry t) (assoc key list)) 221 ((eq entry t) (assoc key list))
221 ((stringp entry) (or (ex-splice-args-in-1-letr-cmd key list) 222 ((stringp entry) (or (ex-splice-args-in-1-letr-cmd key list)
222 (assoc entry list))) 223 (assoc entry list)))
223 ((eq entry nil) (ex-splice-args-in-1-letr-cmd key list)) 224 ((eq entry nil) (ex-splice-args-in-1-letr-cmd key list))
316 "-noprofile") ; bash: ignore .profile 317 "-noprofile") ; bash: ignore .profile
317 ))) 318 )))
318 "Options to pass to the Unix-style shell. 319 "Options to pass to the Unix-style shell.
319 Don't put `-c' here, as it is added automatically." 320 Don't put `-c' here, as it is added automatically."
320 :type '(choice (const nil) string) 321 :type '(choice (const nil) string)
322 :group 'viper-ex)
323
324 (defcustom ex-compile-command "make"
325 "The comand to run when the user types :make."
326 :type 'string
321 :group 'viper-ex) 327 :group 'viper-ex)
322 328
323 (defcustom viper-glob-function 329 (defcustom viper-glob-function
324 (cond (ex-unix-type-shell 'viper-glob-unix-files) 330 (cond (ex-unix-type-shell 'viper-glob-unix-files)
325 ((eq system-type 'emx) 'viper-glob-mswindows-files) ; OS/2 331 ((eq system-type 'emx) 'viper-glob-mswindows-files) ; OS/2
641 ":" 647 ":"
642 initial-str 648 initial-str
643 'viper-ex-history 649 'viper-ex-history
644 ;; no default when working on region 650 ;; no default when working on region
645 (if initial-str 651 (if initial-str
646 "none" 652 nil
647 (car viper-ex-history)) 653 (car viper-ex-history))
648 map 654 map
649 (if initial-str 655 (if initial-str
650 " [Type command to execute on current region]")))) 656 " [Type command to execute on current region]"))))
651 (save-window-excursion 657 (save-window-excursion
853 (setq address (point-marker)))) 859 (setq address (point-marker))))
854 ((eq ex-token-type 'goto-mark) 860 ((eq ex-token-type 'goto-mark)
855 (save-excursion 861 (save-excursion
856 (if (null ex-token) 862 (if (null ex-token)
857 (exchange-point-and-mark) 863 (exchange-point-and-mark)
858 (goto-char (viper-register-to-point 864 (goto-char
859 (1+ (- ex-token ?a)) 'enforce-buffer))) 865 (viper-register-to-point
866 (viper-int-to-char (1+ (- ex-token ?a))) 'enforce-buffer)))
860 (setq address (point-marker))))) 867 (setq address (point-marker)))))
861 address)) 868 address))
862 869
863 870
864 ;; Search pattern and set address 871 ;; Search pattern and set address
1452 (if (not (looking-at "[\n|]")) 1459 (if (not (looking-at "[\n|]"))
1453 (error "`%s': %s" ex-token viper-SpuriousText))) 1460 (error "`%s': %s" ex-token viper-SpuriousText)))
1454 (error "`%s' requires a following letter" ex-token)))) 1461 (error "`%s' requires a following letter" ex-token))))
1455 (save-excursion 1462 (save-excursion
1456 (goto-char (car ex-addresses)) 1463 (goto-char (car ex-addresses))
1457 (point-to-register (1+ (- char ?a)))))) 1464 (point-to-register (viper-int-to-char (1+ (- char ?a)))))))
1458 1465
1459 1466
1460 1467
1461 ;; Alternate file is the file next to the first one in the buffer ring 1468 ;; Alternate file is the file next to the first one in the buffer ring
1462 (defun ex-next (cycle-other-window &optional find-alt-file) 1469 (defun ex-next (cycle-other-window &optional find-alt-file)
2157 (set-mark end) 2164 (set-mark end)
2158 (viper-enlarge-region (point) (mark t)) 2165 (viper-enlarge-region (point) (mark t))
2159 (shell-command-on-region (point) (mark t) command t)) 2166 (shell-command-on-region (point) (mark t) command t))
2160 (goto-char beg))))) 2167 (goto-char beg)))))
2161 2168
2169 (defun ex-compile ()
2170 "Reads args from the command line, then runs make with the args.
2171 If no args are given, then it runs the last compile command.
2172 Type 'mak ' (including the space) to run make with no args."
2173 (let (args)
2174 (save-window-excursion
2175 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
2176 (set-buffer viper-ex-work-buf)
2177 (setq args (buffer-substring (point) (point-max)))
2178 (end-of-line))
2179 ;; Remove the newline that may (will?) be at the end of the args
2180 (if (string= "\n" (substring args (1- (length args))))
2181 (setq args (substring args 0 (1- (length args)))))
2182 ;; Run last command if no args given, else construct a new command.
2183 (setq args
2184 (if (string= "" args)
2185 (if (boundp 'compile-command)
2186 compile-command
2187 ex-compile-command)
2188 (concat ex-compile-command " " args)))
2189 (compile args)
2190 ))
2191
2162 ;; Print line number 2192 ;; Print line number
2163 (defun ex-line-no () 2193 (defun ex-line-no ()
2164 (message "%d" 2194 (message "%d"
2165 (1+ (count-lines 2195 (1+ (count-lines
2166 (point-min) 2196 (point-min)