• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/emacs-93/emacs/lisp/emulation/

Lines Matching +defs:substitute +defs:in +defs:file +defs:name

8 ;; This file is part of GNU Emacs.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
32 (defvar read-file-name-map)
40 (defvar viper-custom-file-name)
42 (defvar explicit-shell-file-name)
45 ;; loading happens only in non-interactive compilation
46 ;; in order to spare non-viperized emacs from being viperized
49 (let ((load-path (cons (expand-file-name ".") load-path)))
70 (defconst viper-ex-work-buf-name " *ex-working-space*")
71 (defvar viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
72 (defconst viper-ex-tmp-buf-name " *ex-tmp*")
73 (defconst viper-ex-print-buf-name " *ex-print*")
74 (defvar viper-ex-print-buf (get-buffer-create viper-ex-print-buf-name))
79 (defun ex-cmd-obsolete (name)
80 (error "`%s': Obsolete command, not supported by Viper" name))
82 (defun ex-cmd-not-yet (name)
83 (error "`%s': Command not implemented in Viper" name))
85 ;; alist entries: name (in any order), command, cont(??)
91 ;; the name gets appended as an argument for the command
95 ("&" (ex-substitute t))
122 ("file" (ex-set-visited-file-name))
148 ("s" "substitute")
149 ("su" "substitute")
150 ("sub" "substitute")
155 ("sr" (ex-substitute t t))
157 ("substitute" (ex-substitute) is-mashed)
175 ("~" (ex-substitute t t))
190 ;; No code should touch anything in the alist entry! (other than the name,
209 ;; If this is a one-letter magic command, splice in args.
210 (defun ex-splice-args-in-1-letr-cmd (key list)
221 ;; Tries to complete the key before using it in the alist.
228 ((stringp entry) (or (ex-splice-args-in-1-letr-cmd key list)
230 ((eq entry nil) (ex-splice-args-in-1-letr-cmd key list))
270 ;; controls are dead weight. We keep it just in case this might be
271 ;; needed in the future.
288 ;; Save reg-exp used in substitute.
292 ;; Replace pattern for substitute.
300 (and (stringp shell-file-name)
314 shell-file-name)))
322 (cond ((string-match "\\(csh$\\|csh.exe$\\)" shell-file-name)
324 ((string-match "\\(bash$\\|bash.exe$\\)" shell-file-name)
344 "Expand the file spec containing wildcard symbols.
358 ;; file used by Ex commands like :r, :w, :n
359 (defvar ex-file nil)
375 ;; flag used in viper-ex-read-file-name to indicate that we may be reading
376 ;; multiple file names. Used for :edit and :next
380 "*If t, :n and :b cycles through files and buffers in other window.
381 Then :N and :B cycles in the current window. If nil, this behavior is
387 "*Cycle through *scratch* and other buffers that don't visit any file."
394 ;; Indicates if Minibuffer was exited temporarily in Ex-command.
418 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
549 ;; don't jump up in :s command
562 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
583 ;; Preceding characters are not the ones allowed in an Ex command
584 ;; or we have typed past command name.
593 ;; Preceding chars may be part of a command name
667 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
689 (get-buffer-create viper-ex-work-buf-name))
729 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
749 ;; the use of eobp instead of eolp permits the use of newlines in
750 ;; pat2 in s/pat1/pat2/
775 ;; specified in variable c
787 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
825 (error "Address expected in this Ex command")))
898 ;; Get a buffer name and set `ex-count' and `ex-flag' if found
904 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
930 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
953 ;; Expand \% and \# in ex command
958 (setq cf buffer-file-name)
959 (setq pf (ex-next nil t))) ; this finds alternative file name
961 (error "No current file to substitute for `%%'"))
963 (error "No alternate file to substitute for `#'"))
965 (set-buffer (get-buffer-create viper-ex-tmp-buf-name))
983 ;; Get a file name and set `ex-variant', `ex-append' and `ex-offset' if found
984 ;; If it is r!, then get the command name and whatever args
985 (defun viper-get-ex-file ()
987 (setq ex-file nil
995 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
1025 ;; this takes care of :r, :w, etc., when they get file names
1029 (setq ex-file (buffer-substring (point) (1- (point-max))))
1030 (setq ex-file
1037 ex-file)
1039 ;; if file name comes from history, don't leave
1043 (substring ex-file (match-end 0) nil))
1044 ;; this must be the last clause in this progn
1045 (substring ex-file (match-beginning 0) (match-end 0))
1048 ;; this leaves only the command name in the work area
1049 ;; file names are gone
1061 (setq ex-file (viper-ex-read-file-name (format ":%s " prompt)))
1062 ;; file was typed in-line
1063 (setq ex-file (or ex-file "")))
1067 ;; Completes file name or exits minibuffer. If Ex command accepts multiple
1068 ;; file names, arranges to re-enter the minibuffer.
1086 (buffer-string) (viper-abbreviate-file-name default-directory))
1094 ;; Read file name from the minibuffer in an ex command.
1097 (defun viper-ex-read-file-name (prompt)
1106 read-file-name-map))
1111 val (read-file-name (concat prompt str) nil default-directory))
1112 (setq val (expand-file-name val))
1120 ;; viper-keep-reading-filename is set in the anonymous function that is
1121 ;; bound to " " in ex-read-filename-map.
1143 (let ((f (buffer-file-name b)))
1146 (let ((s (buffer-name b)))
1158 (file-count 1))
1161 (setq args (format "%s %d) %s\n" args file-count (car l))
1162 file-count (1+ file-count)))
1169 (princ "\n\nThese files are not displayed in any window.\n")
1179 (viper-get-ex-file)
1180 (if (string= ex-file "")
1181 (setq ex-file "~"))
1182 (setq default-directory (file-name-as-directory (expand-file-name ex-file))))
1255 ;; This command can take multiple file names. It replaces the current buffer
1256 ;; with the first file in its argument list
1257 (defun ex-edit (&optional file)
1258 (if (not file)
1259 (viper-get-ex-file))
1260 (cond ((and (string= ex-file "") buffer-file-name)
1261 (setq ex-file (viper-abbreviate-file-name (buffer-file-name))))
1262 ((string= ex-file "")
1266 (if buffer-file-name
1270 (buffer-name))
1272 ((not (verify-visited-file-modtime (current-buffer)))
1275 buffer-file-name)
1284 (message "Buffer %s was left intact" (buffer-name))))
1287 (if (null (setq file (get-file-buffer ex-file)))
1290 (ex-find-file
1291 ;; replace # and % with the previous/current file
1292 (ex-expand-filsyms ex-file (current-buffer)))
1296 (switch-to-buffer file))
1300 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
1307 (ex-fixup-history viper-last-ex-prompt ex-file))
1309 ;; Find-file FILESPEC if it appears to specify a single file.
1312 ;; Each line is assumed to be a file name.
1313 (defun ex-find-file (filespec)
1315 (cond ((file-exists-p filespec) (find-file filespec))
1317 (mapcar 'find-file (funcall viper-glob-function filespec)))
1318 (t (find-file filespec)))
1323 ;; This is executed in response to:
1383 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
1452 ;; If name is omitted, get the name straight from the work buffer."
1453 (defun ex-mark (&optional name)
1458 (if name
1459 (if (eq 1 (length name))
1460 (setq char (string-to-char name))
1461 (error "`%s': Spurious text \"%s\" after mark name"
1462 name (substring name 1)))
1464 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
1481 ;; Alternate file is the file next to the first one in the buffer ring
1482 (defun ex-next (cycle-other-window &optional find-alt-file)
1485 (if (not find-alt-file)
1487 (viper-get-ex-file)
1489 (and (not (string= "" ex-file))
1490 (not (string-match "^[0-9]+$" ex-file))))
1494 (setq count (string-to-number ex-file))
1505 (if find-alt-file (car l)
1507 (if (and (car l) (get-file-buffer (car l)))
1511 (set-window-buffer w (get-file-buffer (car l)))
1513 ;; this puts "next <count>" in the ex-command history
1514 (ex-fixup-history viper-last-ex-prompt ex-file))
1522 (let ((file-or-buffer-name
1532 (or (stringp file-or-buffer-name)
1534 "File and buffer names must be strings, %S" file-or-buffer-name))
1536 (setq buf (cond ((get-buffer file-or-buffer-name))
1537 ((file-exists-p file-or-buffer-name)
1538 (find-file-noselect file-or-buffer-name))
1542 (error "Didn't find buffer %S or file %S"
1543 file-or-buffer-name
1544 (viper-abbreviate-file-name
1545 (expand-file-name file-or-buffer-name))))
1599 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
1608 ;; ex-read doesn't support wildcards, because file completion is a better
1609 ;; mechanism. We also don't support # and % (except in :r <shell-command>
1610 ;; because file history is a better mechanism.
1612 (viper-get-ex-file)
1618 (if (and (not ex-variant) (string= ex-file ""))
1620 (if (null buffer-file-name)
1622 (setq ex-file buffer-file-name)))
1626 ;; replace # and % with the previous/current file
1628 (concat (shell-quote-argument ex-file) ex-cmdfile-args)
1631 (insert-file-contents ex-file)))
1632 (ex-fixup-history viper-last-ex-prompt ex-file ex-cmdfile-args))
1640 ;; Ex recover from emacs \#file\#
1642 (viper-get-ex-file)
1645 (if (string= ex-file "")
1647 (if (null buffer-file-name)
1648 (error "This buffer isn't visiting any file"))
1649 (setq ex-file buffer-file-name))
1650 (setq ex-file (expand-file-name ex-file)))
1651 (if (and (not (string= ex-file (buffer-file-name)))
1655 (recover-file ex-file))
1663 ;; read variable name for ex-set
1667 (cursor-in-echo-area t)
1754 (let ((cursor-in-echo-area t))
1777 ;; make it take effect in curr buff and new bufs
1786 ;; make it take effect in curr buff and new bufs
1792 (setq var "explicit-shell-file-name"
1804 (y-or-n-p (format "Do you want to save this setting in %s "
1805 viper-custom-file-name)))
1807 (viper-save-string-in-file
1808 actual-lisp-cmd viper-custom-file-name
1813 (viper-save-string-in-file
1817 viper-custom-file-name
1819 (viper-save-string-in-file
1820 nil viper-custom-file-name delete-turn-on-auto-fill-pattern)
1821 (viper-save-string-in-file
1822 nil viper-custom-file-name
1848 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
1860 ;; in Ex commands
1884 The Info file for Viper does not seem to be installed.
1886 This file is part of the standard distribution of %sEmacs.
1891 ;; Ex source command. Loads the file specified as argument or `~/.viper'
1893 (viper-get-ex-file)
1894 (if (string= ex-file "")
1895 (load viper-custom-file-name)
1896 (load ex-file)))
1898 ;; Ex substitute command
1900 (defun ex-substitute (&optional repeat r-flag)
1911 (error "No previous pattern to use in substitution"))
1949 ;; This move allows the use of newline as the last character in
1998 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
2017 ;; ex-write doesn't support wildcards, because file completion is a better
2019 ;; because file history is a better mechanism.
2022 (viper-get-ex-file)
2026 ;;(orig-buf-file-name (buffer-file-name))
2027 ;;(orig-buf-name (buffer-name))
2029 temp-buf writing-same-file region
2030 file-exists writing-whole-file)
2036 (concat ex-file ex-cmdfile-args)))
2037 (if (and (string= ex-file "") (not (buffer-file-name)))
2038 (setq ex-file
2039 (read-file-name
2040 (format "Buffer %s isn't visiting any file. File to save in: "
2041 (buffer-name)))))
2043 (setq writing-whole-file (and (= (point-min) beg) (= (point-max) end))
2044 ex-file (if (string= ex-file "")
2045 (buffer-file-name)
2046 (expand-file-name ex-file)))
2047 ;; if ex-file is a directory use the file portion of the buffer file name
2048 (if (and (file-directory-p ex-file)
2049 buffer-file-name
2050 (not (file-directory-p buffer-file-name)))
2051 (setq ex-file
2052 (concat (file-name-as-directory ex-file)
2053 (file-name-nondirectory buffer-file-name))))
2055 (setq file-exists (file-exists-p ex-file)
2056 writing-same-file (string= ex-file (buffer-file-name)))
2059 (if (and writing-whole-file writing-same-file)
2060 ;; saving whole buffer in visited file
2067 (ex-write-info file-exists ex-file (point-min) (point-max))
2069 ;; writing to non-visited file and it already exists
2070 (if (and file-exists (not writing-same-file)
2072 (format "File %s exists. Overwrite? " ex-file))))
2074 ;; writing a region or whole buffer to non-visited file
2083 (set-visited-file-name ex-file) ; xemacs
2084 (set-visited-file-name ex-file 'noquerry) ; emacs
2087 (if (and file-exists ex-append)
2088 (insert-file-contents ex-file))
2096 file-exists ex-file (point-min) (point-max))
2099 ;; temp-buf will be deleted in case of an error
2105 ;; set the right file modification time
2106 (if (and (buffer-file-name) writing-same-file)
2107 (set-visited-file-modtime))
2108 ;; prevent loss of data if saving part of the buffer in visited file
2109 (or writing-whole-file
2110 (not writing-same-file)
2122 (defun ex-write-info (exists file-name beg end)
2124 (viper-abbreviate-file-name file-name)
2125 (if exists "" " [New file]")
2160 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
2165 ;; replace # and % with the previous/current file
2190 (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
2214 ;; Give information on the file visited by the current buffer
2215 (defun viper-info-on-file ()
2219 lines file info)
2221 file (if (buffer-file-name)
2222 (concat (viper-abbreviate-file-name (buffer-file-name)) ":")
2223 (concat (buffer-name) " [Not visiting any file]:"))
2232 (if (< (+ 1 (length info) (length file))
2234 (message "%s" (concat file " " info))
2237 (princ (concat "\n" file "\n\n\t" info "\n\n")))
2244 ;; Without arguments displays info on file. With an arg, sets the visited file
2245 ;; name to that arg
2246 (defun ex-set-visited-file-name ()
2247 (viper-get-ex-file)
2248 (if (string= ex-file "")
2249 (viper-info-on-file)
2250 ;; If ex-file is a directory, use the file portion of the buffer
2251 ;; file name (like ex-write). Do this even if ex-file is a
2252 ;; non-existent directory, since set-visited-file-name signals an
2254 (if (and (string= (file-name-nondirectory ex-file) "")
2255 buffer-file-name
2256 (not (file-directory-p buffer-file-name)))
2257 (setq ex-file (concat (file-name-as-directory ex-file)
2258 (file-name-nondirectory buffer-file-name))))
2259 (set-visited-file-name ex-file)))
2281 (princ (format "shell \t\t\t= %S\n" (if (boundp 'explicit-shell-file-name)
2282 explicit-shell-file-name
2295 ;; print in viper-ex-print-buf.