* region around search hit
@ 2006-07-21 14:06 Drew Adams
0 siblings, 0 replies; 3+ messages in thread
From: Drew Adams @ 2006-07-21 14:06 UTC (permalink / raw)
This could be programmed, but I'm wondering if there is already a quick way
to do this: set the region around the last search occurrence, when isearch
is exited. Likewise, for query-replace (even if exited with C-g).
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: region around search hit
[not found] <mailman.4326.1153642952.9609.help-gnu-emacs@gnu.org>
@ 2006-07-23 19:20 ` Andreas Roehler
2006-07-26 12:16 ` Andreas Roehler
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Roehler @ 2006-07-23 19:20 UTC (permalink / raw)
Drew Adams wrote:
> This could be programmed, but I'm wondering if there is already
> a quick way to do this: set the region around the last search
> occurrence, when isearch is exited. Likewise, for query-replace
> (even if exited with C-g).
No solution, just some ideas:
in isearch.el, (defun isearch-search, starting with
line 2009, positions `match-beginning' and `match-end'
exist.
(setq isearch-success
(funcall
(isearch-search-fun)
isearch-string nil t))
;; Clear RETRY unless we matched some invisible text
;; and we aren't supposed to do that.
(if (or (eq search-invisible t)
(not isearch-success)
(bobp) (eobp)
(= (match-beginning 0) (match-end 0))
Maybe you could some (push-mark) and (point) constructs
insert here and/or store positions.
__
Andreas Roehler
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: region around search hit
[not found] <mailman.4326.1153642952.9609.help-gnu-emacs@gnu.org>
2006-07-23 19:20 ` Andreas Roehler
@ 2006-07-26 12:16 ` Andreas Roehler
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Roehler @ 2006-07-26 12:16 UTC (permalink / raw)
Drew Adams wrote:
> This could be programmed, but I'm wondering if there is already
> a quick way to do this: set the region around the last search
> occurrence, when isearch is exited. Likewise, for query-replace
> (even if exited with C-g).
;; works so far with isearch-forward
;; you have to customize `isearch-set-region' to t
before it takes effect
;; with isearch-backward isearch-pos-to-region still doesn't work that way
(defcustom isearch-set-region nil
"If the region around the last search occurrence, when isearch is exited, should be set"
:type 'boolean
:group 'isearch)
(defun isearch-pos-to-region ()
"Set the region with beginning- and end-positions of the last isearch-string found"
(interactive)
(when isearch-set-region
(goto-char (- isearch-success (length isearch-string)))
(transient-mark-mode t)
(push-mark)
(goto-char isearch-success)))
;; isearch-mode-end-hook
(defun isearch-exit ()
"Exit search normally.
However, if this is the first command after starting incremental
search and `search-nonincremental-instead' is non-nil, do a
nonincremental search instead via `isearch-edit-string'."
(interactive)
(if (and search-nonincremental-instead
(= 0 (length isearch-string)))
(let ((isearch-nonincremental t))
(isearch-edit-string)))
(isearch-done)
(isearch-clean-overlays)
;; 2006-07-26 a.roehler@web.de changed section start
(isearch-pos-to-region)
) ;; 2006-07-26 a.roehler@web.de changed section end
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-07-26 12:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-21 14:06 region around search hit Drew Adams
[not found] <mailman.4326.1153642952.9609.help-gnu-emacs@gnu.org>
2006-07-23 19:20 ` Andreas Roehler
2006-07-26 12:16 ` Andreas Roehler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).