;ELC ;;; compiled by jwz@thalidomide on Thu Mar 24 13:25:44 1994 ;;; from file /th/jwz/emacs19/lisp/prim/replace.el ;;; emacs version 19.10 Lucid (beta9). ;;; bytecomp version 2.22; 22-dec-93. ;;; optimization is on. ;;; this file uses opcodes which do not exist in Emacs 18. (if (and (boundp 'emacs-version) (or (and (boundp 'epoch::version) epoch::version) (string-lessp emacs-version "19"))) (error "This file was compiled for Emacs 19.")) (defvar case-replace t "\ *Non-nil means query-replace should preserve case in replacements.") (byte-code "!M" [boundp query-replace-history nil query-replace-read-args #[(string) "!\"%!\n#%\n \nE*" [nil to from read-from-minibuffer format gettext "%s: " string query-replace-history "%s %s with: " current-prefix-arg] 6]] 2) (fset 'query-replace #[(from-string to-string &optional arg) " \n %!!" [perform-replace from-string to-string t nil arg unread-command-event message gettext "Done"] 6 "\ Replace some occurrences of FROM-STRING with TO-STRING. As each match is found, the user must type a character saying what to do with it. For directions, type \\[help-command] at that time. Preserves case in each replacement if case-replace and case-fold-search are non-nil and FROM-STRING has no uppercase letters. Third arg DELIMITED (prefix arg if interactive) non-nil means replace only matches surrounded by word boundaries. To customize possible responses, change the \"bindings\" in `query-replace-map'." (byte-code "!!" [query-replace-read-args gettext "Query replace"] 3)]) (fset 'query-replace-regexp #[(regexp to-string &optional arg) " \nÉ % !!" [perform-replace regexp to-string t arg unread-command-event message gettext "Done"] 6 "\ Replace some things after point matching REGEXP with TO-STRING. As each match is found, the user must type a character saying what to do with it. For directions, type \\[help-command] at that time. Preserves case in each replacement if case-replace and case-fold-search are non-nil and REGEXP has no uppercase letters. Third arg DELIMITED (prefix arg if interactive) non-nil means replace only matches surrounded by word boundaries. In TO-STRING, \\& means insert what matched REGEXP, and \\=\\ means insert what matched th \\(...\\) in REGEXP." (byte-code "!!" [query-replace-read-args gettext "Query replace regexp"] 3)]) (fset 'map-query-replace-regexp #[(regexp to-strings &optional arg) "\n<\n\nGU\n\" \n\n\"OC\"\n\n\"TO] \nC\"ljR ʉ &) !!" [nil replacements to-strings 0 string-match " " append "" perform-replace regexp t arg unread-command-event message gettext "Done"] 8 "\ Replace some matches for REGEXP with various strings, in rotation. The second argument TO-STRINGS contains the replacement strings, separated by spaces. This command works like `query-replace-regexp' except that each successive replacement uses the next successive replacement string, wrapping around from the last such string to the first. Non-interactively, TO-STRINGS may be a list of replacement strings. A prefix argument N says to use each replacement string N times before rotating to the next." (byte-code "!%!\n\"%\n  E*" [nil to from read-from-minibuffer gettext "Map query replace (regexp): " query-replace-history format "Query replace %s with (space-separated strings): " current-prefix-arg] 6)]) (fset 'replace-string #[(from-string to-string &optional delimited) " \nÉ % !!" [perform-replace from-string to-string nil delimited unread-command-event message gettext "Done"] 6 "\ Replace occurrences of FROM-STRING with TO-STRING. Preserve case in each match if `case-replace' and `case-fold-search' are non-nil and FROM-STRING has no uppercase letters. Third arg DELIMITED (prefix arg if interactive) non-nil means replace only matches surrounded by word boundaries. This function is usually the wrong thing to use in a Lisp program. What you probably want is a loop like this: (while (search-forward OLD-STRING nil t) (replace-match REPLACEMENT nil t)) which will run faster and will not set the mark or print anything." (byte-code "!!" [query-replace-read-args gettext "Replace string"] 3)]) (fset 'replace-regexp #[(regexp to-string &optional delimited) " \n %!!" [perform-replace regexp to-string nil t delimited unread-command-event message gettext "Done"] 6 "\ Replace things after point matching REGEXP with TO-STRING. Preserve case in each match if case-replace and case-fold-search are non-nil and REGEXP has no uppercase letters. Third arg DELIMITED (prefix arg if interactive) non-nil means replace only matches surrounded by word boundaries. In TO-STRING, \\& means insert what matched REGEXP, and \\=\\ means insert what matched th \\(...\\) in REGEXP. This function is usually the wrong thing to use in a Lisp program. What you probably want is a loop like this: (while (re-search-forward REGEXP nil t) (replace-match REPLACEMENT nil nil)) which will run faster and will not set the mark or print anything." (byte-code "!!" [query-replace-read-args gettext "Replace regexp"] 3)]) (defvar regexp-history nil "\ History list for some commands that read regular expressions.") (define-function 'keep-lines 'delete-non-matching-lines) (fset 'delete-non-matching-lines #[(regexp) "ny`m? # d|Ɣby`) W |)y`)mMƔƕUFuA*" [1 start re-search-forward regexp nil move 0 end] 4 "\ Delete all lines except those containing matches for REGEXP. A match split across lines preserves all the lines it lies in. Applies to all lines after point." (byte-code "!É%C" [read-from-minibuffer gettext "Keep lines (containing match for regexp): " nil regexp-history] 6)]) (define-function 'flush-lines 'delete-matching-lines) (fset 'delete-matching-lines #[(regexp) "m? #Ĕby`)y`|c)" [re-search-forward regexp nil t 0 1] 4 "\ Delete lines containing matches for REGEXP. If a match is split across lines, all the lines it lies in are deleted. Applies to lines after point." (byte-code "!É%C" [read-from-minibuffer gettext "Flush lines (containing match for regexp): " nil regexp-history] 6)]) (define-function 'how-many 'count-matches) (fset 'count-matches #[(regexp) "m` #\n`Uuj Te! \"+" [0 nil opoint count re-search-forward regexp t 1 message gettext "%d occurrences"] 4 "\ Print number of matches for REGEXP following point." (byte-code "!É%C" [read-from-minibuffer gettext "How many matches for (regexp): " nil regexp-history] 6)]) (byte-code "!  \" # #!\n! ! ‡" [boundp occur-mode-map nil make-sparse-keymap set-keymap-name define-key "" occur-mode-goto-occurrence button2 occur-mouse-goto occur-buffer occur-nlines occur-pos-list] 4) (fset 'occur-mode #[nil " \n!!!!!!!" [kill-all-local-variables use-local-map occur-mode-map occur-mode major-mode gettext "Occur" mode-name make-local-variable occur-buffer occur-nlines occur-pos-list require mode-motion mode-motion-highlight-line mode-motion-hook run-hooks occur-mode-hook] 2 "\ Major mode for output from \\[occur]. Move point to one of the occurrences in this buffer, then use \\[occur-mode-goto-occurrence] to go to the same occurrence in the buffer that the occurrences were found in. \\{occur-mode-map}"]) (fset 'occur-mouse-goto #[(e) " ! " [mouse-set-point e occur-mode-goto-occurrence] 2 nil "e"]) (fset 'occur-mode-goto-occurrence #[nil "!!!yey`)\"S W Z V \\\\˥) 8 !!! !b*" [occur-buffer buffer-name nil occur-pos-list error gettext "Buffer in which occurrences were found is deleted" 0 count-lines occur-nlines 2 1 occur-number pos "No occurrence on this line" pop-to-buffer marker-position] 4 "\ Go to the line this occurrence was found in, in the buffer it was found in." nil]) (defvar list-matching-lines-default-context-lines 0 "\ *Default number of context lines to include around a `list-matching-lines' match. A negative number means to include that many lines before the match. A positive number means to include that many lines both before and after.") (defvar occur-whole-buffer nil "\ If t, occur operates on whole buffer, otherwise occur starts from point. default is nil.") (define-function 'occur 'list-matching-lines) (fset 'list-matching-lines #[(regexp &optional nlines) "!\npe  \n ye`\"T`)!q! !#c  ) =db dU{#{̔by ގ`\"\\*`̕b̔bW[y`)̕bVTyy`) \"\"\"G\"%& &`ؓq&B\n!c\n  # Z!W[&V%y&S&k,`̔̕Z\\ؓ`W\",\"\"\"\"y,T,\\)&W%y&T&k)y-cqt!G\")-" [nlines prefix-numeric-value list-matching-lines-default-context-lines t 1 make-marker final-context-start prevpos linenum buffer first occur-whole-buffer 0 count-lines gettext "*Occur*" standard-output format "Lines matching %s in buffer %s.\n" regexp buffer-name occur-mode occur-buffer occur-nlines nil occur-pos-list beginning-of-buffer re-search-forward match-data _match_data_ ((store-match-data _match_data_)) start end "%3d" tag make-string 32 empty tem zerop "--------\n" insert-buffer-substring backward-char 58 this-linenum message "%d matching lines."] 7 "\ Show all lines in the current buffer containing a match for REGEXP. If a match spreads across multiple lines, all those lines are shown. If variable `occur-whole-buffer' is non-nil, the entire buffer is searched, otherwise search begins at point. Each line is displayed with NLINES lines before and after, or -NLINES before if NLINES is negative. NLINES defaults to `list-matching-lines-default-context-lines'. Interactively it is the prefix arg. The lines are shown in a buffer named `*Occur*'. It serves as a menu to find any of the occurrences in this buffer. \\[describe-mode] in that buffer will explain how." (byte-code "@ ! \"!lj%GV *\nD" [regexp-history default read-from-minibuffer format gettext "List lines matching regexp (default `%s'): " "List lines matching regexp: " nil input 0 current-prefix-arg] 7)]) (defvar query-replace-help (purecopy "Type Space or `y' to replace one match, Delete or `n' to skip to next,\nRET or `q' to exit, Period to replace one match and exit,\nComma to replace but not move point immediately,\nC-r to enter recursive edit (\\[exit-recursive-edit] to get out again),\nC-w to delete match and recursive edit,\nC-l to clear the screen, redisplay, and offer same replacement again,\n! to replace all remaining matches with no more questions,\n^ to move point back to previous match.") "\ Help message while in query-replace") (defvar query-replace-map nil "\ Keymap that defines the responses to questions in `query-replace'. The \"bindings\" in this map are not commands; they are answers. The valid answers include `act', `skip', `act-and-show', `exit', `act-and-exit', `edit', `delete-and-edit', `recenter', `automatic', `backup', and `help'.") (byte-code " \n\"\n#\n#\n#\n#\n#\n#\n#\n#\n#\n#\n#\n#\n#\n#\n#\n#\n#\n#\n#\n#\n)\"M" [query-replace-map make-sparse-keymap map set-keymap-name define-key " " act "" skip [delete] [backspace] "y" "n" "," act-and-show [escape] exit "q" [return] "." act-and-exit "" edit "" delete-and-edit " " recenter "!" automatic "^" backup "" help "?" "" quit "" autoload isearch-highlight "isearch" perform-replace-next-event #[(event) "ÎĔĕ\"!lj*!" [isearch-highlight t aborted ((isearch-dehighlight aborted)) 0 next-command-event event nil] 3]] 4) (fset 'perform-replace #[(from-string replacements query-flag regexp-flag delimited-flag &optional repeat-count map) "  ??Ǫ ɉʉ  ; !Q m# `= ʔ= mu#˃ ! !<U\\8TG%!#T ɉ()*+*! #!!\"(!(=! $:!P!<(=ˉ*/(=@=@b=A=)=A!A)!@!A! (B=)#*) (C=)#*) (D=) #) (E=)#*%) (F=ˉ*(G=G! (H= I )! ! (J=ʔʕ| I )!) Kˉ*`)LM \"BB)T,` q." [map query-replace-map allocate-event case-fold-search case-replace from-string regexp-flag re-search-forward search-forward nil 0 t match-again lastrepl replace-count next-rotate-count stack keep-going replacement-index next-replacement real-match-data search-string search-function literal nocasify event replacements repeat-count 1 delimited-flag "\\b" regexp-quote push-mark undo-boundary match-data looking-at store-match-data query-flag replace-match (concat (format (gettext "Query replacing %s%s with %s.\n\n") (if regexp-flag (gettext "regexp ") "") from-string next-replacement) (substitute-command-keys query-replace-help)) def replaced done help-form message gettext "Query replacing %s with %s: " perform-replace-next-event lookup-key vector help "*Help*" princ format "Query replacing %s%s with %s.\n\n" "regexp " "" substitute-command-keys query-replace-help exit backup elt "No previous match" ding no-terminate sit-for act act-and-exit act-and-show automatic skip recenter edit recursive-edit delete-and-edit unread-command-event mapcar #[(elt) " ! ! " [markerp elt marker-position] 2]] 15 "\ Subroutine of `query-replace'. Its complexity handles interactive queries. Don't use this in your own program unless you want to query and set the mark just as `query-replace' does. Instead, write a simple loop like this: (while (re-search-forward \"foo[ ]+bar\" nil t) (replace-match \"foobar\" nil nil)) which will run faster and probably do exactly what you want."])