Mercurial > emacs
comparison lisp/emulation/viper-ex.el @ 20206:f44ff2c52fac
new version
author | Michael Kifer <kifer@cs.stonybrook.edu> |
---|---|
date | Sat, 01 Nov 1997 01:46:51 +0000 |
parents | 9bc6a4017c8c |
children | 4327dd36b71b |
comparison
equal
deleted
inserted
replaced
20205:cdaddfc03fe8 | 20206:f44ff2c52fac |
---|---|
193 (defvar ex-append nil) | 193 (defvar ex-append nil) |
194 | 194 |
195 ;; File containing the shell command to be executed at Ex prompt, | 195 ;; File containing the shell command to be executed at Ex prompt, |
196 ;; e.g., :r !date | 196 ;; e.g., :r !date |
197 (defvar ex-cmdfile nil) | 197 (defvar ex-cmdfile nil) |
198 (defvar ex-cmdfile-args "") | |
198 | 199 |
199 ;; flag used in viper-ex-read-file-name to indicate that we may be reading | 200 ;; flag used in viper-ex-read-file-name to indicate that we may be reading |
200 ;; multiple file names. Used for :edit and :next | 201 ;; multiple file names. Used for :edit and :next |
201 (defvar viper-keep-reading-filename nil) | 202 (defvar viper-keep-reading-filename nil) |
202 | 203 |
455 "\\|" "[vg][ \t]*$" | 456 "\\|" "[vg][ \t]*$" |
456 "\\|" "jo.*" | 457 "\\|" "jo.*" |
457 "\\|" "^[ \t]*ta.*" | 458 "\\|" "^[ \t]*ta.*" |
458 "\\|" "^[ \t]*una.*" | 459 "\\|" "^[ \t]*una.*" |
459 "\\|" "^[ \t]*su.*" | 460 "\\|" "^[ \t]*su.*" |
460 "\\|['`][a-z][ \t]*" | 461 "\\|" "['`][a-z][ \t]*" |
462 ;; r! assumes that the next one is a shell command | |
463 "\\|" "\\(r\\|re\\|rea\\|read\\)[ \t]*!" | |
464 ;; w ! assumes that the next one is a shell command | |
465 "\\|" "\\(w\\|wr\\|wri\\|writ.?\\)[ \t]+!" | |
461 "\\|" "![ \t]*[a-zA-Z].*" | 466 "\\|" "![ \t]*[a-zA-Z].*" |
462 "\\)" | 467 "\\)" |
463 "!*"))) | 468 "!*"))) |
464 | 469 |
465 (save-window-excursion ;; put cursor at the end of the Ex working buffer | 470 (save-window-excursion ;; put cursor at the end of the Ex working buffer |
849 (end-of-line) | 854 (end-of-line) |
850 (setq ret (buffer-substring (point-min) (point))) | 855 (setq ret (buffer-substring (point-min) (point))) |
851 (message "%s" ret)) | 856 (message "%s" ret)) |
852 ret)) | 857 ret)) |
853 | 858 |
854 ;; Get a file name and set ex-variant, `ex-append' and `ex-offset' if found | 859 ;; Get a file name and set `ex-variant', `ex-append' and `ex-offset' if found |
860 ;; If it is r!, then get the command name and whatever args | |
855 (defun viper-get-ex-file () | 861 (defun viper-get-ex-file () |
856 (let (prompt) | 862 (let (prompt) |
857 (setq ex-file nil | 863 (setq ex-file nil |
858 ex-variant nil | 864 ex-variant nil |
859 ex-append nil | 865 ex-append nil |
860 ex-offset nil | 866 ex-offset nil |
861 ex-cmdfile nil) | 867 ex-cmdfile nil |
868 ex-cmdfile-args "") | |
862 (save-excursion | 869 (save-excursion |
863 (save-window-excursion | 870 (save-window-excursion |
864 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) | 871 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) |
865 (set-buffer viper-ex-work-buf) | 872 (set-buffer viper-ex-work-buf) |
866 (skip-chars-forward " \t") | 873 (skip-chars-forward " \t") |
906 ex-file) | 913 ex-file) |
907 (progn | 914 (progn |
908 ;; if file name comes from history, don't leave | 915 ;; if file name comes from history, don't leave |
909 ;; minibuffer when the user types space | 916 ;; minibuffer when the user types space |
910 (setq viper-incomplete-ex-cmd nil) | 917 (setq viper-incomplete-ex-cmd nil) |
918 (setq ex-cmdfile-args | |
919 (substring ex-file (match-end 0) nil)) | |
911 ;; this must be the last clause in this progn | 920 ;; this must be the last clause in this progn |
912 (substring ex-file (match-beginning 0) (match-end 0)) | 921 (substring ex-file (match-beginning 0) (match-end 0)) |
913 ) | 922 ) |
914 "")) | 923 "")) |
915 ;; this leaves only the command name in the work area | 924 ;; this leaves only the command name in the work area |
956 (insert "!")) | 965 (insert "!")) |
957 | 966 |
958 (defun ex-cmd-accepts-multiple-files-p (token) | 967 (defun ex-cmd-accepts-multiple-files-p (token) |
959 (member token '("edit" "next" "Next"))) | 968 (member token '("edit" "next" "Next"))) |
960 | 969 |
970 ;; Read file name from the minibuffer in an ex command. | |
961 ;; If user doesn't enter anything, then "" is returned, i.e., the | 971 ;; If user doesn't enter anything, then "" is returned, i.e., the |
962 ;; prompt-directory is not returned. | 972 ;; prompt-directory is not returned. |
963 (defun viper-ex-read-file-name (prompt) | 973 (defun viper-ex-read-file-name (prompt) |
964 (let* ((str "") | 974 (let* ((str "") |
965 (minibuffer-local-completion-map | 975 (minibuffer-local-completion-map |
1546 (if (null buffer-file-name) | 1556 (if (null buffer-file-name) |
1547 (error viper-NoFileSpecified)) | 1557 (error viper-NoFileSpecified)) |
1548 (setq ex-file buffer-file-name))) | 1558 (setq ex-file buffer-file-name))) |
1549 (if ex-cmdfile | 1559 (if ex-cmdfile |
1550 (progn | 1560 (progn |
1551 (setq command (ex-expand-filsyms ex-file (current-buffer))) | 1561 (setq command |
1562 (concat (ex-expand-filsyms ex-file (current-buffer)) | |
1563 ex-cmdfile-args)) | |
1552 (shell-command command t)) | 1564 (shell-command command t)) |
1553 (insert-file-contents ex-file))) | 1565 (insert-file-contents ex-file))) |
1554 (ex-fixup-history viper-last-ex-prompt ex-file)) | 1566 (ex-fixup-history viper-last-ex-prompt ex-file ex-cmdfile-args)) |
1555 | 1567 |
1556 ;; this function fixes ex-history for some commands like ex-read, ex-edit | 1568 ;; this function fixes ex-history for some commands like ex-read, ex-edit |
1557 (defun ex-fixup-history (&rest args) | 1569 (defun ex-fixup-history (&rest args) |
1558 (setq viper-ex-history | 1570 (setq viper-ex-history |
1559 (cons (mapconcat 'identity args " ") (cdr viper-ex-history)))) | 1571 (cons (mapconcat 'identity args " ") (cdr viper-ex-history)))) |
1933 file-exists writing-whole-file) | 1945 file-exists writing-whole-file) |
1934 (if (> beg end) (error viper-FirstAddrExceedsSecond)) | 1946 (if (> beg end) (error viper-FirstAddrExceedsSecond)) |
1935 (if ex-cmdfile | 1947 (if ex-cmdfile |
1936 (progn | 1948 (progn |
1937 (viper-enlarge-region beg end) | 1949 (viper-enlarge-region beg end) |
1938 (shell-command-on-region (point) (mark t) ex-file)) | 1950 (shell-command-on-region (point) (mark t) |
1951 (concat ex-file ex-cmdfile-args))) | |
1939 (if (and (string= ex-file "") (not (buffer-file-name))) | 1952 (if (and (string= ex-file "") (not (buffer-file-name))) |
1940 (setq ex-file | 1953 (setq ex-file |
1941 (read-file-name | 1954 (read-file-name |
1942 (format "Buffer %s isn't visiting any file. File to save in: " | 1955 (format "Buffer %s isn't visiting any file. File to save in: " |
1943 (buffer-name))))) | 1956 (buffer-name))))) |