From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Gideon Stupp Newsgroups: gmane.emacs.devel Subject: Re: [EXPERIMENTAL PATCH] Extending Isearch-repeat-forward/backward to support a prefix argument following suggesion by Juri Linkov Date: Fri, 27 Jan 2012 08:17:44 +0200 Message-ID: References: <87pqe5x6ju.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=f46d0445179b77260a04b77c7446 X-Trace: dough.gmane.org 1327645076 20994 80.91.229.12 (27 Jan 2012 06:17:56 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 27 Jan 2012 06:17:56 +0000 (UTC) Cc: emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jan 27 07:17:51 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rqf8B-00036S-6B for ged-emacs-devel@m.gmane.org; Fri, 27 Jan 2012 07:17:51 +0100 Original-Received: from localhost ([::1]:38315 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rqf8A-0007SF-Ke for ged-emacs-devel@m.gmane.org; Fri, 27 Jan 2012 01:17:50 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:36038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rqf87-0007SA-Jm for emacs-devel@gnu.org; Fri, 27 Jan 2012 01:17:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rqf85-0000e6-Oj for emacs-devel@gnu.org; Fri, 27 Jan 2012 01:17:47 -0500 Original-Received: from mail-tul01m020-f169.google.com ([209.85.214.169]:36781) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rqf85-0000e2-FQ for emacs-devel@gnu.org; Fri, 27 Jan 2012 01:17:45 -0500 Original-Received: by obbta7 with SMTP id ta7so1723799obb.0 for ; Thu, 26 Jan 2012 22:17:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=c96A7lMVB4Ni8DoLL5wWzHMFEHiGrOhdePpZCy4etro=; b=LX8AqenJ/i5oDWSZ/TeMBxNbFGEUV0+gvQo5LSP0on8lz0rMLRA7U/KytFFS/dk1Am 3ZTkCplUN+ZwnToemwLSwmaHpEjBh0iTKWPKQDdLGU/uB6MlOk5up7hJwe337vjPa+KO VgpGmFQznjTwhOSv358ZCEJZWzORNh/g6/oUo= Original-Received: by 10.182.41.5 with SMTP id b5mr5057895obl.79.1327645064635; Thu, 26 Jan 2012 22:17:44 -0800 (PST) Original-Received: by 10.182.242.41 with HTTP; Thu, 26 Jan 2012 22:17:44 -0800 (PST) In-Reply-To: <87pqe5x6ju.fsf@mail.jurta.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.214.169 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:147969 Archived-At: --f46d0445179b77260a04b77c7446 Content-Type: text/plain; charset=ISO-8859-1 Thank you for your comments Juri. Do you have a thought on how to implement this functionality as a package the way Stefan asked for? Negative arguments in particular seem to be challenging. Right now I implemented negative argument navigation by calling isearch-repeat with the opposite functionality but that has all kinds of odd effects. For example the search message changes, C-- C-1 isearch-forward does not go back one matched string but rather just switches to isearch-backward and so on. I did implement visual hints for the negative arguments because that would require changing the way lazy highlight works significantly (lazy-highlight loop wraps around back to the first line and at that point you can't know the negative argument for the current match). On Fri, Jan 27, 2012 at 3:44 AM, Juri Linkov wrote: > > Please try it out. > > Thanks. A few comments below: > > > + ;; 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) > > > + (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)) > > Instead of adding these keybindings, you can just set > `isearch-allow-scroll' to t. > > Also there are plans to add a better variable `isearch-enable-prefix' > in 24.2, you can see more information at this link - > http://thread.gmane.org/gmane.emacs.devel/143829 > > > -(defun isearch-repeat-forward () > > +(defun isearch-repeat-forward (arg) > > > -(defun isearch-repeat-backward () > > +(defun isearch-repeat-backward (arg) > > Please use (&optional arg) for backward-compatibility. > > > + (setq hint (number-to-string count)) > > + (setq count (1+ count)) > > + (set-text-properties 0 (length hint) > '(face lazy-highlight-hint) hint) > > + (overlay-put ov 'before-string hint))) > > A suggestion by Tassilo to use superscripts looks good too, > but then these hints look like references to footnotes :-) > --f46d0445179b77260a04b77c7446 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Thank you for your comments Juri.=A0 Do you have a thought= on how to implement this functionality as a package the way Stefan asked f= or? Negative arguments in particular seem to be challenging. Right now I im= plemented negative argument navigation by calling isearch-repeat with the o= pposite functionality but that has all kinds of odd effects. For example th= e search message changes,=A0 C-- C-1 isearch-forward does not go back one m= atched string but rather just switches to isearch-backward and so on.=A0 I = did=A0 implement visual hints for the negative arguments because that would= require changing the way lazy highlight works significantly (lazy-highligh= t loop wraps around back to the first line and at that point you can't = know the negative argument for the current match).


On Fri, Jan 27, 2012 at 3:44 AM, Juri Li= nkov <juri@jurta.org= > wrote:
> Please try it out.

Thanks. =A0A few comments below:

> + =A0 =A0;; Bring universal-argument and friends back in
> + =A0 =A0(define-key map "\C-u" 'universal-argument)
> + =A0 =A0(define-key map (kbd "C--") 'negative-argument)=
> + =A0 =A0(define-key map (kbd "C-0") 'digit-argument) > + =A0 =A0(define-key map (kbd "C-1") 'digit-argument) > + =A0 =A0(define-key map (kbd "C-2") 'digit-argument) > + =A0 =A0(define-key map (kbd "C-3") 'digit-argument) > + =A0 =A0(define-key map (kbd "C-4") 'digit-argument) > + =A0 =A0(define-key map (kbd "C-5") 'digit-argument) > + =A0 =A0(define-key map (kbd "C-6") 'digit-argument) > + =A0 =A0(define-key map (kbd "C-7") 'digit-argument) > + =A0 =A0(define-key map (kbd "C-8") 'digit-argument) > + =A0 =A0(define-key map (kbd "C-9") 'digit-argument)
> + =A0 =A0(define-key meta-map (kbd "-") 'negative-argume= nt)
> + =A0 =A0(define-key meta-map (kbd "C--") 'negative-argu= ment)
> + =A0 =A0(define-key meta-map (kbd "C-0") 'digit-argumen= t)
> + =A0 =A0(define-key meta-map (kbd "C-1") 'digit-argumen= t)
> + =A0 =A0(define-key meta-map (kbd "C-2") 'digit-argumen= t)
> + =A0 =A0(define-key meta-map (kbd "C-3") 'digit-argumen= t)
> + =A0 =A0(define-key meta-map (kbd "C-4") 'digit-argumen= t)
> + =A0 =A0(define-key meta-map (kbd "C-5") 'digit-argumen= t)
> + =A0 =A0(define-key meta-map (kbd "C-6") 'digit-argumen= t)
> + =A0 =A0(define-key meta-map (kbd "C-7") 'digit-argumen= t)
> + =A0 =A0(define-key meta-map (kbd "C-8") 'digit-argumen= t)
> + =A0 =A0(define-key meta-map (kbd "C-9") 'digit-argumen= t))

Instead of adding these keybindings, you can just set
`isearch-allow-scroll' to t.

Also there are plans to add a better variable `isearch-enable-prefix' in 24.2, you can see more information at this link -
http://thread.gmane.org/gmane.emacs.devel/143829

> -(defun isearch-repeat-forward ()
> +(defun isearch-repeat-forward (arg)

> -(defun isearch-repeat-backward ()
> +(defun isearch-repeat-backward (arg)

Please use (&optional arg) for backward-compatibility.

> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (setq hint (= number-to-string count))
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (setq count = (1+ count))
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (set-text-pr= operties 0 (length hint) '(face lazy-highlight-hint) hint)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (overlay-put= ov 'before-string hint)))

A suggestion by Tassilo to use superscripts looks good too,
but then these hints look like references to footnotes :-)

--f46d0445179b77260a04b77c7446--