* Key map translations
@ 2011-04-12 1:32 Christoph Scholtes
2011-04-12 3:35 ` Sean Sieger
2011-04-12 8:18 ` Key map translations Lennart Borgman
0 siblings, 2 replies; 13+ messages in thread
From: Christoph Scholtes @ 2011-04-12 1:32 UTC (permalink / raw)
To: emacs-devel
I was trying to assign a custom isearch enhancement to 'C-S-s'
(Control-Shift-s), but that seems to be translated to 'C-s'. I skimmed
through the key map section of the manual, but it is unclear to me how I
would override this translation behavior (or if I even can).
Is there any way to see all of these translations (if there are more
than 'C-S-s' -> 'C-s') anywhere? The variable `key-translation-map' was
not very helpful in this regard.
I would like 'C-s' to be isearch-forward and 'C-S-s' to be my custom
function, e.g. `isearch-forward yanking the word at point as the
search-string'. Same with `C-M-S-s' as the regexp version of this command.
Christoph
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Key map translations
2011-04-12 1:32 Key map translations Christoph Scholtes
@ 2011-04-12 3:35 ` Sean Sieger
2011-04-13 1:59 ` Christoph Scholtes
2011-04-12 8:18 ` Key map translations Lennart Borgman
1 sibling, 1 reply; 13+ messages in thread
From: Sean Sieger @ 2011-04-12 3:35 UTC (permalink / raw)
To: emacs-devel
I would like 'C-s' to be isearch-forward and 'C-S-s' to be my custom
function, e.g. `isearch-forward yanking the word at point as the
search-string'. Same with `C-M-S-s' as the regexp version of this
command.
Why not C-c s? C-c S?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Key map translations
2011-04-12 3:35 ` Sean Sieger
@ 2011-04-13 1:59 ` Christoph Scholtes
2011-04-13 2:53 ` Sean Sieger
0 siblings, 1 reply; 13+ messages in thread
From: Christoph Scholtes @ 2011-04-13 1:59 UTC (permalink / raw)
To: emacs-devel
On 4/11/2011 9:35 PM, Sean Sieger wrote:
>
> I would like 'C-s' to be isearch-forward and 'C-S-s' to be my custom
> function, e.g. `isearch-forward yanking the word at point as the
> search-string'. Same with `C-M-S-s' as the regexp version of this
> command.
>
> Why not C-c s? C-c S?
Good question. I think I wanted a more "natural" companion to C-s
(isearch-forward). I'm weird that way, I guess. ;)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Key map translations
2011-04-13 1:59 ` Christoph Scholtes
@ 2011-04-13 2:53 ` Sean Sieger
2011-04-13 3:16 ` Christoph Scholtes
0 siblings, 1 reply; 13+ messages in thread
From: Sean Sieger @ 2011-04-13 2:53 UTC (permalink / raw)
To: emacs-devel
Christoph Scholtes <cschol2112@googlemail.com> writes:
On 4/11/2011 9:35 PM, Sean Sieger wrote:
>
> I would like 'C-s' to be isearch-forward and 'C-S-s' to be my custom
> function, e.g. `isearch-forward yanking the word at point as the
> search-string'. Same with `C-M-S-s' as the regexp version of this
> command.
>
> Why not C-c s? C-c S?
Good question. I think I wanted a more "natural" companion to C-s
(isearch-forward). I'm weird that way, I guess. ;)
Christoph, does C-s C-w already do something similar to what your custom
function does?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Key map translations
2011-04-13 2:53 ` Sean Sieger
@ 2011-04-13 3:16 ` Christoph Scholtes
2011-04-13 7:07 ` Deniz Dogan
0 siblings, 1 reply; 13+ messages in thread
From: Christoph Scholtes @ 2011-04-13 3:16 UTC (permalink / raw)
To: emacs-devel
On 4/12/2011 8:53 PM, Sean Sieger wrote:
> Christoph, does C-s C-w already do something similar to what your custom
> function does?
I use C-s C-w alot, but my function works differently.
this-is-a-long-word
^
With cursor here, C-s C-w will yank
this-is-a-long-word
**
in the search string.
C-S-s, at the same position, would yank
this-is-a-long-word
*******************
i.e. the entire word at point.
Then I can press C-s like normal to move to the next occurrence of the
word. I think this is very handy and usually saves me a lot of C-s C-w
C-w C-w etc.
Christoph
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Key map translations
2011-04-13 3:16 ` Christoph Scholtes
@ 2011-04-13 7:07 ` Deniz Dogan
2011-04-13 23:06 ` isearch-yank-word-at-point (was Re: Key map translations) Christoph Scholtes
0 siblings, 1 reply; 13+ messages in thread
From: Deniz Dogan @ 2011-04-13 7:07 UTC (permalink / raw)
To: Christoph Scholtes; +Cc: emacs-devel
2011/4/13 Christoph Scholtes <cschol2112@googlemail.com>:
> On 4/12/2011 8:53 PM, Sean Sieger wrote:
>
>> Christoph, does C-s C-w already do something similar to what your custom
>> function does?
>
> I use C-s C-w alot, but my function works differently.
>
> this-is-a-long-word
> ^
> With cursor here, C-s C-w will yank
>
> this-is-a-long-word
> **
>
> in the search string.
>
> C-S-s, at the same position, would yank
>
> this-is-a-long-word
> *******************
>
> i.e. the entire word at point.
>
> Then I can press C-s like normal to move to the next occurrence of the word.
> I think this is very handy and usually saves me a lot of C-s C-w C-w C-w
> etc.
>
This is something I've been wanting for a long time but never really
realized it. Is there really nothing similar in isearch already? Maybe
we could add it?
--
Deniz Dogan
^ permalink raw reply [flat|nested] 13+ messages in thread
* isearch-yank-word-at-point (was Re: Key map translations)
2011-04-13 7:07 ` Deniz Dogan
@ 2011-04-13 23:06 ` Christoph Scholtes
2011-04-14 5:21 ` Deniz Dogan
2011-04-27 17:35 ` Jambunathan K
0 siblings, 2 replies; 13+ messages in thread
From: Christoph Scholtes @ 2011-04-13 23:06 UTC (permalink / raw)
To: Deniz Dogan; +Cc: emacs-devel
On 4/13/2011 1:07 AM, Deniz Dogan wrote:
> This is something I've been wanting for a long time but never really
> realized it. Is there really nothing similar in isearch already? Maybe
> we could add it?
I reworked my function a little and the interface is slightly different.
You press `C-s' to enter isearch mode and then `C-a' to select the
entire word at point, much like `C-w' would select the word from point
on. `Word' is in this case defined as a sequence of word and symbol
constituents.
Here is the code:
(defun isearch-yank-word-at-point ()
"Pull word at point into the search string."
(interactive)
;; Only yank if point is on a word constituent or
;; symbol constituent per the syntax table.
(when (or (= (char-syntax (or (char-after) 0)) ?w)
(= (char-syntax (or (char-after) 0)) ?_))
;; If part of the string has been yanked to the search string
;; already, unwind the isearch state stack to the beginning to
;; start over.
(while (not (string= isearch-string ""))
(isearch-pop-state))
;; Go to beginning of word at point
(skip-syntax-backward "w_")
;; and yank entire word into search string.
(isearch-yank-internal
(lambda ()
(skip-syntax-forward "w_")
(point)))))
I bind the command as follows:
(define-key isearch-mode-map (kbd "C-a") 'isearch-yank-word-at-point)
Feedback welcome. I would be happy to add this to isearch.el if people
find it useful.
Christoph
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: isearch-yank-word-at-point (was Re: Key map translations)
2011-04-13 23:06 ` isearch-yank-word-at-point (was Re: Key map translations) Christoph Scholtes
@ 2011-04-14 5:21 ` Deniz Dogan
2011-04-27 17:35 ` Jambunathan K
1 sibling, 0 replies; 13+ messages in thread
From: Deniz Dogan @ 2011-04-14 5:21 UTC (permalink / raw)
To: Christoph Scholtes; +Cc: emacs-devel
2011/4/14 Christoph Scholtes <cschol2112@googlemail.com>:
> On 4/13/2011 1:07 AM, Deniz Dogan wrote:
>
>> This is something I've been wanting for a long time but never really
>> realized it. Is there really nothing similar in isearch already? Maybe
>> we could add it?
>
> I reworked my function a little and the interface is slightly different. You
> press `C-s' to enter isearch mode and then `C-a' to select the entire word
> at point, much like `C-w' would select the word from point on. `Word' is in
> this case defined as a sequence of word and symbol constituents.
>
> Here is the code:
>
> (defun isearch-yank-word-at-point ()
> "Pull word at point into the search string."
> (interactive)
> ;; Only yank if point is on a word constituent or
> ;; symbol constituent per the syntax table.
> (when (or (= (char-syntax (or (char-after) 0)) ?w)
> (= (char-syntax (or (char-after) 0)) ?_))
> ;; If part of the string has been yanked to the search string
> ;; already, unwind the isearch state stack to the beginning to
> ;; start over.
> (while (not (string= isearch-string ""))
> (isearch-pop-state))
>
> ;; Go to beginning of word at point
> (skip-syntax-backward "w_")
> ;; and yank entire word into search string.
> (isearch-yank-internal
> (lambda ()
> (skip-syntax-forward "w_")
> (point)))))
>
>
> I bind the command as follows:
>
> (define-key isearch-mode-map (kbd "C-a") 'isearch-yank-word-at-point)
>
> Feedback welcome. I would be happy to add this to isearch.el if people find
> it useful.
>
> Christoph
>
I think it looks pretty good. However, I'd like it to do something
useful when standing on non-word/symbol constituent characters such as
(. I'd also like to be able to C-a C-a to search for the current word
and the following word.
Thoughts on this?
--
Deniz Dogan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: isearch-yank-word-at-point (was Re: Key map translations)
2011-04-13 23:06 ` isearch-yank-word-at-point (was Re: Key map translations) Christoph Scholtes
2011-04-14 5:21 ` Deniz Dogan
@ 2011-04-27 17:35 ` Jambunathan K
2011-04-27 17:45 ` Drew Adams
1 sibling, 1 reply; 13+ messages in thread
From: Jambunathan K @ 2011-04-27 17:35 UTC (permalink / raw)
To: Christoph Scholtes; +Cc: emacs-devel, Deniz Dogan
Christoph Scholtes <cschol2112@googlemail.com> writes:
> On 4/13/2011 1:07 AM, Deniz Dogan wrote:
>
>> This is something I've been wanting for a long time but never really
>> realized it. Is there really nothing similar in isearch already? Maybe
>> we could add it?
>
> I reworked my function a little and the interface is slightly
> different. You press `C-s' to enter isearch mode and then `C-a' to
> select the entire word at point, much like `C-w' would select the word
> from point on. `Word' is in this case defined as a sequence of word
> and symbol constituents.
>
> Here is the code:
>
> (defun isearch-yank-word-at-point ()
> "Pull word at point into the search string."
> (interactive)
> ;; Only yank if point is on a word constituent or
> ;; symbol constituent per the syntax table.
> (when (or (= (char-syntax (or (char-after) 0)) ?w)
> (= (char-syntax (or (char-after) 0)) ?_))
> ;; If part of the string has been yanked to the search string
> ;; already, unwind the isearch state stack to the beginning to
> ;; start over.
> (while (not (string= isearch-string ""))
> (isearch-pop-state))
>
> ;; Go to beginning of word at point
> (skip-syntax-backward "w_")
> ;; and yank entire word into search string.
> (isearch-yank-internal
> (lambda ()
> (skip-syntax-forward "w_")
> (point)))))
>
>
> I bind the command as follows:
>
> (define-key isearch-mode-map (kbd "C-a") 'isearch-yank-word-at-point)
>
> Feedback welcome. I would be happy to add this to isearch.el if people
> find it useful.
I usually do C-s (C-w)+ while searching for symbols.
This is what I cooked up:
(define-key isearch-mode-map "\C-_" 'isearch-yank-symbol)
(defun isearch-yank-symbol ()
(interactive)
(isearch-yank-internal (lambda ()
(require 'thingatpt)
(forward-symbol 1) (point))))
I chose '_' (underscore) as it stands for symbols in much the same way
as 'w' stands for word.
Searching for symbols is something that I do often and I find it
convenient if some such functionality comes by default with emacs.
Jambunathan K.
--
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: isearch-yank-word-at-point (was Re: Key map translations)
2011-04-27 17:35 ` Jambunathan K
@ 2011-04-27 17:45 ` Drew Adams
0 siblings, 0 replies; 13+ messages in thread
From: Drew Adams @ 2011-04-27 17:45 UTC (permalink / raw)
To: 'Jambunathan K', 'Christoph Scholtes'
Cc: 'Deniz Dogan', emacs-devel
> (define-key isearch-mode-map "\C-_" 'isearch-yank-symbol)
> I chose '_' (underscore) as it stands for symbols in much the same way
> as 'w' stands for word.
I think it's good to reserver `C-_' for something at least somewhat related to
undoing, even in specific keymaps.
The C-_-as-undo association is stronger for most users, I think, than is the
_-as-symbol association.
Just one opinion.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Key map translations
2011-04-12 1:32 Key map translations Christoph Scholtes
2011-04-12 3:35 ` Sean Sieger
@ 2011-04-12 8:18 ` Lennart Borgman
2011-04-13 1:59 ` Christoph Scholtes
1 sibling, 1 reply; 13+ messages in thread
From: Lennart Borgman @ 2011-04-12 8:18 UTC (permalink / raw)
To: Christoph Scholtes; +Cc: emacs-devel
On Tue, Apr 12, 2011 at 3:32 AM, Christoph Scholtes
<cschol2112@googlemail.com> wrote:
> I was trying to assign a custom isearch enhancement to 'C-S-s'
> (Control-Shift-s), but that seems to be translated to 'C-s'. I skimmed
> through the key map section of the manual, but it is unclear to me how I
> would override this translation behavior (or if I even can).
>
> Is there any way to see all of these translations (if there are more than
> 'C-S-s' -> 'C-s') anywhere? The variable `key-translation-map' was not very
> helpful in this regard.
The fallback should only work if there is no direct binding to C-S-s.
Are you defining the key in the right keymap?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Key map translations
2011-04-12 8:18 ` Key map translations Lennart Borgman
@ 2011-04-13 1:59 ` Christoph Scholtes
2011-04-15 1:35 ` Stefan Monnier
0 siblings, 1 reply; 13+ messages in thread
From: Christoph Scholtes @ 2011-04-13 1:59 UTC (permalink / raw)
To: Lennart Borgman; +Cc: emacs-devel
On 4/12/2011 2:18 AM, Lennart Borgman wrote:
> The fallback should only work if there is no direct binding to C-S-s.
> Are you defining the key in the right keymap?
Actually, it looks like I didn't define the key binding right. With the
correct key code for C-S-s it works fine.
However, I still wonder if there is a way to see all the active
translations. They must be defined somewhere?
Christoph
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Key map translations
2011-04-13 1:59 ` Christoph Scholtes
@ 2011-04-15 1:35 ` Stefan Monnier
0 siblings, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2011-04-15 1:35 UTC (permalink / raw)
To: Christoph Scholtes; +Cc: Lennart Borgman, emacs-devel
> However, I still wonder if there is a way to see all the active
> translations. They must be defined somewhere?
Some of the translations (e.g. the mapping from <uppercase> to
<lowercase>, the mapping from S-<key> to <key>, the mapping from
<double-mouse-2> to <mouse-2>, etc...) are hardcoded in the C code of
read-key-sequence. The rest is in input-decode-map, function-key-map,
key-translation-map (and a few more, see the Elisp manual).
Stefan
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2011-04-27 17:45 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-12 1:32 Key map translations Christoph Scholtes
2011-04-12 3:35 ` Sean Sieger
2011-04-13 1:59 ` Christoph Scholtes
2011-04-13 2:53 ` Sean Sieger
2011-04-13 3:16 ` Christoph Scholtes
2011-04-13 7:07 ` Deniz Dogan
2011-04-13 23:06 ` isearch-yank-word-at-point (was Re: Key map translations) Christoph Scholtes
2011-04-14 5:21 ` Deniz Dogan
2011-04-27 17:35 ` Jambunathan K
2011-04-27 17:45 ` Drew Adams
2011-04-12 8:18 ` Key map translations Lennart Borgman
2011-04-13 1:59 ` Christoph Scholtes
2011-04-15 1:35 ` Stefan Monnier
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).