From: Chong Yidong Date: Mon, 23 Dec 2013 03:59:10 +0000 (+0800) Subject: Rename set-temporary-overlay-map -> set-transient-map X-Git-Url: https://git.hcoop.net/bpt/emacs.git/commitdiff_plain/8cd22a0818f3ed6832d4caa1883b32bab3107b54 Rename set-temporary-overlay-map -> set-transient-map * lisp/subr.el (set-transient-map): Rename from set-temporary-overlay-map. Doc fix. * lisp/face-remap.el (text-scale-adjust): * lisp/indent.el (indent-rigidly): * lisp/kmacro.el (kmacro-call-macro): * lisp/minibuffer.el (minibuffer-force-complete): * lisp/repeat.el (repeat): * lisp/simple.el (universal-argument--mode): * lisp/calendar/todo-mode.el (todo-insert-item--next-param): * lisp/progmodes/f90.el (f90-abbrev-start): Callers changed. * lisp/org/org.el (orgstruct-make-binding): Call set-transient-map instead of old name set-temporary-overlay-map. * doc/lispref/keymaps.texi (Controlling Active Maps): Renamed set-temporary-overlay-map to set-transient map. Doc fixes. (Searching Keymaps): The transient keymap takes precedence. --- diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index dbe148dbcf..aae5a1a6cc 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog @@ -1,3 +1,9 @@ +2013-12-23 Chong Yidong + + * keymaps.texi (Controlling Active Maps): Renamed + set-temporary-overlay-map to set-transient map. Doc fixes. + (Searching Keymaps): The transient keymap takes precedence. + 2013-12-23 Glenn Morris * loading.texi (How Programs Do Loading, Load Suffixes): diff --git a/doc/lispref/keymaps.texi b/doc/lispref/keymaps.texi index 855420a70c..86e205cf14 100644 --- a/doc/lispref/keymaps.texi +++ b/doc/lispref/keymaps.texi @@ -747,13 +747,13 @@ pseudo-Lisp description of the order and conditions for searching them: @lisp -(or (cond +(or (@var{find-in} @var{transient-map}) + (cond (overriding-terminal-local-map (@var{find-in} overriding-terminal-local-map)) (overriding-local-map (@var{find-in} overriding-local-map)) ((or (@var{find-in} (get-char-property (point) 'keymap)) - (@var{find-in} @var{temp-map}) (@var{find-in-any} emulation-mode-map-alists) (@var{find-in-any} minor-mode-overriding-map-alist) (@var{find-in-any} minor-mode-map-alist) @@ -764,14 +764,17 @@ them: @end lisp @noindent -@var{find-in} and @var{find-in-any} are pseudo functions that search -in one keymap and in an alist of keymaps, respectively. (Searching a -single keymap for a binding is called @dfn{key lookup}; see @ref{Key -Lookup}.) If the key sequence starts with a mouse event, that event's position -is used instead of point and the current buffer. Mouse events on an -embedded string use non-@code{nil} text properties from that string -instead of the buffer. @var{temp-map} is a pseudo variable that -represents the effect of a @code{set-temporary-overlay-map} call. +Here, @var{find-in} and @var{find-in-any} are pseudo functions that +search in one keymap and in an alist of keymaps, respectively. +(Searching a single keymap for a binding is called @dfn{key lookup}; +see @ref{Key Lookup}.) @var{transient-map} is a pseudo variable that +represents the effect of a @code{set-transient-map} call +(@pxref{Controlling Active Maps}). + + In the above pseudo-code, if a key sequence starts with a mouse +event, that event's position is used instead of point and the current +buffer. Mouse events on an embedded string use non-@code{nil} text +properties from that string instead of the buffer. When a match is found (@pxref{Key Lookup}), if the binding in the keymap is a function, the search is over. However if the keymap entry @@ -951,19 +954,27 @@ are used before @code{minor-mode-map-alist} and @code{minor-mode-overriding-map-alist}. @end defvar -@defun set-temporary-overlay-map keymap &optional keep -This function adds @var{keymap} as a temporary keymap that takes -precedence over most other keymaps. It does not take precedence over -the ``overriding'' maps (see above); and unlike them, if no match for -a key is found in @var{keymap}, the search continues. - -Normally, @var{keymap} is used only once. If the optional argument -@var{pred} is @code{t}, the map stays active if a key from @var{keymap} -is used. @var{pred} can also be a function of no arguments: if it returns -non-@code{nil} then @var{keymap} stays active. - -For a pseudo-Lisp description of exactly how and when this keymap applies, -@pxref{Searching Keymaps}. +@cindex transient keymap +@defun set-transient-map keymap &optional keep +This function adds @var{keymap} as a @dfn{transient} keymap, which +takes precedence over other keymaps for one (or more) subsequent keys. + +Normally, @var{keymap} is used just once, to look up the very next +key. If the optional argument @var{pred} is @code{t}, the map stays +active as long as the user types keys defined in @var{keymap}; when +the user types a key that is not in @var{keymap}, the transient keymap +is deactivated and normal key lookup continues for that key. + +The @var{pred} argument can also be a function. In that case, the +function is called with no arguments, prior to running each command, +while @var{keymap} is active; it should return non-@code{nil} if +@var{keymap} should stay active. + +The transient keymap takes precedence over the ``overriding'' maps +(see above); and unlike them, if no match for a key is found in +@var{keymap}, the key lookup process continues. For a pseudo-Lisp +description of exactly how and when this keymap applies, +@xref{Searching Keymaps}. @end defun @node Key Lookup diff --git a/etc/NEWS b/etc/NEWS index 9e694fbbdd..0496e0d877 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2149,8 +2149,8 @@ log, log10, sqrt, and mod. ** Miscellaneous new functions -*** `set-temporary-overlay-map' sets up a temporary keymap that -takes precedence over most other maps for a short while (normally one key). +*** `set-transient-map' sets up a temporary keymap, active for one key +(and optionally more). This keymap takes precedence over other maps. *** `autoloadp' tests if its argument is an autoloaded object. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index fe564a9c8a..06d2a8270a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,17 @@ +2013-12-23 Chong Yidong + + * subr.el (set-transient-map): Rename from + set-temporary-overlay-map. Doc fix. + + * face-remap.el (text-scale-adjust): + * indent.el (indent-rigidly): + * kmacro.el (kmacro-call-macro): + * minibuffer.el (minibuffer-force-complete): + * repeat.el (repeat): + * simple.el (universal-argument--mode): + * calendar/todo-mode.el (todo-insert-item--next-param): + * progmodes/f90.el (f90-abbrev-start): Callers changed. + 2013-12-22 Kenjiro NAKAYAMA * net/eww.el (eww-tag-select): Add text-property to jump to next diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el index 055c97972a..b230df1744 100644 --- a/lisp/calendar/todo-mode.el +++ b/lisp/calendar/todo-mode.el @@ -5619,7 +5619,7 @@ already entered and those still available." (setq todo-insert-item--argsleft todo-insert-item--newargsleft)) (when prompt (message "Enter a key (so far `%s'): %s" todo-insert-item--keys-so-far prompt)) - (set-temporary-overlay-map map) + (set-transient-map map) (setq todo-insert-item--argsleft argsleft))) ;; ----------------------------------------------------------------------------- diff --git a/lisp/face-remap.el b/lisp/face-remap.el index 7517023779..fb1d974e33 100644 --- a/lisp/face-remap.el +++ b/lisp/face-remap.el @@ -326,7 +326,7 @@ a top-level keymap, `text-scale-increase' or (text-scale-increase step) ;; (unless (zerop step) (message "Use +,-,0 for further adjustment") - (set-temporary-overlay-map + (set-transient-map (let ((map (make-sparse-keymap))) (dolist (mods '(() (control))) (dolist (key '(?- ?+ ?= ?0)) ;; = is often unshifted +. diff --git a/lisp/indent.el b/lisp/indent.el index d8bd765f55..b70414a850 100644 --- a/lisp/indent.el +++ b/lisp/indent.el @@ -196,7 +196,7 @@ indentation by specifying a large negative ARG." (progn (message "Edit region indentation with , , \ and .") - (set-temporary-overlay-map indent-rigidly-map t)) + (set-transient-map indent-rigidly-map t)) (save-excursion (goto-char end) (setq end (point-marker)) diff --git a/lisp/isearch.el b/lisp/isearch.el index f222c8f59c..360fabfa7f 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -2251,7 +2251,7 @@ before the command is executed globally with terminated Isearch." (main-event (aref key 0))) (cond ;; Don't exit Isearch if we're in the middle of some - ;; set-temporary-overlay-map thingy like universal-argument--mode. + ;; `set-transient-map' thingy like `universal-argument--mode'. ((not (eq overriding-terminal-local-map isearch--saved-overriding-local-map))) ;; Don't exit Isearch for isearch key bindings. ((commandp (lookup-key isearch-mode-map key nil))) diff --git a/lisp/kmacro.el b/lisp/kmacro.el index d20b54eba3..4f59c23996 100644 --- a/lisp/kmacro.el +++ b/lisp/kmacro.el @@ -650,10 +650,10 @@ others, use \\[kmacro-name-last-macro]." (if (and kmacro-call-repeat-with-arg arg (> arg 1)) (format " %d times" arg) ""))) - ;; Can't use the `keep-pred' arg because this overlay keymap needs to be - ;; removed during the next run of the kmacro (i.e. we need to add&remove - ;; this overlay-map at each repetition). - (set-temporary-overlay-map + ;; Can't use the `keep-pred' arg because this overlay keymap + ;; needs to be removed during the next run of the kmacro + ;; (i.e. we must add and remove this map at each repetition). + (set-transient-map (let ((map (make-sparse-keymap))) (define-key map (vector repeat-key) `(lambda () (interactive) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 178f87c768..de8cfc5329 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1222,7 +1222,7 @@ Repeated uses step through the possible completions." (interactive) (let ((completion-extra-properties extra-prop)) (completion-in-region start (point) table pred))))) - (set-temporary-overlay-map + (set-transient-map (let ((map (make-sparse-keymap))) (define-key map [remap completion-at-point] cmd) (define-key map (vector last-command-event) cmd) diff --git a/lisp/org/ChangeLog b/lisp/org/ChangeLog index fa9dc824c9..a3f8e35861 100644 --- a/lisp/org/ChangeLog +++ b/lisp/org/ChangeLog @@ -1,3 +1,8 @@ +2013-12-23 Chong Yidong + + * org.el (orgstruct-make-binding): Call set-transient-map instead + of old name set-temporary-overlay-map. + 2013-12-06 Achim Gratz * org-crypt.el: Declare `epg-context´. diff --git a/lisp/org/org.el b/lisp/org/org.el index adaabebc6a..79dbb9b057 100644 --- a/lisp/org/org.el +++ b/lisp/org/org.el @@ -9062,7 +9062,7 @@ if `orgstruct-heading-prefix-regexp' is not empty." (key-description key)))))) thereis (key-binding key)))) (if (keymapp binding) - (set-temporary-overlay-map binding) + (set-transient-map binding) (let ((func (or binding (unless disable 'orgstruct-error)))) diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el index 80f663360e..269b087927 100644 --- a/lisp/progmodes/f90.el +++ b/lisp/progmodes/f90.el @@ -2259,7 +2259,7 @@ Any other key combination is executed normally." (interactive "*") (self-insert-command 1) (when abbrev-mode - (set-temporary-overlay-map + (set-transient-map (let ((map (make-sparse-keymap))) (define-key map [??] 'f90-abbrev-help) (define-key map (vector help-char) 'f90-abbrev-help) diff --git a/lisp/repeat.el b/lisp/repeat.el index 01defa6669..d1798f30d8 100644 --- a/lisp/repeat.el +++ b/lisp/repeat.el @@ -278,7 +278,7 @@ recently executed command not bound to an input event\"." (execute-kbd-macro last-repeatable-command)) (call-interactively last-repeatable-command)))) (when repeat-repeat-char - (set-temporary-overlay-map + (set-transient-map (let ((map (make-sparse-keymap))) (define-key map (vector repeat-repeat-char) (if (null repeat-message-function) 'repeat diff --git a/lisp/simple.el b/lisp/simple.el index d6e61fd209..a6543516a9 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -3321,7 +3321,7 @@ see other processes running on the system, use `list-system-processes'." "Keymap used while processing \\[universal-argument].") (defun universal-argument--mode () - (set-temporary-overlay-map universal-argument-map)) + (set-transient-map universal-argument-map)) (defun universal-argument () "Begin a numeric argument for the following command. diff --git a/lisp/subr.el b/lisp/subr.el index 2a2068ff29..ab2023bd54 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -4266,33 +4266,35 @@ use `called-interactively-p'." (eq 'add-keymap-witness (nth 1 map)) (set symbol tail))))) -(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 -`keymap' text property). Unlike those maps, if no match for a key is -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. - -Optional ON-EXIT argument is a function that is called after the -deactivation of MAP." - (let ((clearfun (make-symbol "clear-temporary-overlay-map"))) +(defun set-transient-map (map &optional keep-pred on-exit) + "Set MAP as a temporary keymap taking precedence over other keymaps. +Normally, MAP is used only once, to look up the very next key. +However, 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. + +Optional arg ON-EXIT, if non-nil, specifies a function that is +called, with no arguments, after MAP is deactivated. + +Note that MAP will take precedence over the \"overriding\" maps +`overriding-terminal-local-map' and `overriding-local-map' (and +over the `keymap' text property). Unlike those maps, if no match +for a key is found in MAP, Emacs continues the normal key lookup +sequence." + (let ((clearfun (make-symbol "clear-transient-map"))) ;; Don't use letrec, because equal (in add/remove-hook) would get trapped ;; in a cycle. (fset clearfun (lambda () - ;; FIXME: Handle the case of multiple temporary-overlay-maps - ;; E.g. if isearch and C-u both use temporary-overlay-maps, Then - ;; the lifetime of the C-u should be nested within the isearch - ;; overlay, so the pre-command-hook of isearch should be - ;; suspended during the C-u one so we don't exit isearch just - ;; because we hit 1 after C-u and that 1 exits isearch whereas it - ;; doesn't exit C-u. - (with-demoted-errors "set-temporary-overlay-map PCH: %S" + ;; FIXME: Handle the case of multiple transient maps. For + ;; example, if isearch and C-u both use transient maps, + ;; then the lifetime of the C-u should be nested within + ;; the isearch overlay, so the pre-command-hook of isearch + ;; should be suspended during the C-u one so we don't exit + ;; isearch just because we hit 1 after C-u and that 1 + ;; exits isearch whereas it doesn't exit C-u. + (with-demoted-errors "set-transient-map PCH: %S" (unless (cond ((null keep-pred) nil) ((eq t keep-pred) (eq this-command