1 ;;; cus-new-user.el --- Customize some important options
3 ;; Author: Lennart Borgman (lennart O borgman A gmail O com)
4 ;; Created: 2009-07-10 Fri
6 ;; Last-Updated: 2009-07-10 Fri
11 ;; Features that might be required by this library:
15 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19 ;; Customize significant options for which different user
20 ;; environment expectations might dictate different defaults.
22 ;; After an idea of Scot Becker on Emacs Devel.
24 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
29 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
31 ;; This program is free software; you can redistribute it and/or
32 ;; modify it under the terms of the GNU General Public License as
33 ;; published by the Free Software Foundation; either version 3, or
34 ;; (at your option) any later version.
36 ;; This program is distributed in the hope that it will be useful,
37 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
38 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
39 ;; General Public License for more details.
41 ;; You should have received a copy of the GNU General Public License
42 ;; along with this program; see the file COPYING. If not, write to
43 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
44 ;; Floor, Boston, MA 02110-1301, USA.
46 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
50 (defvar cusnu-my-skin-widget nil)
52 (defvar cusnu-insert-os-spec-fun nil)
54 ;;(customize-for-new-user)
56 (defun customize-for-new-user (&optional name)
57 "Show special customization page for new user.
60 ;;(setq debug-on-error t)
61 ;;(setq buffer-read-only t)
63 (let ((inhibit-read-only t)
65 (pop-to-buffer (custom-get-fresh-buffer (or name "*Customizations for New Users*")))
69 (widget-insert (propertize "Easy Customization for New Users\n" 'face '(:weight bold :height 1.5)))
70 (setq fill-pos (point))
72 "Below are some custom options that new users often may want to
73 tweak since they may make Emacs a bit more like what they expect from
74 using other software in their environment.
76 After this, at the bottom of this page, is a tool for exporting your own specific options.
77 You choose which to export, make a description and give the group of options a new and click a button.
78 Then you just mail it or put it on the web for others to use.
80 Since Emacs runs in many environment and an Emacs user may use
81 several of them it is hard to decide by default what a user
82 wants/expects. Therefor you are given the possibility to easily
83 do those changes here.
85 Note that this is just a collection of normal custom options.
86 There are no new options here.
90 (fill-region fill-pos (point))
92 ;; Normal custom buffer header
93 (let ((init-file (or custom-file user-init-file)))
94 ;; Insert verbose help at the top of the custom buffer.
95 (when custom-buffer-verbose-help
96 (widget-insert "Editing a setting changes only the text in this buffer."
99 To apply your changes, use the Save or Set buttons.
100 Saving a change normally works by editing your init file."
102 Currently, these settings cannot be saved for future Emacs sessions,
103 possibly because you started Emacs with `-q'.")
104 "\nFor details, see ")
105 (widget-create 'custom-manual
106 :tag "Saving Customizations"
107 "(emacs)Saving Customizations")
108 (widget-insert " in the ")
109 (widget-create 'custom-manual
111 :help-echo "Read the Emacs manual."
115 ;; The custom command buttons are also in the toolbar, so for a
116 ;; time they were not inserted in the buffer if the toolbar was in use.
117 ;; But it can be a little confusing for the buffer layout to
118 ;; change according to whether or nor the toolbar is on, not to
119 ;; mention that a custom buffer can in theory be created in a
120 ;; frame with a toolbar, then later viewed in one without.
121 ;; So now the buttons are always inserted in the buffer. (Bug#1326)
122 ;;; (when (not (and (bound-and-true-p tool-bar-mode) (display-graphic-p)))
123 (if custom-buffer-verbose-help
125 Operate on all settings in this buffer that are not marked HIDDEN:\n"))
126 (let ((button (lambda (tag action active help icon)
129 (widget-create 'push-button :tag tag
130 :help-echo help :action action))))
131 (commands custom-commands))
132 (apply button (pop commands)) ; Set for current session
133 (apply button (pop commands)) ; Save for future sessions
134 (if custom-reset-button-menu
137 (widget-create 'push-button
139 :help-echo "Show a menu with reset operations."
140 :mouse-down-action 'ignore
141 :action 'custom-reset))
143 (apply button (pop commands)) ; Undo edits
144 (apply button (pop commands)) ; Reset to saved
145 (apply button (pop commands)) ; Erase customization
147 (pop commands) ; Help (omitted)
148 (apply button (pop commands)))) ; Exit
149 (widget-insert "\n\n")
151 (widget-insert (propertize "\nThis part is for your own use\n" 'face '(:weight bold :height 1.5)))
152 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
153 ;; Editor emulator level
156 (setq fill-pos (point))
158 "Emacs can emulate some common editing behaviours (and some uncommon too).
159 For the most common ones you can decide if you want to use them here:
161 (fill-region fill-pos (point))
162 (cusnu-mark-part-desc fill-pos (point))
165 (cusnu-insert-options '((cua-mode custom-variable)))
169 (widget-insert (propertize "Viper" 'face 'custom-variable-tag))
171 (setq fill-pos (point))
173 Viper is currently set up in a special way, please see the
174 command `viper-mode'. You can use custom to set up most of
175 it. However if you want to load Viper at startup you must
176 explicitly include \(require 'viper) in your .emacs.
178 (fill-region fill-pos (point))
181 (backward-delete-char 1)
182 (cusnu-insert-options '((viper-mode custom-variable)))
184 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
188 (setq fill-pos (point))
189 (widget-insert (format "OS specific options (%s): \n" system-type))
190 (fill-region fill-pos (point))
191 (cusnu-mark-part-desc fill-pos (point))
193 (if cusnu-insert-os-spec-fun
194 (funcall cusnu-insert-os-spec-fun)
195 (widget-insert "No OS specific customizations.\n"))
197 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
201 (setq fill-pos (point))
203 "Some old time Emacs users want to change the options below:
205 (fill-region fill-pos (point))
206 (cusnu-mark-part-desc fill-pos (point))
208 (cusnu-insert-options '((global-visual-line-mode custom-variable)))
209 (cusnu-insert-options '((word-wrap custom-variable)))
210 (cusnu-insert-options '((blink-cursor-mode custom-variable)))
211 (cusnu-insert-options '((tool-bar-mode custom-variable)))
212 (cusnu-insert-options '((tooltip-mode custom-variable)))
213 ;;(cusnu-insert-options '((initial-scratch-message custom-variable)))
216 (widget-insert (propertize "\n\nThis part is for exporting to others\n\n" 'face '(:weight bold :height 1.5)))
217 (setq fill-pos (point))
219 "My skin options - This is for exporting custom options to other users
220 \(or maybe yourself on another computer).
221 This works the following way:
223 - You add a description of your options and the options you want to export below.
224 Then you click on `Export my skin options'.
225 This creates a file that you can send to other Emacs users.
226 They simply open that file in Emacs and follow the instructions there to test your options
227 and maybe save them for later use if they like them.
228 \(You can follow the instructions yourself to see how it works.)
230 Please change the group symbol name to something specific for you.
232 (fill-region fill-pos (point))
233 (cusnu-mark-part-desc fill-pos (point))
236 (set (make-local-variable 'cusnu-my-skin-widget)
238 (cusnu-insert-options '((cusnu-my-skin-options custom-variable)))))
240 (widget-create 'push-button
241 :tag "Export my skin options "
242 :action (lambda (&rest ignore)
243 (let ((use-dialog-box nil))
244 (call-interactively 'cusnu-export-my-skin-options))))
246 (widget-create 'push-button
247 :tag "Customize my skin options "
248 :action (lambda (&rest ignore)
249 (let ((use-dialog-box nil))
250 (call-interactively 'cusnu-customize-my-skin-options))))
252 (widget-create 'push-button
253 :tag "Reset those options to saved values"
254 :action (lambda (&rest ignore)
255 (let ((use-dialog-box nil))
256 (call-interactively 'cusnu-reset-my-skin-options))))
258 ;; Finish setup buffer
259 (mapc 'custom-magic-reset custom-options)
263 (goto-char (point-min)))))
265 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
266 ;; Example on Emacs+Emacw32
267 (eval-when-compile (require 'emacsw32 nil t))
268 (when (fboundp 'emacsw32-version)
269 (defun cusnu-emacsw32-show-custstart (&rest args)
270 (emacsw32-show-custstart))
271 (setq cusnu-insert-os-spec-fun 'cusnu-insert-emacsw32-specific-part)
272 (defun cusnu-insert-emacsw32-specific-part ()
273 (cusnu-insert-options '((w32-meta-style custom-variable)))
275 (widget-insert (propertize "EmacsW32" 'face 'custom-variable-tag))
277 Easy setup for Emacs+EmacsW32.")
278 (widget-insert "\n ")
279 (widget-create 'push-button :tag "Customize EmacsW32"
281 :action 'cusnu-emacsw32-show-custstart)
282 (widget-insert "\n")))
284 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
286 (defun cusnu-mark-part-desc (beg end)
287 (let ((ovl (make-overlay beg end)))
288 (overlay-put ovl 'face 'highlight)))
290 (defun cusnu-make-xrefs (&optional beg end)
293 (unless beg (setq beg (point-min)))
294 (unless end (setq end (point-max)))
295 (narrow-to-region beg end))
296 (let ((here (point)))
297 (goto-char (point-min))
298 (cusnu-help-insert-xrefs 'cusnu-help-xref-button)
301 (defun widget-info-link-action (widget &optional event)
302 "Open the info node specified by WIDGET."
303 (info-other-window (widget-value widget)))
305 (defun widget-documentation-string-value-create (widget)
306 ;; Insert documentation string.
307 (let ((doc (widget-value widget))
308 (indent (widget-get widget :indent))
309 (shown (widget-get (widget-get widget :parent) :documentation-shown))
311 (if (string-match "\n" doc)
312 (let ((before (substring doc 0 (match-beginning 0)))
313 (after (substring doc (match-beginning 0)))
315 (when (and indent (not (zerop indent)))
316 (insert-char ?\s indent))
318 (widget-documentation-link-add widget start (point))
320 (widget-create-child-and-convert
321 widget (widget-get widget :visibility-widget)
322 :help-echo "Show or hide rest of the documentation."
326 :action 'widget-parent-action
330 (when (and indent (not (zerop indent)))
331 (insert-char ?\s indent))
333 (widget-documentation-link-add widget start (point))
334 (cusnu-make-xrefs start (point))
336 (widget-put widget :buttons (list button)))
337 (when (and indent (not (zerop indent)))
338 (insert-char ?\s indent))
340 (widget-documentation-link-add widget start (point))))
342 (defun cusnu-help-xref-button (match-number type what &rest args)
343 (let ((beg (match-beginning match-number))
344 (end (match-end match-number)))
346 (let ((ovl (make-overlay beg end)))
347 (overlay-put ovl 'face 'highlight))
348 (let* ((tag (match-string match-number))
351 ((eq type 'help-variable)
353 ((eq type 'help-function)
355 ((eq type 'help-info)
360 (delete-region beg end)
362 ;;(tag action active help icon)
363 (widget-create wid-type
367 :keymap custom-mode-link-map
368 :follow-link 'mouse-face
369 :button-face 'custom-link
370 :mouse-face 'highlight
371 :pressed-face 'highlight
376 ;; Override default ... ;-)
377 (define-widget 'documentation-link 'link
378 "Link type used in documentation strings."
380 :help-echo "Describe this symbol"
381 :button-face 'custom-link
382 :action 'widget-documentation-link-action)
384 (defun cusnu-xref-niy (&rest ignore)
385 (message "Not implemented yet"))
387 (defun cusnu-describe-function (wid &rest ignore)
388 (let ((fun (widget-get wid :what))
390 (describe-function fun)))
392 (defun cusnu-help-insert-xrefs (help-xref-button)
393 ;; The following should probably be abstracted out.
398 (while (re-search-forward help-xref-info-regexp nil t)
399 (let ((data (match-string 2)))
401 (unless (string-match "^([^)]+)" data)
402 (setq data (concat "(emacs)" data))))
403 (funcall help-xref-button 2 'help-info data))))
406 (while (re-search-forward help-xref-url-regexp nil t)
407 (let ((data (match-string 1)))
408 (funcall help-xref-button 1 'help-url data))))
409 ;; Mule related keywords. Do this before trying
410 ;; `help-xref-symbol-regexp' because some of Mule
411 ;; keywords have variable or function definitions.
412 (if help-xref-mule-regexp
414 (while (re-search-forward help-xref-mule-regexp nil t)
415 (let* ((data (match-string 7))
416 (sym (intern-soft data)))
418 ((match-string 3) ; coding system
419 (and sym (coding-system-p sym)
420 (funcall help-xref-button 6 'help-coding-system sym)))
421 ((match-string 4) ; input method
422 (and (assoc data input-method-alist)
423 (funcall help-xref-button 7 'help-input-method data)))
424 ((or (match-string 5) (match-string 6)) ; charset
425 (and sym (charsetp sym)
426 (funcall help-xref-button 7 'help-character-set sym)))
427 ((assoc data input-method-alist)
428 (funcall help-xref-button 7 'help-character-set data))
429 ((and sym (coding-system-p sym))
430 (funcall help-xref-button 7 'help-coding-system sym))
431 ((and sym (charsetp sym))
432 (funcall help-xref-button 7 'help-character-set sym)))))))
435 (while (re-search-forward help-xref-symbol-regexp nil t)
436 (let* ((data (match-string 8))
437 (sym (intern-soft data)))
440 ((match-string 3) ; `variable' &c
441 (and (or (boundp sym) ; `variable' doesn't ensure
442 ; it's actually bound
443 (get sym 'variable-documentation))
444 (funcall help-xref-button 8 'help-variable sym)))
445 ((match-string 4) ; `function' &c
446 (and (fboundp sym) ; similarly
447 (funcall help-xref-button 8 'help-function sym)))
448 ((match-string 5) ; `face'
450 (funcall help-xref-button 8 'help-face sym)))
451 ((match-string 6)) ; nothing for `symbol'
456 ;;; (find-function-noselect arg)))
457 ;;; (pop-to-buffer (car location))
458 ;;; (goto-char (cdr location))))
459 (funcall help-xref-button 8 'help-function-def sym))
462 (save-match-data (looking-at "[ \t\n]+face\\W")))
463 (funcall help-xref-button 8 'help-face sym))
464 ((and (or (boundp sym)
465 (get sym 'variable-documentation))
467 ;; We can't intuit whether to use the
468 ;; variable or function doc -- supply both.
469 (funcall help-xref-button 8 'help-symbol sym))
472 (get sym 'variable-documentation))
474 (documentation-property
475 sym 'variable-documentation)
477 (documentation-property
478 (indirect-variable sym)
479 'variable-documentation)
480 (cyclic-variable-indirection nil))))
481 (funcall help-xref-button 8 'help-variable sym))
483 (funcall help-xref-button 8 'help-function sym)))))))
484 ;; An obvious case of a key substitution:
486 (while (re-search-forward
487 ;; Assume command name is only word and symbol
488 ;; characters to get things like `use M-x foo->bar'.
489 ;; Command required to end with word constituent
490 ;; to avoid `.' at end of a sentence.
491 "\\<M-x\\s-+\\(\\sw\\(\\sw\\|\\s_\\)*\\sw\\)" nil t)
492 (let ((sym (intern-soft (match-string 1))))
494 (funcall help-xref-button 1 'help-function sym)))))
495 ;; Look for commands in whole keymap substitutions:
497 ;; Make sure to find the first keymap.
498 (goto-char (point-min))
499 ;; Find a header and the column at which the command
500 ;; name will be found.
502 ;; If the keymap substitution isn't the last thing in
503 ;; the doc string, and if there is anything on the
504 ;; same line after it, this code won't recognize the end of it.
505 (while (re-search-forward "^key +binding\n\\(-+ +\\)-+\n\n"
507 (let ((col (- (match-end 1) (match-beginning 1))))
510 ;; Stop at a pair of blank lines.
511 (not (looking-at "\n\\s-*\n")))
512 ;; Skip a single blank line.
513 (and (eolp) (forward-line))
515 (skip-chars-backward "^ \t\n")
516 (if (and (>= (current-column) col)
517 (looking-at "\\(\\sw\\|\\s_\\)+$"))
518 (let ((sym (intern-soft (match-string 0))))
520 (funcall help-xref-button 0 'help-function sym))))
522 ;;(set-syntax-table stab)
525 (defun cusnu-insert-options (options)
529 (if (= (length options) 1)
530 (mapcar (lambda (entry)
531 (widget-create (nth 1 entry)
532 ;;:documentation-shown t
533 :custom-state 'unknown
534 :tag (custom-unlispify-tag-name
536 :value (nth 0 entry)))
539 (length (length options)))
540 (mapcar (lambda (entry)
542 (message "Creating customization items ...%2d%%"
543 (/ (* 100.0 count) length))
544 (widget-create (nth 1 entry)
545 :tag (custom-unlispify-tag-name
547 :value (nth 0 entry))
548 (setq count (1+ count))
549 (unless (eq (preceding-char) ?\n)
550 (widget-insert "\n"))
551 (widget-insert "\n")))
554 (unless (eq (preceding-char) ?\n)
555 (widget-insert "\n"))
559 (defun cusnu-is-custom-obj (sym)
560 "Return non-nil if symbol SYM is customizable."
561 (or (get sym 'custom-type)
563 (get sym 'custom-group)
566 (define-widget 'custom-symbol 'symbol
567 "A customizable symbol."
568 :prompt-match 'cusnu-is-custom-obj
569 :prompt-history 'widget-variable-prompt-value-history
570 :complete-function (lambda ()
572 (lisp-complete-symbol 'cusnu-is-custom-obj))
573 :tag "Custom option")
575 (defun cusnu-set-my-skin-options (sym val)
576 (set-default sym val)
577 (let ((group (nth 0 val))
579 (members (nth 2 val)))
580 (custom-declare-group group nil doc)
581 (put group 'custom-group nil)
582 (dolist (opt members)
583 (let ((type (cusnu-get-opt-main-type opt)))
585 (custom-add-to-group group opt type))))))
587 (defun cusnu-get-opt-main-type (opt)
589 (cond ((get opt 'face) 'custom-face)
590 ((get opt 'custom-type) 'custom-variable)
591 ((get opt 'custom-group) 'custom-group))))
593 (defgroup all-my-loaded-skin-groups nil
594 "All your loaded skin groups."
598 (defun cusnu-custom-group-p (symbol)
599 (and (intern-soft symbol)
600 (or (and (get symbol 'custom-loads)
601 (not (get symbol 'custom-autoload)))
602 (get symbol 'custom-group))))
604 (defcustom cusnu-my-skin-options '(my-skin-group "My skin group.\n\n\n\n\n" nil)
605 "Your custom skin-like options.
606 The purpose of this variable is to provide for easy export a
607 selection of variables you choose to set to other users.
609 To send these values to other users you export them to a file
610 with `cusnu-export-my-skin-options'."
611 :type '(list (symbol :tag "My custom group symbol name (should be specific to you)")
612 (string :tag "My custom group description")
613 (repeat :tag "Add your custom options below"
614 (custom-symbol :tag "My custom option")))
615 :set 'cusnu-set-my-skin-options
616 :group 'all-my-loaded-skin-groups)
618 ;;(cusnu-ring-bell "bell")
619 (defun cusnu-ring-bell (format-string &rest args)
620 (message "%s" (propertize (apply
621 'format format-string args) 'face 'secondary-selection))
626 (defun cusnu-export-my-skin-options (file)
627 "Export to file FILE custom options in `cusnu-my-skin-options'.
628 The options is exported to elisp code that other users can run to
629 set the options that you have added to `cusnu-my-skin-options'.
631 For more information about this see `cusnu-export-cust-group'."
634 (let ((grp (nth 0 cusnu-my-skin-options))
636 (let ((state (plist-get (cdr cusnu-my-skin-widget) :custom-state)))
638 ((set saved) nil) ;;(error "test, state=%s" state))
639 (standard (cusnu-ring-bell "Please enter your options first"))
640 (t (cusnu-ring-bell "My Skin Options must be saved or set, use the State button, %s" state))))
641 (unless (nth 2 cusnu-my-skin-options)
642 (cusnu-ring-bell "You have not added any of your options"))
644 (setq file (read-file-name "Save to file: ")))
645 (when (file-exists-p file)
646 (cusnu-ring-bell "File %s already exists, choose another file name" file))
647 (setq buf (find-file-other-window file))
648 (with-current-buffer buf
649 (unless (eq major-mode 'emacs-lisp-mode) (emacs-lisp-mode))
650 (unless (file-exists-p (buffer-file-name))
652 (cusnu-export-cust-group grp buf))))
654 (defun cusnu-customize-my-skin-options ()
656 (customize-group-other-window (nth 0 cusnu-my-skin-options)))
658 (defun cusnu-reset-my-skin-options ()
659 "Reset to my defaults for those options.
662 (cusnu-reset-group-options-to-my-defaults (nth 0 cusnu-my-skin-options)))
664 (defun cusnu-reset-group-options-to-my-defaults (group)
665 (dolist (sym-typ (get group 'custom-group))
666 (let ((symbol (nth 0 sym-typ))
667 ;;(type (cusnu-get-opt-main-type symbol))
668 (type (nth 1 sym-typ))
671 ((eq type 'custom-variable)
672 ;; First try reset to saved.
673 (let* ((set (or (get symbol 'custom-set) 'set-default))
674 (value (get symbol 'saved-value))
675 (comment (get symbol 'saved-variable-comment)))
676 (cond ((or comment value)
677 (put symbol 'variable-comment comment)
678 (custom-push-theme 'theme-value symbol 'user 'set (car-safe value))
680 (funcall set symbol (eval (car value)))
681 (error (message "%s" err))))
682 ;; If symbol was not saved then reset to standard.
684 (unless (get symbol 'standard-value)
685 (error "No standard setting known for %S" symbol))
686 (put symbol 'variable-comment nil)
687 (put symbol 'customized-value nil)
688 (put symbol 'customized-variable-comment nil)
689 (custom-push-theme 'theme-value symbol 'user 'reset)
690 (custom-theme-recalc-variable symbol)
691 (put symbol 'saved-value nil)
692 (put symbol 'saved-variable-comment nil)
694 ((eq type 'custom-face)
695 ;; First try reset to saved
696 (let* ((value (get symbol 'saved-face))
697 (comment (get symbol 'saved-face-comment)))
698 (cond ((or value comment)
699 (put symbol 'customized-face nil)
700 (put symbol 'customized-face-comment nil)
701 (custom-push-theme 'theme-face symbol 'user 'set value)
702 (face-spec-set symbol value t)
703 (put symbol 'face-comment comment))
704 ;; If symbol was not saved then reset to standard.
706 (setq value (get symbol 'face-defface-spec))
708 (error "No standard setting for this face"))
709 (put symbol 'customized-face nil)
710 (put symbol 'customized-face-comment nil)
711 (custom-push-theme 'theme-face symbol 'user 'reset)
712 (face-spec-set symbol value t)
713 (custom-theme-recalc-face symbol)
715 (put symbol 'saved-face nil)
716 (put symbol 'saved-face-comment nil)
718 (t (error "not iy"))))))
720 (defun cusnu-export-cust-group (group buf)
721 "Export custom group GROUP to end of buffer BUF.
722 Only the options that has been customized will be exported.
724 The group is exported as elisp code. Running the code will
725 create a group with just those members. After this it opens a
726 customization buffer with the new group.
728 The code will also set the options to the customized values, but
729 it will not save them in the users init file.
731 See also the comment in the exported file."
733 (doc (get group 'group-documentation))
735 (members (mapcar (lambda (rec)
737 (get group 'custom-group))))
738 (with-current-buffer buf
739 (insert (format-time-string ";; Here is my skin custom group %Y-%m-%d.\n"))
741 (insert (format ";;;;;; Customization group name: %s\n" group))
743 (let ((here (point)))
745 (comment-region here (point))
746 (fill-region here (point)))
747 (cusnu-get-options-and-faces members 'groups 'options 'faces)
748 (unless (or options faces)
749 (cusnu-ring-bell "There are no options or faces in %s customized by you" group))
751 ;; This file defines the group and sets the options in it, but does
752 ;; not save the values to your init file.
754 ;; To set the values evaluate this file. To do that open this file in Emacs and to
758 ;; To go back to your default evaluate next line (place point at the end and to C-x C-e):
760 (insert (format ";; (cusnu-reset-group-options-to-my-defaults '%s)\n\n" group))
761 (insert (format "(let ((grp '%s))\n" group))
762 (insert (format " (custom-declare-group grp nil %S)\n" doc))
763 (insert " (put grp 'custom-group nil)\n")
764 (insert (format " (custom-add-to-group 'all-my-loaded-skin-groups '%s 'custom-group)\n" group))
765 (dolist (opt members)
766 (let ((type (cusnu-get-opt-main-type opt)))
768 (insert (format " (custom-add-to-group grp '%s '%s)\n"
770 (insert " (custom-set-variables\n")
771 (dolist (opt options)
772 (let ((my-val (or (get opt 'saved-value)
773 (get opt 'customized-value))))
775 (insert (format " '(%s %S)\n" opt (custom-quote (symbol-value opt)))))))
777 (insert " (custom-set-faces\n")
779 (let ((my-val (get opt 'customized-face)))
781 (insert (format " '(%s %S)\n" opt my-val)))))
783 (insert (format "\n(customize-group '%s)\n" group))
786 (defun cusnu-get-options-and-faces (members groups-par options-par faces-par)
787 (dolist (sym members)
788 (insert (format ";; sym=%s\n" sym))
789 (cond ((and (get sym 'custom-type)
790 (or (get sym 'saved-value)
791 (get sym 'customize-value)))
792 (add-to-list options-par sym))
793 ((and (get sym 'face)
794 (get sym 'customized-face))
795 (add-to-list faces-par sym))
796 ((get sym 'custom-group)
797 (unless (memq sym groups-par) ;; Don't loop
798 (cusnu-get-options-and-faces groups-par options-par faces-par)))
799 (t (insert ";; Not a custom variable or face: %s\n" sym)))))
801 (provide 'cus-new-user)
802 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
803 ;;; cus-new-user.el ends here