From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel,gmane.emacs.help Subject: Re: Customize: Space char in `character' specification Date: Tue, 23 May 2006 11:38:34 +0200 Message-ID: <4472D81A.9000202@gmx.at> References: <44703F85.7020400@gmx.at> <4471876C.7050405@gmx.at> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------070201050703050603000500" X-Trace: sea.gmane.org 1148377314 19170 80.91.229.2 (23 May 2006 09:41:54 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 23 May 2006 09:41:54 +0000 (UTC) Cc: help-gnu-emacs@gnu.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue May 23 11:41:52 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FiTOh-0005H5-S9 for ged-emacs-devel@m.gmane.org; Tue, 23 May 2006 11:41:52 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FiTOh-0006PT-Dd for ged-emacs-devel@m.gmane.org; Tue, 23 May 2006 05:41:51 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FiTOS-0006Ow-K9 for emacs-devel@gnu.org; Tue, 23 May 2006 05:41:36 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FiTOO-0006Ne-NZ for emacs-devel@gnu.org; Tue, 23 May 2006 05:41:36 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FiTOO-0006NP-Jz for emacs-devel@gnu.org; Tue, 23 May 2006 05:41:32 -0400 Original-Received: from [213.165.64.21] (helo=mail.gmx.net) by monty-python.gnu.org with smtp (Exim 4.52) id 1FiTSZ-0002vR-MR for emacs-devel@gnu.org; Tue, 23 May 2006 05:45:52 -0400 Original-Received: (qmail invoked by alias); 23 May 2006 09:41:30 -0000 Original-Received: from N936P013.adsl.highway.telekom.at (EHLO [62.47.60.237]) [62.47.60.237] by mail.gmx.net (mp034) with SMTP; 23 May 2006 11:41:30 +0200 X-Authenticated: #14592706 User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en Original-To: Reiner Steib In-Reply-To: X-Y-GMX-Trusted: 0 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:55114 gmane.emacs.help:35218 Archived-At: This is a multi-part message in MIME format. --------------070201050703050603000500 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit The attached patch should accept newlines. It breaks with two conveniences though: 1. Field boundaries with character fields are gone. I had to remove that step since it is done once only (at widget-setup time) and not repeated in the after-change hook. If I had left that in, character widgets would appear visually different with regard to whether their initial value was a newline or not. In the first case there would _always_ have been an empty line after the line containing the field regardless of whether the modified value is a newline or not. In the second case the empty line would appear iff the modified value is a newline. 2. The size of a character field has changed from 1 to 0. Hence if you erase all characters in the field, there won't be any visible clues left that there's a field here. I had to change that since otherwise wid-edit would have automatically inserted a space (in its after-change hook) after a user erased all characters in the field. That space could have been subsequently used by `custom-variable-set' instead of raising an error. Note that tabbing doesn't stop at empty widgets. I don't consider that too serious since empty character widgets are invalid anyway. I tried to keep any side-effects of the patch within the character widget environment. Nevertheless you should test it extensively. --------------070201050703050603000500 Content-Type: text/plain; name="wid-edit.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="wid-edit.patch" *** wid-edit.el Tue Apr 11 16:23:54 2006 --- wid-edit.el Tue May 23 10:59:04 2006 *************** *** 343,349 **** (or (not widget-field-add-space) (widget-get widget :size)))) (if (functionp help-echo) (setq help-echo 'widget-mouse-help)) ! (when (= (char-before to) ?\n) ;; When the last character in the field is a newline, we want to ;; give it a `field' char-property of `boundary', which helps the ;; C-n/C-p act more naturally when entering/leaving the field. We --- 343,350 ---- (or (not widget-field-add-space) (widget-get widget :size)))) (if (functionp help-echo) (setq help-echo 'widget-mouse-help)) ! (when (and (= (char-before to) ?\n) ! (not (eq (car widget) 'character))) ;; When the last character in the field is a newline, we want to ;; give it a `field' char-property of `boundary', which helps the ;; C-n/C-p act more naturally when entering/leaving the field. We *************** *** 3378,3386 **** "A character." :tag "Character" :value 0 ! :size 1 :format "%{%t%}: %v\n" ! :valid-regexp "\\`.\\'" :error "This field should contain a single character" :value-to-internal (lambda (widget value) (if (stringp value) --- 3379,3388 ---- "A character." :tag "Character" :value 0 ! :size 0 :format "%{%t%}: %v\n" ! :value-get 'widget-character-value-get ! :valid-regexp "\\`\\(?:.\\|\n\\)\\'" :error "This field should contain a single character" :value-to-internal (lambda (widget value) (if (stringp value) *************** *** 3393,3398 **** --- 3395,3396 ---- :match (lambda (widget value) (char-valid-p value))) + (defun widget-character-value-get (widget) + "Return character value." + (let ((from (widget-field-start widget)) + (to (widget-field-end widget)) + (buffer (widget-field-buffer widget)) + (secret (widget-get widget :secret))) + (if (and from to) + (with-current-buffer buffer + (let ((result (buffer-substring-no-properties from to))) + (when secret + (let ((index 0)) + (while (< (+ from index) to) + (aset result index + (get-char-property (+ from index) 'secret)) + (setq index (1+ index))))) + result)) + (widget-get widget :value)))) + (define-widget 'list 'group "A Lisp list." :tag "List" --------------070201050703050603000500 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --------------070201050703050603000500--