From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel,gmane.emacs.bugs Subject: Re: [EXPERIMENTAL PATCH] Extending Isearch-repeat-forward/backward to support a prefix argument following suggesion by Juri Linkov Date: Thu, 26 Jan 2012 19:46:07 +0100 Message-ID: <8762fyfgk0.fsf@thinkpad.tsdh.de> References: <87lioufh0t.fsf@thinkpad.tsdh.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1327603606 24943 80.91.229.12 (26 Jan 2012 18:46:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 26 Jan 2012 18:46:46 +0000 (UTC) Cc: juri@jurta.org, bug-gnu-emacs@gnu.org, emacs-devel@gnu.org To: Gideon Stupp Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 26 19:46:42 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from [140.186.70.17] (helo=lists.gnu.org) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RqULK-0004wO-2B for ged-emacs-devel@m.gmane.org; Thu, 26 Jan 2012 19:46:42 +0100 Original-Received: from localhost ([::1]:58555 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqUL6-0004Fi-V1 for ged-emacs-devel@m.gmane.org; Thu, 26 Jan 2012 13:46:28 -0500 Original-Received: from [140.186.70.92] (port=59056 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqUL2-0004F3-UJ for emacs-devel@gnu.org; Thu, 26 Jan 2012 13:46:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RqUKp-0004Cp-BI for emacs-devel@gnu.org; Thu, 26 Jan 2012 13:46:22 -0500 Original-Received: from out3-smtp.messagingengine.com ([66.111.4.27]:59410) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqUKp-0004Cg-8d for emacs-devel@gnu.org; Thu, 26 Jan 2012 13:46:11 -0500 Original-Received: from compute3.internal (compute3.nyi.mail.srv.osa [10.202.2.43]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id C017320EB0 for ; Thu, 26 Jan 2012 13:46:10 -0500 (EST) Original-Received: from frontend1.nyi.mail.srv.osa ([10.202.2.160]) by compute3.internal (MEProxy); Thu, 26 Jan 2012 13:46:10 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=from:to:cc:subject:references:date :in-reply-to:message-id:mime-version:content-type; s=smtpout; bh=+CVF31FFISg7zKiepPX74M2bntM=; b=PtpyDmtllauyqYLinKa5mSu3bpGF tn/yJlzf2xiaKAP4HWiNVmIfWqZbEgy4Jqhkgirs7eOXx0ozsBzfezT9gCnp/3mO ZRDMZZjGAjrlsoL4G8+vlKFuoF4T52Mg20IjgzUKoutFEa57NnxcXhLU+weN+6db NoT5XItbjzS/1UQ= X-Sasl-enc: 29Fks2M/MDA9jTaF29VxduXiX6MXN4pDfe85kCZXUkD+ 1327603570 Original-Received: from thinkpad.tsdh.de (91-67-11-43-dynip.superkabel.de [91.67.11.43]) by mail.messagingengine.com (Postfix) with ESMTPSA id 0FD968E0124; Thu, 26 Jan 2012 13:46:08 -0500 (EST) In-Reply-To: <87lioufh0t.fsf@thinkpad.tsdh.de> (Tassilo Horn's message of "Thu, 26 Jan 2012 19:36:02 +0100") User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.92 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.111.4.27 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:147950 gmane.emacs.bugs:56051 Archived-At: --=-=-= Content-Type: text/plain Tassilo Horn writes: >> This experimental patch implements a suggestion by Juri Linkov to >> extend isearch-repeat-forward/backward to support a prefix argument. > > I like it. I adapted it a bit to show the hints at the position where > point would be if that one's selected, and I added also a bit > superscript magic, which suits me better, visually. (Well, that should > be customizable, of course.) Ups, I forgot to attach the patch. Bye, Tassilo --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=isearchnavjuri.patch === modified file 'lisp/isearch.el' --- lisp/isearch.el 2012-01-19 07:21:25 +0000 +++ lisp/isearch.el 2012-01-26 18:32:18 +0000 @@ -333,6 +333,21 @@ '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) + ;; Define isearch help map. @@ -417,10 +432,25 @@ ;; We need these explicit definitions because, in a dense keymap, ;; the binding for t does not affect characters. ;; We use a dense keymap to save space. + (while (< i ?\s) (define-key map (make-string 1 i) 'isearch-other-control-char) (setq i (1+ i))) + ;; Bring universal-argument and friends back in + (define-key map "\C-u" 'universal-argument) + (define-key map (kbd "C--") 'negative-argument) + (define-key map (kbd "C-0") 'digit-argument) + (define-key map (kbd "C-1") 'digit-argument) + (define-key map (kbd "C-2") 'digit-argument) + (define-key map (kbd "C-3") 'digit-argument) + (define-key map (kbd "C-4") 'digit-argument) + (define-key map (kbd "C-5") 'digit-argument) + (define-key map (kbd "C-6") 'digit-argument) + (define-key map (kbd "C-7") 'digit-argument) + (define-key map (kbd "C-8") 'digit-argument) + (define-key map (kbd "C-9") 'digit-argument) + ;; Single-byte printing chars extend the search string by default. (setq i ?\s) (while (< i 256) @@ -434,7 +464,20 @@ ;; default local key binding for any key not otherwise bound. (let ((meta-map (make-sparse-keymap))) (define-key map (char-to-string meta-prefix-char) meta-map) - (define-key map [escape] meta-map)) + (define-key map [escape] meta-map) + (define-key meta-map (kbd "-") 'negative-argument) + (define-key meta-map (kbd "C--") 'negative-argument) + (define-key meta-map (kbd "C-0") 'digit-argument) + (define-key meta-map (kbd "C-1") 'digit-argument) + (define-key meta-map (kbd "C-2") 'digit-argument) + (define-key meta-map (kbd "C-3") 'digit-argument) + (define-key meta-map (kbd "C-4") 'digit-argument) + (define-key meta-map (kbd "C-5") 'digit-argument) + (define-key meta-map (kbd "C-6") 'digit-argument) + (define-key meta-map (kbd "C-7") 'digit-argument) + (define-key meta-map (kbd "C-8") 'digit-argument) + (define-key meta-map (kbd "C-9") 'digit-argument)) + (define-key map (vector meta-prefix-char t) 'isearch-other-meta-char) ;; Several non-printing chars change the searching behavior. @@ -528,6 +571,7 @@ ;; These are all set with setq while isearching ;; and bound locally while editing the search string. +(defvar isearch-hint-count 0) (defvar isearch-forward nil) ; Searching in the forward direction. (defvar isearch-regexp nil) ; Searching for a regexp. (defvar isearch-word nil) ; Searching for words. @@ -1340,15 +1384,30 @@ (isearch-push-state) (isearch-update)) -(defun isearch-repeat-forward () +(defun isearch-repeat-forward (arg) "Repeat incremental search forwards." - (interactive) - (isearch-repeat 'forward)) + (interactive "p") + (while (> arg 0) + (isearch-repeat 'forward) + (setq arg (1- arg)) + (setq isearch-hint-count (1+ isearch-hint-count))) + (while (< arg 0) + (isearch-repeat 'backward) + (setq arg (1+ arg)) + (setq isearch-hint-count (1+ isearch-hint-count))) + (isearch-update)) -(defun isearch-repeat-backward () +(defun isearch-repeat-backward (arg) "Repeat incremental search backwards." - (interactive) - (isearch-repeat 'backward)) + (interactive "p") + (while (> arg 0) + (isearch-repeat 'backward) + (setq arg (1- arg)) + (setq isearch-hint-count (1+ isearch-hint-count))) + (while (< arg 0) + (isearch-repeat 'forward) + (setq arg (1+ arg))) + (setq isearch-hint-count (1+ isearch-hint-count))) (defun isearch-toggle-regexp () "Toggle regexp searching on or off." @@ -2627,6 +2686,7 @@ (defvar isearch-lazy-highlight-word nil) (defvar isearch-lazy-highlight-forward nil) (defvar isearch-lazy-highlight-error nil) +(defvar isearch-lazy-highlight-hint-count nil) (defun lazy-highlight-cleanup (&optional force) "Stop lazy highlighting and remove extra highlighting from current buffer. @@ -2671,6 +2731,9 @@ isearch-lazy-highlight-window-end)) (not (eq isearch-forward isearch-lazy-highlight-forward)) + (not (eq isearch-lazy-highlight-hint-count + isearch-hint-count)) + ;; In case we are recovering from an error. (not (equal isearch-error isearch-lazy-highlight-error)))) @@ -2693,6 +2756,7 @@ isearch-lazy-highlight-regexp isearch-regexp isearch-lazy-highlight-space-regexp search-whitespace-regexp isearch-lazy-highlight-word isearch-word + isearch-lazy-highlight-hint-count isearch-hint-count isearch-lazy-highlight-forward isearch-forward) (unless (equal isearch-string "") (setq isearch-lazy-highlight-timer @@ -2739,7 +2803,8 @@ "Update highlighting of other matches for current search." (let ((max lazy-highlight-max-at-a-time) (looping t) - nomore) + nomore + (count 1)) (with-local-quit (save-selected-window (if (and (window-live-p isearch-lazy-highlight-window) @@ -2773,8 +2838,19 @@ (forward-char -1))) ;; non-zero-length match - (let ((ov (make-overlay mb me))) + (let ((ov (make-overlay mb me)) hint) (push ov isearch-lazy-highlight-overlays) + (if (not isearch-lazy-highlight-wrapped) + (progn + (setq hint (number-to-string count)) + (setq count (1+ count)) + (set-text-properties 0 (length hint) + '(face lazy-highlight-hint + display ((height 0.7) (raise 0.3))) + hint) + (if isearch-lazy-highlight-forward + (overlay-put ov 'after-string hint) + (overlay-put ov 'before-string hint)))) ;; 1000 is higher than ediff's 100+, ;; but lower than isearch main overlay's 1001 (overlay-put ov 'priority 1000) --=-=-=--