From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#5937: 23.1.95; why saving empty abbrev tables Date: Mon, 12 Apr 2010 14:32:07 -0400 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1271098858 19067 80.91.229.12 (12 Apr 2010 19:00:58 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 12 Apr 2010 19:00:58 +0000 (UTC) Cc: 5937@debbugs.gnu.org To: Leo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Apr 12 21:00:56 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1O1OrU-0000tt-TL for geb-bug-gnu-emacs@m.gmane.org; Mon, 12 Apr 2010 21:00:56 +0200 Original-Received: from localhost ([127.0.0.1]:34337 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O1Or2-00009P-Mo for geb-bug-gnu-emacs@m.gmane.org; Mon, 12 Apr 2010 14:59:28 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O1Oqy-00009A-0j for bug-gnu-emacs@gnu.org; Mon, 12 Apr 2010 14:59:24 -0400 Original-Received: from [140.186.70.92] (port=33750 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O1Oql-00006D-Cb for bug-gnu-emacs@gnu.org; Mon, 12 Apr 2010 14:59:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O1OqP-0006L3-1n for bug-gnu-emacs@gnu.org; Mon, 12 Apr 2010 14:58:50 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:51663) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O1OqO-0006Ky-U5 for bug-gnu-emacs@gnu.org; Mon, 12 Apr 2010 14:58:49 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1O1ORR-00016a-Jb; Mon, 12 Apr 2010 14:33:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 12 Apr 2010 18:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 5937 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 5937-submit@debbugs.gnu.org id=B5937.12710971344235 (code B ref 5937); Mon, 12 Apr 2010 18:33:01 +0000 Original-Received: (at 5937) by debbugs.gnu.org; 12 Apr 2010 18:32:14 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O1OQg-00016G-AN for submit@debbugs.gnu.org; Mon, 12 Apr 2010 14:32:14 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.183] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O1OQe-000168-Q9 for 5937@debbugs.gnu.org; Mon, 12 Apr 2010 14:32:13 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAMMDw0tMCqWu/2dsb2JhbACbOnK8eoUMBItG X-IronPort-AV: E=Sophos;i="4.52,192,1270440000"; d="scan'208";a="60694386" Original-Received: from 76-10-165-174.dsl.teksavvy.com (HELO pastel.home) ([76.10.165.174]) by ironport2-out.pppoe.ca with ESMTP; 12 Apr 2010 14:32:08 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 7BD117F1B; Mon, 12 Apr 2010 14:32:07 -0400 (EDT) In-Reply-To: (Leo's message of "Mon, 12 Apr 2010 16:23:44 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 12 Apr 2010 14:33:01 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:36216 Archived-At: > Why empty abbrev tables are saved to file? Don't know. > It seems to make it more difficult for editing (edit-abbrevs) because > the buffer is full of empty abbrev. I wonder if saving only non-empty > tables is better and user friendlier. It does sound like a good idea. Any objection? > (defun abbrev-table-empty-p (table) > "Return nil if there are no abbrev symbols in abbrev table object TABLE." > (unless (abbrev-table-p table) > (error "Non abbrev table object")) > (not (catch 'some > (mapatoms (lambda (sym) > (when (abbrev-symbol (symbol-name sym) table) > (throw 'some t))) > table)))) > (defadvice write-abbrev-file (around nonempty-abbrev-tables activate) > "Ignore empty abbrev tables when writing to FILE." > (let ((file (ad-get-arg 0)) > (coding-system-for-write 'emacs-mule) > (tables (loop for table in abbrev-table-name-list > unless (abbrev-table-empty-p (symbol-value table)) > collect table))) > (or (and file (> (length file) 0)) (setq file abbrev-file-name)) > (with-temp-file file > (insert ";;-*-coding: emacs-mule;-*-\n") > (dolist (table (sort tables > (lambda (s1 s2) > (string< (symbol-name s1) > (symbol-name s2))))) > (insert-abbrev-table-description table nil))))) Obviously, defadvice wouldn't be the right approach for us. And rather than (abbrev-symbol (symbol-name sym) table), we can use (symbol-value sym). We should also eliminate abbrev tables that only contain "system abbrevs". Stefan