From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Hans BKK Newsgroups: gmane.emacs.help Subject: Re: Generating a listing of all symbols (16K+) and labeling subsets Date: Fri, 18 Apr 2014 19:50:27 -0700 (PDT) Message-ID: References: <38d1beb3-fffd-4718-ae10-be9646ac4a63@googlegroups.com> <6753f7ae-da6d-4065-9c53-a6f1e59b7ef5@googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1397876124 23863 80.91.229.3 (19 Apr 2014 02:55:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Apr 2014 02:55:24 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Apr 19 04:55:19 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WbLR0-0000ZE-I7 for geh-help-gnu-emacs@m.gmane.org; Sat, 19 Apr 2014 04:55:18 +0200 Original-Received: from localhost ([::1]:40702 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WbLR0-000862-3K for geh-help-gnu-emacs@m.gmane.org; Fri, 18 Apr 2014 22:55:18 -0400 X-Received: by 10.58.228.201 with SMTP id sk9mr12419957vec.35.1397875828056; Fri, 18 Apr 2014 19:50:28 -0700 (PDT) X-Received: by 10.182.111.170 with SMTP id ij10mr223114obb.18.1397875827918; Fri, 18 Apr 2014 19:50:27 -0700 (PDT) Original-Path: usenet.stanford.edu!cm18no4187287qab.0!news-out.google.com!gi6ni537igc.0!nntp.google.com!c1no378969igq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help In-Reply-To: <6753f7ae-da6d-4065-9c53-a6f1e59b7ef5@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2602:306:334f:a5e0:34d6:6f1d:10e2:9ffb; posting-account=IUdGewoAAACF9WtA3i8stuVyXNk2FqaH Original-NNTP-Posting-Host: 2602:306:334f:a5e0:34d6:6f1d:10e2:9ffb User-Agent: G2/1.0 Injection-Date: Sat, 19 Apr 2014 02:50:27 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.help:204948 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:97213 Archived-At: > > The currently-in-development Emacs 24.4 includes `macrop'[1]. I can't > > vouch for what (if any) other versions it's appropriate for, but it did > > succeed in a couple very basic experiments on 24.3.1. > > [1] > > http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/subr.el?h=emacs-24#n2664 OK, just dropped that snippet at the top of my listing.el file and macrop works a treat, thanks! Here's a shortened listing of the cond-tree for each symbol type and my taxonomy if anyone cares to comment further on my terminology: ((fboundp sym) ; ALL functions ((commandp sym) ((keymapp sym) (princ "command - keymap:\t\t\t\t\t") ((subrp (symbol-function sym)) (princ "command - built-in primitive:\t\t") ((byte-code-function-p (symbol-function sym)) (princ "command - byte-code:\t\t\t") ((functionp sym) (princ "command - elisp:\t\t\t") (t ; (non-command) functions ((macrop sym) (princ "function - macro:\t\t\t") ((keymapp sym) (princ "function - keymap:\t\t\t\t") ((subrp (symbol-function sym)) (princ "function - built-in primitive:\t\t") ((byte-code-function-p (symbol-function sym)) (princ "function - byte-code:\t\t\t") ((functionp sym) (princ "function - elisp:\t\t\t") (t (princ "other ~function (aliases??):\t"))) ) ((boundp sym) ; ALL variables ((custom-variable-p sym) (princ "user (custom) option:\t\t\t") ((keywordp sym) (princ "keyword:\t\t\t\t\t") (t (princ "non-user (setq) variable:\t\t")) ) ((facep sym) (princ "face:\t\t\t\t\t") (t (princ "other (misc) symbol:\t\t\t") ) ---------------------- And current counts - note will probably drop outputting the first category to the list unless someone suggests another meaningful symbol type to track other (misc): 8734 keyword: 323 faces: 50 variables: 2542 user (custom) option: 659 non-user (setq) variable: 1183 functions (non-command): 4277 keymap: 34 built-in primitive: 1022 byte-code: 2342 other (bound?) function: 335 command: 2373 keymap:3 built-in primitive: 88 byte-code: 762 other command: 1561 macro:298 =================== and finally the code itself if anyone wants to suggest other improvements or to give it a whirl on their setup. ------------------- (defun macrop (object) "Non-nil if and only if OBJECT is a macro." (let ((def (indirect-function object t))) (when (consp def) (or (eq 'macro (car def)) (and (autoloadp def) (memq (nth 4 def) '(macro t))))))) (defun list-hh-symbols () "Display a list of Emacs symbols - names only" (interactive) (message "Looking up all symbols...") (with-output-to-temp-buffer "*List Symbols*" (let (vars) (mapatoms (function (lambda (sym) (setq vars (cons sym vars))))) (setq vars (sort vars 'string-lessp)) (while vars (let ((sym (car vars))) (cond ((fboundp sym) ; ALL functions (cond ((commandp sym) (cond ((keymapp sym) (princ "=======\n") (princ "\n") (princ "command - keymap:\t\t\t\t\t") (prin1 sym) (princ "\n\n")) ((subrp (symbol-function sym)) (princ "=============================\n") (princ "command - built-in primitive:\t\t") (prin1 sym) (princ "\n\n")) ((byte-code-function-p (symbol-function sym)) (princ "====================\n") (princ "command - byte-code:\t\t\t") (prin1 sym) (princ "\n\n")) ((functionp sym) (princ "================\n") (princ "command - elisp:\t\t\t") (prin1 sym) (princ "\n\n")) (t (princ "===============\n") (princ "other command:\t\t\t\t") (prin1 sym) (princ "\n\n")) ) ) (t ; (non-command) functions (cond ((macrop sym) (princ "================\n") (princ "function - macro:\t\t\t") (prin1 sym) (princ "\n\n")) ((keymapp sym) (princ "==================\n") (princ "\n") (princ "function - keymap:\t\t\t\t") (prin1 sym) (princ "\n\n")) ((subrp (symbol-function sym)) (princ "==============================\n") (princ "function - built-in primitive:\t\t") (prin1 sym) (princ "\n\n")) ((byte-code-function-p (symbol-function sym)) (princ "=====================\n") (princ "function - byte-code:\t\t\t") (prin1 sym) (princ "\n\n")) ((functionp sym) (princ "=================\n") (princ "function - elisp:\t\t\t") (prin1 sym) (princ "\n\n")) (t (princ "============================\n") (princ "other ~function (aliases??):\t") (prin1 sym) (princ "\n\n")) ) ) ) ) ((boundp sym) ; ALL variables (cond ((custom-variable-p sym) (princ "=====================\n") (princ "user (custom) option:\t\t\t") (prin1 sym) (princ "\n\n")) ((keywordp sym) (princ "========\n") (princ "\n") (princ "keyword:\t\t\t\t\t") (prin1 sym) (princ "\n\n")) (t (princ "=========================\n") (princ "non-user (setq) variable:\t\t") (prin1 sym) (princ "\n\n")) ) ) ((facep sym) (princ "=====\n") (princ "\n") (princ "face:\t\t\t\t\t") (prin1 sym) (princ "\n\n")) (t (princ "====================\n") (princ "other (misc) symbol:\t\t\t") (prin1 sym) (princ "\n\n")) ) (setq vars (cdr vars)))) (message "Looking up all symbols...done") (with-current-buffer "*List Symbols*" (setq buffer-read-only t))))) ;;;;;;;;;;;;;;;;;;;;;;; (provide 'hh-list-symbols) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; hh-list-symbols.el ends here