From: Drew Adams <drew.adams@oracle.com>
To: "Juri Linkov" <juri@jurta.org>,
"Gauthier Östervall" <gauthier@ostervall.se>
Cc: emacs-devel@gnu.org
Subject: RE: [PATCH] Make `C-x {' and `C-x }' repeatable
Date: Wed, 22 May 2013 10:44:54 -0700 (PDT) [thread overview]
Message-ID: <c2372ad0-c16e-4ac3-81cf-6ca835547330@default> (raw)
In-Reply-To: <87mwrombc3.fsf@mail.jurta.org>
Juri's suggestion is a good one.
There is another way to do this (which I have mentioned before):
;; Needs library `repeat.el'. Either autoload it or add (require 'repeat)
;; to a command that needs it.
;;;### (autoload 'repeat-command "repeat" t nil)
(defun repeat-command (command) ; To be added to `repeat.el'.
"Repeat COMMAND."
(let ((repeat-message-function 'ignore))
(setq last-repeatable-command command)
(repeat nil)))
You can then make a repeatable command from any ordinary command.
E.g., window-sizing:
(defun window-widen (arg)
"...."
(interactive "P")
(repeat-command 'enlarge-window-horizontally))
(defun window-narrow (arg)
"...."
(interactive "P")
(repeat-command 'shrink-window-horizontally))
(defun window-heighten (arg)
"...."
(interactive "P")
(repeat-command 'enlarge-window))
(defun window-shorten (arg)
"...."
(interactive "P")
(repeat-command 'shrink-window))
Bind to any keys you like. E.g., replace non-repeatable cmds:
(define-key ctl-x-map [(?})] 'window-widen)
(define-key ctl-x-map [(?{)] 'window-narrow)
(define-key ctl-x-map [(?^)] 'window-heighten)
(define-key ctl-x-map [(?-)] 'window-shorten)
And you can put them all on a `window-size-map' keymap, as Juri suggested:
(defvar window-size-map (make-sparse-keymap) "...")
(define-key window-size-map [right] 'window-widen)
(define-key window-size-map [left] 'window-narrow)
(define-key window-size-map [up] 'window-heighten)
(define-key window-size-map [down] 'window-shorten)
(global-set-key [f2] window-size-map)
Juri's suggestion too, of course, does not prevent you from having separate repeatable and non-repeatable commands. E.g.,
(defun window-widen (arg) ; Repeatable `enlarge-window-horizontally'
"...."
(interactive "p")
(enlarge-window-horizontally arg)
(set-temporary-overlay-map window-size-map))
An advantage of Juri's suggestion over the `repeat-command' approach is that it is not just for repeating a particular command. You can easily switch from `right' to `left' or `down'. E.g., `f2 right right down down left'. With the `repeat-command' approach you cannot: it recognizes only one command; it is really about repetition.
An advantage of the `repeat-command' approach over Juri's suggestion is that the prefix arg that you give at the outset is used for each repeated step.
With Juri's suggestion, a prefix arg is available for only the first step. Typically you want to repeatedly increase/decrease by the same amount. You cannot even provide a separate prefix arg for each step (which would be annoying in general but might have a use in some contexts).
With Juri's suggestion you can make the first use of a command use a step size of 6, but repeating it puts you back to a step size of 1. Perhaps there is a simple fix to make Juri's suggestion behave better in this respect.
---
I take advantage of this thread to point out bug #14095, which I think is relevant here and which has so far gotten no response. It is a regression introduced at the same time as that of bug #122232 (which was fixed). The change that introduced both problems is the use of `set-temporary-overlay-map' (also pertinent to Juri's suggestion here).
I want to have a repeatable command bound to a key on `isearch-mode-map'. E.g., I bind repeatable command `isearchp-yank-line' to `C-y C-e', so I can successively yank multiple lines into the search string. E.g., during Isearch:
C-y C-e C-e C-e ...
That works with the older `repeat.el' code. It is broken now because of a change to `repeat-repeat-char' so that it uses `set-temporary-overlay-map '. This is because the temporary (overlay) map is overruled by `overriding(-terminal)-local-map', which Isearch uses.
I would really like to see this bug fixed. Users should be able to use repeatable keys on `isearch-mode-map'.
next prev parent reply other threads:[~2013-05-22 17:44 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-20 19:59 [PATCH] Make `C-x {' and `C-x }' repeatable Gauthier Östervall
2013-05-21 9:58 ` Vitalie Spinu
2013-05-21 13:53 ` Gauthier Östervall
2013-05-21 18:34 ` Juri Linkov
2013-05-22 17:44 ` Drew Adams [this message]
2013-05-22 18:55 ` Juri Linkov
2013-05-22 21:39 ` Drew Adams
2013-05-22 22:08 ` Stefan Monnier
2013-05-22 23:53 ` Drew Adams
2013-05-23 0:18 ` chad
2013-05-23 16:19 ` Drew Adams
2013-05-23 16:48 ` Stefan Monnier
2013-05-23 19:52 ` Drew Adams
2013-05-24 4:53 ` Stephen J. Turnbull
2013-05-24 15:55 ` Drew Adams
2013-05-24 17:00 ` Stephen J. Turnbull
2013-05-22 21:47 ` Stefan Monnier
2013-05-22 22:24 ` Stefan Monnier
2013-05-22 23:53 ` Drew Adams
2013-05-23 22:30 ` Juri Linkov
2013-05-24 3:58 ` Stefan Monnier
2013-05-22 19:05 ` Stefan Monnier
2013-05-23 12:21 ` Gauthier Östervall
2013-05-23 13:41 ` Stefan Monnier
2013-05-23 22:04 ` Juri Linkov
2013-05-24 9:38 ` Alan Mackenzie
2013-05-24 20:31 ` Juri Linkov
2013-05-25 20:01 ` Alan Mackenzie
2013-05-25 20:40 ` Juri Linkov
2013-06-02 21:05 ` isearch-allow-prefix [Was: [PATCH] Make `C-x {' and `C-x }' repeatable] Alan Mackenzie
2013-06-04 18:03 ` Juri Linkov
2013-06-04 21:24 ` Alan Mackenzie
2013-06-05 8:23 ` Juri Linkov
2013-06-05 21:02 ` Alan Mackenzie
2013-06-06 6:07 ` isearch-allow-move [Was: isearch-allow-prefix] Juri Linkov
2013-06-06 12:45 ` Stefan Monnier
2013-06-06 15:07 ` Juri Linkov
2013-06-06 15:43 ` Drew Adams
2013-06-06 16:39 ` Stefan Monnier
2013-06-07 7:07 ` Juri Linkov
2013-06-06 20:07 ` Alan Mackenzie
2013-06-07 6:59 ` Juri Linkov
2013-06-07 10:30 ` Alan Mackenzie
2013-06-07 19:30 ` Juri Linkov
2013-06-09 20:09 ` Juri Linkov
2013-06-11 19:35 ` Juri Linkov
2013-06-07 20:04 ` Juri Linkov
2013-06-09 12:07 ` [PATCH] set-temporary-overlay-map improvement and make windresize exit on other commands Vitalie Spinu
2013-06-09 16:03 ` Stefan Monnier
2013-06-09 17:12 ` Vitalie Spinu
2013-06-13 20:44 ` Stefan Monnier
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c2372ad0-c16e-4ac3-81cf-6ca835547330@default \
--to=drew.adams@oracle.com \
--cc=emacs-devel@gnu.org \
--cc=gauthier@ostervall.se \
--cc=juri@jurta.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 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.