unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Drew Adams <drew.adams@oracle.com>
Cc: emacs-devel@gnu.org
Subject: Re: `isearch-allow-scroll' - a misnomer and a bad design
Date: Sat, 10 Sep 2011 11:10:54 +0000	[thread overview]
Message-ID: <20110910111054.GA2460@acm.acm> (raw)
In-Reply-To: <7002A9DA9A804F0B9F6F251FD3A2B263@us.oracle.com>

Hi, Drew.

A bit of clarification:

On Fri, Sep 09, 2011 at 04:07:02PM -0700, Drew Adams wrote:

> That's my point.  Like those commands, I want to make use of this `C-u' feature.
> But I do not want to also allow scrolling during Isearch.

[ .... ]

> > What would you suggest?  What does the option really do, in your
> > judgement?  Scrolling is an essential part of the option.

> AFAICT, it does two things:

> 1. It invokes any command that has property `isearch-scroll' or `scroll-command'
> on its symbol - without necessarily exiting Isearch.

NO NO NO!!!  A "scrolling command" is a command which MOST DEFINITELY
DOESN'T exit the isearch.  This is the definition of "scrolling command"
in isearch.  With this in mind, please think through everything you've written.

[ .... ]

> 2. It passes a prefix arg through to any key (its command) that follows it.

Bear in mind that C-u `universal-argument' is a scrolling command in its
own right.  So we can construe what you're asking for thusly: to have an
option for a subset of scrolling commands to be executable in isearch

> Neither of these has anything to do with scrolling, necessarily.  Change the
> names to remove `scroll' and you will see that.

[ .... ]

> (And the code that gives the scrolling commands their Isearch behavior should
> not even be in isearch.el, IMO.)

I'm not sure what you mean by this.  Their "isearch behaviour" is part of
isearch.  These commands operate precisely the same way, regardless of
whether they're called from isearch or not.

[ .... ]

> > > 1b. For another thing (i.e., forgetting about `C-u'), *any* 
> > >     command can benefit from the same Isearch feature as a
> > >     scrolling command.  It suffices to put a non-nil
> > >     `isearch-scroll' property on the command symbol.

> > This isn't true.

> It is true, AFAICT.  Nothing prevents you from putting property `isearch-scroll'
> on *any* command, to get Isearch to pass through to it.

The current isearch, with isearch-allow-scroll set, will pass a C-u
through to the next command regardless of whether that command is a
scrolling command.

> > Only commands which don't foul up the isearch can be
> > permitted to use the feature.  Only a few commands meet the criteria.
> > `universal-argument' is such a command.

> (It would be up to the command they are passed through to to decide whether to
> exit.

That would be something entirely new.  It might involve such a command
returning t/nil to instruct isearch to exit or not.  But that would be a
horrible kludge.  (Every command being adjusted to do this?  What about
other uses of the return value?  There are an awful lot of commands)

> Granted that users might not want to mess around with the scrolling commands
> (whether via `put' or Customize), perhaps you will recognize that a user might
> want to not have Isearch pass through to some command that library `foo' thinks
> it is a great idea to pass through to by default.

You mean "pass through a C-u"?  I don't see this at all.  Perhaps you
have a specific use case in mind.

> > Again, familiarise yourself with just how restricted the permissible
> > commands are.  There's a list of criteria in isearch.el 
> > ~L1760 (think - number of yards in a mile :-).

> I read that comment, and I read the code.

You haven't given any hint that you've really understood these
restrictions.  Imagine a quasi-scrolling command that breaks one of them.
Say, for example, it moves point.  You would then be in the middle of an
isearch with point not at the head of the current search string.

I'm not saying that it wouldn't be possible to extend the semantics of
isearch to make this valid, but it would be difficult.  At least it might
be technically possible but it most assuredly wouldn't be politically
possible.

> That said, I don't want to belabor this part.  My main interest is in freeing up
> `C-u', which you have already agreed to.

[ .... ]

> I would like to see `C-u' passed through - that's the main point.  Either
> systematically or optionally, but if optionally then separately from allowing
> scrolling.

Try out this patch; I think it does what you want.  (It's obviously very
rough code, in desperate need of refactoring, but it might work.)


*** isearch.el~	2011-09-04 15:31:05.000000000 +0000
--- isearch.el	2011-09-10 10:58:02.000000000 +0000
***************
*** 1966,1976 ****
  	   (apply 'isearch-unread keylist)
  	   (isearch-edit-string))
            ;; Handle a scrolling function.
!           ((and isearch-allow-scroll
!                 (progn (setq key (isearch-reread-key-sequence-naturally keylist))
!                        (setq keylist (listify-key-sequence key))
!                        (setq main-event (aref key 0))
!                        (setq scroll-command (isearch-lookup-scroll-key key))))
             ;; From this point onwards, KEY, KEYLIST and MAIN-EVENT hold a
             ;; complete key sequence, possibly as modified by function-key-map,
             ;; not merely the one or two event fragment which invoked
--- 1966,1985 ----
  	   (apply 'isearch-unread keylist)
  	   (isearch-edit-string))
            ;; Handle a scrolling function.
!           ((or
! 	    (and isearch-allow-scroll
! 		 (progn (setq key (isearch-reread-key-sequence-naturally keylist))
! 			(setq keylist (listify-key-sequence key))
! 			(setq main-event (aref key 0))
! 			(setq scroll-command (isearch-lookup-scroll-key key))))
! 	    (progn
! 	      (setq key (isearch-reread-key-sequence-naturally keylist)
! 		    keylist (listify-key-sequence key)
! 		    main-event (aref key 0)
! 		    scroll-command (key-binding key))
! 	      (or (eq scroll-command 'universal-argument)
! 		  (eq scroll-command 'negative-argument)
! 		  (eq scroll-command 'digit-argument))))
             ;; From this point onwards, KEY, KEYLIST and MAIN-EVENT hold a
             ;; complete key sequence, possibly as modified by function-key-map,
             ;; not merely the one or two event fragment which invoked

-- 
Alan Mackenzie (Nuremberg, Germany).



  parent reply	other threads:[~2011-09-10 11:10 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-09 20:38 `isearch-allow-scroll' - a misnomer and a bad design Drew Adams
2011-09-09 21:52 ` Alan Mackenzie
2011-09-09 23:07   ` Drew Adams
2011-09-10  0:58     ` Stefan Monnier
2011-09-10  7:48       ` Drew Adams
2011-09-10 11:28       ` Alan Mackenzie
2011-09-10 16:44         ` Drew Adams
2011-09-10 11:47       ` Juri Linkov
2011-09-10 12:13         ` Alan Mackenzie
2011-09-10  2:03     ` Stephen J. Turnbull
2011-09-10 11:10     ` Alan Mackenzie [this message]
2011-09-10 16:43       ` Drew Adams
2011-09-10 19:04         ` Alan Mackenzie
2011-09-10 20:22           ` PJ Weisberg
2011-09-10 23:06             ` Stephen J. Turnbull
2011-09-11  0:47           ` Drew Adams
2011-09-11 10:39     ` Alan Mackenzie
2011-09-11 16:54       ` Drew Adams
2011-09-11 17:30         ` Alan Mackenzie
2011-09-11 18:53           ` Drew Adams
2011-09-12  2:46             ` Richard Stallman
2011-09-12  9:36               ` Alan Mackenzie
2011-09-13  1:39                 ` Richard Stallman
2011-09-13 14:27                   ` Alan Mackenzie
2011-09-13 20:05                     ` Richard Stallman
2011-09-13 21:04                       ` Drew Adams
2011-09-13 22:52                         ` Juri Linkov
2011-09-14  0:32                           ` Daniel Colascione
2011-09-14  0:41                             ` Drew Adams
2011-09-14 14:10                               ` Richard Stallman
2011-09-14 14:35                                 ` PJ Weisberg
2011-09-15  4:11                                   ` Richard Stallman
2011-09-14 14:44                                 ` Drew Adams
2011-09-18  2:52                                   ` Richard Stallman
2011-09-19 19:08                                     ` chad
2011-09-20 15:16                                       ` Richard Stallman
2011-09-20 19:17                                         ` Michael Welsh Duggan
2011-09-20 19:59                                           ` Dani Moncayo
2011-09-21  1:22                                             ` Stefan Monnier
2011-09-21 14:51                                               ` Richard Stallman
2011-09-21 15:01                                                 ` Dani Moncayo
2011-09-21 15:10                                                 ` Drew Adams
2011-09-21 16:35                                                 ` Stephen J. Turnbull
     [not found]                                                   ` <E1R6Tii-0000zy-Jw@f!! encepost.gnu.org>
2011-09-21 20:48                                                   ` Richard Stallman
2011-09-21 21:13                                                     ` Drew Adams
2011-09-22 13:58                                                       ` Richard Stallman
2011-10-08 21:13                                                       ` Drew Adams
2011-09-22  5:33                                                     ` Stephen J. Turnbull
2011-09-22 13:59                                                       ` Richard Stallman
2011-09-22 10:35                                                     ` Alan Mackenzie
2011-09-22 21:44                                                       ` Richard Stallman
2011-09-22 22:23                                                         ` PJ Weisberg
2011-09-23 12:30                                                           ` Richard Stallman
2011-09-21  9:04                                             ` Alan Mackenzie
2011-09-21  9:27                                               ` Dani Moncayo
2011-09-21  9:29                                               ` chad
2011-09-21 13:22                                               ` Drew Adams
2011-09-21 14:50                                             ` Richard Stallman
2011-09-12 14:59               ` Drew Adams

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=20110910111054.GA2460@acm.acm \
    --to=acm@muc.de \
    --cc=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    /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.
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).