emacs-devel
[Top][All Lists]
Advanced

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

Re: Emacs Lisp's future


From: Thorsten Jolitz
Subject: Re: Emacs Lisp's future
Date: Tue, 30 Sep 2014 21:18:47 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Thorsten Jolitz <address@hidden> writes:

> Nic Ferrier <address@hidden> writes:
>
>> Thorsten Jolitz <address@hidden> writes:
>>
>>> address@hidden (Phillip Lord) writes:
>>> May be an Org table would be a good input format:
>>>
>>> #+BEGIN_ORG
>>> | (key . fun) |             |             |
>>> |-------------+-------------+-------------|
>>> |             |             |             |
>>> | (key . fun) | (key . fun) | (key . fun) |
>>> | (key . fun) | (key . fun) |             |
>>> |             |             |             |
>>> | (key . fun) | (key . fun) |             |
>>> |-------------+-------------+-------------|
>>> |             | (key . fun) |             |
>>> #+END_ORG
>>
>>
>> You should totally do this. I'd love to play with it.
>
> 'discover-context-menus' look like this:
>
> #+BEGIN_SRC emacs-lisp
> (dired
>  (description "DIRectory EDitor")
>  (actions
>   ("Navigation"
>    ("DEL" "unmark backward" dired-unmark-backward)
>    ("RET" "find file" dired-find-file)
>    ("SPC" "next line" dired-next-line)
>    ("<" "prev dirline" dired-prev-dirline)
>    (">" "next dirline" dired-next-dirline)
>    ("^" "up directory" dired-up-directory)
>    ("j" "goto file" dired-goto-file)
>    ("i" "maybe insert subdir" dired-maybe-insert-subdir)
>    ("n" "next line" dired-next-line)
>    ("p" "previous line" dired-previous-line)
>    ("v" "view file" dired-view-file)
>    ("w" "copy filename as kill" dired-copy-filename-as-kill)) ...))
> #+END_SRC
>
> and it could easily be derived form an org table:
>
>
> | Navigation |  |
> | (DEL . dired-find-file) |    (RET . dired-find-file)|

[Ups, sorry ...  did C-c C-c in the table, but wasn't in Org-mode but in
message-mode, so sent the message accidentally]

Calling 'org-table-to-lisp on this table

| Navigation              |                         |
| DEL dired-find-file     | RET dired-find-file     |

 yields:

(("Navigation" "") ("DEL dired-find-file" "RET dired-find-file"))

Using that as arg for this (imperfect) mapping function

#+BEGIN_SRC emacs-lisp
(defun tj/org-tbl-to-context-menu (org-tbl-as-lisp)
   (mapcar
   (lambda (--row)
     (mapcar
      (lambda (--cell)
        (let ((cell-split (split-string --cell " " t)))
          (if (eq (length cell-split) 2)
              (list (car cell-split)
                    (mapconcat
                     'identity
                     (split-string
                      (cadr cell-split) "\\(?:dired\\)?-" t)
                     " ")
                    (intern (cadr cell-split)))
            cell-split)))
      --row))
   org-tbl-as-lisp))
#+END_SRC

yields something (at least somehow) similar to 'discover-context-menus':

#+BEGIN_SRC emacs-lisp
((("Navigation") nil) (("DEL" "find file" dired-find-file) ("RET" "find
file" dired-find-file)))
#+END_SRC

but to make it useful, makey.el would need to consider empty tbl-cells
as well as empty tbl-rows as well as hlines when drawing the UI grid.

-- 
cheers,
Thorsten




reply via email to

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