annotate lisp/behavior.el @ 5353:38e24b8be4ea

Improve the lexical scoping in #'block, #'return-from. lisp/ChangeLog addition: 2011-02-07 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el: * bytecomp.el (byte-compile-initial-macro-environment): Shadow `block', `return-from' here, we implement them differently when byte-compiling. * bytecomp.el (byte-compile-active-blocks): New. * bytecomp.el (byte-compile-block-1): New. * bytecomp.el (byte-compile-return-from-1): New. * bytecomp.el (return-from-1): New. * bytecomp.el (block-1): New. These are two aliases that exist to have their own associated byte-compile functions, which functions implement `block' and `return-from'. * cl-extra.el (cl-macroexpand-all): Fix a bug here when macros in the environment have been compiled. * cl-macs.el (block): * cl-macs.el (return): * cl-macs.el (return-from): Be more careful about lexical scope in these macros. * cl.el: * cl.el ('cl-block-wrapper): Removed. * cl.el ('cl-block-throw): Removed. These aren't needed in code generated by this XEmacs. They shouldn't be needed in code generated by XEmacs 21.4, but if it turns out the packages do need them, we can put them back. 2011-01-30 Mike Sperber <mike@xemacs.org> * font-lock.el (font-lock-fontify-pending-extents): Don't fail if `font-lock-mode' is unset, which can happen in the middle of `revert-buffer'. 2011-01-23 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (delete): * cl-macs.el (delq): * cl-macs.el (remove): * cl-macs.el (remq): Don't use the compiler macro if these functions were given the wrong number of arguments, as happens in lisp-tests.el. * cl-seq.el (remove, remq): Removed. I added these to subr.el, and forgot to remove them from here. 2011-01-22 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el (byte-compile-setq, byte-compile-set): Remove kludge allowing keywords' values to be set, all the code that does that is gone. * cl-compat.el (elt-satisfies-test-p): * faces.el (set-face-parent): * faces.el (face-doc-string): * gtk-font-menu.el: * gtk-font-menu.el (gtk-reset-device-font-menus): * msw-font-menu.el: * msw-font-menu.el (mswindows-reset-device-font-menus): * package-get.el (package-get-installedp): * select.el (select-convert-from-image-data): * sound.el: * sound.el (load-sound-file): * x-font-menu.el (x-reset-device-font-menus-core): Don't quote keywords, they're self-quoting, and the win from backward-compatibility is sufficiently small now that the style problem overrides it. 2011-01-22 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (block, return-from): Require that NAME be a symbol in these macros, as always documented in the #'block docstring and as required by Common Lisp. * descr-text.el (unidata-initialize-unihan-database): Correct the use of non-symbols in #'block and #'return-from in this function. 2011-01-15 Aidan Kehoe <kehoea@parhasard.net> * cl-extra.el (concatenate): Accept more complicated TYPEs in this function, handing the sequences over to #'coerce if we don't understand them here. * cl-macs.el (inline): Don't proclaim #'concatenate as inline, its compiler macro is more useful than doing that. 2011-01-11 Aidan Kehoe <kehoea@parhasard.net> * subr.el (delete, delq, remove, remq): Move #'remove, #'remq here, they don't belong in cl-seq.el; move #'delete, #'delq here from fns.c, implement them in terms of #'delete*, allowing support for sequences generally. * update-elc.el (do-autoload-commands): Use #'delete*, not #'delq here, now the latter's no longer dumped. * cl-macs.el (delete, delq): Add compiler macros transforming #'delete and #'delq to #'delete* calls. 2011-01-10 Aidan Kehoe <kehoea@parhasard.net> * dialog.el (make-dialog-box): Correct a misplaced parenthesis here, thank you Mats Lidell in 87zkr9gqrh.fsf@mail.contactor.se ! 2011-01-02 Aidan Kehoe <kehoea@parhasard.net> * dialog.el (make-dialog-box): * list-mode.el (display-completion-list): These functions used to use cl-parsing-keywords; change them to use defun* instead, fixing the build. (Not sure what led to me not including this change in d1b17a33450b!) 2011-01-02 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (define-star-compiler-macros): Make sure the form has ITEM and LIST specified before attempting to change to calls with explicit tests; necessary for some tests in lisp-tests.el to compile correctly. (stable-union, stable-intersection): Add compiler macros for these functions, in the same way we do for most of the other functions in cl-seq.el. 2011-01-01 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (dolist, dotimes, do-symbols, macrolet) (symbol-macrolet): Define these macros with defmacro* instead of parsing the argument list by hand, for the sake of style and readability; use backquote where appropriate, instead of calling #'list and and friends, for the same reason. 2010-12-30 Aidan Kehoe <kehoea@parhasard.net> * x-misc.el (device-x-display): Provide this function, documented in the Lispref for years, but not existing previously. Thank you Julian Bradfield, thank you Jeff Mincy. 2010-12-30 Aidan Kehoe <kehoea@parhasard.net> * cl-seq.el: Move the heavy lifting from this file to C. Dump the cl-parsing-keywords macro, but don't use defun* for the functions we define that do take keywords, dynamic scope lossage makes that not practical. * subr.el (sort, fillarray): Move these aliases here. (map-plist): #'nsublis is now built-in, but at this point #'eql isn't necessarily available as a test; use #'eq. * obsolete.el (cl-delete-duplicates): Make this available for old compiler macros and old code. (memql): Document that this is equivalent to #'member*, and worse. * cl.el (adjoin, subst): Removed. These are in C. 2010-12-30 Aidan Kehoe <kehoea@parhasard.net> * simple.el (assoc-ignore-case): Remove a duplicate definition of this function (it's already in subr.el). * iso8859-1.el (char-width): On non-Mule, make this function equivalent to that produced by (constantly 1), but preserve its docstring. * subr.el (subst-char-in-string): Define this in terms of #'substitute, #'nsubstitute. (string-width): Define this using #'reduce and #'char-width. (char-width): Give this a simpler definition, it makes far more sense to check for mule at load time and redefine, as we do in iso8859-1.el. (store-substring): Implement this in terms of #'replace, now #'replace is cheap. 2010-12-30 Aidan Kehoe <kehoea@parhasard.net> * update-elc.el (lisp-files-needed-for-byte-compilation) (lisp-files-needing-early-byte-compilation): cl-macs belongs in the former, not the latter, it is as fundamental as bytecomp.el. 2010-12-30 Aidan Kehoe <kehoea@parhasard.net> * cl.el: Provde the Common Lisp program-error, type-error as error symbols. This doesn't nearly go far enough for anyone using the Common Lisp errors. 2010-12-29 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (delete-duplicates): If the form has an incorrect number of arguments, don't attempt a compiler macroexpansion. 2010-12-29 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (cl-safe-expr-p): Forms that start with the symbol lambda are also safe. 2010-12-29 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (= < > <= >=): For these functions' compiler macros, the optimisation is safe even if the first and the last arguments have side effects, since they're only used the once. 2010-12-29 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (inline-side-effect-free-compiler-macros): Unroll a loop here at macro-expansion time, so these compiler macros are compiled. Use #'eql instead of #'eq in a couple of places for better style. 2010-12-29 Aidan Kehoe <kehoea@parhasard.net> * cl-extra.el (notany, notevery): Avoid some dynamic scope stupidity with local variable names in these functions, when they weren't prefixed with cl-; go into some more detail in the doc strings. 2010-12-29 Aidan Kehoe <kehoea@parhasard.net> * byte-optimize.el (side-effect-free-fns): #'remove, #'remq are free of side-effects. (side-effect-and-error-free-fns): Drop dot, dot-marker from the list. 2010-11-17 Aidan Kehoe <kehoea@parhasard.net> * cl-extra.el (coerce): In the argument list, name the first argument OBJECT, not X; the former name was always used in the doc string and is clearer. Handle vector type specifications which include the length of the target sequence, error if there's a mismatch. * cl-macs.el (cl-make-type-test): Handle type specifications starting with the symbol 'eql. 2010-11-14 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (eql): Don't remove the byte-compile property of this symbol. That was necessary to override a bug in bytecomp.el where #'eql was confused with #'eq, which bug we no longer have. If neither expression is constant, don't attempt to handle the expression in this compiler macro, leave it to byte-compile-eql, which produces better code anyway. * bytecomp.el (eq): #'eql is not the function associated with the byte-eq byte code. (byte-compile-eql): Add an explicit compile method for this function, for cases where the cl-macs compiler macro hasn't reduced it to #'eq or #'equal. 2010-10-25 Aidan Kehoe <kehoea@parhasard.net> Add compiler macros and compilation sanity-checking for various functions that take keywords. * byte-optimize.el (side-effect-free-fns): #'symbol-value is side-effect free and not error free. * bytecomp.el (byte-compile-normal-call): Check keyword argument lists for sanity; store information about the positions where keyword arguments start using the new byte-compile-keyword-start property. * cl-macs.el (cl-const-expr-val): Take a new optional argument, cl-not-constant, defaulting to nil, in this function; return it if the expression is not constant. (cl-non-fixnum-number-p): Make this into a separate function, we want to pass it to #'every. (eql): Use it. (define-star-compiler-macros): Use the same code to generate the member*, assoc* and rassoc* compiler macros; special-case some code in #'add-to-list in subr.el. (remove, remq): Add compiler macros for these two functions, in preparation for #'remove being in C. (define-foo-if-compiler-macros): Transform (remove-if-not ...) calls to (remove ... :if-not) at compile time, which will be a real win once the latter is in C. (define-substitute-if-compiler-macros) (define-subst-if-compiler-macros): Similarly for these functions. (delete-duplicates): Change this compiler macro to use #'plists-equal; if we don't have information about the type of SEQUENCE at compile time, don't bother attempting to inline the call, the function will be in C soon enough. (equalp): Remove an old commented-out compiler macro for this, if we want to see it it's in version control. (subst-char-in-string): Transform this to a call to nsubstitute or nsubstitute, if that is appropriate. * cl.el (ldiff): Don't call setf here, this makes for a load-time dependency problem in cl-macs.el 2010-06-14 Stephen J. Turnbull <stephen@xemacs.org> * term/vt100.el: Refer to XEmacs, not GNU Emacs, in permissions. * term/bg-mouse.el: * term/sup-mouse.el: Put copyright notice in canonical "Copyright DATE AUTHOR" form. Refer to XEmacs, not GNU Emacs, in permissions. * site-load.el: Add permission boilerplate. * mule/canna-leim.el: * alist.el: Refer to XEmacs, not APEL/this program, in permissions. * mule/canna-leim.el: Remove my copyright, I've assigned it to the FSF. 2010-06-14 Stephen J. Turnbull <stephen@xemacs.org> * gtk.el: * gtk-widget-accessors.el: * gtk-package.el: * gtk-marshal.el: * gtk-compose.el: * gnome.el: Add copyright notice based on internal evidence. 2010-06-14 Stephen J. Turnbull <stephen@xemacs.org> * easymenu.el: Add reference to COPYING to permission notice. * gutter.el: * gutter-items.el: * menubar-items.el: Fix typo "Xmacs" in permissions notice. 2010-06-14 Stephen J. Turnbull <stephen@xemacs.org> * auto-save.el: * font.el: * fontconfig.el: * mule/kinsoku.el: Add "part of XEmacs" text to permission notice. 2010-10-14 Aidan Kehoe <kehoea@parhasard.net> * byte-optimize.el (side-effect-free-fns): * cl-macs.el (remf, getf): * cl-extra.el (tailp, cl-set-getf, cl-do-remf): * cl.el (ldiff, endp): Tighten up Common Lisp compatibility for #'ldiff, #'endp, #'tailp; add circularity checking for the first two. #'cl-set-getf and #'cl-do-remf were Lisp implementations of #'plist-put and #'plist-remprop; change the names to aliases, changes the macros that use them to using #'plist-put and #'plist-remprop directly. 2010-10-12 Aidan Kehoe <kehoea@parhasard.net> * abbrev.el (fundamental-mode-abbrev-table, global-abbrev-table): Create both these abbrev tables using the usual #'define-abbrev-table calls, rather than attempting to special-case them. * cl-extra.el: Force cl-macs to be loaded here, if cl-extra.el is being loaded interpreted. Previously other, later files would redundantly call (load "cl-macs") when interpreted, it's more reasonable to do it here, once. * cmdloop.el (read-quoted-char-radix): Use defcustom here, we don't have any dump-order dependencies that would prevent that. * custom.el (eval-when-compile): Don't load cl-macs when interpreted or when byte-compiling, rely on cl-extra.el in the former case and the appropriate entry in bytecomp-load-hook in the latter. Get rid of custom-declare-variable-list, we have no dump-time dependencies that would require it. * faces.el (eval-when-compile): Don't load cl-macs when interpreted or when byte-compiling. * packages.el: Remove some inaccurate comments. * post-gc.el (cleanup-simple-finalizers): Use #'delete-if-not here, now the order of preloaded-file-list has been changed to make it available. * subr.el (custom-declare-variable-list): Remove. No need for it. Also remove a stub define-abbrev-table from this file, given the current order of preloaded-file-list there's no need for it. 2010-10-10 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el (byte-compile-constp) Forms quoted with FUNCTION are also constant. (byte-compile-initial-macro-environment): In #'the, if FORM is constant and does not match TYPE, warn at byte-compile time. 2010-10-10 Aidan Kehoe <kehoea@parhasard.net> * backquote.el (bq-vector-contents, bq-list*): Remove; the former is equivalent to (append VECTOR nil), the latter to (list* ...). (bq-process-2): Use (append VECTOR nil) instead of using #'bq-vector-contents to convert to a list. (bq-process-1): Now we use list* instead of bq-list * subr.el (list*): Moved from cl.el, since it is now required to be available the first time a backquoted form is encountered. * cl.el (list*): Move to subr.el. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * test-harness.el (Check-Message): Add an omitted comma here, thank you the buildbot. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * hash-table.el (hash-table-key-list, hash-table-value-list) (hash-table-key-value-alist, hash-table-key-value-plist): Remove some useless #'nreverse calls in these files; our hash tables have no order, it's not helpful to pretend they do. * behavior.el (read-behavior): Do the same in this file, in some code evidently copied from hash-table.el. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * info.el (Info-insert-dir): * format.el (format-deannotate-region): * files.el (cd, save-buffers-kill-emacs): Use #'some, #'every and related functions for applying boolean operations to lists, instead of rolling our own ones that cons and don't short-circuit. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el (byte-compile-initial-macro-environment): * cl-macs.el (the): Rephrase the docstring, make its implementation when compiling files a little nicer. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * descr-text.el (unidata-initialize-unicodedata-database) (unidata-initialize-unihan-database, describe-char-unicode-data) (describe-char-unicode-data): Wrap calls to the database functions with (with-fboundp ...), avoiding byte compile warnings on builds without support for the database functions. (describe-char): (reduce #'max ...), not (apply #'max ...), no need to cons needlessly. (describe-char): Remove a redundant lambda wrapping #'extent-properties. (describe-char-unicode-data): Call #'nsubst when replacing "" with nil in the result of #'split-string, instead of consing inside mapcar. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * x-faces.el (x-available-font-sizes): * specifier.el (let-specifier): * package-ui.el (pui-add-required-packages): * msw-faces.el (mswindows-available-font-sizes): * modeline.el (modeline-minor-mode-menu): * minibuf.el (minibuf-directory-files): Replace the O2N (delq nil (mapcar (lambda (W) (and X Y)) Z)) with the ON (mapcan (lambda (W) (and X (list Y))) Z) in these files. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (= < > <= >=): When these functions are handed more than two arguments, and those arguments have no side effects, transform to a series of two argument calls, avoiding funcall in the byte-compiled code. * mule/mule-cmds.el (finish-set-language-environment): Take advantage of this change in a function called 256 times at startup. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el (byte-compile-function-form, byte-compile-quote) (byte-compile-quote-form): Warn at compile time, and error at runtime, if a (quote ...) or a (function ...) form attempts to quote more than one object. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * byte-optimize.el (byte-optimize-apply): Transform (apply 'nconc (mapcar ...)) to (mapcan ...); warn about use of the first idiom. * update-elc.el (do-autoload-commands): * packages.el (packages-find-package-library-path): * frame.el (frame-list): * extents.el (extent-descendants): * etags.el (buffer-tag-table-files): * dumped-lisp.el (preloaded-file-list): * device.el (device-list): * bytecomp-runtime.el (proclaim-inline, proclaim-notinline) Use #'mapcan, not (apply #'nconc (mapcar ...) in all these files. * bytecomp-runtime.el (eval-when-compile, eval-and-compile): In passing, mention that these macros also evaluate the body when interpreted. tests/ChangeLog addition: 2011-02-07 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-tests.el: Test lexical scope for `block', `return-from'; add a Known-Bug-Expect-Failure for a contorted example that fails when byte-compiled.
author Aidan Kehoe <kehoea@parhasard.net>
date Mon, 07 Feb 2011 12:01:24 +0000
parents 2def0d83a5e3
children 308d34e9f07d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2546
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
1 ;;; behavior.el --- consistent interface onto packages
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
2
2546
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
3 ;; Copyright (C) 2000, 2001, 2002, 2003 Ben Wing.
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
4
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
5 ;; Author: Ben Wing
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
6 ;; Maintainer: XEmacs Development Team
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
7 ;; Keywords: internal, dumped
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
8
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
9 ;; This file is part of XEmacs.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
10
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
14 ;; any later version.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
15
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
19 ;; General Public License for more details.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
20
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
23 ;; Free Software Foundation, 59 Temple Place - Suite 330,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
25
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
26 ;;; Synched up with: Not in FSF.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
27
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
28 ;;; Authorship:
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
29
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
30 ;; Created July 2000 by Ben Wing.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
31
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
32 ;;; Commentary:
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
33
2546
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
34 ;; This file is dumped with XEmacs.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
35
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
36 ;; This file is part of the "Behaviors" project and is a work in progress.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
37 ;; The purpose of the project is to provide (a) a consistent interface (at
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
38 ;; the API level) onto the functionality provided by packages, and (b) an
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
39 ;; easy-to-use user interface for this functionality, something that
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
40 ;; *really works*.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
41 ;;
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
42 ;; First, what characteristics do/should packages have? (NOTE: In this
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
43 ;; discussion below, `package' and `behavior' are being used more or less
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
44 ;; interchangeably. Eventually this will get resolved.)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
45
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
46 ;; 1) A file, or one or more file, containing the code of the package. In
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
47 ;; addition, a "head" file in the case that the package needs to be
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
48 ;; loaded in order to get its functionality (e.g. "load-to-enable"
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
49 ;; packages -- an abomination that is tolerated only with severe
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
50 ;; displeasure).
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
51 ;; 2) A Lisp name -- a fairly short symbol (2-3 words max), uncapitalized,
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
52 ;; without use of excessive abbreviation and with words set off by
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
53 ;; dashes. This should be the same as the name of the topmost custom
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
54 ;; group associated with the package (see next item), and preferably the
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
55 ;; same as the common prefix used for variables defined by your package
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
56 ;; and the name of the head file of the package.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
57 ;; 3) Associated custom group listing the settings associated with the package.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
58 ;; 4) Enable and disable methods for turning on or off the functionality of
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
59 ;; the package, if it's amenable to such a model. Most packages are of two
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
60 ;; types:
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
61 ;;
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
62 ;; (a) They add some functionality to XEmacs, which is incorporated
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
63 ;; into and makes changes to the normal functionality of XEmacs. Once the
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
64 ;; package is enabled, the user doesn't have to do anything specific for
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
65 ;; the package to do its thing -- it happens automatically if the user is
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
66 ;; using the area whose behavior has been changed. These include packages
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
67 ;; such as `avoid' (which makes the mouse poointer move when the cursor
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
68 ;; gets too close), EFS (which adds the ability to treat an FTP site as
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
69 ;; part of the local file system), the packages that supply the
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
70 ;; mode-specific handling for various files, etc
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
71 ;;
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
72 ;; (b) They provide functionality in the form of specific command to be
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
73 ;; invoked. This can be as simple as the `hippie-expand' command (tries
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
74 ;; lots of different expansion methods for the text before point, to
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
75 ;; try and get a result) and as complicated as GNUS or VM.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
76 ;;
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
77 ;; Some packages might provide both -- you can enable them and they
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
78 ;; incorporate some functionality into the XEmacs base, but while
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
79 ;; they're enabled they provide certain commands. #### We need some
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
80 ;; thought here, and case-by-case analysis, to determine if this really
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
81 ;; makes sense -- can the enable/disable be removed and whatever needs
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
82 ;; to happen incorporated as part of the command? can the
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
83 ;; enable/disable just added to the commands?
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
84 ;;
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
85 ;; 5) Packages of type (b) just above will have a list of commands that can be
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
86 ;; run. They should be in standard menubar format -- i.e. just like a
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
87 ;; submenu, but without the initial string indidicating the name of the
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
88 ;; menu.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
89 ;; 6) Short doc string, for use in a menu item. *NOT* necessarily the same
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
90 ;; as the documentation for the Custom group, which is often too long.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
91 ;; 7) Long documentation.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
92 ;;
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
93 ;; Good package etiquette:
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
94 ;;
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
95 ;;
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
96 ;; -- Never mess with the menu yourself, or try to "cheat" by putting yourself
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
97 ;; high up in the hierarchy, e.g. at the top-level or directly off a
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
98 ;; top-level group that expects to contain only groups of groups, not
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
99 ;; end-level groups.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
100 ;;
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
101 ;; -- Never use the `override-behavior' commands or the like for specifying
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
102 ;; (in an overriding fashion) the exact appearance of the hierarchies.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
103 ;;
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
104 ;; -- For type (a), with enable/disable methods:
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
105 ;;
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
106 ;; (a) Loading the file should NOT DO ANYTHING. Not enable, not add hooks,
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
107 ;; nothing.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
108 ;; (b) Both enable and disable hooks must exist. The disable hook must
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
109 ;; completely reset the environment to how it was before the package
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
110 ;; was enabled. This includes restoring the prior bindings for
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
111 ;; modified key bindings. #### We need some helper function to assist
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
112 ;; with remembering the old key bindings and putting them back only
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
113 ;; when new key bindings haven't been made -- but recognize when those
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
114 ;; new key bondings were attached as a result of loading another
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
115 ;; package, so that after any order of loading and unloading a series
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
116 ;; of packages, the original bindings will eventually occur. (Something
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
117 ;; like `advice' for key definitions.) Replacement of functions should
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
118 ;; happen through `advice'.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
119 ;;
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
120 ;; We recognize that many packages out there don't follow these precepts at
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
121 ;; all. Many or most of them are install-only, often happening
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
122 ;; automatically when the file is loaded. Converting these will be a step
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
123 ;; at a time: First, redo the latter type so that the initialization code
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
124 ;; is put into a function and not run automatically upon load. Next step,
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
125 ;; try to provide some sort of disable. Third step, work on making sure
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
126 ;; that disable removes *everything* and enable puts it all back. Fourth
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
127 ;; step, work on properly advising keys and functions.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
128 ;;
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
129
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
130 ;; Comparison/Integration with Custom:
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
131
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
132 ;; Custom only handles variable settings, and has no concept of standard
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
133 ;; enable/disable methods for a package, a standard way of specifying
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
134 ;; package documentation, or a list of commands associated with a package.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
135 ;; Also, its groups do not always map very well onto packages and the
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
136 ;; resulting hierarchy is too big, confusing, difficult-to-navigate, and
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
137 ;; incoherent. More generally it does not address at all the basic problem
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
138 ;; that a hierarchy created in a decentralized fashion -- and by a large
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
139 ;; number of authors, some more competent than others -- will inevitably be
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
140 ;; incoherent when put together.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
141 ;;
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
142
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
143 ;; In general, ease-of-use was not the overarching goal of Custom. The
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
144 ;; primary goal of Custom seems to have been to provide a consistent interface
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
145 ;; and get all the packages to use it. Ease-of-use -- or even following
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
146 ;; established user-interface standards -- has taken a far-distant second, and
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
147 ;; appears in many respects to be an afterthought that never had any serious
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
148 ;; effort investigated into it.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
149 ;;
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
150 ;; The eventual intent of this project is to integrate with custom. The final
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
151 ;; intent of integration is that this project subsumes Custom completely,
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
152 ;; making Custom the unified, user-friendly means of controlling XEmacs that
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
153 ;; has never properly existed. However, that will take a lot of work. For
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
154 ;; the meantime, the plan is to develop the Behavior subsystem independent of
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
155 ;; Custom, with ease-of-use as the primary goal, and get it to the point where
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
156 ;; it encompasses most packages out there, has stabilized its interface, and
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
157 ;; works well. At that point, we will consider integration with Custom. (Note
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
158 ;; that the hard part of the Behavior work is not actually behaviorizing the
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
159 ;; packages, but developing the interface itself.)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
160 ;;
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
161 ;; As for integrating with Custom -- ideally that would mean simply extending
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
162 ;; defgroup, but that is not really possible given that backward-compatibility
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
163 ;; would not work -- existing versions of `defgroup' give an error when
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
164 ;; presented with an unknown keyword. In practice, then, this might mean that
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
165 ;; a separate `define-behavior' command (or `defpackage', or the like) will
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
166 ;; still exist.
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
167
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
168 ;;; Code:
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
169
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
170 ;; Hash table mapping behavior names to property lists, with entries for
2546
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
171 ;; :group, :custom-group, :short-doc, :require, :enable, :disable,
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
172 ;; and :commands.
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
173 (defconst behavior-hash-table (make-hash-table))
2546
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
174 ;; Hash table mapping groups to property lists (entries for :group, :children,
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
175 ;; :short-doc).
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
176 (defconst behavior-group-hash-table (make-hash-table))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
177 ;; Hash table with override information for groups.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
178 ;; :short-doc).
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
179 (defconst behavior-override-hash-table (make-hash-table))
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
180
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
181 (defvar within-behavior-enabling-disabling nil)
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
182
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
183 (defgroup behaviors nil
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
184 "Behaviors -- high-level functionality interface.")
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
185
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
186 ;; List of enabled behaviors.
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
187 (defcustom enabled-behavior-list nil
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
188 "List of currently enabled behaviors.
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
189 Normally, don't set it directly; use `enable-behavior' or `disable-behavior'."
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
190 :initialize #'set-default
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
191 :set #'(lambda (sym val)
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
192 (if within-behavior-enabling-disabling
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
193 (set sym val)
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
194 (let* ((old-val enabled-behavior-list)
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
195 (disable-list (set-difference old-val val))
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
196 (enable-list (set-difference val old-val)))
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
197 (dolist (b disable-list)
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
198 (disable-behavior b t))
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
199 (dolist (b enable-list)
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
200 (enable-behavior b t))
897
7da79fbe37bb [xemacs-hg @ 2002-07-02 19:09:22 by stephent]
stephent
parents: 800
diff changeset
201 (assert (equal (sort (copy-sequence enabled-behavior-list) 'string-lessp)
7da79fbe37bb [xemacs-hg @ 2002-07-02 19:09:22 by stephent]
stephent
parents: 800
diff changeset
202 (sort (copy-sequence val) 'string-lessp))))))
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
203 :type '(repeat (symbol :tag "Behavior"))
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
204 :group 'behaviors)
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
205
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
206
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
207 (defvar behavior-history nil
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
208 "History of entered behaviors.")
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
209
2546
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
210 (defun behavior-group-p (group)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
211 "Non-nil if GROUP is the name of a valid behavior group."
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
212 (not (null (gethash group behavior-group-hash-table))))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
213
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
214 (defun check-behavior-group (group)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
215 "Verify that GROUP is a valid behavior group, or nil.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
216 Return GROUP if so."
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
217 (or (behavior-group-p group)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
218 (error 'invalid-argument "Invalid behavior group" group))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
219 group)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
220
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
221 (defun* define-behavior (name doc-string &key
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
222 group custom-group
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
223 (short-doc
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
224 (capitalize-string-as-title
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
225 (replace-in-string (symbol-name name) "-" " ")))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
226 require enable disable commands
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
227 &allow-other-keys)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
228 ;; We allow other keys to allow for the possibility of extensions by
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
229 ;; later versions of XEmacs. Packages should be able to support those
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
230 ;; extensions without worrying about causing problems with older versions
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
231 ;; of XEmacs.
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
232 "Define a behavior named NAME.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
233 DOC-STRING must be specified, a description of what the behavior does
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
234 when it's enabled and how to further control it (typically through
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
235 custom variables). Accepted keywords are
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
236
2546
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
237 :group Symbol naming the behavior group this behavior is within.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
238 :custom-group Symbol naming the custom group containing the options that
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
239 can be set in association with this behavior. If not specified,
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
240 the custom group with the same name as the behavior will be
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
241 used, if it exists.
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
242 :short-doc A \"pretty\" version of the name, for use in menus. If omitted
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
243 a prettified name will be generated.
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
244 :require A single symbol or a list of such symbols, which need to be
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
245 present at enable time, or will be loaded using `require'.
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
246 :enable A function of no variables, which turns the behavior on.
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
247 :disable A function of no variables, which turns the behavior off.
2546
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
248 :commands A list of interactive commands that can be invoked in
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
249 conjunction with the behavior. These will appear in a submenu
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
250 along with the rest of the items for the behavior.
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
251
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
252 Behaviors are assumed to be global, and to take effect immediately; if
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
253 the underlying package is per-buffer, it may have to scan all existing
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
254 buffers and frob them. When a behavior is disabled, it should completely
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
255 go away *everywhere*, as if it were never invoked at all.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
256
2546
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
257 The :disable keyword can be missing, although this is considered bad
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
258 practice. In such a case, attempting to disable the behavior will signal
2546
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
259 an error unless you use the `force' option.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
260
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
261 The :enable keyword can be missing. This is useful for behaviors that
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
262 are really a series of related commands without anything semantically
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
263 corresponding to \"turning on\" or \"turning off\" the behavior.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
264
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
265 A behavior with no :enable and no :command is possible. This might be
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
266 used, for example, by a behavior that encapsulates a series of related
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
267 Lisp functions. Such behaviors may be handled specially, e.g. not
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
268 displayed in the menus or displayed in a separate location, since they
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
269 have no user-invocable behavior."
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
270 (let ((entry (list :group (check-behavior-group group)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
271 :custom-group custom-group
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
272 :short-doc short-doc :require require
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
273 :enable enable :disable disable
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
274 :commands commands)))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
275 (puthash name entry behavior-hash-table))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
276 ;; update the children list of the group we're in (maybe nil).
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
277 (unless (member name (getf (gethash group behavior-group-hash-table)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
278 :children))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
279 (push name (getf (gethash group behavior-group-hash-table) :children))))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
280
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
281 (defun* override-behavior (name &key
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
282 short-doc
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
283 group
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
284 include
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
285 demote-others)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
286 "Override the default properties of a behavior group NAME.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
287 Normally, groups are created and assigned properties by individual packages.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
288 The resulting hierarchy may not make much sense globally. This function
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
289 allows the hierarchy and appearance of a group to be specified globally,
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
290 and will take precendence over the properties assigned by `define-behavior-group'. This allows a global organization to be imposed on groups, while still allowing for graceful handling of new or unknown groups.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
291
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
292 NAME can be a symbol specifying a group name, or a list of
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
293 \(PARENT [...] NAME), where a path from a particular parent is explicitly
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
294 given. (This latter form allows the same name to be assigned to more than one
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
295 group.)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
296
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
297 Accepted keywords are
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
298
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
299 :short-doc A \"pretty\" version of the name, for use in menus.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
300 :group Parent group, if any. Should not be given if the parents are
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
301 explicitly specified in NAME.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
302 :include A list of behaviors that are specifically included in this
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
303 group, in addition to those that are included by the behaviors
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
304 themselves.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
305 :demote-others If non-nil, exclude all behaviors not specified in the :include
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
306 list and put them instead (i.e. \"demote\" them) to another group,
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
307 usually a subgroup."
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
308 (let ((entry (list :group (check-behavior-group group)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
309 :short-doc short-doc
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
310 :include include
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
311 :demote-others demote-others)))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
312 (puthash name entry behavior-override-hash-table)))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
313
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
314 (defun* define-behavior-group (name &key
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
315 (short-doc
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
316 (capitalize-string-as-title
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
317 (replace-in-string (symbol-name name) "-"
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
318 " ")))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
319 group)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
320 "Define a behavior group NAME.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
321
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
322 NAME can be a symbol specifying a group name, or a list of
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
323 \(PARENT [...] NAME), where a path from a particular parent is explicitly
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
324 given. (This latter form allows the same name to be assigned to more than one
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
325 group.)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
326
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
327 Accepted keywords are
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
328
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
329 :short-doc A \"pretty\" version of the name, for use in menus. If omitted
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
330 a prettified name will be generated.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
331 :group Parent group, if any. Should not be given if the parents are
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
332 explicitly specified in NAME."
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
333 (let ((entry (list :group (check-behavior-group group)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
334 :short-doc short-doc)))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
335 (puthash name entry behavior-group-hash-table))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
336 ;; update the children list of the parent (maybe nil).
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
337 (push name (getf (gethash group behavior-group-hash-table) :children)))
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
338
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
339 (defun read-behavior (prompt &optional must-match initial-contents history
2546
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
340 default-value)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
341 "Return a behavior symbol from the minibuffer, prompting with string PROMPT.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
342 If non-nil, optional second arg INITIAL-CONTENTS is a string to insert
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
343 in the minibuffer before reading.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
344 Third arg HISTORY, if non-nil, specifies a history list. (It defaults to
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
345 `behavior-history'.)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
346 Fourth arg DEFAULT-VALUE is the default value. If non-nil, it is used
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
347 for history command, and as the value to return if the user enters the
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
348 empty string."
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
349 (let ((result
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
350 (completing-read
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
351 prompt
5271
2def0d83a5e3 Don't uselessly call #'nreverse, #'hash-table-key-list and friends.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4372
diff changeset
352 (let (list)
2def0d83a5e3 Don't uselessly call #'nreverse, #'hash-table-key-list and friends.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4372
diff changeset
353 (maphash #'(lambda (key value)
2def0d83a5e3 Don't uselessly call #'nreverse, #'hash-table-key-list and friends.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4372
diff changeset
354 (push (cons (symbol-name key) value) list))
2def0d83a5e3 Don't uselessly call #'nreverse, #'hash-table-key-list and friends.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4372
diff changeset
355 behavior-hash-table)
2def0d83a5e3 Don't uselessly call #'nreverse, #'hash-table-key-list and friends.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4372
diff changeset
356 list)
2546
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
357 nil must-match initial-contents (or history 'behavior-history)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
358 default-value)))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
359 (if (and result (stringp result))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
360 (intern result)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
361 result)))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
362
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
363 (defun behavior-enabled-p (behavior)
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
364 "Non-nil if BEHAVIOR (a symbol) if currently enabled."
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
365 (memq behavior enabled-behavior-list))
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
366
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
367 (defun enable-behavior (behavior &optional force)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
368 "Enable the specified behavior."
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
369 (interactive (list (read-behavior "Enable Behavior: " t) current-prefix-arg))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
370 (let ((plist (gethash behavior behavior-hash-table)))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
371 (or plist (error 'invalid-argument "Not a behavior" behavior))
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
372 (or force (not (memq behavior enabled-behavior-list))
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
373 (error 'invalid-change "Behavior already enabled" behavior))
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
374 (let ((require (getf plist :require))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
375 (enable (getf plist :enable)))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
376 (cond ((listp require)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
377 (mapc #'(lambda (sym) (require sym)) require))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
378 ((symbolp require)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
379 (require require))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
380 ((null require))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
381 (t (error 'invalid-argument "Invalid :require spec" require)))
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
382 (message "Enabling behavior %s..." behavior)
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
383 (if enable (funcall enable))
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
384 (message "Enabling behavior %s...done" behavior)
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
385 (let ((within-behavior-enabling-disabling t))
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
386 (customize-set-variable 'enabled-behavior-list
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
387 (cons behavior enabled-behavior-list))))))
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
388
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
389 (defun disable-behavior (behavior &optional force)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
390 "Disable the specified behavior."
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
391 (interactive (list (read-behavior "Disable Behavior: " t)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
392 current-prefix-arg))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
393 (let ((plist (gethash behavior behavior-hash-table)))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
394 (or plist (error 'invalid-argument "Not a behavior" behavior))
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
395 (or force (memq behavior enabled-behavior-list)
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
396 (error 'invalid-change "Behavior not enabled" behavior))
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
397 (let ((require (getf plist :require))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
398 (disable (getf plist :disable)))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
399 (cond ((listp require)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
400 (mapc #'(lambda (sym) (require sym)) require))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
401 ((symbolp require)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
402 (require require))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
403 ((null require))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
404 (t (error 'invalid-argument "Invalid :require spec" require)))
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
405 (message "Disabling behavior %s..." behavior)
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
406 (if disable (funcall disable))
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
407 (message "Disabling behavior %s...done" behavior)
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
408 (let ((within-behavior-enabling-disabling t))
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
409 (customize-set-variable 'enabled-behavior-list
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 502
diff changeset
410 (delq behavior enabled-behavior-list))))))
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
411
2546
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
412 (defun compute-behavior-group-children (group hash)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
413 "Compute the actual children for GROUP and its subgroups.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
414 This takes into account the override information specified."
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
415 (let* ((group-plist (gethash group behavior-group-hash-table))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
416 (override (gethash group behavior-override-hash-table))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
417 (children (getf group-plist :children)))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
418 )
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
419 )
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
420
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
421 (defun behavior-menu-filter-1 (menu group)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
422 (submenu-generate-accelerator-spec
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
423 (let* (
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
424 ;;options
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
425 ;;help
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
426 (enable
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
427 (menu-split-long-menu
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
428 (menu-sort-menu
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
429 (let ((group-plist (gethash group behavior-group-hash-table)))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
430 (loop for behavior in (getf group-plist :children)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
431 nconc (if (behavior-group-p behavior)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
432 (list
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
433 (cons (getf
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
434 (gethash behavior behavior-group-hash-table)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
435 :short-doc)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
436 (behavior-menu-filter-1 menu behavior)))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
437 (let* ((plist (gethash behavior behavior-hash-table))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
438 (commands (getf plist :commands)))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
439 (nconc
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
440 (if (getf plist :enable)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
441 `([,(format "%s (%s) [toggle]"
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
442 (getf plist :short-doc)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
443 behavior)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
444 (if (memq ',behavior
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
445 enabled-behavior-list)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
446 (disable-behavior ',behavior)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
447 (enable-behavior ',behavior))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
448 :active ,(if (getf plist :disable) t
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
449 (not (memq
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
450 ',behavior
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
451 enabled-behavior-list)))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
452 :style toggle
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
453 :selected (memq ',behavior
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
454 enabled-behavior-list)]))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
455 (cond ((null commands) nil)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
456 ((and (eq (length commands) 1)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
457 (vectorp (elt commands 0)))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
458 (let ((comm (copy-sequence
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
459 (elt commands 0))))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
460 (setf (elt comm 0)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
461 (format "%s (%s)"
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
462 (elt comm 0) behavior))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
463 (list comm)))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
464 (t (list
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
465 (cons (format "%s (%s) Commands"
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
466 (getf plist :short-doc)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
467 behavior)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
468 commands)))))))))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
469 ))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
470 )
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
471 )
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
472 enable)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
473 '(?p)))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
474
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
475 (defun behavior-menu-filter (menu)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
476 (append
4372
ebb35ddea76a Byte-compile menu lambdas; make the menu of available tutorials more readable.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2546
diff changeset
477 `(("%_Package Utilities"
2546
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
478 ("%_Set Download Site"
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
479 ("%_Official Releases"
4372
ebb35ddea76a Byte-compile menu lambdas; make the menu of available tutorials more readable.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2546
diff changeset
480 :filter ,#'(lambda (&rest junk)
ebb35ddea76a Byte-compile menu lambdas; make the menu of available tutorials more readable.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2546
diff changeset
481 (menu-split-long-menu
ebb35ddea76a Byte-compile menu lambdas; make the menu of available tutorials more readable.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2546
diff changeset
482 (submenu-generate-accelerator-spec
ebb35ddea76a Byte-compile menu lambdas; make the menu of available tutorials more readable.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2546
diff changeset
483 (package-ui-download-menu)))))
2546
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
484 ("%_Pre-Releases"
4372
ebb35ddea76a Byte-compile menu lambdas; make the menu of available tutorials more readable.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2546
diff changeset
485 :filter ,#'(lambda (&rest junk)
ebb35ddea76a Byte-compile menu lambdas; make the menu of available tutorials more readable.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2546
diff changeset
486 (menu-split-long-menu
ebb35ddea76a Byte-compile menu lambdas; make the menu of available tutorials more readable.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2546
diff changeset
487 (submenu-generate-accelerator-spec
ebb35ddea76a Byte-compile menu lambdas; make the menu of available tutorials more readable.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2546
diff changeset
488 (package-ui-pre-release-download-menu)))))
2546
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
489 ("%_Site Releases"
4372
ebb35ddea76a Byte-compile menu lambdas; make the menu of available tutorials more readable.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2546
diff changeset
490 :filter ,#'(lambda (&rest junk)
ebb35ddea76a Byte-compile menu lambdas; make the menu of available tutorials more readable.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2546
diff changeset
491 (menu-split-long-menu
ebb35ddea76a Byte-compile menu lambdas; make the menu of available tutorials more readable.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2546
diff changeset
492 (submenu-generate-accelerator-spec
ebb35ddea76a Byte-compile menu lambdas; make the menu of available tutorials more readable.
Aidan Kehoe <kehoea@parhasard.net>
parents: 2546
diff changeset
493 (package-ui-site-release-download-menu))))))
2546
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
494 "--:shadowEtchedIn"
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
495 ["%_Update Package Index" package-get-update-base]
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
496 ["%_List and Install" pui-list-packages]
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
497 ["U%_pdate Installed Packages" package-get-update-all]
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
498 ["%_Help" (Info-goto-node "(xemacs)Packages")])
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
499 "----")
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
500 (behavior-menu-filter-1 menu nil)))
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
501
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
502 ;; Initialize top-level group.
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
503 (puthash nil '(:children nil :short-doc "Root") behavior-group-hash-table)
5d1743698fb3 [xemacs-hg @ 2005-02-03 05:26:39 by ben]
ben
parents: 1346
diff changeset
504
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
505 (provide 'behavior)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
506
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents:
diff changeset
507 ;;; finder-inf.el ends here