unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Conkeror like hints for incremental search
@ 2012-01-23 17:52 Gideon Stupp
  2012-01-24  7:55 ` Tassilo Horn
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Gideon Stupp @ 2012-01-23 17:52 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 550 bytes --]

This patch adds Conkeror like hints to incremental-search's currently
matched strings.
This way it is possible to choose one of the highlighted possibilities
without completing the search string (useful when using incremental
search for navigation).
The hints can be toggled on or off at any point during the search with
isearch-toggle-hints (which is mapped to C-f by default). Note that to
save keystrokes characters are used as hints instead of just numbers.

Anyway, please review it and if there is any interest in it merge it.

Thanks, Gideon.

[-- Attachment #2: 0001-Conkeror-like-hints-for-isearch-highlight.patch --]
[-- Type: text/x-patch, Size: 12504 bytes --]

From aa12a3d6ac7e2dae9e3f25336c4f01a3507913b4 Mon Sep 17 00:00:00 2001
From: gstupp <gstupp@debian.(none)>
Date: Sun, 22 Jan 2012 17:22:40 +0200
Subject: [PATCH] Conkeror like hints for incremental search

This patch adds Conkeror like hints to incremental-search's currently matched strings.
This way it is possible to choose one of the highlighted possibilities
without completing the search string (useful when using incremental search for navigation).
The hints can be toggled on or off at any point during the search with isearch-toggle-hints (which is mapped to C-f by default).
To save keystrokes characters are used as hints instead of just numbers.

---
 lisp/isearch.el          |  138 ++++++++++++++++++++++++++++++++++++++-------
 lisp/replace.el          |    3 +-
 lisp/textmodes/ispell.el |    3 +-
 3 files changed, 120 insertions(+), 24 deletions(-)

diff --git a/lisp/isearch.el b/lisp/isearch.el
index ce75911..ffbf6de 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -315,6 +315,11 @@ A value of nil means highlight all matches."
 		 (integer :tag "Some"))
   :group 'lazy-highlight)
 
+(defcustom lazy-highlight-hint-chars (purecopy "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+  "Set of characters to use for hints."
+  :type 'string
+  :group 'lazy-highlight)
+
 (defface lazy-highlight
   '((((class color) (min-colors 88) (background light))
      (:background "paleturquoise"))
@@ -333,6 +338,22 @@ A value of nil means highlight all matches."
                                 'lazy-highlight-face
                                 "22.1")
 (defvar lazy-highlight-face 'lazy-highlight)
+
+(defface lazy-highlight-hint
+  '((((class color) (min-colors 88) (background light))
+     (:background "paleturquoise" :bold t))
+    (((class color) (min-colors 88) (background dark))
+     (:background "paleturquoise4" :bold t))
+    (((class color) (min-colors 16))
+     (:background "turquoise3" :bold t))
+    (((class color) (min-colors 8))
+     (:background "turquoise3" :bold t))
+    (t (:underline t)))
+  "Face for lazy highlighting hints."
+  :group 'lazy-highlight
+  :group 'basic-faces)
+
+(defvar hint-map (make-hash-table :test 'equal))
 \f
 ;; Define isearch help map.
 
@@ -499,6 +520,7 @@ This is like `describe-bindings', but displays only Isearch keys."
     ;; Suggest some alternates...
     (define-key map "\M-c" 'isearch-toggle-case-fold)
     (define-key map "\M-r" 'isearch-toggle-regexp)
+    (define-key map "\C-f" 'isearch-toggle-hints)
     (define-key map "\M-e" 'isearch-edit-string)
 
     (define-key map "\M-sr" 'isearch-toggle-regexp)
@@ -553,7 +575,7 @@ Each set is a vector of the form:
   "Recorded minimum/maximal point for the current search.")
 (defvar isearch-just-started nil)
 (defvar isearch-start-hscroll 0)	; hscroll when starting the search.
-
+(defvar isearch-hints nil)
 ;; case-fold-search while searching.
 ;;   either nil, t, or 'yes.  'yes means the same as t except that mixed
 ;;   case in the search string is ignored.
@@ -653,6 +675,7 @@ If you try to exit with the search string still empty, it invokes
 Type \\[isearch-toggle-case-fold] to toggle search case-sensitivity.
 Type \\[isearch-toggle-regexp] to toggle regular-expression mode.
 Type \\[isearch-toggle-word] to toggle word mode.
+Type \\[isearch-toggle-hints] to toggle hints on/off.
 Type \\[isearch-edit-string] to edit the search string in the minibuffer.
 
 Also supported is a search ring of the previous 16 search strings.
@@ -767,6 +790,7 @@ It is called by the function `isearch-forward' and other related functions."
 	isearch-adjusted nil
 	isearch-yank-flag nil
 	isearch-error nil
+	isearch-hints nil
 	isearch-slow-terminal-mode (and (<= baud-rate search-slow-speed)
 					(> (window-height)
 					   (* 4
@@ -927,7 +951,6 @@ NOPUSH is t and EDIT is t."
     (kill-local-variable 'input-method-function))
 
   (force-mode-line-update)
-
   ;; If we ended in the middle of some intangible text,
   ;; move to the further end of that intangible text.
   (let ((after (if (eobp) nil
@@ -1380,6 +1403,13 @@ Use `isearch-exit' to quit without signaling."
   (sit-for 1)
   (isearch-update))
 
+(defun isearch-toggle-hints ()
+  "Toggle hints on or off."
+  (interactive)
+  (setq isearch-hints (not isearch-hints))
+  (setq isearch-error nil)
+  (isearch-update))
+
 (defun isearch-query-replace (&optional delimited regexp-flag)
   "Start `query-replace' with string to replace from last search string.
 The arg DELIMITED (prefix arg if interactive), if non-nil, means replace
@@ -2078,9 +2108,24 @@ Isearch mode."
      (isearch-text-char-description char))))
 
 (defun isearch-process-search-string (string message)
-  (setq isearch-string (concat isearch-string string)
-	isearch-message (concat isearch-message message))
-  (isearch-search-and-update))
+  (let* ((hint-position (gethash string hint-map)))
+    (if hint-position
+	(progn
+	  (setq isearch-success t
+		isearch-error nil)
+	  (if isearch-forward
+	      (progn
+		(setq isearch-other-end (car hint-position))
+		(goto-char (cadr hint-position)))
+	    (progn
+	      (setq isearch-other-end (cadr hint-position))
+		(goto-char (car hint-position))))
+	  (isearch-done)
+	  (isearch-clean-overlays))
+      (progn
+	(setq isearch-string (concat isearch-string string)
+	    isearch-message (concat isearch-message message))
+	(isearch-search-and-update)))))
 
 \f
 ;; Search Ring
@@ -2623,6 +2668,7 @@ since they have special meaning in a regexp."
 (defvar isearch-lazy-highlight-window-end nil)
 (defvar isearch-lazy-highlight-case-fold-search nil)
 (defvar isearch-lazy-highlight-regexp nil)
+(defvar isearch-lazy-highlight-hints nil)
 (defvar isearch-lazy-highlight-space-regexp nil)
 (defvar isearch-lazy-highlight-word nil)
 (defvar isearch-lazy-highlight-forward nil)
@@ -2639,6 +2685,7 @@ is nil.  This function is called when exiting an incremental search if
         (delete-overlay (car isearch-lazy-highlight-overlays))
         (setq isearch-lazy-highlight-overlays
               (cdr isearch-lazy-highlight-overlays))))
+  (clrhash hint-map)
   (when isearch-lazy-highlight-timer
     (cancel-timer isearch-lazy-highlight-timer)
     (setq isearch-lazy-highlight-timer nil)))
@@ -2665,6 +2712,8 @@ by other Emacs features."
 			  isearch-regexp))
 		 (not (eq isearch-lazy-highlight-word
 			  isearch-word))
+		 (not (eq isearch-lazy-highlight-hints
+			  isearch-hints))
                  (not (= (window-start)
                          isearch-lazy-highlight-window-start))
                  (not (= (window-end)   ; Window may have been split/joined.
@@ -2691,6 +2740,7 @@ by other Emacs features."
 	  isearch-lazy-highlight-last-string  isearch-string
 	  isearch-lazy-highlight-case-fold-search isearch-case-fold-search
 	  isearch-lazy-highlight-regexp       isearch-regexp
+	  isearch-lazy-highlight-hints         isearch-hints
 	  isearch-lazy-highlight-space-regexp search-whitespace-regexp
 	  isearch-lazy-highlight-word         isearch-word
 	  isearch-lazy-highlight-forward      isearch-forward)
@@ -2735,10 +2785,65 @@ Attempt to do the search exactly the way the pending Isearch would."
 	success)
     (error nil)))
 
+(defvar isearch-lazy-highlight-deferred-overlays "Overlay definitions cached until presented")
+
+(defun isearch-lazy-highlight-overlay-throttled-setup ()
+"Setup the overlays and register hint action"
+(let ((max lazy-highlight-max-at-a-time)
+      (looping t))
+  (while (and looping isearch-lazy-highlight-deferred-overlays)
+    (let* ((m (pop isearch-lazy-highlight-deferred-overlays))
+	   (mb (nth 0 m))
+	   (me (nth 1 m))
+	   (hint (nth 2 m))
+	   (ov (make-overlay mb me)))
+      (if hint
+	  (progn (set-text-properties 0 1 '(face lazy-highlight-hint) hint)
+		 (overlay-put ov 'before-string hint)
+		 (puthash hint (list mb me) hint-map)
+		 ))
+      (push ov isearch-lazy-highlight-overlays)
+      ;; 1000 is higher than ediff's 100+,
+      ;; but lower than isearch main overlay's 1001
+      (overlay-put ov 'priority 1000)
+      (overlay-put ov 'face lazy-highlight-face)
+      (overlay-put ov 'window (selected-window))
+
+      (when max
+	(setq max (1- max))
+	(if (<= max 0)
+	    (setq looping nil)))))
+
+  ;; Still more work to do
+  (if isearch-lazy-highlight-deferred-overlays
+      (setq isearch-lazy-highlight-timer
+	    (run-at-time lazy-highlight-interval nil
+			 'isearch-lazy-highlight-overlay-throttled-setup)))))
+
+(defun isearch-lazy-highlight-add-hints (inlist)
+  (let ((hint-chars (mapcar 'string (append lazy-highlight-hint-chars nil)))
+	(get-following-chars-func (function (lambda (arg) (buffer-substring-no-properties (nth 1 arg) (1+ (nth 1 arg))))))
+	out mb me s tmp next-hint)
+    (if  isearch-lazy-highlight-hints
+	(progn
+	  ;; Gather all the chars immediately after our overlays and avoid using them
+	  (setq tmp (delete-dups (mapcar get-following-chars-func inlist)))
+	  ;; Filter out the chars we found from hint-chars
+	  (setq hint-chars (delq nil (mapcar '(lambda (c) (if (not (member c tmp)) c)) hint-chars)))
+	  (dolist (m inlist nil)
+	    (setq mb (car m))
+	    (setq me (cadr m))
+	    (setq s nil)
+	    (setq next-hint (buffer-substring-no-properties me (1+ me)))
+	    (setq s (pop hint-chars))
+	    (push (list mb me s) out)))
+      (setq out inlist))
+    out))
+
 (defun isearch-lazy-highlight-update ()
   "Update highlighting of other matches for current search."
-  (let ((max lazy-highlight-max-at-a-time)
-        (looping t)
+  (let ((looping t)
+	(deferred-overlays nil)
         nomore)
     (with-local-quit
       (save-selected-window
@@ -2752,10 +2857,6 @@ Attempt to do the search exactly the way the pending Isearch would."
 			 isearch-lazy-highlight-start))
 	    (while looping
 	      (let ((found (isearch-lazy-highlight-search)))
-		(when max
-		  (setq max (1- max))
-		  (if (<= max 0)
-		      (setq looping nil)))
 		(if found
 		    (let ((mb (match-beginning 0))
 			  (me (match-end 0)))
@@ -2773,13 +2874,7 @@ Attempt to do the search exactly the way the pending Isearch would."
 			      (forward-char -1)))
 
 			;; non-zero-length match
-			(let ((ov (make-overlay mb me)))
-			  (push ov isearch-lazy-highlight-overlays)
-			  ;; 1000 is higher than ediff's 100+,
-			  ;; but lower than isearch main overlay's 1001
-			  (overlay-put ov 'priority 1000)
-			  (overlay-put ov 'face lazy-highlight-face)
-			  (overlay-put ov 'window (selected-window))))
+			(push (list mb me) deferred-overlays))
 		      (if isearch-lazy-highlight-forward
 			  (setq isearch-lazy-highlight-end (point))
 			(setq isearch-lazy-highlight-start (point)))))
@@ -2798,10 +2893,9 @@ Attempt to do the search exactly the way the pending Isearch would."
 			(setq isearch-lazy-highlight-start (window-end))
 			(goto-char (min (or isearch-lazy-highlight-end-limit (point-max))
 					(window-end))))))))
-	    (unless nomore
-	      (setq isearch-lazy-highlight-timer
-		    (run-at-time lazy-highlight-interval nil
-				 'isearch-lazy-highlight-update)))))))))
+	    (setq isearch-lazy-highlight-deferred-overlays
+		      (isearch-lazy-highlight-add-hints (reverse deferred-overlays)))
+	    (isearch-lazy-highlight-overlay-throttled-setup)))))))
 
 (defun isearch-resume (string regexp word forward message case-fold)
   "Resume an incremental search.
diff --git a/lisp/replace.el b/lisp/replace.el
index cb6d7d2..610c984 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -2116,7 +2116,8 @@ make, or the user didn't cancel the call."
 	    (search-whitespace-regexp nil)
 	    (isearch-case-fold-search case-fold)
 	    (isearch-forward t)
-	    (isearch-error nil))
+	    (isearch-error nil)
+	    (isearch-hints nil))
 	;; Set isearch-word to nil because word-replace is regexp-based,
 	;; so `isearch-search-fun' should not use `word-search-forward'.
 	(if (and isearch-word isearch-regexp) (setq isearch-word nil))
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index c1fcb60..e82adfd 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -2455,7 +2455,8 @@ The variable `ispell-highlight-face' selects the face to use for highlighting."
 		  (regexp-quote (buffer-substring-no-properties start end))
 		  "\\b"))
 		(isearch-regexp t)
-		(isearch-case-fold-search nil))
+		(isearch-case-fold-search nil)
+		(isearch-hints nil))
 	    (isearch-lazy-highlight-new-loop
 	     (if (boundp 'reg-start) reg-start)
 	     (if (boundp 'reg-end)   reg-end)))
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] Conkeror like hints for incremental search
  2012-01-23 17:52 [PATCH] Conkeror like hints for incremental search Gideon Stupp
@ 2012-01-24  7:55 ` Tassilo Horn
  2012-01-24 10:09   ` gideon.stupp
  2012-01-24 11:44 ` Juanma Barranquero
  2012-01-24 22:55 ` Juri Linkov
  2 siblings, 1 reply; 12+ messages in thread
From: Tassilo Horn @ 2012-01-24  7:55 UTC (permalink / raw)
  To: Gideon Stupp; +Cc: emacs-devel

Gideon Stupp <gideon.stupp@gmail.com> writes:

Hi Gideon,

> This patch adds Conkeror like hints to incremental-search's currently
> matched strings.
> This way it is possible to choose one of the highlighted possibilities
> without completing the search string (useful when using incremental
> search for navigation).

isearch is my main navigation feature, so I've just given your patch a
try.  Here's my feedback:

  - The characters inserted in front of matches are somewhat baffling
    (First I've thought: Why do I have all those typos?!).  At least in
    X11 frames, I'd make them smaller than the usual text, maybe even
    superscript.  And it would be nice if the hint chars where appended
    to matches in forward isearch but prepended in backward isearch.
    That way, the hint char would indicate the position of point when
    selecting that match.

  - Concerning navigation speed, I don't feel that those type hints help
    me.  It might do so if the visible buffer portion contains tons of
    matches, but in my regular use, there are only ~3 matches, so
    hitting C-s or C-r repeatedly is faster for me than switching my
    finger to some other key.

  - I think C-f (and all other keys normally used for navigation) is a
    bad choice, because that's what people usually use for leaving
    isearch.  Maybe M-h would be ok.  It has some mnemonics, and its
    usual binding of `mark-paragraph' isn't too useful in isearch.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Re: [PATCH] Conkeror like hints for incremental search
  2012-01-24  7:55 ` Tassilo Horn
@ 2012-01-24 10:09   ` gideon.stupp
  2012-01-24 17:39     ` Stefan Monnier
  0 siblings, 1 reply; 12+ messages in thread
From: gideon.stupp @ 2012-01-24 10:09 UTC (permalink / raw)
  To: Tassilo Horn, Gideon Stupp; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 3014 bytes --]

Hi Tassilo, thanks for taking the time to the the patch!

On , Tassilo Horn <tassilo@member.fsf.org> wrote:
> Gideon Stupp gideon.stupp@gmail.com> writes:



> Hi Gideon,



> > This patch adds Conkeror like hints to incremental-search's currently

> > matched strings.

> > This way it is possible to choose one of the highlighted possibilities

> > without completing the search string (useful when using incremental

> > search for navigation).



> isearch is my main navigation feature, so I've just given your patch a

> try. Here's my feedback:



> - The characters inserted in front of matches are somewhat baffling

> (First I've thought: Why do I have all those typos?!). At least in

> X11 frames, I'd make them smaller than the usual text, maybe even

> superscript.

Agreed. Maybe the face should be customizable.

> And it would be nice if the hint chars where appended

> to matches in forward isearch but prepended in backward isearch.

> That way, the hint char would indicate the position of point when

> selecting that match.


Interesting. I played around with various possibilities and finally decided  
to always put the hints at the beginning because that is what Conkeror  
does. Again,
maybe it should be customizable.



> - Concerning navigation speed, I don't feel that those type hints help

> me. It might do so if the visible buffer portion contains tons of

> matches, but in my regular use, there are only ~3 matches, so

> hitting Cs or Cr repeatedly is faster for me than switching my

> finger to some other key.

As you say, the usefulness of the hints is really for those infrequent but  
annoying cases where there are more than a few matches. There are two  
typical scenarios where I find myself using them. The first one
is when I need to jump to a position on the screen that is not unique. For  
example lets say I am editing isearch.el and I see call to  
function "isearch-toggle-hints" that I want to change. Since searching  
for "isearch" is futile, I can search for "toggle", hopefully reach the  
correct line and then go back a word. But it seems easier to start the  
search with Cs Cf, type in a few characters of the prefix of "isearch" (3  
characters are usually enough) and then use the hint if necessary. The  
second even more annoying use case is when I am searching for a string that  
I believed to be unique, but turns out to have multiple hits. In this case,  
instead of cancelling the search and starting a new one I can just press Cf  
and use the hints to jump to the correct place.




> - I think Cf (and all other keys normally used for navigation) is a

> bad choice, because that's what people usually use for leaving

> isearch. Maybe Mh would be ok. It has some mnemonics, and its

> usual binding of `mark-paragraph' isn't too useful in isearch.
Understood. Still it would be nice to be able to start a hinted search  
without switching between the control key (for Cs) and the Meta key.




> Bye,

> Tassilo



Thanks again, Gideon.

[-- Attachment #2: Type: text/html, Size: 3888 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Conkeror like hints for incremental search
  2012-01-23 17:52 [PATCH] Conkeror like hints for incremental search Gideon Stupp
  2012-01-24  7:55 ` Tassilo Horn
@ 2012-01-24 11:44 ` Juanma Barranquero
  2012-01-24 22:55 ` Juri Linkov
  2 siblings, 0 replies; 12+ messages in thread
From: Juanma Barranquero @ 2012-01-24 11:44 UTC (permalink / raw)
  To: Gideon Stupp; +Cc: emacs-devel

On Mon, Jan 23, 2012 at 18:52, Gideon Stupp <gideon.stupp@gmail.com> wrote:

> Anyway, please review it and if there is any interest in it merge it.

Please send proposed patches to the bug tracker
<bug-gnu-emacs@gnu.org>, starting the message with

Package: emacs
Tags: patch

and also appropriate "Version:" and "Severity:" pseudo-headers, if required.

The file admin/notes/bugtracker contains additional information on the
use of the Emacs bug tracker.

Thanks,

    Juanma



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Conkeror like hints for incremental search
  2012-01-24 10:09   ` gideon.stupp
@ 2012-01-24 17:39     ` Stefan Monnier
  2012-01-24 18:47       ` Gideon Stupp
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2012-01-24 17:39 UTC (permalink / raw)
  To: gideon.stupp; +Cc: Tassilo Horn, emacs-devel

This looks like an interesting addition.
Could you try and refactor it as a separate package?
I guess you'd still need a few changes to isearch, so please try and
refactor it so as to modify isearch.el as little as possible and only by
adding one (or maybe two) hooks.  Hopefully those hooks can be "generic"
rather than specific to your particular extension.


        Stefan



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Conkeror like hints for incremental search
  2012-01-24 17:39     ` Stefan Monnier
@ 2012-01-24 18:47       ` Gideon Stupp
  2012-01-24 19:12         ` Stefan Monnier
  0 siblings, 1 reply; 12+ messages in thread
From: Gideon Stupp @ 2012-01-24 18:47 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Tassilo Horn, emacs-devel@gnu.org

Hi Stefan.

I need to think about it a bit to see how to do it but I will try to come up with a solution following your guidelines. 

Thanks, Gideon.

On 24 בינו 2012, at 19:39, Stefan Monnier <monnier@IRO.UMontreal.CA> wrote:

> This looks like an interesting addition.
> Could you try and refactor it as a separate package?
> I guess you'd still need a few changes to isearch, so please try and
> refactor it so as to modify isearch.el as little as possible and only by
> adding one (or maybe two) hooks.  Hopefully those hooks can be "generic"
> rather than specific to your particular extension.
> 
> 
>        Stefan



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Conkeror like hints for incremental search
  2012-01-24 18:47       ` Gideon Stupp
@ 2012-01-24 19:12         ` Stefan Monnier
  0 siblings, 0 replies; 12+ messages in thread
From: Stefan Monnier @ 2012-01-24 19:12 UTC (permalink / raw)
  To: Gideon Stupp; +Cc: Tassilo Horn, emacs-devel@gnu.org

> I need to think about it a bit to see how to do it but I will try to come up
> with a solution following your guidelines. 

Feel free to think out loud on this list ;-)


        Stefan



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Conkeror like hints for incremental search
  2012-01-23 17:52 [PATCH] Conkeror like hints for incremental search Gideon Stupp
  2012-01-24  7:55 ` Tassilo Horn
  2012-01-24 11:44 ` Juanma Barranquero
@ 2012-01-24 22:55 ` Juri Linkov
  2012-01-25 11:03   ` gideon.stupp
  2 siblings, 1 reply; 12+ messages in thread
From: Juri Linkov @ 2012-01-24 22:55 UTC (permalink / raw)
  To: Gideon Stupp; +Cc: emacs-devel

> Anyway, please review it and if there is any interest in it merge it.

Thanks for proposing a useful feature.

I suggest to implement more simple and clean design that is
based on well-known Emacs features:

1. On the next matched strings display numbers counting from 1.
   You could try doing with tooltips that will look like in Conkeror,
   (this might be too slow, but worth trying).
   This is easy to do in `isearch-lazy-highlight-update'

2. Add a new numeric argument `count' to `isearch-repeat-forward' (`C-s')
   and `isearch-repeat-backward' (`C-r').

   This would allow easy navigation with e.g. `C-8 C-s' for the 8-th match
   in forward direction.

3. For backward matches we could display negative numbers,
   and `C-s' will treat negative arguments like `C- C-8 C-s'
   as positive counts for backward search.

   Also `C-r' would treat positive arguments like `C-8 C-r' as positive
   counts in backward direction.  A negative arguments for `C-r' like
   `C- C-8 C-r' would go to the 8-th match in forward direction, naturally.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Re: [PATCH] Conkeror like hints for incremental search
  2012-01-24 22:55 ` Juri Linkov
@ 2012-01-25 11:03   ` gideon.stupp
  2012-01-25 11:29     ` Juri Linkov
  0 siblings, 1 reply; 12+ messages in thread
From: gideon.stupp @ 2012-01-25 11:03 UTC (permalink / raw)
  To: Juri Linkov, Gideon Stupp; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1230 bytes --]

Nice idea. Let me try and tweak the patch to work in this way. I want to  
test it and see how it feels.

Thanks, Gideon.

On , Juri Linkov <juri@jurta.org> wrote:
> > Anyway, please review it and if there is any interest in it merge it.



> Thanks for proposing a useful feature.



> I suggest to implement more simple and clean design that is

> based on well-known Emacs features:



> 1. On the next matched strings display numbers counting from 1.

> You could try doing with tooltips that will look like in Conkeror,

> (this might be too slow, but worth trying).

> This is easy to do in `isearch-lazy-highlight-update'



> 2. Add a new numeric argument `count' to `isearch-repeat-forward' (`Cs')

> and `isearch-repeat-backward' (`Cr').



> This would allow easy navigation with eg `C-8 Cs' for the 8-th match

> in forward direction.



> 3. For backward matches we could display negative numbers,

> and `Cs' will treat negative arguments like `C- C-8 Cs'

> as positive counts for backward search.



> Also `Cr' would treat positive arguments like `C-8 Cr' as positive

> counts in backward direction. A negative arguments for `Cr' like

> `C- C-8 Cr' would go to the 8-th match in forward direction, naturally.



[-- Attachment #2: Type: text/html, Size: 1826 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Conkeror like hints for incremental search
  2012-01-25 11:03   ` gideon.stupp
@ 2012-01-25 11:29     ` Juri Linkov
  2012-01-25 11:59       ` gideon.stupp
  0 siblings, 1 reply; 12+ messages in thread
From: Juri Linkov @ 2012-01-25 11:29 UTC (permalink / raw)
  To: gideon.stupp; +Cc: emacs-devel

> Nice idea. Let me try and tweak the patch to work in this way. I want to
> test it and see how it feels.

BTW, there is another useful search feature missing in Isearch.

In Chromium, the Search prompt displays the current search position
and the total number of matches.  It would be useful to implement this
in Isearch.  It helps to orient oneself while searching - to see
how many matches are remaining to visit with C-s, etc.

This information could be displayed in the mode-line in the usual format
that can be seen in some Emacs packages, e.g. "7/24".

The main problem is in the performance impact to count the total
number of matches.  Perhaps to not affect the responsiveness
these computations should be placed in `isearch-lazy-highlight'.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Re: [PATCH] Conkeror like hints for incremental search
  2012-01-25 11:29     ` Juri Linkov
@ 2012-01-25 11:59       ` gideon.stupp
  2012-01-25 14:00         ` Stephen J. Turnbull
  0 siblings, 1 reply; 12+ messages in thread
From: gideon.stupp @ 2012-01-25 11:59 UTC (permalink / raw)
  To: Juri Linkov, gideon.stupp; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1081 bytes --]

Chromium counts all the matches in the page, presented or hidden. For Emacs  
I don't think it is feasible to read the entire file. BTW  
isearch-lazy-highlight takes into consideration only the matches that are  
currently on screen.

Thanks, Gideon.

On , Juri Linkov <juri@jurta.org> wrote:
> > Nice idea. Let me try and tweak the patch to work in this way. I want to

> > test it and see how it feels.



> BTW, there is another useful search feature missing in Isearch.



> In Chromium, the Search prompt displays the current search position

> and the total number of matches. It would be useful to implement this

> in Isearch. It helps to orient oneself while searching - to see

> how many matches are remaining to visit with Cs, etc.



> This information could be displayed in the mode-line in the usual format

> that can be seen in some Emacs packages, eg "7/24".



> The main problem is in the performance impact to count the total

> number of matches. Perhaps to not affect the responsiveness

> these computations should be placed in `isearch-lazy-highlight'.



[-- Attachment #2: Type: text/html, Size: 1435 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Re: [PATCH] Conkeror like hints for incremental search
  2012-01-25 11:59       ` gideon.stupp
@ 2012-01-25 14:00         ` Stephen J. Turnbull
  0 siblings, 0 replies; 12+ messages in thread
From: Stephen J. Turnbull @ 2012-01-25 14:00 UTC (permalink / raw)
  To: gideon.stupp; +Cc: Juri Linkov, emacs-devel

gideon.stupp@gmail.com writes:

 > Chromium counts all the matches in the page, presented or hidden. For Emacs  
 > I don't think it is feasible to read the entire file.

For non-regexp search, in interactive use, Emacs should be plenty fast
to search and count entire files up to a few MB, and maybe an order of
magnitude or three more.  At the very least it should be tried!




^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-01-25 14:00 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-23 17:52 [PATCH] Conkeror like hints for incremental search Gideon Stupp
2012-01-24  7:55 ` Tassilo Horn
2012-01-24 10:09   ` gideon.stupp
2012-01-24 17:39     ` Stefan Monnier
2012-01-24 18:47       ` Gideon Stupp
2012-01-24 19:12         ` Stefan Monnier
2012-01-24 11:44 ` Juanma Barranquero
2012-01-24 22:55 ` Juri Linkov
2012-01-25 11:03   ` gideon.stupp
2012-01-25 11:29     ` Juri Linkov
2012-01-25 11:59       ` gideon.stupp
2012-01-25 14:00         ` Stephen J. Turnbull

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).