unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#15568: Lookup this-command-keys without a prefix argument
@ 2013-10-08 23:21 Juri Linkov
  2013-10-09 18:14 ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2013-10-08 23:21 UTC (permalink / raw)
  To: 15568

As discovered in bug#15200, (lookup-key isearch-mode-map (this-command-keys))
can't decide whether the key sequence is bound to an isearch command or not.

(lookup-key isearch-mode-map (kbd "C-u C-l")) => 1
(lookup-key isearch-mode-map (kbd "C-u C-w")) => 1

both return 1.

The length of universal-argument-num-events was used to remove
the prefix from this-command-keys to lookup a key without prefix,
but since universal-argument-num-events is gone it's unclear
what could replace it.





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

* bug#15568: Lookup this-command-keys without a prefix argument
  2013-10-08 23:21 bug#15568: Lookup this-command-keys without a prefix argument Juri Linkov
@ 2013-10-09 18:14 ` Stefan Monnier
  2013-10-09 23:57   ` Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2013-10-09 18:14 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 15568

> As discovered in bug#15200, (lookup-key isearch-mode-map (this-command-keys))
> can't decide whether the key sequence is bound to an isearch command or not.

Actually, this is easy to fix: use this-single-command-keys.


        Stefan





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

* bug#15568: Lookup this-command-keys without a prefix argument
  2013-10-09 18:14 ` Stefan Monnier
@ 2013-10-09 23:57   ` Juri Linkov
  2013-10-10  1:02     ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2013-10-09 23:57 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 15568-done

>> As discovered in bug#15200, (lookup-key isearch-mode-map (this-command-keys))
>> can't decide whether the key sequence is bound to an isearch command or not.
>
> Actually, this is easy to fix: use this-single-command-keys.

Ah, I expected such a command, but missed it when looked
at the list of commands with the prefix "this-command-...".

Also I discovered that to support a key sequence like
`C-s C-u C-u C-l' requires adding the command `universal-argument-more'
(and `universal-argument-minus' for completeness).

I installed a fix for these problems.





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

* bug#15568: Lookup this-command-keys without a prefix argument
  2013-10-09 23:57   ` Juri Linkov
@ 2013-10-10  1:02     ` Stefan Monnier
  2013-10-10 23:58       ` Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2013-10-10  1:02 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 15568-done

> Also I discovered that to support a key sequence like
> `C-s C-u C-u C-l' requires adding the command `universal-argument-more'
> (and `universal-argument-minus' for completeness).

Indeed, tho I think your fix is a workaround rather than a real fix:
Basically after the first C-u we're in some kind of transient
"universal-argument mode" and isearch shouldn't have to know the list of
commands that can be run in this mode, it should instead just "wait for
the mode to exit".

This is a general issue regarding interaction between various uses of
set-temporary-overlay-map (and friends, since isearch doesn't actually
use set-temporary-overlay-map).  There should be some kind of notion of
nesting, where the outer set-temporary-overlay-map should not exit as
long as the inner one is still active.

> I installed a fix for these problems.

Thanks.


        Stefan





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

* bug#15568: Lookup this-command-keys without a prefix argument
  2013-10-10  1:02     ` Stefan Monnier
@ 2013-10-10 23:58       ` Juri Linkov
  2013-10-11  2:30         ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2013-10-10 23:58 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 15568

>> Also I discovered that to support a key sequence like
>> `C-s C-u C-u C-l' requires adding the command `universal-argument-more'
>> (and `universal-argument-minus' for completeness).
>
> Indeed, tho I think your fix is a workaround rather than a real fix:
> Basically after the first C-u we're in some kind of transient
> "universal-argument mode" and isearch shouldn't have to know the list of
> commands that can be run in this mode, it should instead just "wait for
> the mode to exit".
>
> This is a general issue regarding interaction between various uses of
> set-temporary-overlay-map (and friends, since isearch doesn't actually
> use set-temporary-overlay-map).  There should be some kind of notion of
> nesting, where the outer set-temporary-overlay-map should not exit as
> long as the inner one is still active.

Maybe `universal-argument--mode' should be defined as a minor mode
and provide a variable with the same name that can be checked by isearch.
This mode can be disabled using `on-exit'.  Something like:

(defun universal-argument--mode ()
  (setq universal-argument--mode t)
  (set-temporary-overlay-map
   universal-argument-map nil
   (lambda () (setq universal-argument--mode nil))))

and in isearch.el:

          (and isearch-allow-prefix
	       (or (memq this-command '(universal-argument
					digit-argument
					negative-argument))
		   universal-argument--mode))





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

* bug#15568: Lookup this-command-keys without a prefix argument
  2013-10-10 23:58       ` Juri Linkov
@ 2013-10-11  2:30         ` Stefan Monnier
  2013-10-11 12:50           ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2013-10-11  2:30 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 15568

> Maybe `universal-argument--mode' should be defined as a minor mode
> and provide a variable with the same name that can be checked by isearch.

No, isearch shouldn't need to know anything about universal-argument,
other than "it follows the convention for set-temporary-overlay-map".


        Stefan





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

* bug#15568: Lookup this-command-keys without a prefix argument
  2013-10-11  2:30         ` Stefan Monnier
@ 2013-10-11 12:50           ` Stefan Monnier
  2013-10-11 23:49             ` Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2013-10-11 12:50 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 15568

>> Maybe `universal-argument--mode' should be defined as a minor mode
>> and provide a variable with the same name that can be checked by isearch.
> No, isearch shouldn't need to know anything about universal-argument,
> other than "it follows the convention for set-temporary-overlay-map".

Here's an idea: check if (eq overriding-terminal-local-map isearch-mode-map)


        Stefan





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

* bug#15568: Lookup this-command-keys without a prefix argument
  2013-10-11 12:50           ` Stefan Monnier
@ 2013-10-11 23:49             ` Juri Linkov
  0 siblings, 0 replies; 8+ messages in thread
From: Juri Linkov @ 2013-10-11 23:49 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 15568

> Here's an idea: check if (eq overriding-terminal-local-map isearch-mode-map)

I tried this approach and it passes my tests:

=== modified file 'lisp/isearch.el'
--- lisp/isearch.el	2013-10-09 23:52:46 +0000
+++ lisp/isearch.el	2013-10-11 23:49:42 +0000
@@ -2240,10 +2240,12 @@ (defun isearch-pre-command-hook ()
       (setq this-command 'isearch-edit-string))
      ;; Handle a scrolling function or prefix argument.
      ((or (and isearch-allow-prefix
-	       (memq this-command '(universal-argument
-				    universal-argument-more
-				    universal-argument-minus
-				    digit-argument negative-argument)))
+	       (or (memq this-command '(universal-argument
+					digit-argument
+					negative-argument))
+		   ;; Check if a prefix arg added a nested map.
+		   (and overriding-terminal-local-map
+			(not (eq overriding-terminal-local-map isearch-mode-map)))))
 	  (and isearch-allow-scroll
 	       (or (eq (get this-command 'isearch-scroll) t)
 		   (eq (get this-command 'scroll-command) t))))






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

end of thread, other threads:[~2013-10-11 23:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-08 23:21 bug#15568: Lookup this-command-keys without a prefix argument Juri Linkov
2013-10-09 18:14 ` Stefan Monnier
2013-10-09 23:57   ` Juri Linkov
2013-10-10  1:02     ` Stefan Monnier
2013-10-10 23:58       ` Juri Linkov
2013-10-11  2:30         ` Stefan Monnier
2013-10-11 12:50           ` Stefan Monnier
2013-10-11 23:49             ` Juri Linkov

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).