From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.devel Subject: Re: saved user abbrevs and system abbrevs Date: Thu, 30 Nov 2006 21:54:47 -0500 Message-ID: References: <2godqqnetw.fsf@fencepost.gnu.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1164941730 18263 80.91.229.2 (1 Dec 2006 02:55:30 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 1 Dec 2006 02:55:30 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 01 03:55:28 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 1GpyYg-0005Y1-Q3 for ged-emacs-devel@m.gmane.org; Fri, 01 Dec 2006 03:55:27 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GpyYg-0007aX-F4 for ged-emacs-devel@m.gmane.org; Thu, 30 Nov 2006 21:55:26 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GpyYP-0007Wn-2J for emacs-devel@gnu.org; Thu, 30 Nov 2006 21:55:09 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GpyYO-0007VI-DY for emacs-devel@gnu.org; Thu, 30 Nov 2006 21:55:08 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GpyYO-0007V1-0Y for emacs-devel@gnu.org; Thu, 30 Nov 2006 21:55:08 -0500 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GpyYN-00057r-Sq for emacs-devel@gnu.org; Thu, 30 Nov 2006 21:55:08 -0500 Original-Received: from localhost ([127.0.0.1]) by fencepost.gnu.org with esmtp (Exim 4.52) id 1GpyY7-0006l1-1j; Thu, 30 Nov 2006 21:54:54 -0500 Original-To: rms@gnu.org X-Spook: dictionary credit card SEAL Team 6 advisors Treasury X-Ran: QbMGub5ds(FP})6ex@zOmYCglT.G)o8ZRe"HH6.==Sm<[$"UD|%2VGyD{(j%v$^Jh_r2t! X-Hue: cyan X-Attribution: GM In-Reply-To: (Richard Stallman's message of "Thu, 30 Nov 2006 14:48:54 -0500") User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) 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:63178 Archived-At: Richard Stallman wrote: > (defvar foo-abbrev-table nil) > > ;; Do not override any user abbrev for "foo". > (unless (abbrev-expansion "foo" foo-abbrev-table) > (define-abbrev foo-abbrev-table "foo" "foobar" nil 0 t)) > > Maybe we should change define-abbrev so that defining a system > abbrev does not override any user abbrev (unless you specify > "override") in some way. OK. I was really wondering if there was some way to avoid the problem of not being able to initialize an abbrev-table in its defvar, since it seems a bit odd/annoying/hard to remember. But I guess that there isn't really, and that it does not matter that much. Here's a patch for your suggestion. *** abbrev.c 18 Apr 2006 20:57:56 -0000 1.69 --- abbrev.c 1 Dec 2006 02:47:52 -0000 *************** *** 83,89 **** Lisp_Object Vpre_abbrev_expand_hook, Qpre_abbrev_expand_hook; ! Lisp_Object Qsystem_type, Qcount; DEFUN ("make-abbrev-table", Fmake_abbrev_table, Smake_abbrev_table, 0, 0, 0, doc: /* Create a new, empty abbrev table object. */) --- 83,89 ---- Lisp_Object Vpre_abbrev_expand_hook, Qpre_abbrev_expand_hook; ! Lisp_Object Qsystem_type, Qcount, Qforce; DEFUN ("make-abbrev-table", Fmake_abbrev_table, Smake_abbrev_table, 0, 0, 0, doc: /* Create a new, empty abbrev table object. */) *************** *** 123,129 **** \(The default is zero.) SYSTEM-FLAG, if non-nil, says that this is a "system" abbreviation ! which should not be saved in the user's abbreviation file. */) (table, name, expansion, hook, count, system_flag) Lisp_Object table, name, expansion, hook, count, system_flag; { --- 123,131 ---- \(The default is zero.) SYSTEM-FLAG, if non-nil, says that this is a "system" abbreviation ! which should not be saved in the user's abbreviation file. ! Unless SYSTEM-FLAG is `force', a system abbreviation will not ! overwrite a non-system abbreviation of the same name. */) (table, name, expansion, hook, count, system_flag) Lisp_Object table, name, expansion, hook, count, system_flag; { *************** *** 131,136 **** --- 133,148 ---- CHECK_VECTOR (table); CHECK_STRING (name); + /* If defining a system abbrev, do not overwrite a non-system abbrev + of the same name, unless 'force is used. */ + if (!NILP (system_flag) && !EQ (system_flag, Qforce)) + { + sym = Fintern_soft (name, table); + + if (!NILP (SYMBOL_VALUE (sym)) && + NILP (Fplist_get (XSYMBOL (sym)->plist, Qsystem_type))) return Qnil; + } + if (NILP (count)) count = make_number (0); else *************** *** 640,645 **** --- 652,660 ---- Qcount = intern ("count"); staticpro (&Qcount); + Qforce = intern ("force"); + staticpro (&Qforce); + DEFVAR_LISP ("abbrev-table-name-list", &Vabbrev_table_name_list, doc: /* List of symbols whose values are abbrev tables. */); Vabbrev_table_name_list = Fcons (intern ("fundamental-mode-abbrev-table"),