From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Leo Newsgroups: gmane.emacs.bugs Subject: bug#5937: 23.1.95; why saving empty abbrev tables Date: Thu, 15 Apr 2010 11:26:55 +0100 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 1271327646 19128 80.91.229.12 (15 Apr 2010 10:34:06 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 15 Apr 2010 10:34:06 +0000 (UTC) Cc: 5937@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Apr 15 12:34:01 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 1O2MOU-0007UG-Rg for geb-bug-gnu-emacs@m.gmane.org; Thu, 15 Apr 2010 12:33:59 +0200 Original-Received: from localhost ([127.0.0.1]:38805 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O2MOU-0002oR-2W for geb-bug-gnu-emacs@m.gmane.org; Thu, 15 Apr 2010 06:33:58 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O2MJo-00086C-AD for bug-gnu-emacs@gnu.org; Thu, 15 Apr 2010 06:29:08 -0400 Original-Received: from [140.186.70.92] (port=33886 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O2MJm-00084a-Bz for bug-gnu-emacs@gnu.org; Thu, 15 Apr 2010 06:29:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O2MJi-0004ch-VI for bug-gnu-emacs@gnu.org; Thu, 15 Apr 2010 06:29:06 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:43655) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O2MJi-0004cX-3A for bug-gnu-emacs@gnu.org; Thu, 15 Apr 2010 06:29:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1O2MIk-0001hH-2r; Thu, 15 Apr 2010 06:28:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Leo Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Apr 2010 10:28:02 +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.12713272256511 (code B ref 5937); Thu, 15 Apr 2010 10:28:02 +0000 Original-Received: (at 5937) by debbugs.gnu.org; 15 Apr 2010 10:27:05 +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 1O2MHp-0001gy-FX for submit@debbugs.gnu.org; Thu, 15 Apr 2010 06:27:05 -0400 Original-Received: from ppsw-33.csi.cam.ac.uk ([131.111.8.133]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O2MHm-0001gc-8x for 5937@debbugs.gnu.org; Thu, 15 Apr 2010 06:27:03 -0400 X-Cam-AntiVirus: no malware found X-Cam-SpamDetails: not scanned X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Original-Received: from smaug.linux.pwf.cam.ac.uk ([193.60.95.72]:36988) by ppsw-33.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.159]:587) with esmtpsa (LOGIN:sl392) (TLSv1:DHE-RSA-AES128-SHA:128) id 1O2MHf-0004nN-Cl (Exim 4.70) (return-path ); Thu, 15 Apr 2010 11:26:55 +0100 In-Reply-To: (Stefan Monnier's message of "Mon, 12 Apr 2010 14:32:07 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 15 Apr 2010 06:28:02 -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:36258 Archived-At: On 2010-04-12 19:32 +0100, Stefan Monnier wrote: >> 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? I have been using this in my init file and I like it. It makes it easier to see what's actually defined. (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 prepare-abbrev-list-buffer (around nonempty-abbrev-tables activate) "Ignore empty abbrev tables." (let ((abbrev-table-name-list (loop for table in abbrev-table-name-list unless (abbrev-table-empty-p (symbol-value table)) collect table))) ad-do-it)) (defadvice write-abbrev-file (around nonempty-abbrev-tables activate) "Ignore empty abbrev tables when writing to FILE." (let ((abbrev-table-name-list (loop for table in abbrev-table-name-list unless (abbrev-table-empty-p (symbol-value table)) collect table))) ad-do-it)) [...] > 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". Regarding the :system property, I have experienced some oddity but I by-passed that instead of looking into it for lack of time. Here's what happened. When I use define-abbrev to define some system abbrevs and then M-x edit-abbrevs and move to the table where those abbrevs are defined then paste some non-system abbrevs from, for example, another abbrev file. Those pasted abbrevs are treated as system abbrevs and not saved. Sometimes when the table already have non-system abbrevs, they are turned into system ones and get lost. I had a backup of the abbrev file so that didn't cause me any trouble. > > Stefan Leo