[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: mykie.el
From: |
Stefan Monnier |
Subject: |
Re: mykie.el |
Date: |
Fri, 03 Jan 2014 23:34:01 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
> Here's an example of context-dependent usage:
> (mykie:global-set-key "C-j"
> :default '(progn
> (delete-trailing-whitespace)
> (case major-mode
> (org-mode (org-return-indent))
> (t (newline-and-indent))))
> :C-u&eolp '(fill-region (point-at-bol) (point-at-eol))
> :region 'query-replace-regexp)
> (many other keywords are available, e.g. :prog for activating only in
> programming modes)
Is that really much better than:
(global-set-key "\C-j"
(lambda ()
(interactive)
(cond
(current-prefix-arg (fill-region (point-at-bol) (point-at-eol)))
((and (use-region-p) (eolp))
(call-interactively 'query-replace-regexp))
(t
(delete-trailing-whitespace)
(case major-mode
(org-mode (org-return-indent))
(t (newline-and-indent)))))))
IIUC the need for "context dependent bindings" becomes more interesting
when you want the different cases to be specified independently.
As in
(my-global-set-key "\C-j"
:predicate current-prefix-arg
:action (fill-region (point-at-bol) (point-at-eol)))
(my-global-set-key "\C-j"
:predicate (and (use-region-p) (eolp))
:action 'query-replace-regexp)
I'm not sure exactly how best to do that, tho.
Stefan
- Re: enable MELPA & Marmalade by defaul [was: mykie.el], (continued)
- Re: enable MELPA & Marmalade by defaul [was: mykie.el], Richard Stallman, 2014/01/07
- RE: enable MELPA & Marmalade by defaul [was: mykie.el], Drew Adams, 2014/01/07
- Re: enable MELPA & Marmalade by defaul [was: mykie.el], Stephen J. Turnbull, 2014/01/07
- Re: enable MELPA & Marmalade by defaul [was: mykie.el], Richard Stallman, 2014/01/08
- Re: enable MELPA & Marmalade by defaul [was: mykie.el], Ted Zlatanov, 2014/01/07
- RE: enable MELPA & Marmalade by defaul [was: mykie.el], Drew Adams, 2014/01/07
- Re: enable MELPA & Marmalade by defaul [was: mykie.el], Richard Stallman, 2014/01/07
Re: mykie.el,
Stefan Monnier <=
- Re: mykie.el, Leo Liu, 2014/01/04
- Re: mykie.el, Mitchel Humpherys, 2014/01/05
- Re: mykie.el, Nicolas Richard, 2014/01/06
- Re: mykie.el, Ted Zlatanov, 2014/01/06
- Re: mykie.el, Stefan Monnier, 2014/01/06
- Re: mykie.el, Ted Zlatanov, 2014/01/07
- Re: mykie.el, Stefan Monnier, 2014/01/07
- Re: mykie.el, Ted Zlatanov, 2014/01/08
- Re: mykie.el, Stefan Monnier, 2014/01/08