From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Experimental features Date: Thu, 28 Jun 2007 14:51:29 -0400 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1183056710 31139 80.91.229.12 (28 Jun 2007 18:51:50 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 28 Jun 2007 18:51:50 +0000 (UTC) Cc: emacs-devel@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jun 28 20:51:49 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1I3z5j-00079D-Oj for ged-emacs-devel@m.gmane.org; Thu, 28 Jun 2007 20:51:44 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I3z5j-0005wo-6M for ged-emacs-devel@m.gmane.org; Thu, 28 Jun 2007 14:51:43 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1I3z5h-0005wZ-0h for emacs-devel@gnu.org; Thu, 28 Jun 2007 14:51:41 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1I3z5f-0005wN-Gm for emacs-devel@gnu.org; Thu, 28 Jun 2007 14:51:39 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I3z5f-0005wK-BA for emacs-devel@gnu.org; Thu, 28 Jun 2007 14:51:39 -0400 Original-Received: from x254-36.xtpr.umontreal.ca ([132.204.254.36] helo=ceviche.home) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1I3z5d-00009t-Kd; Thu, 28 Jun 2007 14:51:37 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id D9696B4DB6; Thu, 28 Jun 2007 14:51:29 -0400 (EDT) In-Reply-To: (Richard Stallman's message of "Sun\, 24 Jun 2007 19\:47\:06 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) X-detected-kernel: Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:74012 Archived-At: > 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))) + +(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