* view-mode keymap @ 2012-12-31 15:04 Daimrod 2012-12-31 16:15 ` Jambunathan K ` (3 more replies) 0 siblings, 4 replies; 12+ messages in thread From: Daimrod @ 2012-12-31 15:04 UTC (permalink / raw) To: help-gnu-emacs I like `view-mode' but it conflicts with others minor mode map (paredit in my case). I would like to know if there is a better way to make a keymap that takes precedence over the others than manipulating `minor-mode-map-alist'. Here is my current implementation: (add-hook 'view-mode-hook (lambda () ;; Makes sure `view-mode-map' is the first minor mode map ;; available in `minor-mode-map-alist', because in case of ;; conflicting bindings, the first one is used. (unless (eq 'view-mode (caar minor-mode-map-alist)) (setf minor-mode-map-alist (cons (cons 'view-mode view-mode-map) (cl-remove 'view-mode minor-mode-map-alist :key #'car)))))) -- Daimrod/Greg ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: view-mode keymap 2012-12-31 15:04 view-mode keymap Daimrod @ 2012-12-31 16:15 ` Jambunathan K [not found] ` <mailman.16432.1356970328.855.help-gnu-emacs@gnu.org> ` (2 subsequent siblings) 3 siblings, 0 replies; 12+ messages in thread From: Jambunathan K @ 2012-12-31 16:15 UTC (permalink / raw) To: Daimrod; +Cc: help-gnu-emacs I think, `make-composed-keymap' can help here. > I like `view-mode' but it conflicts with others minor mode map (paredit > in my case). > > I would like to know if there is a better way to make a keymap that > takes precedence over the others than manipulating > `minor-mode-map-alist'. > > Here is my current implementation: > > (add-hook 'view-mode-hook > (lambda () > ;; Makes sure `view-mode-map' is the first minor mode map > ;; available in `minor-mode-map-alist', because in case of > ;; conflicting bindings, the first one is used. > (unless (eq 'view-mode (caar minor-mode-map-alist)) > (setf minor-mode-map-alist > (cons (cons 'view-mode view-mode-map) > (cl-remove 'view-mode minor-mode-map-alist > :key #'car)))))) -- ^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <mailman.16432.1356970328.855.help-gnu-emacs@gnu.org>]
* Re: view-mode keymap [not found] ` <mailman.16432.1356970328.855.help-gnu-emacs@gnu.org> @ 2013-01-02 14:22 ` Daimrod 2013-01-03 6:28 ` Jambunathan K [not found] ` <mailman.16584.1357194301.855.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 12+ messages in thread From: Daimrod @ 2013-01-02 14:22 UTC (permalink / raw) To: help-gnu-emacs Jambunathan K <kjambunathan@gmail.com> writes: > I think, `make-composed-keymap' can help here. > > >> I like `view-mode' but it conflicts with others minor mode map (paredit >> in my case). >> >> I would like to know if there is a better way to make a keymap that >> takes precedence over the others than manipulating >> `minor-mode-map-alist'. >> >> Here is my current implementation: >> >> (add-hook 'view-mode-hook >> (lambda () >> ;; Makes sure `view-mode-map' is the first minor mode map >> ;; available in `minor-mode-map-alist', because in case of >> ;; conflicting bindings, the first one is used. >> (unless (eq 'view-mode (caar minor-mode-map-alist)) >> (setf minor-mode-map-alist >> (cons (cons 'view-mode view-mode-map) >> (cl-remove 'view-mode minor-mode-map-alist >> :key #'car)))))) I've looked at it but I don't see how it can help. I don't want to create a new keymap, I want `view-mode-map' to take priority over other keymaps. I've looked at the documentation and it seems that changing the order in `minor-mode-map-alist' is the only way to manage priorities between keymap, because they shouldn't conflict in there first place. -- Daimrod/Greg ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: view-mode keymap 2013-01-02 14:22 ` Daimrod @ 2013-01-03 6:28 ` Jambunathan K [not found] ` <mailman.16584.1357194301.855.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 12+ messages in thread From: Jambunathan K @ 2013-01-03 6:28 UTC (permalink / raw) To: Daimrod; +Cc: help-gnu-emacs Daimrod <daimrod@gmail.com> writes: > Jambunathan K <kjambunathan@gmail.com> writes: > >> I think, `make-composed-keymap' can help here. >> >> >>> I like `view-mode' but it conflicts with others minor mode map (paredit >>> in my case). >>> >>> I would like to know if there is a better way to make a keymap that >>> takes precedence over the others than manipulating >>> `minor-mode-map-alist'. >>> >>> Here is my current implementation: >>> >>> (add-hook 'view-mode-hook >>> (lambda () >>> ;; Makes sure `view-mode-map' is the first minor mode map >>> ;; available in `minor-mode-map-alist', because in case of >>> ;; conflicting bindings, the first one is used. >>> (unless (eq 'view-mode (caar minor-mode-map-alist)) >>> (setf minor-mode-map-alist >>> (cons (cons 'view-mode view-mode-map) >>> (cl-remove 'view-mode minor-mode-map-alist >>> :key #'car)))))) > > I've looked at it but I don't see how it can help. I don't want to > create a new keymap, I want `view-mode-map' to take priority over other > keymaps. I was hoping that something like this (use-local-map (make-composed-keymap view-mode-map (current-local-map))) will put `view-mode-map' on top of the keymap stack and thus overwrite paredit's bindings. I see that DEL (backspace) key is shared between view-mode and paredit. My little experimentation that the above snippet failst to produce the effect expected by me. Do you think I am reading the doc of the APIs (used above) incorrectly? > > I've looked at the documentation and it seems that changing the order in > `minor-mode-map-alist' is the only way to manage priorities between > keymap, because they shouldn't conflict in there first place. -- ^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <mailman.16584.1357194301.855.help-gnu-emacs@gnu.org>]
* Re: view-mode keymap [not found] ` <mailman.16584.1357194301.855.help-gnu-emacs@gnu.org> @ 2013-01-03 11:10 ` Daimrod 2013-01-03 12:21 ` Daimrod 0 siblings, 1 reply; 12+ messages in thread From: Daimrod @ 2013-01-03 11:10 UTC (permalink / raw) To: help-gnu-emacs Jambunathan K <kjambunathan@gmail.com> writes: > Daimrod <daimrod@gmail.com> writes: > >> Jambunathan K <kjambunathan@gmail.com> writes: >> >>> I think, `make-composed-keymap' can help here. >>> >>> >>>> I like `view-mode' but it conflicts with others minor mode map (paredit >>>> in my case). >>>> >>>> I would like to know if there is a better way to make a keymap that >>>> takes precedence over the others than manipulating >>>> `minor-mode-map-alist'. >>>> >>>> Here is my current implementation: >>>> >>>> (add-hook 'view-mode-hook >>>> (lambda () >>>> ;; Makes sure `view-mode-map' is the first minor mode map >>>> ;; available in `minor-mode-map-alist', because in case of >>>> ;; conflicting bindings, the first one is used. >>>> (unless (eq 'view-mode (caar minor-mode-map-alist)) >>>> (setf minor-mode-map-alist >>>> (cons (cons 'view-mode view-mode-map) >>>> (cl-remove 'view-mode minor-mode-map-alist >>>> :key #'car)))))) >> >> I've looked at it but I don't see how it can help. I don't want to >> create a new keymap, I want `view-mode-map' to take priority over other >> keymaps. > > I was hoping that something like this > > (use-local-map > (make-composed-keymap view-mode-map > (current-local-map))) > > will put `view-mode-map' on top of the keymap stack and thus overwrite > paredit's bindings. > > I see that DEL (backspace) key is shared between view-mode and paredit. > My little experimentation that the above snippet failst to produce the > effect expected by me. > > Do you think I am reading the doc of the APIs (used above) incorrectly? No, the problem is not the way you're building the keymap, but how keymaps are searched. From (info "(elisp) Searching Keymaps") > (or (cond > (overriding-terminal-local-map > (FIND-IN overriding-terminal-local-map)) > (overriding-local-map > (FIND-IN overriding-local-map)) > ((or (FIND-IN (get-char-property (point) 'keymap)) > (FIND-IN TEMP-MAP) > (FIND-IN-ANY emulation-mode-map-alists) > (FIND-IN-ANY minor-mode-overriding-map-alist) > (FIND-IN-ANY minor-mode-map-alist) > (if (get-text-property (point) 'local-map) > (FIND-IN (get-char-property (point) 'local-map)) > (FIND-IN (current-local-map)))))) > (FIND-IN (current-global-map))) It searches through `minor-mode-map-alist' _before_ looking at `current-local-map'. I could use `overriding-local-map' instead of `current-local-map' if it was a buffer local variable. But it's not, and I'm afraid that making it buffer local might break things in a weird way. >> >> I've looked at the documentation and it seems that changing the order in >> `minor-mode-map-alist' is the only way to manage priorities between >> keymap, because they shouldn't conflict in there first place. -- Daimrod/Greg ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: view-mode keymap 2013-01-03 11:10 ` Daimrod @ 2013-01-03 12:21 ` Daimrod 2013-01-03 13:10 ` Eric Abrahamsen [not found] ` <mailman.16601.1357218351.855.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 12+ messages in thread From: Daimrod @ 2013-01-03 12:21 UTC (permalink / raw) To: help-gnu-emacs Daimrod <daimrod@gmail.com> writes: > Jambunathan K <kjambunathan@gmail.com> writes: > >> Daimrod <daimrod@gmail.com> writes: >> >>> Jambunathan K <kjambunathan@gmail.com> writes: >>> >>>> I think, `make-composed-keymap' can help here. >>>> >>>> >>>>> I like `view-mode' but it conflicts with others minor mode map (paredit >>>>> in my case). >>>>> >>>>> I would like to know if there is a better way to make a keymap that >>>>> takes precedence over the others than manipulating >>>>> `minor-mode-map-alist'. >>>>> >>>>> Here is my current implementation: >>>>> >>>>> (add-hook 'view-mode-hook >>>>> (lambda () >>>>> ;; Makes sure `view-mode-map' is the first minor mode map >>>>> ;; available in `minor-mode-map-alist', because in case of >>>>> ;; conflicting bindings, the first one is used. >>>>> (unless (eq 'view-mode (caar minor-mode-map-alist)) >>>>> (setf minor-mode-map-alist >>>>> (cons (cons 'view-mode view-mode-map) >>>>> (cl-remove 'view-mode minor-mode-map-alist >>>>> :key #'car)))))) >>> >>> I've looked at it but I don't see how it can help. I don't want to >>> create a new keymap, I want `view-mode-map' to take priority over other >>> keymaps. >> >> I was hoping that something like this >> >> (use-local-map >> (make-composed-keymap view-mode-map >> (current-local-map))) >> >> will put `view-mode-map' on top of the keymap stack and thus overwrite >> paredit's bindings. >> >> I see that DEL (backspace) key is shared between view-mode and paredit. >> My little experimentation that the above snippet failst to produce the >> effect expected by me. >> >> Do you think I am reading the doc of the APIs (used above) incorrectly? > > No, the problem is not the way you're building the keymap, but how > keymaps are searched. > > From (info "(elisp) Searching Keymaps") >> (or (cond >> (overriding-terminal-local-map >> (FIND-IN overriding-terminal-local-map)) >> (overriding-local-map >> (FIND-IN overriding-local-map)) >> ((or (FIND-IN (get-char-property (point) 'keymap)) >> (FIND-IN TEMP-MAP) >> (FIND-IN-ANY emulation-mode-map-alists) >> (FIND-IN-ANY minor-mode-overriding-map-alist) >> (FIND-IN-ANY minor-mode-map-alist) >> (if (get-text-property (point) 'local-map) >> (FIND-IN (get-char-property (point) 'local-map)) >> (FIND-IN (current-local-map)))))) >> (FIND-IN (current-global-map))) > > It searches through `minor-mode-map-alist' _before_ looking at > `current-local-map'. > > I could use `overriding-local-map' instead of `current-local-map' if it > was a buffer local variable. But it's not, and I'm afraid that making it > buffer local might break things in a weird way. However I've just noticed that I can use `minor-mode-overriding-map-alist' instead of `minor-mode-map-alist'. So now my code is: (add-hook 'view-mode-hook (lambda () ;; In `view-mode', `view-mode-map' overrides other minor ;; mode maps. (pushnew (cons 'view-mode view-mode-map) minor-mode-overriding-map-alist :key #'car))) A bit more cleaner :) >>> I've looked at the documentation and it seems that changing the order in >>> `minor-mode-map-alist' is the only way to manage priorities between >>> keymap, because they shouldn't conflict in there first place. -- Daimrod/Greg ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: view-mode keymap 2013-01-03 12:21 ` Daimrod @ 2013-01-03 13:10 ` Eric Abrahamsen [not found] ` <mailman.16601.1357218351.855.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 12+ messages in thread From: Eric Abrahamsen @ 2013-01-03 13:10 UTC (permalink / raw) To: help-gnu-emacs Daimrod <daimrod@gmail.com> writes: > So now my code is: > > (add-hook 'view-mode-hook > (lambda () > ;; In `view-mode', `view-mode-map' overrides other minor > ;; mode maps. > (pushnew (cons 'view-mode view-mode-map) > minor-mode-overriding-map-alist > :key #'car))) > > A bit more cleaner :) Thanks! This was annoying me too, but not enough to look into it. I'll try the fix... ^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <mailman.16601.1357218351.855.help-gnu-emacs@gnu.org>]
* Re: view-mode keymap [not found] ` <mailman.16601.1357218351.855.help-gnu-emacs@gnu.org> @ 2013-01-03 15:45 ` Daimrod 0 siblings, 0 replies; 12+ messages in thread From: Daimrod @ 2013-01-03 15:45 UTC (permalink / raw) To: help-gnu-emacs Eric Abrahamsen <eric@ericabrahamsen.net> writes: > Daimrod <daimrod@gmail.com> writes: > >> So now my code is: >> >> (add-hook 'view-mode-hook >> (lambda () >> ;; In `view-mode', `view-mode-map' overrides other minor >> ;; mode maps. >> (pushnew (cons 'view-mode view-mode-map) >> minor-mode-overriding-map-alist >> :key #'car))) >> >> A bit more cleaner :) > > Thanks! This was annoying me too, but not enough to look into it. I'll > try the fix... > > You're welcome :) -- Daimrod/Greg ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: view-mode keymap 2012-12-31 15:04 view-mode keymap Daimrod 2012-12-31 16:15 ` Jambunathan K [not found] ` <mailman.16432.1356970328.855.help-gnu-emacs@gnu.org> @ 2013-01-02 16:43 ` Michael Heerdegen [not found] ` <mailman.16535.1357144973.855.help-gnu-emacs@gnu.org> 3 siblings, 0 replies; 12+ messages in thread From: Michael Heerdegen @ 2013-01-02 16:43 UTC (permalink / raw) To: help-gnu-emacs Daimrod <daimrod@gmail.com> writes: > I like `view-mode' but it conflicts with others minor mode map (paredit > in my case). Why do you need to use `paredit-mode', a mode for editing, and `view-mode' that makes the buffer read-only, at the same time? Michael. ^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <mailman.16535.1357144973.855.help-gnu-emacs@gnu.org>]
* Re: view-mode keymap [not found] ` <mailman.16535.1357144973.855.help-gnu-emacs@gnu.org> @ 2013-01-02 17:08 ` Daimrod 2013-01-03 14:43 ` William Xu [not found] ` <mailman.16604.1357224259.855.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 12+ messages in thread From: Daimrod @ 2013-01-02 17:08 UTC (permalink / raw) To: help-gnu-emacs Michael Heerdegen <michael_heerdegen@web.de> writes: > Daimrod <daimrod@gmail.com> writes: > >> I like `view-mode' but it conflicts with others minor mode map (paredit >> in my case). > > Why do you need to use `paredit-mode', a mode for editing, and > `view-mode' that makes the buffer read-only, at the same time? Well, I was playing with `view-mode', trying to integrate it with some other minor modes to read a text without too much visual noise (hiding the header-line, the mode-line and centering the content). And I tried it on the current buffer which was the source of those modes, it didn't work as I expected, I tried to understand, and so here I am. > Michael. > -- Daimrod/Greg ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: view-mode keymap 2013-01-02 17:08 ` Daimrod @ 2013-01-03 14:43 ` William Xu [not found] ` <mailman.16604.1357224259.855.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 12+ messages in thread From: William Xu @ 2013-01-03 14:43 UTC (permalink / raw) To: help-gnu-emacs Daimrod <daimrod@gmail.com> writes: > Michael Heerdegen <michael_heerdegen@web.de> writes: > >> Daimrod <daimrod@gmail.com> writes: >> >>> I like `view-mode' but it conflicts with others minor mode map (paredit >>> in my case). >> >> Why do you need to use `paredit-mode', a mode for editing, and >> `view-mode' that makes the buffer read-only, at the same time? > > Well, I was playing with `view-mode', trying to integrate it with some > other minor modes to read a text without too much visual noise (hiding > the header-line, the mode-line and centering the content). And I tried > it on the current buffer which was the source of those modes, it didn't > work as I expected, I tried to understand, and so here I am. Maybe you can try this minor mode: ;; View file like a simple `less'. Provide limited less keys, mainly j, ;; k, f, b, g, G, etc. https://github.com/xwl/less/blob/master/less.el I bind `C-c v' to enable it, type `e' to exit. -- William http://xwl.appspot.com ^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <mailman.16604.1357224259.855.help-gnu-emacs@gnu.org>]
* Re: view-mode keymap [not found] ` <mailman.16604.1357224259.855.help-gnu-emacs@gnu.org> @ 2013-01-03 15:44 ` Daimrod 0 siblings, 0 replies; 12+ messages in thread From: Daimrod @ 2013-01-03 15:44 UTC (permalink / raw) To: help-gnu-emacs William Xu <william.xwl@gmail.com> writes: > Daimrod <daimrod@gmail.com> writes: > >> Michael Heerdegen <michael_heerdegen@web.de> writes: >> >>> Daimrod <daimrod@gmail.com> writes: >>> >>>> I like `view-mode' but it conflicts with others minor mode map (paredit >>>> in my case). >>> >>> Why do you need to use `paredit-mode', a mode for editing, and >>> `view-mode' that makes the buffer read-only, at the same time? >> >> Well, I was playing with `view-mode', trying to integrate it with some >> other minor modes to read a text without too much visual noise (hiding >> the header-line, the mode-line and centering the content). And I tried >> it on the current buffer which was the source of those modes, it didn't >> work as I expected, I tried to understand, and so here I am. > > Maybe you can try this minor mode: > > ;; View file like a simple `less'. Provide limited less keys, mainly j, > ;; k, f, b, g, G, etc. > > https://github.com/xwl/less/blob/master/less.el > > I bind `C-c v' to enable it, type `e' to exit. Thanks, but I think I'll keep `view-mode' now that I've found a workaround. -- Daimrod/Greg ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2013-01-03 15:45 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-12-31 15:04 view-mode keymap Daimrod 2012-12-31 16:15 ` Jambunathan K [not found] ` <mailman.16432.1356970328.855.help-gnu-emacs@gnu.org> 2013-01-02 14:22 ` Daimrod 2013-01-03 6:28 ` Jambunathan K [not found] ` <mailman.16584.1357194301.855.help-gnu-emacs@gnu.org> 2013-01-03 11:10 ` Daimrod 2013-01-03 12:21 ` Daimrod 2013-01-03 13:10 ` Eric Abrahamsen [not found] ` <mailman.16601.1357218351.855.help-gnu-emacs@gnu.org> 2013-01-03 15:45 ` Daimrod 2013-01-02 16:43 ` Michael Heerdegen [not found] ` <mailman.16535.1357144973.855.help-gnu-emacs@gnu.org> 2013-01-02 17:08 ` Daimrod 2013-01-03 14:43 ` William Xu [not found] ` <mailman.16604.1357224259.855.help-gnu-emacs@gnu.org> 2013-01-03 15:44 ` Daimrod
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).