From: Vitalie Spinu <spinuvit@gmail.com>
To: Juri Linkov <juri@jurta.org>
Cc: "Stefan Monnier" <monnier@iro.umontreal.ca>,
"Gauthier Östervall" <gauthier@ostervall.se>,
emacs-devel@gnu.org
Subject: [PATCH] set-temporary-overlay-map improvement and make windresize exit on other commands
Date: Sun, 09 Jun 2013 14:07:16 +0200 [thread overview]
Message-ID: <87mwqzo5cb.fsf_-_@gmail.com> (raw)
In-Reply-To: <87txlts7so.fsf@mail.jurta.org> (Juri Linkov's message of "Fri, 24 May 2013 01:04:40 +0300")
[-- Attachment #1: Type: text/plain, Size: 756 bytes --]
Here are two simple patches that make windresize work with
set-temporary-overlay-map.
First patch is to emacs trunk and adds ON-EXIT argument to
set-temporary-overlay-map. Irrespective of windresize I think this is a
useful addition anyhow. It opens the way for set-temporary-overlay-map
to be directly used by electric commands that need to clean up temporary
buffers, messages, window configuration etc.
Second patch is to windresize. Depending on the value of
windresize-exit-on-other-command, windresize will exit on any other
command than those defined in windresize-map. I set it to t by
default. It seems like a nicer default given the discussion on current
thread.
My .emacs now has
(define-key ctl-x-map "w" 'windresize)
Vitalie
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-add-ON-EXIT-argument-to-set-temporary-overlay-map.patch --]
[-- Type: text/x-diff, Size: 2200 bytes --]
From 103046272cb842451c57c6bf097755b2ef40f474 Mon Sep 17 00:00:00 2001
From: Vitalie Spinu <spinuvit@gmail.com>
Date: Sun, 9 Jun 2013 13:38:23 +0200
Subject: [PATCH] add ON-EXIT argument to set-temporary-overlay-map
* lisp/subr.el (set-temporary-overlay-map): Optional ON-EXIT argument is
a function that is called after the deactivation of MAP.
---
lisp/subr.el | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/lisp/subr.el b/lisp/subr.el
index 65943ae..bb35a9a 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4260,7 +4260,7 @@ If NUM is non-nil, return non-nil iff F can be called with NUM args."
(and (>= num (car res))
(or (eq 'many (cdr res)) (<= num (cdr res)))))))
-(defun set-temporary-overlay-map (map &optional keep-pred)
+(defun set-temporary-overlay-map (map &optional keep-pred on-exit)
"Set MAP as a temporary keymap taking precedence over most other keymaps.
Note that this does NOT take precedence over the \"overriding\" maps
`overriding-terminal-local-map' and `overriding-local-map' (or the
@@ -4270,7 +4270,10 @@ found in MAP, the normal key lookup sequence then continues.
Normally, MAP is used only once. If the optional argument
KEEP-PRED is t, MAP stays active if a key from MAP is used.
KEEP-PRED can also be a function of no arguments: if it returns
-non-nil then MAP stays active."
+non-nil then MAP stays active.
+
+Optional ON-EXIT argument is a function that is called after the
+deactivation of MAP."
(let* ((clearfunsym (make-symbol "clear-temporary-overlay-map"))
(overlaysym (make-symbol "t"))
(alist (list (cons overlaysym map)))
@@ -4286,7 +4289,9 @@ non-nil then MAP stays active."
(set ',overlaysym nil) ;Just in case.
(remove-hook 'pre-command-hook ',clearfunsym)
(setq emulation-mode-map-alists
- (delq ',alist emulation-mode-map-alists))))))
+ (delq ',alist emulation-mode-map-alists))
+ ,(when on-exit
+ `(funcall ',on-exit))))))
(set overlaysym overlaysym)
(fset clearfunsym clearfun)
(add-hook 'pre-command-hook clearfunsym)
--
1.8.1.2
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: patch-windresize-exit-on-other-command.patch --]
[-- Type: text/x-diff, Size: 2056 bytes --]
*** /home/vitoshka/Dropbox/ELPA/windresize-0.1/windresize.el.~1~ 2013-06-09 12:01:27.257902916 +0200
--- /home/vitoshka/Dropbox/ELPA/windresize-0.1/windresize.el 2013-06-09 13:46:50.737784424 +0200
***************
*** 109,114 ****
--- 109,120 ----
:group 'convenience
:type 'integer)
+ (defcustom windresize-exit-on-other-command t
+ "If non-nil, windresize will exit on any command not defined in
+ `windresize-map'"
+ :group 'convenience
+ :type 'boolean)
+
(defcustom windresize-modifiers '((meta shift) meta
(control meta) control)
"A list of modifiers for arrow keys commands.
***************
*** 157,164 ****
(defvar windresize-map
(let ((map (make-sparse-keymap)))
(define-key map [remap self-insert-command] 'windresize-other-char)
- (define-key map (kbd "M-x") 'windresize-other-char)
- (define-key map (kbd "C-h") 'windresize-other-char)
;; move borders outwards or shrink/enlarge
(define-key map [left] 'windresize-left)
(define-key map [right] 'windresize-right)
--- 163,168 ----
***************
*** 364,371 ****
(current-window-configuration))
(setq windresize-buffer (current-buffer))
;; set overriding map and pre/post-command hooks
! (setq overriding-terminal-local-map windresize-map)
! (setq overriding-local-map-menu-flag t)
(windresize-add-command-hooks)
;; set the initial message
(setq windresize-msg
--- 368,379 ----
(current-window-configuration))
(setq windresize-buffer (current-buffer))
;; set overriding map and pre/post-command hooks
! (if windresize-exit-on-other-command
! (set-temporary-overlay-map windresize-map t 'windresize-exit)
! (define-key windresize-map (kbd "M-x") 'windresize-other-char)
! (define-key windresize-map (kbd "C-h") 'windresize-other-char)
! (setq overriding-terminal-local-map windresize-map)
! (setq overriding-local-map-menu-flag t))
(windresize-add-command-hooks)
;; set the initial message
(setq windresize-msg
[-- Attachment #4: Type: text/plain, Size: 2396 bytes --]
>> Juri Linkov <juri@jurta.org>
>> on Fri, 24 May 2013 01:04:40 +0300 wrote:
>>> I will give it a try, but I feel that functionality should be
>>> built-in.
>>
>> Yes clearly, that is needed before we can consider it to make C-x
>> [{}^] redundant.
JL> If the goal is to replace `C-x [{}^]' with one global keybinding,
JL> the currently free and intuitive key prefix for window related commands
JL> would be `C-x w', so that a command to activate window-resizing
JL> key sequence could be bound to `C-x w r'.
JL> Until this is implemented, something like below could help
JL> for experimenting with possible implementations:
JL> (defvar window-resize-keymap
JL> (let ((map (make-sparse-keymap)))
JL> ;; Standard keys:
JL> (define-key map "0" 'delete-window)
JL> (define-key map "1" 'delete-other-windows)
JL> (define-key map "2" 'split-window-below)
JL> (define-key map "3" 'split-window-right)
JL> (define-key map "o" 'other-window)
JL> (define-key map "^" 'enlarge-window)
JL> (define-key map "}" 'enlarge-window-horizontally)
JL> (define-key map "{" 'shrink-window-horizontally)
JL> (define-key map "-" 'shrink-window-if-larger-than-buffer)
JL> (define-key map "+" 'balance-windows)
JL> ;; Additional keys:
JL> (define-key map "v" 'shrink-window)
JL> (define-key map [down] 'shrink-window)
JL> (define-key map [up] 'enlarge-window)
JL> (define-key map [left] 'shrink-window-horizontally)
JL> (define-key map [right] 'enlarge-window-horizontally)
JL> map)
JL> "Keymap to resize windows.")
JL> (advice-add 'enlarge-window-horizontally :after (lambda (delta)
JL> (set-temporary-overlay-map window-resize-keymap)))
JL> (advice-add 'shrink-window-horizontally :after (lambda (delta)
JL> (set-temporary-overlay-map window-resize-keymap)))
JL> (advice-add 'enlarge-window :after (lambda (delta &optional horizontal)
JL> (set-temporary-overlay-map window-resize-keymap)))
JL> (advice-add 'shrink-window :after (lambda (delta &optional horizontal)
JL> (set-temporary-overlay-map window-resize-keymap)))
JL> (defun window-resize-init ()
JL> (interactive)
JL> (message "Use window-resizing keys...")
JL> (set-temporary-overlay-map window-resize-keymap))
JL> (define-key ctl-x-map "wr" 'window-resize-init)
next prev parent reply other threads:[~2013-06-09 12:07 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
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 ` Vitalie Spinu [this message]
2013-06-09 16:03 ` [PATCH] set-temporary-overlay-map improvement and make windresize exit on other commands 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=87mwqzo5cb.fsf_-_@gmail.com \
--to=spinuvit@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=gauthier@ostervall.se \
--cc=juri@jurta.org \
--cc=monnier@iro.umontreal.ca \
/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.