unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Re: list of elisp primitives ?
Date: Sun, 22 Dec 2019 16:01:49 +0100	[thread overview]
Message-ID: <87mubk8kv6.fsf@gmx.net> (raw)
In-Reply-To: <5E53A27C-7C86-4275-AC12-9799C3CB1956@traduction-libre.org> (Jean-Christophe Helary's message of "Sun, 22 Dec 2019 13:14:41 +0900")

On Sun, 22 Dec 2019 13:14:41 +0900 Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org> wrote:

> What I'm trying to do is this:
>
>>  I was thinking that because of the sheer amount of functions in the elisp
>> reference, it might be much easier to start programming with the primitives
>> to understand how elisp works at its core, and then climb the ladder when
>> need arises...
>
> i.e. trying to find a limited subset of functions that one can use to program
> in elisp and do non-trivial things but that do not involve searching the
> reference at all times.
>
> I'm thinking like in standard learners dictionaries, there are clear
> indications, like asterisks, that tell the learner whether the word is basic
> (generally about 2000 words) or intermediate (about 4000 words).
>
> People who know the basic words can get by and express most of what they need
> to express in daily life.
>
> For ex, it is estimated that there are about 140k words in French, but daily
> use only requires 1k. Let's lower the number of passively known words to 40k,
> that's 50 functions in Elisp...

One way to come up with a list of "basic Elisp" functions is to compare
the usage frequencies in individual Elisp libraries; the most frequently
used functions in a reasonable number of libraries are likely to be the
most basic.  Here's a little hack to get a quick rough estimate for a
single file or buffer of Lisp code (to get a really accurate count would
take quite a bit more effort, which has probably already been done, but
I'm not aware of it):

(defun srb-count-lisp-funs (&optional buffer)
  "Display a frequency table of Lisp functions in BUFFER.
Called interactively with a prefix argument, use the current
buffer, otherwise, prompt for a file, visit it and use its
buffer."
  (interactive "P")
  (let ((fnh (make-hash-table :test 'equal))
	;; FIXME: false positives with let, funargs, alists, ...
	(flh (lambda (h)
	       (save-excursion
		 (save-restriction
		   (goto-char (point-min))
		   (while (search-forward "(" nil t)
		     (let ((sym (symbol-at-point)))
		       (when sym (puthash sym (1+ (gethash sym h 0)) h))))))))
	(bname (buffer-name))
	fnl)
    (if buffer
	(funcall flh fnh)
      (with-temp-buffer
	(let ((file (read-file-name "File: ")))
	  (insert-file-contents file)
	  (funcall flh fnh)
	  (setq bname (file-name-nondirectory file)))))
    (maphash (lambda (key val) (setq fnl (append fnl (list (cons key val)))))
	     fnh)
    (setq fnl (sort fnl (lambda (a b) (> (cdr a) (cdr b)))))
    (with-current-buffer (generate-new-buffer (concat "fn freqs (" bname ")"))
      (dolist (e fnl)
	(insert (symbol-name (car e)) ": " (number-to-string (cdr e)) "\n"))
      (view-buffer (current-buffer)))))

Steve Berman



  parent reply	other threads:[~2019-12-22 15:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-22  2:59 list of elisp primitives ? Jean-Christophe Helary
2019-12-22  3:21 ` Eduardo Ochs
2019-12-22  3:43   ` Jean-Christophe Helary
     [not found]     ` <CADs++6hB7ZKnEWOZ=XOGdA=W_CacCE2=354ARfNFtWvStaCF3g@mail.gmail.com>
2019-12-22  4:14       ` Jean-Christophe Helary
     [not found]         ` <CADs++6j+niJy3hvrTEJ-LrqcitFuffX=1Duca7pU30a8qfh_zg@mail.gmail.com>
2019-12-22  4:38           ` Jean-Christophe Helary
2019-12-22 15:01         ` Stephen Berman [this message]
2019-12-22 17:31         ` Drew Adams
2019-12-26 17:39           ` Jean-Christophe Helary
2019-12-26 18:00             ` arthur miller
2019-12-26 18:09             ` Drew Adams
2019-12-26 18:22               ` Jean-Christophe Helary
2019-12-26 18:33             ` Stefan Monnier
2019-12-26 21:17             ` Eduardo Ochs
2019-12-27  0:21               ` Jean-Christophe Helary
2019-12-22 14:56     ` Óscar Fuentes
2019-12-22 22:34       ` Jean-Christophe Helary
2019-12-22 19:21 ` Marcin Borkowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mubk8kv6.fsf@gmx.net \
    --to=stephen.berman@gmx.net \
    --cc=emacs-devel@gnu.org \
    --cc=jean.christophe.helary@traduction-libre.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).