A match split across lines preserves all the lines it lies in.
Applies to all lines after point."
(interactive (list (read-from-minibuffer
- "sKeep lines (containing match for regexp): "
+ "Keep lines (containing match for regexp): "
nil nil nil 'regexp-history)))
(save-excursion
(or (bolp) (forward-line 1))
If a match is split across lines, all the lines it lies in are deleted.
Applies to lines after point."
(interactive (list (read-from-minibuffer
- "sFlush lines (containing match for regexp): "
+ "Flush lines (containing match for regexp): "
nil nil nil 'regexp-history)))
(save-excursion
(while (and (not (eobp))
(defun how-many (regexp)
"Print number of matches for REGEXP following point."
(interactive (list (read-from-minibuffer
- "sHow many matches for (regexp): "
+ "How many matches for (regexp): "
nil nil nil 'regexp-history)))
(let ((count 0) opoint)
(save-excursion
(setq mode-name "Occur")
(make-local-variable 'occur-buffer)
(make-local-variable 'occur-nlines)
- (make-local-variable 'occur-pos-list))
+ (make-local-variable 'occur-pos-list)
+ (run-hooks 'occur-mode-hook))
(defun occur-mode-goto-occurrence ()
"Go to the line this occurrence was found in, in the buffer it was found in."
(+ 2 (* 2 occur-nlines)))
(t 1)))))
(pos (nth occur-number occur-pos-list)))
+ (or pos
+ (error "No occurrence on this line"))
(pop-to-buffer occur-buffer)
(goto-char (marker-position pos))))
\f
(interactive (list (let* ((default (car regexp-history))
(input
(read-from-minibuffer
- (format "List lines matching regexp (default `%s'): " default)
+ (if default
+ (format "List lines matching regexp (default `%s'): " default)
+ "List lines matching regexp: ")
nil nil nil
'regexp-history)))
(if (> (length input) 0) input
;; to make that display both SPC and Y.
(defconst query-replace-help
"Type Space or `y' to replace one match, Delete or `n' to skip to next,
-ESC or `q' to exit, Period to replace one match and exit,
+RET or `q' to exit, Period to replace one match and exit,
Comma to replace but not move point immediately,
C-r to enter recursive edit (\\[exit-recursive-edit] to get out again),
C-w to delete match and recursive edit,
(define-key query-replace-map "y" 'act)
(define-key query-replace-map "n" 'skip)
(define-key query-replace-map "," 'act-and-show)
-(define-key query-replace-map "\e" 'exit)
(define-key query-replace-map "q" 'exit)
+(define-key query-replace-map "\r" 'exit)
+(define-key query-replace-map [return] 'exit)
(define-key query-replace-map "." 'act-and-exit)
(define-key query-replace-map "\C-r" 'edit)
(define-key query-replace-map "\C-w" 'delete-and-edit)
;; Loop reading commands until one of them sets done,
;; which means it has finished handling this occurrence.
(while (not done)
- (message "Query replacing %s with %s: "
+ (message (substitute-command-keys
+ "Query replacing %s with %s: (\\<query-replace-map>\\[help] for help) ")
from-string next-replacement)
(setq key (read-event))
(setq key (vector key))