all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: Another Custom problem
       [not found] <E17wanS-000200-00@fencepost.gnu.org>
@ 2002-10-02  9:11 ` Per Abrahamsen
  0 siblings, 0 replies; only message in thread
From: Per Abrahamsen @ 2002-10-02  9:11 UTC (permalink / raw)
  Cc: Jens Schmidt, bug-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 552 bytes --]

Hi,

I had to invent a deep copy mechanism for widgets to solve this one.
It will make customize slower, as more garbage is created.

Here is the patch.  I have not commited it to CVS.

Regard,

Per

2002-10-02  Per Abrahamsen  <abraham@dina.kvl.dk>

	* wid-edit.el (widget-types-copy): New function.
	(default): Added :copy keyword.
	(menu-choice): Ditto.
	(checklist): Ditto.
	(radio-button-choice): Ditto.
	(editable-list): Ditto.
	(group): Ditto.
	(widget-copy): New function.
	(widget-create-child): Use it.
	(widget-create-child-value): Use it.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: PATCH_14 --]
[-- Type: text/x-patch, Size: 5767 bytes --]

Index: lisp/wid-edit.el
===================================================================
RCS file: /cvsroot/emacs//emacs/lisp/wid-edit.el,v
retrieving revision 1.112
diff -c -r1.112 wid-edit.el
*** lisp/wid-edit.el	23 Jul 2002 19:20:53 -0000	1.112
--- lisp/wid-edit.el	2 Oct 2002 09:04:42 -0000
***************
*** 688,694 ****
  
  (defun widget-create-child (parent type)
    "Create widget of TYPE."
!   (let ((widget (copy-sequence type)))
      (widget-put widget :parent parent)
      (unless (widget-get widget :indent)
        (widget-put widget :indent (+ (or (widget-get parent :indent) 0)
--- 688,694 ----
  
  (defun widget-create-child (parent type)
    "Create widget of TYPE."
!   (let ((widget (widget-copy type)))
      (widget-put widget :parent parent)
      (unless (widget-get widget :indent)
        (widget-put widget :indent (+ (or (widget-get parent :indent) 0)
***************
*** 699,705 ****
  
  (defun widget-create-child-value (parent type value)
    "Create widget of TYPE with value VALUE."
!   (let ((widget (copy-sequence type)))
      (widget-put widget :value (widget-apply widget :value-to-internal value))
      (widget-put widget :parent parent)
      (unless (widget-get widget :indent)
--- 699,705 ----
  
  (defun widget-create-child-value (parent type value)
    "Create widget of TYPE with value VALUE."
!   (let ((widget (widget-copy type)))
      (widget-put widget :value (widget-apply widget :value-to-internal value))
      (widget-put widget :parent parent)
      (unless (widget-get widget :indent)
***************
*** 714,719 ****
--- 714,723 ----
    "Delete WIDGET."
    (widget-apply widget :delete))
  
+ (defun widget-copy (widget)
+   "Make a deep copy of WIDGET."
+   (widget-apply (copy-sequence widget) :copy))
+ 
  (defun widget-convert (type &rest args)
    "Convert TYPE to a widget without inserting it in the buffer.
  The optional ARGS are additional keyword arguments."
***************
*** 1271,1276 ****
--- 1275,1285 ----
  	    found (widget-apply child :validate)))
      found))
  
+ (defun widget-types-copy (widget)
+   "Copy :args as widget types in WIDGET."
+   (widget-put widget :args (mapcar 'widget-copy (widget-get widget :args)))
+   widget)
+ 
  ;; Made defsubst to speed up face editor creation.
  (defsubst widget-types-convert-widget (widget)
    "Convert :args as widget types in WIDGET."
***************
*** 1308,1313 ****
--- 1317,1323 ----
    :button-face-get 'widget-default-button-face-get 
    :sample-face-get 'widget-default-sample-face-get 
    :delete 'widget-default-delete
+   :copy 'identity
    :value-set 'widget-default-value-set
    :value-inline 'widget-default-value-inline
    :default-get 'widget-default-default-get
***************
*** 1853,1858 ****
--- 1863,1869 ----
  (define-widget 'menu-choice 'default
    "A menu of options."
    :convert-widget  'widget-types-convert-widget
+   :copy 'widget-types-copy
    :format "%[%t%]: %v"
    :case-fold t
    :tag "choice"
***************
*** 2091,2096 ****
--- 2102,2108 ----
  (define-widget 'checklist 'default
    "A multiple choice widget."
    :convert-widget 'widget-types-convert-widget
+   :copy 'widget-types-copy
    :format "%v"
    :offset 4
    :entry-format "%b %v"
***************
*** 2268,2273 ****
--- 2280,2286 ----
  (define-widget 'radio-button-choice 'default
    "Select one of multiple options."
    :convert-widget 'widget-types-convert-widget
+   :copy 'widget-types-copy
    :offset 4
    :format "%v"
    :entry-format "%b %v"
***************
*** 2456,2461 ****
--- 2469,2475 ----
  (define-widget 'editable-list 'default
    "A variable list of widgets of the same type."
    :convert-widget 'widget-types-convert-widget
+   :copy 'widget-types-copy
    :offset 12
    :format "%v%i\n"
    :format-handler 'widget-editable-list-format-handler
***************
*** 2631,2636 ****
--- 2645,2651 ----
  (define-widget 'group 'default
    "A widget which groups other widgets inside."
    :convert-widget 'widget-types-convert-widget
+   :copy 'widget-types-copy
    :format "%v"
    :value-create 'widget-group-value-create
    :value-delete 'widget-children-value-delete
Index: man/widget.texi
===================================================================
RCS file: /cvsroot/emacs//emacs/man/widget.texi,v
retrieving revision 1.14
diff -c -r1.14 widget.texi
*** man/widget.texi	23 Jul 2002 19:10:02 -0000	1.14
--- man/widget.texi	2 Oct 2002 09:04:44 -0000
***************
*** 4,10 ****
  @setfilename ../info/widget
  @settitle The Emacs Widget Library
  @ifnottex
! Copyright @copyright{} 2000 Free Software Foundation, Inc.
  
  Permission is granted to copy, distribute and/or modify this document
  under the terms of the GNU Free Documentation License, Version 1.1 or
--- 4,10 ----
  @setfilename ../info/widget
  @settitle The Emacs Widget Library
  @ifnottex
! Copyright @copyright{} 2000, 2002 Free Software Foundation, Inc.
  
  Permission is granted to copy, distribute and/or modify this document
  under the terms of the GNU Free Documentation License, Version 1.1 or
***************
*** 1536,1541 ****
--- 1536,1554 ----
  
  @defun widget-value-convert-widget widget
  Initialize @code{:value} from @code{:args} in @var{widget}.
+ @end defun
+ 
+ @vindex copy@r{ keyword}
+ @item :copy
+ Function to deep copy a widget type.  It takes a shallow copy of the
+ widget type as an argument (made by @code{copy-sequence}), and returns a
+ deep copy.  The purpose of this is to avoid having different instances
+ of combined widgets share nested attributes.
+ 
+ The following predefined functions can be used here:
+ 
+ @defun widget-types-copy widget
+ Copy @code{:args} as widget types in @var{widget}.
  @end defun
  
  @vindex value-to-internal@r{ keyword}

[-- Attachment #3: Type: text/plain, Size: 3053 bytes --]


Richard Stallman <rms@gnu.org> writes:

> This is a different bug report from the same person, also in the heart
> of Custom.  Could you look at this one, please?
>
>
> From: Jens Schmidt <Jens.Schmidt27@epost.de>
> Message-ID: <u4rc69nfd.fsf@oracle.com>
> Lines: 56
> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1
> MIME-Version: 1.0
> Content-Type: text/plain; charset=us-ascii
> Sender: bug-gnu-emacs-admin@gnu.org
> Errors-To: bug-gnu-emacs-admin@gnu.org
> X-BeenThere: bug-gnu-emacs@gnu.org
> X-Mailman-Version: 2.0.11
> Precedence: bulk
> List-Help: <mailto:bug-gnu-emacs-request@gnu.org?subject=help>
> List-Post: <mailto:bug-gnu-emacs@gnu.org>
> List-Subscribe: <http://mail.gnu.org/mailman/listinfo/bug-gnu-emacs>,
> 	<mailto:bug-gnu-emacs-request@gnu.org?subject=subscribe>
> List-Id: Bug reports for GNU Emacs,
> 	the Swiss army knife of text editors <bug-gnu-emacs.gnu.org>
> List-Unsubscribe: <http://mail.gnu.org/mailman/listinfo/bug-gnu-emacs>,
> 	<mailto:bug-gnu-emacs-request@gnu.org?subject=unsubscribe>
> List-Archive: <http://mail.gnu.org/pipermail/bug-gnu-emacs/>
> Date: 01 Oct 2002 16:41:26 +0100
>
> This bug report will be sent to the Free Software Foundation,
> not to your local site managers!
> Please write in English, because the Emacs maintainers do not have
> translators to read other languages for them.
>
> Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list,
> and to the gnu.emacs.bug news group.
>
> In GNU Emacs 21.1.1 (i386-msvc-nt4.0.1381)
>  of 2001-10-22 on buffy
> configured using `configure --with-msvc (12.00)'
> Important settings:
>   value of $LC_ALL: nil
>   value of $LC_COLLATE: nil
>   value of $LC_CTYPE: nil
>   value of $LC_MESSAGES: nil
>   value of $LC_MONETARY: nil
>   value of $LC_NUMERIC: nil
>   value of $LC_TIME: nil
>   value of $LANG: ENU
>   locale-coding-system: iso-latin-1
>   default-enable-multibyte-characters: t
>
> Please describe exactly what actions triggered the bug
> and the precise symptoms of the bug:
>
>
> [Note: This has nothing to do with the bug I filed yesterday.
> Only the example is almost the same.]
>
>
> Consider the following customization variable:
>
> (defcustom test '((0 . "abc"))
>   "xxx"
>   :type '(repeat (choice string
>                          (cons :value (3 . "def") integer string))))
>
> In the fresh customization buffer for `test' execute the
> following sequence of actions:
>
>   Hit 2nd "INS"
>   Hit 2nd "Value Menu" and choose "Cons cell"
>
> This sequence correctly inserts the 2nd cell (3 . "def").
>
> Now continue:
>
>   Hit 1st "Value Menu" and choose "String"
>   Hit 1st "Value Menu" and choose "Cons cell" again
>   Hit 3rd "INS"
>   Hit 3rd "Value Menu" and choose "Cons cell"
>
> This sequence inserts the 3rd cell (0 . "abc").  That is, instead
> of inserting the default value as for the 2nd cell, the 1st cell
> just gets duplicated.
>
>
>
> _______________________________________________
> Bug-gnu-emacs mailing list
> Bug-gnu-emacs@gnu.org
> http://mail.gnu.org/mailman/listinfo/bug-gnu-emacs


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-10-02  9:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <E17wanS-000200-00@fencepost.gnu.org>
2002-10-02  9:11 ` Another Custom problem Per Abrahamsen

Code repositories for project(s) associated with this external index

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

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