[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: mykie.el
From: |
Ted Zlatanov |
Subject: |
Re: mykie.el |
Date: |
Tue, 07 Jan 2014 18:21:57 -0500 |
User-agent: |
Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux) |
On Mon, 06 Jan 2014 19:37:01 -0500 Stefan Monnier <address@hidden> wrote:
SM> Is that really much better than [vanilla Emacs lisp]?
>> Yes. The difference is huge for a beginner.
SM> I'm far from convinced. The beginner will have to learn the
SM> mykie-specific sublanguage. Maybe it's slightly simpler, but then this
SM> effort won't help him understand other code.
That's a problem with anything that hides code complexity, and yet we do
it all the time. I doubt beginners can handle `pcase' and the
subtleties of context-sensitive key definitions, so I think for this
specific case the simplification is necessary.
SM> Making it easier to customize Emacs is great, but it's better if it also
SM> gets you some way towards hacking on Emacs so as to become a contributor.
I completely disagree with that line of thinking.
SM> Of course, there are cosmetic issues in the mykie.el syntax that rub me
SM> the wrong way. Most obvious is the need to quote code. I already spend
SM> enough time telling people not to quote their lambdas and trying to fix
SM> code that abuses `eval' in all kinds of useless ways.
That's a good point.
...
SM> (global-set-key "C-j"
SM> (sm-combined-command
SM> (:C-u&eolp (fill-region (point-at-bol) (point-at-eol)))
SM> (:region 'query-replace-regexp)
SM> (t
SM> (delete-trailing-whitespace)
SM> (case major-mode
SM> (org-mode (org-return-indent))
SM> (t (newline-and-indent))))))
SM> And sm-combined-command is a very simple macro:
SM> (defconst sm-combined-command-predicates
SM> '((:region . (use-region-p))
SM> (:C-u . current-prefix-arg)
SM> (:C-u&eolp . (and current-prefix-arg (eolp)))
SM> ...))
SM> (defmacro sm-combined-command (branches)
SM> `(lambda ()
SM> (interactive)
SM> (cond
SM> ,@(mapcar (lambda (branch)
SM> `(,(or (cdr (assq (car branch)
SM> sm-combined-command-predicates))
SM> (car branch))
SM> ,@(pcase (cdr branch)
SM> (`(',cmd) `((call-interactively ',cmd)))
SM> (,cmds cmds))))
SM> branches))))
That's very nice (you and your pcase :). I think it's fairly difficult
to explain *how* it works to a beginner and would need lots of
documentation, but from the user's standpoint it's exactly what I was
hoping to bring out of mykie.el. The developers can then contribute
more predicates and the users can happily use them.
The important question for you and Yamada-san is, would you be
interested in something like `sm-combined-command' in the Emacs core,
regardless of how mykie.el evolves? Then mykie.el can remain a place
for experimentation and perhaps it can use `sm-combined-command'
internally, enriching it with special extensions that maybe don't make
sense in the core.
The other way I imagine is to put mykie.el in the GNU ELPA, but I would
rather enable this facility by default if there are no objections.
Ted
- Re: enable MELPA & Marmalade by defaul [was: mykie.el], (continued)
Re: mykie.el, Stefan Monnier, 2014/01/03
- 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 <=
- Re: mykie.el, Stefan Monnier, 2014/01/07
- Re: mykie.el, Ted Zlatanov, 2014/01/08
- Re: mykie.el, Stefan Monnier, 2014/01/08
- Re: mykie.el, Ted Zlatanov, 2014/01/08
- Re: mykie.el, Stefan Monnier, 2014/01/08
- Re: mykie.el, Tassilo Horn, 2014/01/09
- Re: mykie.el, Stefan Monnier, 2014/01/09
- Re: mykie.el, Yuta Yamada, 2014/01/09
- Re: mykie.el, Yuta Yamada, 2014/01/11
- Re: mykie.el, Stefan Monnier, 2014/01/12