[Top][All Lists]

[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 <address@hidden> writes:

> () address@hidden
> () 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

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

#+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
            (lambda (--pair)
              (when (member (car --pair) keys2)
                 (list (car --pair)
                       (cdr --pair)
                       (cdr (assoc (car --pair) cmd-syms2)))))


reply via email to

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