all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] Isearch: yanking before point
@ 2007-08-21 15:59 Johannes Weiner
  2007-08-22  3:15 ` Richard Stallman
  2007-08-22 15:08 ` Johan Bockgård
  0 siblings, 2 replies; 12+ messages in thread
From: Johannes Weiner @ 2007-08-21 15:59 UTC (permalink / raw)
  To: Emacs development discussions

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

Hi Emacs-hackers,

It happens often enough that I want to search for a word that is *before* the
point.  Isearch already allows yanking the word/line after the point into the
minibuffer, so I extended isearch in the same manner for before-point yanking.

	Hannes

[-- Attachment #2: emacs-isearch-yank-before-point.patch --]
[-- Type: text/x-diff, Size: 1615 bytes --]

diff -Naur emacs.orig/lisp/isearch.el emacs/lisp/isearch.el
--- emacs.orig/lisp/isearch.el	2007-08-21 17:51:40.000000000 +0200
+++ emacs/lisp/isearch.el	2007-08-21 17:52:40.000000000 +0200
@@ -371,9 +371,11 @@
     (define-key map [?\S-\ ] 'isearch-printing-char)
 
     (define-key map    "\C-w" 'isearch-yank-word-or-char)
+    (define-key map    "\C-b" 'isearch-yank-word-before-point)
     (define-key map "\M-\C-w" 'isearch-del-char)
     (define-key map "\M-\C-y" 'isearch-yank-char)
     (define-key map    "\C-y" 'isearch-yank-line)
+    (define-key map    "\C-l" 'isearch-yank-line-before-point)
 
     ;; Turned off because I find I expect to get the global definition--rms.
     ;; ;; Instead bind C-h to special help command for isearch-mode.
@@ -1371,6 +1373,11 @@
   (interactive)
   (isearch-yank-internal (lambda () (forward-word 1) (point))))
 
+(defun isearch-yank-word-before-point ()
+  "Pull previous word from buffer into search string."
+  (interactive)
+  (isearch-yank-internal (lambda () (backward-word) (point))))
+
 (defun isearch-yank-line ()
   "Pull rest of line from buffer into search string."
   (interactive)
@@ -1378,6 +1385,13 @@
    (lambda () (let ((inhibit-field-text-motion t))
 		(line-end-position (if (eolp) 2 1))))))
 
+(defun isearch-yank-line-before-point ()
+  "Pull whole line up to point into search string."
+  (interactive)
+  (isearch-yank-internal
+   (lambda () (let ((inhibit-field-text-motion t))
+		(line-beginning-position (if (bolp) 0 1))))))
+
 (defun isearch-search-and-update ()
   ;; Do the search and update the display.
   (when (or isearch-success

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: [PATCH] Isearch: yanking before point
  2007-08-21 15:59 [PATCH] Isearch: yanking before point Johannes Weiner
@ 2007-08-22  3:15 ` Richard Stallman
  2007-08-22  3:33   ` Johannes Weiner
  2007-08-22 15:08 ` Johan Bockgård
  1 sibling, 1 reply; 12+ messages in thread
From: Richard Stallman @ 2007-08-22  3:15 UTC (permalink / raw)
  To: Johannes Weiner; +Cc: emacs-devel

    It happens often enough that I want to search for a word that is *before* the
    point.  Isearch already allows yanking the word/line after the point into the
    minibuffer, so I extended isearch in the same manner for before-point yanking.

Thanks for the suggestion, but I will not agree to it.
I want C-b and C-l to exit isearch as they do now.

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

* Re: [PATCH] Isearch: yanking before point
  2007-08-22  3:15 ` Richard Stallman
@ 2007-08-22  3:33   ` Johannes Weiner
  2007-08-22  7:25     ` Tassilo Horn
  0 siblings, 1 reply; 12+ messages in thread
From: Johannes Weiner @ 2007-08-22  3:33 UTC (permalink / raw)
  To: Richard Stallman; +Cc: emacs-devel

Hi,

On Tue, Aug 21, 2007 at 11:15:14PM -0400, Richard Stallman wrote:
>     It happens often enough that I want to search for a word that is *before* the
>     point.  Isearch already allows yanking the word/line after the point into the
>     minibuffer, so I extended isearch in the same manner for before-point yanking.
> 
> Thanks for the suggestion, but I will not agree to it.
> I want C-b and C-l to exit isearch as they do now.

I really do not insist on those keys, they were the first think I could think
of and not being already used in Isearch.

Do you have any suggestions what keys could be used instead?

	Hannes

-- 
Machines have less problems.  I would like to be a machine.
	-- Andy Warhol

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

* Re: [PATCH] Isearch: yanking before point
  2007-08-22  3:33   ` Johannes Weiner
@ 2007-08-22  7:25     ` Tassilo Horn
  2007-08-22 14:20       ` Johannes Weiner
  2007-08-22 15:17       ` Stefan Monnier
  0 siblings, 2 replies; 12+ messages in thread
From: Tassilo Horn @ 2007-08-22  7:25 UTC (permalink / raw)
  To: emacs-devel

Johannes Weiner <hannes@saeurebad.de> writes:

Hi Johannes,

>> Thanks for the suggestion, but I will not agree to it.  I want C-b
>> and C-l to exit isearch as they do now.
>
> I really do not insist on those keys, they were the first think I
> could think of and not being already used in Isearch.
>
> Do you have any suggestions what keys could be used instead?

I'd suggest M-w for `isearch-yank-word-before-point' and M-l for
`isearch-yank-line-before-point'.  That reminds me of scrolling up and
down, where the C-binding moves forward and the M-binding backward.

And maybe both functions should be renamed to
`isearch-yank-word-or-char-backward' and `isearch-yank-line-backward.

Just my 2 cents.

Bye,
Tassilo

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

* Re: [PATCH] Isearch: yanking before point
  2007-08-22  7:25     ` Tassilo Horn
@ 2007-08-22 14:20       ` Johannes Weiner
  2007-08-23  0:45         ` Richard Stallman
  2007-08-22 15:17       ` Stefan Monnier
  1 sibling, 1 reply; 12+ messages in thread
From: Johannes Weiner @ 2007-08-22 14:20 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: emacs-devel

Hi Tassilo,

On Wed, Aug 22, 2007 at 09:25:14AM +0200, Tassilo Horn wrote:
> >> Thanks for the suggestion, but I will not agree to it.  I want C-b
> >> and C-l to exit isearch as they do now.
> >
> > I really do not insist on those keys, they were the first think I
> > could think of and not being already used in Isearch.
> >
> > Do you have any suggestions what keys could be used instead?
> 
> I'd suggest M-w for `isearch-yank-word-before-point' and M-l for
> `isearch-yank-line-before-point'.  That reminds me of scrolling up and
> down, where the C-binding moves forward and the M-binding backward.

I would prefer them over the ones I chose first too.

> And maybe both functions should be renamed to
> `isearch-yank-word-or-char-backward' and `isearch-yank-line-backward.

Alright, will do that.

> Just my 2 cents.

Thank you!

	Hannes

-- 
(eq 'today (cadr life-days))

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

* Re: [PATCH] Isearch: yanking before point
  2007-08-21 15:59 [PATCH] Isearch: yanking before point Johannes Weiner
  2007-08-22  3:15 ` Richard Stallman
@ 2007-08-22 15:08 ` Johan Bockgård
  2007-08-23  0:45   ` Richard Stallman
  1 sibling, 1 reply; 12+ messages in thread
From: Johan Bockgård @ 2007-08-22 15:08 UTC (permalink / raw)
  To: emacs-devel

Johannes Weiner <hannes@saeurebad.de> writes:

> It happens often enough that I want to search for a word that is
> *before* the point. Isearch already allows yanking the word/line after
> the point into the minibuffer, so I extended isearch in the same
> manner for before-point yanking.

I think it should work like a mirror image of isearch-yank-word; insert
the word at the beginning of the search string and advance start of
match backwards.

-- 
Johan Bockgård

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

* Re: [PATCH] Isearch: yanking before point
  2007-08-22  7:25     ` Tassilo Horn
  2007-08-22 14:20       ` Johannes Weiner
@ 2007-08-22 15:17       ` Stefan Monnier
  2007-08-23  5:56         ` Stefan Reichör
  1 sibling, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2007-08-22 15:17 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: emacs-devel

> I'd suggest M-w for `isearch-yank-word-before-point' and M-l for
> `isearch-yank-line-before-point'.  That reminds me of scrolling up and
> down, where the C-binding moves forward and the M-binding backward.

Could we just add a single binding for "yank as follows" which would put
isearch in a submode where you can move with the usual movement commands and
that corresponding text would thus be yanked?

This way we only need to use a single key-binding and we get to reuse all
the old movement key bindings we all know and love without having to learn
"oh right in isearch, to move forward one word I need C-w rather than M-f
and to move back one word is M-w rather than M-b, and to move one line is 
M-l rather than C-p and there's no equivalent to C-M-f and ..."


        Stefan

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

* Re: [PATCH] Isearch: yanking before point
  2007-08-22 14:20       ` Johannes Weiner
@ 2007-08-23  0:45         ` Richard Stallman
  0 siblings, 0 replies; 12+ messages in thread
From: Richard Stallman @ 2007-08-23  0:45 UTC (permalink / raw)
  To: Johannes Weiner; +Cc: tassilo, emacs-devel

    > I'd suggest M-w for `isearch-yank-word-before-point' and M-l for
    > `isearch-yank-line-before-point'.  That reminds me of scrolling up and
    > down, where the C-binding moves forward and the M-binding backward.

    I would prefer them over the ones I chose first too.

I think I use both of these, on occasion, to exit an isearch.  I don't
want them to be redefined.  I think there are already too many keys
that have special meanings in isearch, and I do not want to add any more.

If we poll the users, and the users clearly want this change, I won't
object.  Otherwise, I do object.

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

* Re: [PATCH] Isearch: yanking before point
  2007-08-22 15:08 ` Johan Bockgård
@ 2007-08-23  0:45   ` Richard Stallman
  0 siblings, 0 replies; 12+ messages in thread
From: Richard Stallman @ 2007-08-23  0:45 UTC (permalink / raw)
  To: Johan Bockgård; +Cc: emacs-devel

    I think it should work like a mirror image of isearch-yank-word; insert
    the word at the beginning of the search string and advance start of
    match backwards.

Perhaps C-w in a reverse search should operate towards the start
of the buffer.

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

* Re: [PATCH] Isearch: yanking before point
  2007-08-22 15:17       ` Stefan Monnier
@ 2007-08-23  5:56         ` Stefan Reichör
  2007-08-23  6:15           ` David Kastrup
  2007-08-23 19:41           ` Peter Lee
  0 siblings, 2 replies; 12+ messages in thread
From: Stefan Reichör @ 2007-08-23  5:56 UTC (permalink / raw)
  To: emacs-devel

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>> I'd suggest M-w for `isearch-yank-word-before-point' and M-l for
>> `isearch-yank-line-before-point'.  That reminds me of scrolling up and
>> down, where the C-binding moves forward and the M-binding backward.
>
> Could we just add a single binding for "yank as follows" which would put
> isearch in a submode where you can move with the usual movement commands and
> that corresponding text would thus be yanked?
>
> This way we only need to use a single key-binding and we get to reuse all
> the old movement key bindings we all know and love without having to learn
> "oh right in isearch, to move forward one word I need C-w rather than M-f
> and to move back one word is M-w rather than M-b, and to move one line is 
> M-l rather than C-p and there's no equivalent to C-M-f and ..."

That is a GREAT idea!

That way I would have to remember the key to enter the intuitive
isearch selection mode. Then I could use the standard movement
bindings. Now I have to remember a different set of bindings for
isearch movement.

We could even provide a way to make this behaviour the default for
users that prefer a single set of movement bindings.


Stefan.

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

* Re: [PATCH] Isearch: yanking before point
  2007-08-23  5:56         ` Stefan Reichör
@ 2007-08-23  6:15           ` David Kastrup
  2007-08-23 19:41           ` Peter Lee
  1 sibling, 0 replies; 12+ messages in thread
From: David Kastrup @ 2007-08-23  6:15 UTC (permalink / raw)
  To: Stefan Reichör; +Cc: emacs-devel

Stefan Reichör <stefan@xsteve.at> writes:

> Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
>
>>> I'd suggest M-w for `isearch-yank-word-before-point' and M-l for
>>> `isearch-yank-line-before-point'.  That reminds me of scrolling up and
>>> down, where the C-binding moves forward and the M-binding backward.
>>
>> Could we just add a single binding for "yank as follows" which would put
>> isearch in a submode where you can move with the usual movement commands and
>> that corresponding text would thus be yanked?
>>
>> This way we only need to use a single key-binding and we get to reuse all
>> the old movement key bindings we all know and love without having to learn
>> "oh right in isearch, to move forward one word I need C-w rather than M-f
>> and to move back one word is M-w rather than M-b, and to move one line is 
>> M-l rather than C-p and there's no equivalent to C-M-f and ..."
>
> That is a GREAT idea!

How about ESC i for "escape isearch"?  And another M-i to get back in
again?

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: [PATCH] Isearch: yanking before point
  2007-08-23  5:56         ` Stefan Reichör
  2007-08-23  6:15           ` David Kastrup
@ 2007-08-23 19:41           ` Peter Lee
  1 sibling, 0 replies; 12+ messages in thread
From: Peter Lee @ 2007-08-23 19:41 UTC (permalink / raw)
  To: emacs-devel

>>>> Stefan Reichör writes:

    > Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
    >>> I'd suggest M-w for `isearch-yank-word-before-point' and M-l for
    >>> `isearch-yank-line-before-point'.  That reminds me of scrolling up and
    >>> down, where the C-binding moves forward and the M-binding backward.
    >> 
    >> Could we just add a single binding for "yank as follows" which would put
    >> isearch in a submode where you can move with the usual movement commands and
    >> that corresponding text would thus be yanked?
    >> 
    >> This way we only need to use a single key-binding and we get to reuse all
    >> the old movement key bindings we all know and love without having to learn
    >> "oh right in isearch, to move forward one word I need C-w rather than M-f
    >> and to move back one word is M-w rather than M-b, and to move one line is 
    >> M-l rather than C-p and there's no equivalent to C-M-f and ..."

    > That is a GREAT idea!

I would love this feature... it's a good idea.

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

end of thread, other threads:[~2007-08-23 19:41 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-21 15:59 [PATCH] Isearch: yanking before point Johannes Weiner
2007-08-22  3:15 ` Richard Stallman
2007-08-22  3:33   ` Johannes Weiner
2007-08-22  7:25     ` Tassilo Horn
2007-08-22 14:20       ` Johannes Weiner
2007-08-23  0:45         ` Richard Stallman
2007-08-22 15:17       ` Stefan Monnier
2007-08-23  5:56         ` Stefan Reichör
2007-08-23  6:15           ` David Kastrup
2007-08-23 19:41           ` Peter Lee
2007-08-22 15:08 ` Johan Bockgård
2007-08-23  0:45   ` Richard Stallman

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.