Re: iswitchb-mode and iswitchb-global-map
>> > 1. Shouldn't `iswitchb-global-map' be renamed >> > `iswitchb-mode-map'? Wouldn't that better follow the >> > minor-mode naming convention? >> >> Yes, but iswitchb-mode-map is already used for something else, so it would >> be an incompatible change. > I see. I didn't know that. Is that map perhaps for a local version of the > minor mode? No, it's for the actual iswitchb minibuffer interaction. So it should probably be renamed from iswitchb-mode-map to iswitchb-minibuffer-map. In any case: post-22. Stefan ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
RE: iswitchb-mode and iswitchb-global-map
> > > 2. Shouldn't `iswitchb-global-map' be redefined anew each > > > time `iswitchb-mode' is turned on? > > > > Kind of, yes. I've changed the code to use command remapping > > instead to get > > the same kind of result. I haven't yet given it a try, but I took a quick look at the code. Since there is no remapping equivalent of the 4th arg to substitute-key-definition, I suppose that the code now captures whatever the current bindings of `switch-to-buffer' etc. are, instead of capturing only their `global-map' bindings. Is that correct? Maybe that would be a good thing (better), maybe not. I'm not sure - I guess so. The behavior would be different from before, in any case. Now, the bindings set up might be different, depending on what they are when the mode is turned on. Am I right that the remapping will cause (part of) `iswitchb-global-map' to be redefined anew each time its keys are looked up? That's even better than renewing it each time `iswitchb-mode' is turned on, which was what I proposed (#2). I'm not too sure how command remapping works. The map is created only once here, and put onto `minor-mode-map-alist' once and for all, as before. But, IIUC, the bindings for this in the map are remappings, which are essentially dynamic bindings. That is, the map itself is static and isn't updated each time the mode is entered (as I had suggested), but those bindings are always calculated dynamically, by remapping. If that's how it works, that's pretty cool. I hadn't thought about remapping that way before: the binding takes place at the time of key lookup. Very late binding binding ;-). Another difference from my idea of updating `minor-mode-map-alist' each time the mode is turned on, and using `substitute-key-definition' with `global-map', comes from the fact that remapping only works through a single level. I'm not sure what that would mean in practice, if two or more modes remap the same commands. Precedence in `minor-mode-map-alist' is what counts, so there would be a difference in behavior, in any case. My approach of deleting and reinserting the map in `minor-mode-map-alist' would give users some flexibility when dealing with "dueling" minor modes: they could turn two modes on in a particular order to choose which one grabs contested bindings. Command remapping doesn't allow that, by itself; to get that effect, I think you would still need to dynamically change the order of `minor-mode-map-alist'. Let me know if this makes no sense or I'm missing something. It's late and I'm tired. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
RE: iswitchb-mode and iswitchb-global-map
> > 1. Shouldn't `iswitchb-global-map' be renamed > > `iswitchb-mode-map'? Wouldn't that better follow the > > minor-mode naming convention? > > Yes, but iswitchb-mode-map is already used for something else, so it would > be an incompatible change. I see. I didn't know that. Is that map perhaps for a local version of the minor mode? That is, are there two different maps, one for global use and one for local use? I'm just curious - this is new to me. If so, is there a naming convention for that, or should there be one? How about `iswitch-global-mode-map', instead, to signal that a (minor) mode is involved? > > 2. Shouldn't `iswitchb-global-map' be redefined anew each > > time `iswitchb-mode' is turned on? > > Kind of, yes. I've changed the code to use command remapping > instead to get > the same kind of result. I'm interested, so I'll take a look when I get a chance. Perhaps a similar approach would be useful for my code as well. I guess perhaps you mean that you used remapping in place of substitute-key-definition. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: iswitchb-mode and iswitchb-global-map
> 1. Shouldn't `iswitchb-global-map' be renamed > `iswitchb-mode-map'? Wouldn't that better follow the > minor-mode naming convention? Yes, but iswitchb-mode-map is already used for something else, so it would be an incompatible change. > 2. Shouldn't `iswitchb-global-map' be redefined anew each > time `iswitchb-mode' is turned on? Kind of, yes. I've changed the code to use command remapping instead to get the same kind of result. Stefan ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
iswitchb-mode and iswitchb-global-map
I think these are both bugs, but you might not think so. You might want to think them over, in any case. 1. Shouldn't `iswitchb-global-map' be renamed `iswitchb-mode-map'? Wouldn't that better follow the minor-mode naming convention? 2. Shouldn't `iswitchb-global-map' be redefined anew each time `iswitchb-mode' is turned on? I say this because it uses `substitute-key-definition'. New global bindings for the commands in question (e.g. `switch-to-buffer') will not be taken into account, otherwise. This has an impact in two ways: 1) If `switch-to-buffer' is later bound globally to something different from `C-x b' (an additional binding or a substituted binding), then that binding won't be picked up when `iswitchb-mode' is re-entered later. 2) If some other command is later bound to `C-x b', even if `iswitch-mode' is re-entered later than that, `iswitch-mode' will still co-opt `C-x b' (I think it should not, in that case). In one of my own libraries, the minor mode function, `icicle-mode', unbinds the mode-map variable, `icicle-mode-map', whenever the mode is turned off. Whenever the mode is turned on, `icicle-mode' calls a function that does the following. Shouldn't `iswitchb-mode' do something similar (because it too uses `substitute-key-definition')? a. Delete `icicle-mode's entry from `minor-mode-map-alist' (if present from previously turning on the mode). b. Define `icicle-mode-map' from scratch. Like the code that defines `iswitchb-global-map', this code uses `substitute-key-definition' for `switch-to-buffer': (substitute-key-definition 'switch-to-buffer 'icicle-buffer icicle-mode-map (current-global-map)) c. Add the mode entry to `minor-mode-map-alist' (this is thus done anew each time the mode is turned on). In effect, this is all just a way to render the minor-mode map definition dynamic. Because the mode map is defined using `substitute-key-definition', I want the bindings to reflect the latest state of the global keymap. I wish there were an easier way to do this. I wish, for instance, that you could just provide, as the cdr of an entry to `minor-mode-map-alist', an expression to be evaled to a keymap value, or perhaps a function that is called to return a keymap value. That's not possible today, IIUC: you must provide, as the cdr, a literal keymap or a symbol whose symbol-function is a keymap (the function cell is looked up; the function is not called). I'd like that expression to be evaled, or that function to be called, whenever the mode is turned on. If that were not practical, it could be evaled/called each time `minor-mode-map-alist' were consulted for a key lookup. In that case, the expression or function would then need to determine if it needed to refresh the map (i.e. if the mode was just entered). BTW, something I don't understand, and don't see documented: Does `define-minor-mode' somehow add an entry to `minor-mode-map-alist'? Looking at the `iswitchb-mode' code, I don't see where that is done there. Yet the entry (iswitchb-mode . iswitchb-global-map) is nevertheless present in `minor-mode-map-alist'. I'm wondering what code put it there? I looked at the `define-minor-mode' macro definition too, but I didn't see anything that updated `minor-mode-map-alist'. It's a mystery to me. I wonder if others are also confused about this and think, like I was thinking, that a minor-mode definition must itself push the mode entry onto `minor-mode-map-alist'. Perhaps the doc should say something about this not being necessary, because it happens automatically. But how does it happen? In GNU Emacs 22.0.91.1 (i386-mingw-nt5.1.2600) of 2006-12-11 on LENNART-69DE564 X server distributor `Microsoft Corp.', version 5.1.2600 configured using `configure --with-gcc (3.4) --cflags -Id:/g/include' ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug