unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Thien-Thi Nguyen <ttn@glug.org>
Cc: emacs-devel@gnu.org
Subject: Re: Idea for determining what users use
Date: 27 May 2003 10:39:23 -0400	[thread overview]
Message-ID: <jkof1o5u90.fsf@glug.org> (raw)
In-Reply-To: Richard Stallman's message of "Tue, 27 May 2003 08:45:20 -0400"

Richard Stallman <rms@gnu.org> writes:

   Imagine a function called note-feature-used.
   You call it like this:  (note-feature-used 'foo "Foo").
   The first time you call it, it sends mail to
   emacs-features-used@gnu.org with subject Foo,
   asking you for permission to send it,
   and it records (setq foo t) in your .emacs file.
   If you call it again, it does nothing.

knowing how ego-driven programmers are, i fear this would lead to lots
of spam as every little (sub-)feature is instrumented so.  perhaps this
can be ameliorated somewhat by batching up the samples into one var, say
`*$USER-features-used*' and providing `M-x report-used-features'.  this
allows any externalizable object to be reported (not just symbols), and
sidesteps the possibility of clobbering useful variables due to the ever
odious single-namespace problem.  we use $USER because a single ~/.emacs
can be used by many people.

some aspects of this two-phase approach are demonstrated by the poll at:

 http://www.glug.org/people/ttn/software/minor-mode-survey/

the relevant elisp is below for those w/o www access.

   We could put these calls into various files and functions 
   in order to find out (after the next release) whether anyone uses them.

IMHO, it is better not to tie such a poll to any specific release, since
a release is just a snapshot of various disparate albeit concurrent
activities.  release info could be included in `*$USER-features-used*',
however (along w/ extra commentary, etc).

another thing to keep in mind: at some installations there is a local
emacs guru who sets up the site-lisp dir, etc.  if a two-phase approach
is taken, it should allow the sampled data to be vetted through this
person as they usually have additional insight into the local emacs
situation apart from the end user.  in fact, whatever mechanism we
settle on could be a good tool for these people as well as for emacs
programmers w/ savannah write privs.

thi


______________________________________________
;;; minor-mode-survey.el
;;; author: ttn@gnu.org
;;; created: 2001/03/09 03:28:44
;;; modified: 2001/03/16 02:33:06 -- ignore errors in `buffer-modes-usage'
;;; public domain

;; these were mailed to gnu-emacs-help@gnu.org

(defun buffer-modes-usage (buffer)
  (with-current-buffer buffer
    (cons major-mode
          (let ((acc nil) (mma minor-mode-alist))
            (while mma                  ; avoid cl :-P
              (ignore-errors
                (let ((minor-mode (caar mma)))
                  ;; use `describe-mode' inclusion method -- see help.el
                  (when (and (symbol-value minor-mode)
                             (fboundp minor-mode))
                    (setq acc (cons minor-mode acc)))))
              (setq mma (cdr mma)))
            acc))))

(defun compose-mode-usage-mail ()
  (interactive)
  (let ((forms (mapcar 'buffer-modes-usage (buffer-list)))
        (mail-self-blind nil))
    (compose-mail "ttn@gnu.org" "minor mode survey response")
    (goto-char (point-max))
    (let ((standard-output (current-buffer)))
      (mapcar '(lambda (form)
                 (unless (= 1 (length form)) ; ignorance is bliss
                   (print form)))
              forms)))
  (setq fill-prefix ";;; ")
  (insert "\n;;; additional comments (fill-prefix set to \""
          fill-prefix
          "\")\n;;; "))

;; new stuff

(require 'cl)                           ; use the source luke!

(defun sort-freq-hash (hash)
  (let (unsorted)
    (maphash (lambda (x count) (push (cons count x) unsorted)) hash)
    (sort unsorted (lambda (a b) (> (car a) (car b))))))

(defun insert-compressed-freq-list (ls)
  (let ((last-seen 0))
    (dolist (x ls)
      (insert (if (= (car x) last-seen)
                  (format " %s" (cdr x))
                (setq last-seen (car x))
                (format "\n- %d %s" (car x) (cdr x))))))
  (insert "\n\n"))

(defun analyze-mode-usage-response (data)
  (insert (format "%d buffers scanned" (length data)))
  (dolist (x data) (setcdr x (remove-duplicates (sort (cdr x) 'string<))))
  (setq data (delete-duplicates data :test 'equal))
  (insert (format " (%d w/ unique mode signatures)\n" (length data)))
  (dolist (x data) (insert (format "- %s\n" x)))
  (insert "\n")
  ;; major mode summary
  (let ((majs (make-hash-table)))
    (dolist (x data) (incf (gethash (car x) majs 0)))
    (insert (format "%d unique major modes, sorted by instances in unique sig"
                    (hash-table-count majs)))
    (insert-compressed-freq-list (sort-freq-hash majs)))
  ;; minor mode
  (let ((mins (make-hash-table)) sorted)
    ;; summary
    (dolist (x (apply 'append (mapcar 'cdr data))) (incf (gethash x mins 0)))
    (insert (format "%d unique minor modes, sorted by instances in unique sig"
                    (hash-table-count mins)))
    (setq sorted (sort-freq-hash mins))
    (insert-compressed-freq-list sorted)
    ;; details: clumps and bros
    (insert "FOO-MINOR-MODE: CONCURRENT:COUNT CONCURRENT:COUNT ...\n"
            "- MOST CONCURRENT MINOR MODE\n"
            "- NEXT MOST CONCURRENT MINOR MODE\n"
            "- ...\n\n")
    (dolist (m (mapcar 'cdr sorted))
      (insert (format "%s:" m))
      (let* ((mdata (mapcar 'cdr data))
             (hood (remove-if-not (lambda (sig) (memq m (cdr sig))) mdata))
             (clumps (make-hash-table))
             (bros (make-hash-table)))
        (dolist (h hood) (incf (gethash (1- (length h)) clumps 0)))
        (dolist (b (remove m (apply 'append hood))) (incf (gethash b bros 0)))
        (dolist (x (sort (sort-freq-hash clumps)
                         (lambda (a b) (< (cdr a) (cdr b)))))
          (insert (format " %d:%d" (cdr x) (car x))))
        (insert-compressed-freq-list (sort-freq-hash bros))))))

(defun summarize-mode-usage-responses (file)
  (interactive "fMail file: ")
  (find-file file)
  (unless (eq 'rmail-mode major-mode)
    (error "wrong file, dude"))
  (let (data comments)
    (do ((i 1 (1+ i)))
        ((> i rmail-total-messages))
      (rmail-show-message i)
      (goto-char (point-min))
      (search-forward "\n\n")
      ;; pass twice to handle interspersed comments
      (let ((beg (point)))
        (goto-char beg)
        (ignore-errors (while t (push (read (current-buffer)) data)))
        (goto-char beg)
        (while (re-search-forward "^;;;\\(.+\n\\)" (point-max) t)
          (push (match-string 1) comments)))
      (push "----------------------------\n" comments))
    (kill-buffer (current-buffer))
    (switch-to-buffer "*Mode Usage Response Summary*")
    (erase-buffer)
    (analyze-mode-usage-response data)
    (insert "\n")
    (dolist (comment (reverse comments)) (insert comment))
    ;; gratuitous prettiness
    (while (re-search-backward "^---+\n\\s-*\n" (point-min) t)
      (replace-match ""))
    (re-search-backward "^---+\n" (point-min) t)
    (while (search-backward "-mode" (point-min) 1)
      (replace-match ""))))

;;; minor-mode-survey.el ends here

  parent reply	other threads:[~2003-05-27 14:39 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-27 12:45 Idea for determining what users use Richard Stallman
2003-05-27 13:27 ` David Kastrup
2003-05-27 14:16 ` Vincent LADEUIL
2003-05-27 14:28 ` Stefan Monnier
2003-05-28  0:43   ` Kim F. Storm
2003-05-28  7:04     ` Juanma Barranquero
2003-05-28 13:54   ` Richard Stallman
2003-05-28 14:33     ` Stefan Monnier
2003-05-30  0:49       ` Richard Stallman
2003-05-27 14:39 ` Thien-Thi Nguyen [this message]
2003-05-27 15:32   ` Stephen J. Turnbull
2003-05-28 23:58   ` Richard Stallman
2003-05-29 11:35     ` Thien-Thi Nguyen
2003-05-30  0:48       ` Richard Stallman
2003-05-31 12:37         ` Thien-Thi Nguyen
2003-06-01 15:53           ` Richard Stallman
2003-06-01 20:26             ` Thien-Thi Nguyen
2003-06-03  4:06               ` Richard Stallman
     [not found] ` <m1r86ktqxx.fsf@vila.local.>
2003-05-28 13:54   ` Richard Stallman
2003-05-28 14:40     ` Vincent LADEUIL
     [not found]     ` <m1y90rp221.fsf@vila.local.>
2003-05-30  0:49       ` Richard Stallman
2003-05-30  7:28         ` Jan D.
2003-05-30 13:29           ` Stefan Monnier
2003-05-30 14:52             ` Jan D.
2003-05-30 15:40               ` Stefan Monnier
2003-05-30 16:32                 ` Alex Schroeder
2003-05-31 19:51                   ` Richard Stallman
2003-06-01  0:48                     ` Peter Lee
2003-06-01  1:24                     ` Luc Teirlinck
2003-06-01  1:59                       ` Luc Teirlinck
2003-06-02 11:16                         ` Richard Stallman
2003-06-03 22:55                           ` Kim F. Storm
2003-06-05  0:08                             ` Richard Stallman
2003-06-06  0:21                               ` Kim F. Storm
2003-06-07 10:22                                 ` Richard Stallman
2003-05-30 16:45                 ` Jan D.
2003-05-30 16:57                   ` Stefan Monnier
2003-05-31 19:51             ` Richard Stallman
2003-05-30 23:47 ` Kim F. Storm
2003-05-30 23:04   ` Miles Bader
2003-06-03 22:24     ` Kim F. Storm
2003-05-30 23:14   ` { SPAM 2 }::Re: " Luc Teirlinck
2003-05-30 23:40     ` Luc Teirlinck
2003-05-31 10:45     ` Kai Großjohann
2003-06-01 15:52   ` Richard Stallman
2003-06-01  5:06 ` Luc Teirlinck
2003-06-02 11:16   ` Richard Stallman
2003-06-03  2:43     ` Luc Teirlinck
2003-06-04  8:53       ` Richard Stallman
2003-06-03  4:05     ` Luc Teirlinck

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=jkof1o5u90.fsf@glug.org \
    --to=ttn@glug.org \
    --cc=emacs-devel@gnu.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).