all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: rms@gnu.org
Cc: emacs-devel@gnu.org
Subject: Re: Experimental features
Date: Thu, 28 Jun 2007 14:51:29 -0400	[thread overview]
Message-ID: <jwvlke4oku8.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <E1I2bnO-0007ET-AV@fencepost.gnu.org> (Richard Stallman's message of "Sun\, 24 Jun 2007 19\:47\:06 -0400")

>     1 - sometimes a single `setq' is not enough to activate a feature.
> That is true, but I don't see that this means we need a special
> framework for these features.

There's no special framework involved.  Just a convention for how to call
the activation function.

>     2 - I like the idea of being able to list the experimental features.
> I think NEWS is good enough for that.

I agree that it's not absolutely important to be able to get
a mechanically-generated list, but it's a good thing.  And since its only
cost is to use a standard naming convention for the activation function, it
seems very much worth it.

> If a feature is a self-contained major mode, and certainly won't affect
> anyone that doesn't enable that mode, that is automatically safe to try
> installing.  So we can just install it with nothing special.

Sure, there are such cases.  E.g. css-mode.  I'm not interested in those
cases here, since we already know how to handle them.

> But if feature involves adding code in some existing files, files
> which have other purposes and uses, that added code might break
> something.  So we might want to add an explicit conditional around
> each piece of code added in other files, so that we KNOW this feature
> can't break anything if you don't enable it.

Or if css-mode did something potentially undesirable in its major-mode
function, in which case enabling it by default for *.css files may not be
desirable either.

A sample patch is attached, which shows the command I'd like to add, the
change to autoload.el to make it more easily accessible, and an example of
how it might be used with vc-bzr.


        Stefan


Index: lisp/emacs-lisp/autoload.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/autoload.el,v
retrieving revision 1.126
diff -u -r1.126 autoload.el
--- lisp/emacs-lisp/autoload.el	26 Jun 2007 19:53:11 -0000	1.126
+++ lisp/emacs-lisp/autoload.el	28 Jun 2007 18:49:15 -0000
@@ -305,6 +305,12 @@
   (interactive "fGenerate autoloads for file: ")
   (autoload-generate-file-autoloads file (current-buffer)))
 
+(defvar experimental-feature nil
+  "File-local variable indicating that this package is experimental.
+Experimental packages need to be explicitly activated by calling
+activate-experimental-PACKAGE.")
+(put 'experimental-feature 'safe-local-variable 'booleanp)
+
 ;; When called from `generate-file-autoloads' we should ignore
 ;; `generated-autoload-file' altogether.  When called from
 ;; `update-file-autoloads' we don't know `outbuf'.  And when called from
@@ -409,6 +409,8 @@
                   (forward-line 1))))))
 
           (when output-start
+            (let ((experimental (and (local-variable-p 'experimental-feature)
+                                     experimental-feature)))
             (with-current-buffer outbuf
               (save-excursion
                 ;; Insert the section-header line which lists the file name
@@ -417,8 +419,11 @@
                 (autoload-insert-section-header
                  outbuf autoloads-done load-name relfile
                  (nth 5 (file-attributes relfile)))
-                (insert ";;; Generated autoloads from " relfile "\n"))
-              (insert generate-autoload-section-trailer)))
+                  (insert ";;; Generated autoloads from " relfile "\n")
+                  (when experimental
+                    (insert "(defun activate-experimental-" load-name " ()\n")))
+                (when experimental (insert ")\n"))
+                (insert generate-autoload-section-trailer))))
           (message "Generating autoloads for %s...done" file))
         (or visited
             ;; We created this buffer, so we should kill it.
Index: lisp/simple.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/simple.el,v
retrieving revision 1.863
diff -u -r1.863 simple.el
--- lisp/simple.el	23 Jun 2007 12:18:52 -0000	1.863
+++ lisp/simple.el	28 Jun 2007 18:49:15 -0000
@@ -5596,6 +5596,30 @@
 	 buffer-invisibility-spec)
     (setq buffer-invisibility-spec nil)))
 \f
+
+(defconst activate-experimental-prefix "activate-experimental-")
+(defun activate-experimental-feature (feature)
+  "Activate the feature FEATURE which is considered experimental."
+  (interactive
+   (let ((features
+          (delete "feature"
+                  (mapcar (lambda (str)
+                            (substring
+                             str (length activate-experimental-prefix)))
+                          (all-completions activate-experimental-prefix
+                                           obarray 'fboundp)))))
+     (if (null features)
+         (error "No experimental features in this release")
+       (list (completing-read "Feature: " features)))))
+  (let ((f (intern-soft (concat activate-experimental-prefix
+                                (if (symbolp feature)
+                                    (symbol-name feature)
+                                  feature)))))
+    ;; If the function is not defined, assume this used to be an
+    ;; experimental feature but has now been blessed as a fully supported
+    ;; feature, so there's nothing left to do to activate it.
+    (when (fboundp f) (funcall f))))
+
 ;; Minibuffer prompt stuff.
 
 ;(defun minibuffer-prompt-modification (start end)
Index: lisp/vc-bzr.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/vc-bzr.el,v
retrieving revision 1.7
diff -u -r1.7 vc-bzr.el
--- lisp/vc-bzr.el	28 Jun 2007 02:01:54 -0000	1.7
+++ lisp/vc-bzr.el	28 Jun 2007 18:49:15 -0000
@@ -549,5 +549,10 @@
     (remove-hook 'vc-post-command-functions 'vc-bzr-post-command-function)))
 
 (provide 'vc-bzr)
+
+;; Local Variables:
+;; experimental-feature: t
+;; End:
+
 ;; arch-tag: 8101bad8-4e92-4e7d-85ae-d8e08b4e7c06
 ;;; vc-bzr.el ends here

  reply	other threads:[~2007-06-28 18:51 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-22 21:05 Experimental features Stefan Monnier
2007-06-22 21:22 ` Lennart Borgman (gmail)
2007-06-23  4:15   ` Stefan Monnier
2007-06-23 12:40     ` Thien-Thi Nguyen
2007-06-23 19:07       ` Stefan Monnier
2007-06-23  2:51 ` dhruva
2007-06-23  6:00 ` Andreas Röhler
2007-06-24  1:43   ` T. V. Raman
2007-06-24  3:02     ` Eli Zaretskii
2007-06-24  3:59       ` T. V. Raman
2007-06-24 18:42         ` Eli Zaretskii
2007-06-23 13:19 ` Richard Stallman
2007-06-23 13:37   ` Juanma Barranquero
2007-06-24 14:40     ` Richard Stallman
2007-06-24 14:53       ` Juanma Barranquero
2007-06-24 19:25         ` Stefan Monnier
2007-06-23 19:16   ` Stefan Monnier
2007-06-24 14:41     ` Richard Stallman
2007-06-24 19:23       ` Stefan Monnier
2007-06-24 23:47         ` Richard Stallman
2007-06-28 18:51           ` Stefan Monnier [this message]
2007-06-29 19:33             ` Richard Stallman

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

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

  git send-email \
    --in-reply-to=jwvlke4oku8.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=rms@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.