emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mykie.el


From: Yuta Yamada
Subject: Re: mykie.el
Date: Wed, 08 Jan 2014 16:21:15 -0500 (EST)

> > SM> You could add it to subr-x.el (after 24.4),
> 
> > Wonderful, thanks.  Yamada-san, WDYT?  Do you want to work on the
> > approach Stefan suggested in the Emacs core and integrate mykie.el with
> > it, or would you rather keep mykie.el separate from this work?
> 
> 

Oh, I misunderstood meaning.
(Sorry I'm English learner yet.)

That means mykie can in the Emacs core if mykie fixed the cosmetic
problems. right?
If it's yes.
I would like mykie to in the Emacs core.

I already fixed some cosmetic issues at future branch.
done:
 - delete needless quotation
 - treat 't symbol as default function
almost done:
 - delete wrong eval(remaining two eval...)
yet:
 - use parenthesized syntax to lispish
 - mykie:global-set-key -> other name

However current mykie took just different approach to check conditions.
Below function is mykie's core logic.

(defun* mykie (&rest args &allow-other-keys)
  (catch 'done
    ;;    ↓ check wheter ignore major-mode overriding
    (loop initially (when (eq 'exit (mykie:init args)) (return))
          ;; collect user specified keywords
          with keywords = (loop for arg in args if (keywordp arg) collect arg)
          ;; conditions separate three group: region, C-u, otherwise
          for conditions in mykie:group-conditions
          ;; check region-acitive-p or current-prefix-arg if needed
          if (funcall mykie:precheck-function conditions) do
          (loop with conds = (symbol-value conditions)
                for keyword in keywords
                ;; conds is like (:C-u&eolp . (eolp))
                if (and (loop for (expect . c) in conds
                              if (or (eq expect keyword)
                                     ;; irregular case for :MAJOR-MODE
                                     ;; C-u*N, M-N
                                     (and (stringp expect)
                                          (string-match
                                           expect (symbol-name keyword))))
                              do (return t))
                        (mykie:predicate conds keyword))
                do (progn (setq mykie:current-state keyword)
                          ;; do specific command
                          (mykie:execute (plist-get args keyword))
                          (throw 'done 'done)))
          ;; do :default or t's function if function was not found
          finally (mykie:execute (or (plist-get args :default)
                                     (plist-get args t)))))
  ;; for :repeat
  (unless (mykie:repeat-p)
    (setq mykie:current-point (point))))

I like pre check function that can ignore needless conditions.
Is it ok?
There is a merit. User don't need useless (region-active-p) or
current-prefix-arg when user register user's condition.

About remaining cosmetic issues,
 - mykie:global-set-key -> ather name and use combind macro

Above mykie function can call like this
(mykie :default '(message "default") :C-u '(message "C-u"))

I don't have much experience of lisp macro.
So I can't say correctly whether it can implement by lisp macro.
But can we use like this?:

(defmacro sm-combind-command (&rest branches)
  `(lambda ()
     (interactive)
     (apply 'mykie ,branches)))

I tried above macro, but I couldn't use correctly.
Could someone help me?
Or Is it impossible?

yet:
 - use parenthesized syntax to lispish

I prefer without parenthesized syntax.
But if we can use above macro then it's easy to create parenthesized
syntax or not too.

Sorry long sentence.
I want to know current mykie can use at next Emacs core.
Or do I need more change?

Yuta



reply via email to

[Prev in Thread] Current Thread [Next in Thread]