help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Generating a listing of all symbols (16K+) and labeling subsets


From: Thorsten Jolitz
Subject: Re: Generating a listing of all symbols (16K+) and labeling subsets
Date: Fri, 18 Apr 2014 12:09:59 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Thien-Thi Nguyen <ttn@gnu.org> writes:

> () hansbkk@gmail.com
> () Thu, 17 Apr 2014 22:09:35 -0400
>
>    I'd specifically like to ask about the logic of the
>    categorizing breakdown and for better taxonomy terms.
>
> It is a category error to categorize Emacs Lisp symbols into
> (single) buckets, unless you wish to defer understanding.  :-D

I wrote something similar (but much simpler) recently for getting a list
of all mode commands with keybindings, and detecting keybinding
conflicts between two modes:

* Compare Keymaps

#+begin_src emacs-lisp
(defun omm-get-cmd-symbols-with-keys (rgxp mode &optional req)
  "Return alist of (key . sym) pairs where sym matches RGXP.

Require REQ and load MODE in temp buffer before doing the real
work. Push the intermediary results of `mapatoms' to
`omm-tmp-storage'.

Usage example:
 (pp (omm-get-cmd-symbols-with-keys
   \"\\(^org-\\|^orgtbl-\\)\" 'org-mode 'org))"
  (setq omm-tmp-storage nil)
  (mapatoms
   (lambda (--sym)
     (eval
      `(and (commandp --sym)
            (string-match ,rgxp (symbol-name --sym))
            (with-temp-buffer
              (when ,req
                (require (quote ,req)))
              (funcall (quote ,mode))
              (let ((cmd-key (substitute-command-keys
                              (concat
                               "\\[" (symbol-name --sym) "]"))))
                (push
                 (cons
                  (if (string-match "^M-x " cmd-key)
                      nil cmd-key)
                  --sym)
                 omm-tmp-storage)))))))
  (delq nil
        (mapcar
         (lambda (--pair) (if (car --pair) --pair nil))
         (delq nil omm-tmp-storage))))
#+end_src

#+begin_src emacs-lisp
(defun omm-get-keybinding-conflicts (cmd-syms1 cmd-syms2)
  "Return alist with common keys of CMD-SYMS1 and CMD-SYMS2.

The return-list consists of sublists of this form

  (event definition-map1 definition-map2)

Usage example:

  (pp (omm-get-keybinding-conflicts
     (omm-get-cmd-symbols-with-keys \"^magit-\" 'magit-mode)
     (omm-get-cmd-symbols-with-keys \"^dired-\" 'dired-mode)))"
  (let ((keys2 (map 'car cmd-syms2))) ; FIXME with org-mode-map
     (delq nil
           (mapcar
            (lambda (--pair)
              (when (member (car --pair) keys2)
                 (list (car --pair)
                       (cdr --pair)
                       (cdr (assoc (car --pair) cmd-syms2)))))
            cmd-syms1))))
#+end_src


-- 
cheers,
Thorsten




reply via email to

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