unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Tomas Nordin <tomasn@posteo.net>
To: Jean-Christophe Helary <jean.christophe.helary@gmail.com>,
	Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>
Subject: Re: killing the result of isearch
Date: Sun, 12 Nov 2017 21:02:05 +0100	[thread overview]
Message-ID: <87wp2vw9j6.fsf@fliptop> (raw)
In-Reply-To: <8EEDAF80-5CD1-4BEE-8DB2-262BEDA7C829@gmail.com>

Jean-Christophe Helary <jean.christophe.helary@gmail.com> writes:

>> On Nov 8, 2017, at 2:53, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> 
>> Many Emacs users rely on isearch for navigation, in which case the above could prove annoying.  Also, currently isearch pushes a mark at the position where you started the search
>
> Thank you, that confirms my understanding. I've been using it with that purpose a number of times and it is very practical, but the fact that it does not give access by default to the match makes it more a navigation (find location) function than something to actually use the match.

As an exercise I wrote this. Can you try it. I think it behaves the way
you expect sort of.

(defun tn-frozen-search (arg &optional start-point)
  "Search forward for a preloaded frozen term.

With a prefix argument prompt for a search term (a regular
expression). With no prefix argument, use the last search from
the search-ring.

Activate the match as a region. Then, if `delete-selection-mode'
has been toggled on, one can \"just act\" on that region.

This function is for interactive use only. There will be an
overwrap with no ding."

  (interactive "P")
  (when arg
    (push (read-string "Search: ") search-ring))
  (unless start-point
    (push-mark nil t nil))
  (let ((success (re-search-forward (car search-ring) nil t)))
    (cond
     (success
      (push-mark (car (match-data)) t t))
     ((and (= (point) (point-min)) (not success))
      (if start-point
          ;; if search fail and start-point is defined, go back to start
          ;; point (recursive call)
          (goto-char start-point)
        )
      (ding)
      (message "No match for %S" (car search-ring)))
     ((not success)
      (if (not start-point)
          (setq start-point (point)))
      ;; this makes it just over-wrap with no ding
      (goto-char (point-min))
      (message "frozen search ****OVERWRAP****")
      (tn-frozen-search nil start-point)) 
     (t
      (message "semantic error in code"))))) ; hit C-x C-e

(global-set-key (kbd "<f9>") 'tn-frozen-search)

With this setup, hitting F9 will search and select the last searched
term. Hitting C-u F9 will giva a prompt for a search term.

There are room for improvement of course, but as a starting point maybe.



  reply	other threads:[~2017-11-12 20:02 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-07  2:41 killing the result of isearch Jean-Christophe Helary
2017-11-07  5:34 ` Drew Adams
2017-11-07  6:01   ` Jean-Christophe Helary
2017-11-07  6:25     ` Søren Pilgård
     [not found]     ` <mailman.3103.1510035932.27995.help-gnu-emacs@gnu.org>
2017-11-07  7:07       ` Loris Bennett
2017-11-07  7:49         ` Jean-Christophe Helary
2017-11-07  8:43         ` Jean-Christophe Helary
     [not found]         ` <mailman.3106.1510044223.27995.help-gnu-emacs@gnu.org>
2017-11-07 10:49           ` Loris Bennett
2017-11-07 12:45             ` Jean-Christophe Helary
2017-11-07 15:26               ` Drew Adams
2017-11-07 15:51                 ` Jean-Christophe Helary
2017-11-07 16:46                   ` Drew Adams
2017-11-07 22:38                     ` Jean-Christophe Helary
2017-11-07 16:53                   ` Eric Abrahamsen
2017-11-07 17:24                     ` Drew Adams
2017-11-07 17:45                       ` Eric Abrahamsen
2017-11-08  8:21               ` Thien-Thi Nguyen
2017-11-08 13:47                 ` Emanuel Berg
2017-11-11 15:36                   ` Charles A. Roelli
     [not found]             ` <mailman.3114.1510058721.27995.help-gnu-emacs@gnu.org>
2017-11-07 15:08               ` Loris Bennett
2017-11-07 15:28                 ` Jean-Christophe Helary
2017-11-07 16:24                   ` Drew Adams
2017-11-07 22:34                     ` Jean-Christophe Helary
2017-11-07 22:54                       ` Drew Adams
2017-11-08 22:24                   ` Tomas Nordin
2017-11-08 22:44                     ` Jean-Christophe Helary
2017-11-08 23:07                       ` Emanuel Berg
2017-11-09 21:38                       ` Tomas Nordin
2017-11-10 13:11                         ` Jean-Christophe Helary
2017-11-10 16:54                           ` Drew Adams
2017-11-07  8:31     ` Marcin Borkowski
2017-11-07 15:26     ` Drew Adams
2017-11-07 20:59     ` Bob Proulx
2017-11-07 22:10       ` Drew Adams
2017-11-07 22:53         ` Bob Proulx
2017-11-07 23:15       ` Jean-Christophe Helary
2017-11-08  4:27         ` Bob Proulx
2017-11-08  5:29           ` Jean-Christophe Helary
2017-11-08 18:50             ` Bob Proulx
2017-11-07 17:53 ` Stefan Monnier
2017-11-07 22:59   ` Jean-Christophe Helary
2017-11-12 20:02     ` Tomas Nordin [this message]
2017-11-12 22:13       ` Emanuel Berg
2017-11-13 21:17         ` Tomas Nordin
2017-11-13 22:13           ` Emanuel Berg
2017-11-20  3:24           ` Emanuel Berg
2017-11-15 14:48       ` Emanuel Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wp2vw9j6.fsf@fliptop \
    --to=tomasn@posteo.net \
    --cc=help-gnu-emacs@gnu.org \
    --cc=jean.christophe.helary@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).